|
Class: LayoutFrame
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
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.
View
LayoutOrigin
AlignmentOrigin
Layout
Rectangle
Point
instance creation
-
bottomFrame: pixels
-
create a new layoutFrame which makes the child take a fixed frame at the bottom
-
bottomInset: pixels
-
create a new layoutFrame which insets the child at the bottom by some pixels
-
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)
|
-
inset: pixels
-
create a new layoutFrame which insets the child by some pixels
-
leftFraction: lF offset: lO rightFraction: rF offset: rO topFraction: tF offset: tO bottomFraction: bF offset: bO
-
create a new layoutFrame
-
leftFraction: lF rightFraction: rF topFraction: tF bottomFraction: bF
-
create a new layoutFrame
-
leftFrame: pixels
-
create a new layoutFrame which makes the child take a fixed frame at the left
-
leftOffset: lO rightOffset: rO topOffset: tO bottomOffset: bO
-
create a new layoutFrame
-
leftOffset: lO topOffset: tO rightOffset: rO bottomOffset: bO
-
create a new layoutFrame
-
origin: origin corner: corner
-
create a new layoutFrame from an oldStyle origin-corner rectangle.
Added to make migration from Rectangles to LayoutFrames easier.
-
rightFrame: pixels
-
create a new layoutFrame which makes the child take a fixed frame at the right
-
topFrame: pixels
-
create a new layoutFrame which makes the child take a fixed frame at the top
-
topInset: pixels
-
create a new layoutFrame which insets the child at the top by some pixels
accessing
-
bottomFraction
-
Return the y-coordinate of the bottom of the relative rectangle as a percentage of the height of the reference rectangle.
-
bottomFraction: something
-
Set the y-coordinate of the bottom of the relative rectangle to be a fraction of the height of the reference rectangle.
-
bottomFraction: something offset: o
-
set both bottomFraction and offset
-
bottomInset: pixels
-
set bottomOffset for an inset at the bottom
-
bottomOffset
-
return bottomOffset
-
bottomOffset: something
-
set bottomOffset
-
fractions: fractionRectangle offsets: offsetRectangle
-
LayoutFrame fractions:(0 @ 0 corner:1.0 @ 1.0) offsets:(0 @ 0 corner:0 @ 0)
-
horizontalInset: aNumber
-
setup the offsets for insetting horizontally the frame aNumber pixels at all sides
-
inset: aNumber
-
setup the offsets for insetting the frame aNumber pixels at all sides
-
leftFraction: lF offset: lO rightFraction: rF offset: rO topFraction: tF offset: tO bottomFraction: bF offset: bO
-
set all fields
-
leftFraction: lF rightFraction: rF
-
-
leftFraction: lF rightFraction: rF topFraction: tF bottomFraction: bF
-
-
leftOffset: lO rightOffset: rO
-
set the horizontal offset fields
-
leftOffset: lO rightOffset: rO topOffset: tO bottomOffset: bO
-
set all offset fields
-
rightFraction
-
return rightFraction
-
rightFraction: something
-
set rightFraction
-
rightFraction: rF bottomFraction: bF
-
-
rightFraction: something offset: o
-
set rightFraction and offset
-
rightInset: pixels
-
set rightOffset for an inset at the right
-
rightOffset
-
return rightOffset
-
rightOffset: something
-
set rightOffset
-
topFraction: tF bottomFraction: bF
-
-
topOffset: newTopOffset bottomOffset: newBottomOffset
-
-
verticalInset: aNumber
-
setup the offsets for insetting vertically the frame aNumber pixels
at all sides
comparing
-
= anObject
-
-
hash
-
computing
-
rectangleRelativeTo: superRectangle preferred: prefRectHolder
-
compute the rectangle represented by the receiver,
given the superView's rectangle and the view's preferredExtent.
converting
-
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
|
-
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
-
initialize
-
bottomFraction := rightFraction := 1.
printing & storing
-
displayOn: aGCOrStream
-
return a printed representation of the receiver for displaying
queries
-
corner
-
-
isLayoutFrame
-
return true, if this is a layoutFrame
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
|
|