checkin from browser
authorClaus Gittinger <cg@exept.de>
Mon, 22 Jul 1996 11:02:58 +0200
changeset 323 ee2f4da361a6
parent 322 d0c2dab3961e
child 324 87185f6f9b9d
checkin from browser
BorderedWrapper.st
LayoutWrapper.st
VComponent.st
VisualComponent.st
VisualPart.st
Wrapper.st
--- a/BorderedWrapper.st	Sat Jul 20 13:08:10 1996 +0200
+++ b/BorderedWrapper.st	Mon Jul 22 11:02:58 1996 +0200
@@ -270,19 +270,6 @@
     "Modified: 5.6.1996 / 01:53:00 / cg"
 ! !
 
-!BorderedWrapper methodsFor:'accessing - bounds'!
-
-bounds:newBounds
-    |v|
-
-    bounds := newBounds.
-    component bounds:(newBounds insetBy:self inset).
-    (v := self view) notNil ifTrue:[v invalidate]
-
-    "Created: 5.6.1996 / 00:52:49 / cg"
-    "Modified: 5.6.1996 / 02:35:30 / cg"
-! !
-
 !BorderedWrapper methodsFor:'displaying'!
 
 displayOn:aGC
@@ -352,6 +339,30 @@
     "Created: 19.7.1996 / 17:22:33 / cg"
 ! !
 
+!BorderedWrapper methodsFor:'private'!
+
+layoutChanged
+    |subBounds b|
+
+    component notNil ifTrue:[
+        b := bounds insetBy:self inset.
+        
+        layout notNil ifTrue:[
+            subBounds := (layout 
+                            rectangleRelativeTo:b
+                            preferred:b) rounded.
+        ] ifFalse:[
+            subBounds := b
+        ].
+
+        origin := b origin.
+"/ Transcript show:layout displayString; show:'subbounds: '; showCR:subBounds.
+        component bounds:subBounds.
+    ]
+
+    "Created: 19.7.1996 / 21:25:02 / cg"
+! !
+
 !BorderedWrapper methodsFor:'queries'!
 
 hasBorder
@@ -369,5 +380,5 @@
 !BorderedWrapper  class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/BorderedWrapper.st,v 1.5 1996-07-19 17:20:04 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/BorderedWrapper.st,v 1.6 1996-07-22 09:01:46 cg Exp $'
 ! !
--- 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 $'
 ! !
--- a/VComponent.st	Sat Jul 20 13:08:10 1996 +0200
+++ b/VComponent.st	Mon Jul 22 11:02:58 1996 +0200
@@ -126,10 +126,17 @@
 preferredBounds
     "return my preferredBounds"
 
-    ^ 100@100
+    ^ 0@0 extent:100@100
 
     "Created: 8.5.1996 / 23:36:29 / cg"
+    "Modified: 19.7.1996 / 20:06:28 / cg"
+!
+
+preferredExtent
+    ^ self preferredBounds extent
+
     "Modified: 9.5.1996 / 00:13:22 / cg"
+    "Created: 19.7.1996 / 20:06:19 / cg"
 !
 
 right
@@ -332,5 +339,5 @@
 !VisualComponent  class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/Attic/VComponent.st,v 1.11 1996-07-19 17:21:08 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/Attic/VComponent.st,v 1.12 1996-07-22 09:02:58 cg Exp $'
 ! !
--- a/VisualComponent.st	Sat Jul 20 13:08:10 1996 +0200
+++ b/VisualComponent.st	Mon Jul 22 11:02:58 1996 +0200
@@ -126,10 +126,17 @@
 preferredBounds
     "return my preferredBounds"
 
-    ^ 100@100
+    ^ 0@0 extent:100@100
 
     "Created: 8.5.1996 / 23:36:29 / cg"
+    "Modified: 19.7.1996 / 20:06:28 / cg"
+!
+
+preferredExtent
+    ^ self preferredBounds extent
+
     "Modified: 9.5.1996 / 00:13:22 / cg"
+    "Created: 19.7.1996 / 20:06:19 / cg"
 !
 
 right
@@ -332,5 +339,5 @@
 !VisualComponent  class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/VisualComponent.st,v 1.11 1996-07-19 17:21:08 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/VisualComponent.st,v 1.12 1996-07-22 09:02:58 cg Exp $'
 ! !
--- a/VisualPart.st	Sat Jul 20 13:08:10 1996 +0200
+++ b/VisualPart.st	Mon Jul 22 11:02:58 1996 +0200
@@ -5,7 +5,7 @@
 	category:'Graphics-Display Objects'
 !
 
-!VisualPart class methodsFor:'documentation'!
+!VisualPart  class methodsFor:'documentation'!
 
 documentation
 "
@@ -96,9 +96,13 @@
      The default here is to ignore this, but some wrappers like
      to resize when this happens."
 
-    ^ self
+"/Transcript show:'container '; show:container; show:' of '; show:self; 
+"/           show:' changed size to '; showCR:container viewRectangle.
+
+    self bounds:container viewRectangle
 
     "Created: 4.6.1996 / 21:27:58 / cg"
+    "Modified: 19.7.1996 / 21:20:58 / cg"
 ! !
 
 !VisualPart ignoredMethodsFor:'view protocol mimicri'!
@@ -135,8 +139,8 @@
     "Created: 5.6.1996 / 00:49:19 / cg"
 ! !
 
-!VisualPart class methodsFor:'documentation'!
+!VisualPart  class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/VisualPart.st,v 1.5 1996-06-05 18:27:36 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/VisualPart.st,v 1.6 1996-07-22 09:02:16 cg Exp $'
 ! !
--- a/Wrapper.st	Sat Jul 20 13:08:10 1996 +0200
+++ b/Wrapper.st	Mon Jul 22 11:02:58 1996 +0200
@@ -157,13 +157,6 @@
 
 !Wrapper methodsFor:'view protocol mimicri'!
 
-containerChangedSize
-"/    component containerChangedSize
-
-    "Created: 19.7.1996 / 17:31:40 / cg"
-    "Modified: 19.7.1996 / 17:46:16 / cg"
-!
-
 containerMapped
     component containerMapped
 
@@ -199,5 +192,5 @@
 !Wrapper  class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/Wrapper.st,v 1.7 1996-07-19 17:21:16 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/Wrapper.st,v 1.8 1996-07-22 09:02:32 cg Exp $'
 ! !