VisualPart.st
changeset 2671 3e8b7f22722e
parent 2670 82dbebce194f
child 2672 5d7fd9552774
--- a/VisualPart.st	Sun May 10 14:32:26 2009 +0200
+++ b/VisualPart.st	Sun May 10 16:08:28 2009 +0200
@@ -134,11 +134,13 @@
 !VisualPart methodsFor:'accessing-dimensions'!
 
 bounds:newBounds
-    frame notNil ifTrue:[
-        container invalidate:frame.
-    ].
+    self assert:(newBounds left isInteger).
+    self assert:(newBounds width isInteger).
+    self assert:(newBounds top isInteger).
+    self assert:(newBounds height isInteger).
+
     frame := newBounds.
-    container invalidate:frame.
+
 ! !
 
 !VisualPart methodsFor:'view protocol mimicri'!
@@ -147,6 +149,20 @@
     ^ 0
 !
 
+computeBoundingBox
+    layout notNil ifTrue:[
+        container notNil ifTrue:[
+            self bounds:(layout 
+                    rectangleRelativeTo:(0@0 extent:container extent "container bounds")
+                    preferred:self preferredBounds).
+        ]
+    ] ifFalse:[
+        self error.
+    ].
+
+    ^ frame
+!
+
 computeCorner
     ^ self corner
 !
@@ -195,7 +211,7 @@
 
     (c := container) notNil ifTrue:[
         container := nil.
-        c invalidate:self bounds.
+        frame notNil ifTrue:[ c invalidate:frame ].
         c removeComponent:self.
     ].
 !
@@ -213,8 +229,21 @@
 !
 
 geometryLayout:newLayoutOrNil
+    container notNil ifTrue:[
+        frame notNil ifTrue:[
+            container invalidate:(frame insetBy:-2).
+        ]
+    ].
+
     frame := nil.
     layout := newLayoutOrNil.
+
+    container notNil ifTrue:[
+        self computeBoundingBox.
+        frame notNil ifTrue:[
+            container invalidate:(frame insetBy:-2).
+        ]
+    ].
 !
 
 invalidate
@@ -349,5 +378,5 @@
 !VisualPart class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/VisualPart.st,v 1.17 2009-05-10 12:32:26 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/VisualPart.st,v 1.18 2009-05-10 14:08:28 cg Exp $'
 ! !