eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'LayoutFrame':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: LayoutFrame


Inheritance:

   Object
   |
   +--Layout
      |
      +--LayoutOrigin
         |
         +--LayoutFrame
            |
            +--ConstrainedLayoutFrame

Package:
stx:libview2
Category:
Graphics-Geometry
Version:
rev: 1.51 date: 2022/07/19 08:56:03
user: stefan
file: LayoutFrame.st directory: libview2
module: stx stc-classLibrary: libview2

Description:


This class is provided to make porting of existing ST-80/Squeak applications
easier. Instances can be used to control the geometry of a subview, within
its superview. Like a layoutOrigin, it controls the origin of a component
by given fraction and offset dimensions; in addition, the bottom-right
corner is also controlled by corresponding values. 
Therefore, the component's preferredExtent is ignored.

Notice: 
    this class was implemented using protocol information
    from alpha testers - it may not be complete or compatible to
    the corresponding ST-80 class. 
    If you encounter any incompatibilities, please forward a note 
    describing the incompatibility verbal (i.e. no code) to the ST/X team.

copyright

COPYRIGHT (c) 1995 by Claus Gittinger All Rights Reserved This software is furnished under a license and may be used only in accordance with the terms of that license and with the inclusion of the above copyright notice. This software may not be provided or otherwise made available to, or used by, any other person. No title to or ownership of the software is hereby transferred.

Class protocol:

instance creation
o  bottomFrame: pixels
create a new layoutFrame which makes the child take a fixed frame at the bottom

o  bottomInset: pixels
create a new layoutFrame which insets the child at the bottom by some pixels

o  fractions: fractionRectangle offsets: offsetRectangle
create a new layoutFrame given a rectangle of fractions and a rectangle of offsets

Usage example(s):

     LayoutFrame 
        fractions:(0 @ 0 corner:1.0 @ 1.0) 
        offsets:(0 @ 0 corner:0 @ 0)

o  inset: pixels
create a new layoutFrame which insets the child by some pixels

o  leftFraction: lF offset: lO rightFraction: rF offset: rO topFraction: tF offset: tO bottomFraction: bF offset: bO
create a new layoutFrame

o  leftFraction: lF rightFraction: rF topFraction: tF bottomFraction: bF
create a new layoutFrame

o  leftFrame: pixels
create a new layoutFrame which makes the child take a fixed frame at the left

o  leftOffset: lO rightOffset: rO topOffset: tO bottomOffset: bO
create a new layoutFrame

o  leftOffset: lO topOffset: tO rightOffset: rO bottomOffset: bO
create a new layoutFrame

o  origin: origin corner: corner
create a new layoutFrame from an oldStyle origin-corner rectangle.
Added to make migration from Rectangles to LayoutFrames easier.

o  rightFrame: pixels
create a new layoutFrame which makes the child take a fixed frame at the right

o  topFrame: pixels
create a new layoutFrame which makes the child take a fixed frame at the top

o  topInset: pixels
create a new layoutFrame which insets the child at the top by some pixels


Instance protocol:

accessing
o  bottomFraction
Return the y-coordinate of the bottom of the relative rectangle as a percentage of the height of the reference rectangle.

o  bottomFraction: aFraction
Set the y-coordinate of the bottom of the relative rectangle to be a fraction of the height of the reference rectangle.

o  bottomFraction: aFraction offset: o
set both bottomFraction (0..1) and offset

o  bottomInset: pixels
set bottomOffset for an inset at the bottom

o  bottomOffset
return bottomOffset

o  bottomOffset: something
set bottomOffset

o  fractions: fractionRectangle offsets: offsetRectangle
LayoutFrame fractions:(0 @ 0 corner:1.0 @ 1.0) offsets:(0 @ 0 corner:0 @ 0)

o  horizontalInset: aNumber
setup the offsets for insetting horizontally the frame aNumber pixels at all sides

o  inset: aNumber
setup the offsets for insetting the frame aNumber pixels at all sides

o  leftFraction: lF offset: lO rightFraction: rF offset: rO topFraction: tF offset: tO bottomFraction: bF offset: bO
set all fields

o  leftFraction: lF rightFraction: rF

o  leftFraction: lF rightFraction: rF topFraction: tF bottomFraction: bF

o  leftOffset: lO rightOffset: rO
set the horizontal offset fields

o  leftOffset: lO rightOffset: rO topOffset: tO bottomOffset: bO
set all offset fields

o  rightFraction
return rightFraction

o  rightFraction: aFraction
set rightFraction (0..1)

o  rightFraction: rF bottomFraction: bF

o  rightFraction: aFraction offset: o
set rightFraction (0..1) and offset

o  rightInset: pixels
set rightOffset for an inset at the right

o  rightOffset
return rightOffset

o  rightOffset: something
set rightOffset

o  topFraction: tF bottomFraction: bF

o  topOffset: newTopOffset bottomOffset: newBottomOffset

o  verticalInset: aNumber
setup the offsets for insetting vertically the frame aNumber pixels
at all sides

comparing
o  = anObject

o  hash

computing
o  rectangleRelativeTo: superRectangle preferred: prefRectHolder
compute the rectangle represented by the receiver,
given the superView's rectangle and the view's preferredExtent.

Usage example(s):

     |superRect lF|

     superRect := 0@0 corner:99@99.
     lF := (LayoutFrame new).
     lF leftFraction:0.25;
        topFraction:0.25;
        rightFraction:0.75;
        bottomFraction:0.75.
     lF rectangleRelativeTo:superRect preferred:(0@0 corner:30@30) 

converting
o  fromLiteralArrayEncoding: encoding
read my values from an encoding.
The encoding is supposed to be of the form:
(LayoutFrame orgOffsX relOrgX orgOffsY relOrgY cornOffsX relCornX cornOffsY relCornY)
This is the reverse to literalArrayEncoding.

Usage example(s):

      LayoutFrame new fromLiteralArrayEncoding:#(#LayoutFrame 70 0 2 0 0 1 25 0 )
      #(#LayoutFrame 70 0 2 0 0 1 25 0 ) decodeAsLiteralArray 

o  literalArrayEncoding
encode myself as an array, from which a copy of the receiver
can be reconstructed with #decodeAsLiteralArray.
The encoding is:
(#LayoutFrame orgOffsX relOrgX orgOffsY relOrgY cornOffsX relCornX cornOffsY relCornY)

initialization
o  initialize
bottomFraction := rightFraction := 1.

printing & storing
o  displayOn: aGCOrStream
return a printed representation of the receiver for displaying

queries
o  corner

o  isLayoutFrame
return true, if this is a layoutFrame


Examples:


Although the examples below use a button as component, they work of course with any type of subview .... arrange for the button to be in 0.25 @ 0.25 -> 0.75 @ 0.75. This is the same as with relative origin/corner.
    |top button|

    top := StandardSystemView new.
    top extent:300@300.

    button := Button label:'component'.
    top add:button in:(LayoutFrame new
                            leftFraction:0.25;
                            topFraction:0.25;
                            rightFraction:0.75;
                            bottomFraction:0.75).

    top open
like above, but adds additional offset to the origin: This is the same as with relative origin/corner and setting left & right insets.
    |top button|

    top := StandardSystemView new.
    top extent:300@300.

    button := Button label:'component'.
    top add:button in:(LayoutFrame new
                            leftFraction:0.25; leftOffset:10;
                            topFraction:0.25;  topOffset:-20;
                            rightFraction:0.75;
                            bottomFraction:0.75).

    top open
like above, with offsets on all edges, actually simulating a constant inset on all four edges:
    |top button|

    top := StandardSystemView new.
    top extent:300@300.

    button := Button label:'component'.
    top add:button in:(LayoutFrame new
                            leftFraction:0.0; leftOffset:10;
                            topFraction:0.0;  topOffset:10;
                            rightFraction:1.0; rightOffset:-10;
                            bottomFraction:1.0; bottomOffset:-10).

    top open


ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Mon, 14 Oct 2024 02:35:36 GMT