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.48 date: 2019/07/17 08:26:36
user: cg
file: LayoutFrame.st directory: libview2
module: stx stc-classLibrary: libview2
Author:
Claus Gittinger

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.


Related information:

    View
    LayoutOrigin
    AlignmentOrigin
    Layout
    Rectangle
    Point

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: something
Set the y-coordinate of the bottom of the relative rectangle to be a fraction of the height of the reference rectangle.

o  bottomFraction: something offset: o
set both bottomFraction 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: something
set rightFraction

o  rightFraction: rF bottomFraction: bF

o  rightFraction: something offset: o
set rightFraction 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.

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:
(#LayoutOrigin 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.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Tue, 19 Mar 2024 05:03:07 GMT