VisualPart.st
changeset 2675 a68038b7c4c3
parent 2674 70cdd1b4318c
child 2676 131b8d5bd5ef
--- a/VisualPart.st	Mon May 11 10:29:42 2009 +0200
+++ b/VisualPart.st	Wed May 13 13:23:32 2009 +0200
@@ -12,7 +12,8 @@
 "{ Package: 'stx:libview2' }"
 
 VisualComponent subclass:#VisualPart
-	instanceVariableNames:'container layout name'
+	instanceVariableNames:'container layout name visibilityChannel originChannel
+		extentChannel'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'Compatibility-ST80-Graphics-Display Objects'
@@ -86,6 +87,16 @@
     "Created: 9.5.1996 / 00:31:41 / cg"
 !
 
+extentChannel
+    ^ extentChannel
+!
+
+extentChannel:something
+    extentChannel removeDependent:self.
+    extentChannel := something.
+    extentChannel notNil ifTrue:[ extentChannel addDependent:self].
+!
+
 graphicsContext
     "return the graphicsContext"
 
@@ -112,6 +123,16 @@
     name := something.
 !
 
+originChannel
+    ^ originChannel
+!
+
+originChannel:something
+    originChannel removeDependent:self.
+    originChannel := something.
+    originChannel notNil ifTrue:[ originChannel addDependent:self].
+!
+
 topComponent
     "return the top component - typically the topView"
 
@@ -129,18 +150,27 @@
 
     "Created: 4.6.1996 / 21:32:34 / cg"
     "Modified: 5.6.1996 / 01:20:13 / cg"
+!
+
+visibilityChannel
+    ^ visibilityChannel
+!
+
+visibilityChannel:something
+    visibilityChannel removeDependent:self.
+    visibilityChannel := something.
+    visibilityChannel notNil ifTrue:[ visibilityChannel addDependent:self].
 ! !
 
 !VisualPart methodsFor:'accessing-dimensions'!
 
 bounds:newBounds
-    self assert:(newBounds left isInteger).
-    self assert:(newBounds width isInteger).
-    self assert:(newBounds top isInteger).
-    self assert:(newBounds height isInteger).
+"/    self assert:(newBounds left isInteger).
+"/    self assert:(newBounds width isInteger).
+"/    self assert:(newBounds top isInteger).
+"/    self assert:(newBounds height isInteger).
 
-    frame := newBounds.
-
+    frame := newBounds rounded.
 !
 
 possiblyInvalidate
@@ -152,6 +182,22 @@
     ].
 ! !
 
+!VisualPart methodsFor:'change & update'!
+
+update:something with:aParameter from:changedObject
+    "/ invalidate is always ok - however, it will redraw bg, fg and line
+    "/ and therefore may produce flicker (unless double buffering)
+
+    (changedObject == originChannel 
+    or:[ changedObject == extentChannel ]) ifTrue:[
+self container clearRectangle:self frame.
+self container invalidateRectangle:self frame repairNow:false.
+        "/ self invalidate.   "/ invalidate old region
+        frame := nil.
+    ].
+    self invalidate.
+! !
+
 !VisualPart methodsFor:'view protocol mimicri'!
 
 bottomInset
@@ -159,12 +205,31 @@
 !
 
 computeBoundingBox
-    layout notNil ifTrue:[
-        container notNil ifTrue:[
-            self bounds:(layout 
-                    rectangleRelativeTo:(0@0 extent:container extent "container bounds")
-                    preferred:self preferredBounds).
-        ]
+    |newBounds newOrigin newExtent delta|
+
+    container notNil ifTrue:[
+        layout notNil ifTrue:[
+            newBounds := layout 
+                            rectangleRelativeTo:(0@0 extent:container extent "container bounds")
+                            preferred:self preferredBounds.
+        ].
+        (newExtent := extentChannel value) notNil ifTrue:[
+            newBounds isNil ifTrue:[
+                newBounds := 0@0 extent:newExtent.
+            ] ifFalse:[
+                newBounds extent:newExtent
+            ]
+        ].
+        (newOrigin := originChannel value) notNil ifTrue:[
+            newBounds isNil ifTrue:[
+                newBounds := newOrigin extent:(self preferredExtent).
+            ].
+            delta := newOrigin - newBounds origin.
+            newBounds origin:newOrigin corner:(newBounds corner + delta).
+        ].
+        newBounds notNil ifTrue:[
+            self bounds:newBounds.
+        ].
     ].
 
     ^ frame
@@ -378,5 +443,5 @@
 !VisualPart class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/VisualPart.st,v 1.21 2009-05-11 08:29:42 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/VisualPart.st,v 1.22 2009-05-13 11:23:32 cg Exp $'
 ! !