--- a/LayoutWrapper.st Sat Jul 20 13:08:10 1996 +0200
+++ b/LayoutWrapper.st Mon Jul 22 11:02:58 1996 +0200
@@ -29,6 +29,28 @@
t open
[exEnd]
+ [exBegin]
+ |top frame1 view1 frame2 view2|
+
+ top := StandardSystemView new.
+ frame1 := LayoutWrapper new.
+ frame1 layout:(0.1@0.1 corner:0.9@0.9) asLayout.
+ top addSubView:frame1.
+
+ view1 := View new.
+ view1 viewBackground:Color red.
+ frame1 component:view1.
+
+ frame2 := LayoutWrapper new.
+ frame2 layout:(0.1@0.1 corner:0.9@0.9) asLayout.
+ view1 addSubView:frame2.
+
+ view2 := View new.
+ view2 viewBackground:Color green.
+ frame2 component:view2.
+
+ top openWithExtent:200@200
+ [exEnd]
"
! !
@@ -51,6 +73,15 @@
!LayoutWrapper methodsFor:'accessing'!
+bounds:newBounds
+"/ Transcript showCR:newBounds.
+ bounds := newBounds.
+ self layoutChanged
+
+ "Created: 19.7.1996 / 20:10:09 / cg"
+ "Modified: 19.7.1996 / 21:20:42 / cg"
+!
+
layout
"return layout"
@@ -63,9 +94,33 @@
"set the layout"
layout := something.
+ self layoutChanged
"Created: 26.5.1996 / 16:18:11 / cg"
- "Modified: 5.6.1996 / 13:58:55 / cg"
+ "Modified: 19.7.1996 / 20:15:20 / cg"
+! !
+
+!LayoutWrapper methodsFor:'private'!
+
+layoutChanged
+ |subBounds|
+
+ component notNil ifTrue:[
+ layout notNil ifTrue:[
+ subBounds := (layout
+ rectangleRelativeTo:bounds
+ preferred:bounds) rounded.
+ ] ifFalse:[
+ subBounds := bounds
+ ].
+
+ origin := subBounds origin.
+"/ Transcript show:layout displayString; show:'subbounds: '; showCR:subBounds.
+ component bounds:subBounds.
+ ]
+
+ "Created: 19.7.1996 / 20:15:05 / cg"
+ "Modified: 19.7.1996 / 21:20:46 / cg"
! !
!LayoutWrapper methodsFor:'queries'!
@@ -74,25 +129,96 @@
^ true
"Created: 19.7.1996 / 17:51:16 / cg"
+!
+
+preferredBounds
+ |b w h lw lh|
+
+ bounds := component preferredBounds.
+ layout isNil ifTrue:[^ bounds].
+
+ w := bounds width.
+ h := bounds height.
+
+ "/ now, inverse apply the layouts values
+
+ lw := layout rightFraction - layout leftFraction.
+ lw ~~ 0 ifTrue:[
+ lw := w * (1 / lw)
+ ].
+ lh := layout bottomFraction - layout topFraction.
+ lh ~~ 0 ifTrue:[
+ lh := h * (1 / lh)
+ ].
+ lw := lw + layout rightOffset - layout leftOffset.
+ lh := lh + layout bottomOffset - layout topOffset.
+
+ ^ 0@0 corner:(lw rounded @ lh rounded)
+
+ "Created: 19.7.1996 / 17:51:16 / cg"
+ "Modified: 19.7.1996 / 20:08:51 / cg"
! !
!LayoutWrapper methodsFor:'view protocol mimicri'!
-containerChangedSize
- "my container changed its size.
- Resize my component according the layout spec"
+computeOrigin
+ "return my origin"
+
+ ^ 0@0
+
+ "Created: 19.7.1996 / 20:05:37 / cg"
+!
+
+origin:org corner:corn
+ |newLayout l r t b lF rF tF bF lO rO tO bO|
- layout notNil ifTrue:[
- self bounds:(layout rectangleRelativeTo:(container viewRectangle)
- preferred:(self preferredBounds)) rounded.
- component containerChangedSize
- ]
+ newLayout := LayoutFrame new.
+ l := org x.
+ l isInteger ifTrue:[
+ lO := l.
+ lF := 0.0
+ ] ifFalse:[
+ lO := 0.
+ lF := l
+ ].
+ r := corn x.
+ r isInteger ifTrue:[
+ rO := r.
+ rF := 0.0
+ ] ifFalse:[
+ rO := 0.
+ rF := r
+ ].
+ t := org y.
+ t isInteger ifTrue:[
+ tO := t.
+ tF := 0.0
+ ] ifFalse:[
+ tO := 0.
+ tF := t
+ ].
+ b := corn y.
+ b isInteger ifTrue:[
+ bO := b.
+ bF := 0.0
+ ] ifFalse:[
+ bO := 0.
+ bF := b
+ ].
- "Modified: 19.7.1996 / 17:47:54 / cg"
+ newLayout
+ leftFraction:lF offset:lO;
+ rightFraction:rF offset:rO;
+ topFraction:tF offset:tO;
+ bottomFraction:bF offset:bO.
+
+ self layout:newLayout
+
+ "Modified: 19.7.1996 / 21:22:11 / cg"
! !
!LayoutWrapper class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview2/LayoutWrapper.st,v 1.3 1996-07-19 17:21:29 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libview2/LayoutWrapper.st,v 1.4 1996-07-22 09:01:25 cg Exp $'
! !