--- a/LayoutFrm.st Sat Apr 27 16:19:26 1996 +0200
+++ b/LayoutFrm.st Sat Apr 27 19:51:19 1996 +0200
@@ -45,66 +45,85 @@
See also:
LayoutOrigin AlignmentOrigin Layout
- 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 to the ST/X team.
+ 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.
[author:]
Claus Gittinger
+
+ [see also:]
+ View
+ LayoutOrigin AlignmentOrigin Layout
+ Rectangle Point
"
!
examples
"
- |top button|
+ Although the examples below use a button as component,
+ they work of course with any type of subview ....
+
- top := StandardSystemView new.
- top extent:300@300.
+ arrange for the button to be in 0.25 @ 0.25 -> 0.75 @ 0.75.
+ This is the same as with relative origin/corner.
+ [exBegin]
+ |top button|
- button := Button label:'component'.
- top add:button in:(LayoutFrame new
- leftFraction:0.25;
- topFraction:0.25;
- rightFraction:0.75;
- bottomFraction:0.75).
+ top := StandardSystemView new.
+ top extent:300@300.
- top open
+ button := Button label:'component'.
+ top add:button in:(LayoutFrame new
+ leftFraction:0.25;
+ topFraction:0.25;
+ rightFraction:0.75;
+ bottomFraction:0.75).
+
+ top open
+ [exEnd]
like above, but adds additional offset to the origin:
-
- |top button|
+ This is the same as with relative origin/corner
+ and setting left & right insets.
+ [exBegin]
+ |top button|
- top := StandardSystemView new.
- top extent:300@300.
+ 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).
+ 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
+ top open
+ [exEnd]
- like above, with offsets on all edges, actually simulating
- a constant inset on all four edges:
+ like above, with offsets on all edges,
+ actually simulating a constant inset on all four edges:
+ [exBegin]
+ |top button|
- |top button|
-
- top := StandardSystemView new.
- top extent:300@300.
+ 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).
+ 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
+ top open
+ [exEnd]
"
! !
@@ -242,39 +261,42 @@
!
rectangleRelativeTo:superRectangle preferred:prefRect
+ "compute the rectangle represented by the receiver,
+ given the superViews rectangle and the views preferredExtent."
+
|x1 y1 x2 y2|
leftOffset isNil ifTrue:[
- x1 := 0
+ x1 := 0
] ifFalse:[
- x1 := leftOffset
+ x1 := leftOffset
].
topOffset isNil ifTrue:[
- y1 := 0
+ y1 := 0
] ifFalse:[
- y1 := topOffset
+ y1 := topOffset
].
rightOffset isNil ifTrue:[
- x2 := 0
+ x2 := 0
] ifFalse:[
- x2 := rightOffset
+ x2 := rightOffset
].
bottomOffset isNil ifTrue:[
- y2 := 0
+ y2 := 0
] ifFalse:[
- y2 := bottomOffset
+ y2 := bottomOffset
].
leftFraction notNil ifTrue:[
- x1 := x1 + (superRectangle width * leftFraction)
+ x1 := x1 + (superRectangle width * leftFraction)
].
topFraction notNil ifTrue:[
- y1 := y1 + (superRectangle height * topFraction)
+ y1 := y1 + (superRectangle height * topFraction)
].
rightFraction notNil ifTrue:[
- x2 := x2 + (superRectangle width * rightFraction)
+ x2 := x2 + (superRectangle width * rightFraction)
].
bottomFraction notNil ifTrue:[
- y2 := y2 + (superRectangle height * bottomFraction)
+ y2 := y2 + (superRectangle height * bottomFraction)
].
^ Rectangle origin:x1@y1 corner:x2@y2
@@ -284,15 +306,17 @@
superRect := 0@0 corner:100@100.
lF := (LayoutFrame new).
lF leftFraction:0.25;
- topFraction:0.25;
- rightFraction:0.75;
- bottomFraction:0.75.
+ topFraction:0.25;
+ rightFraction:0.75;
+ bottomFraction:0.75.
lF rectangleRelativeTo:superRect preferred:(0@0 corner:30@30)
"
+
+ "Modified: 27.4.1996 / 14:54:03 / cg"
! !
!LayoutFrame class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview2/Attic/LayoutFrm.st,v 1.12 1996-04-25 16:20:26 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libview2/Attic/LayoutFrm.st,v 1.13 1996-04-27 17:50:45 cg Exp $'
! !