*** empty log message ***
authorClaus Gittinger <cg@exept.de>
Fri, 16 Jul 2004 16:40:32 +0200
changeset 2003 196bdcaf1859
parent 2002 cec6022a2d39
child 2004 a0245a3e8cdc
*** empty log message ***
TransparentBox.st
--- a/TransparentBox.st	Tue Jul 13 12:51:22 2004 +0200
+++ b/TransparentBox.st	Fri Jul 16 16:40:32 2004 +0200
@@ -1,53 +1,47 @@
-'From Smalltalk/X, Version:5.2.2 on 07-04-2004 at 04:07:23 PM'                  !
-
 "{ Package: 'stx:libview2' }"
 
 View subclass:#TransparentBox
-	instanceVariableNames:''
+	instanceVariableNames:'shapeForm'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'Views-Basic'
 !
 
+!TransparentBox class methodsFor:'documentation'!
+
+examples
+"
+    | tv b1 b2 |
+
+    b1 := Button label:'hello'.
+    b1 origin:10@10.
+
+    b2 := Button label:'hello'.
+    b2 origin:100@100.
+
+    tv := self new.
+    tv extent:200@200.
+
+    tv addSubView:b1.
+    tv addSubView:b2.
+    tv open
+"
+! !
 
 !TransparentBox methodsFor:'events'!
 
 sizeChanged:how
-
-    self computeShape.
-"/    self clear;redraw.
-
-    ^super sizeChanged: how.
-
-
-
+    shapeForm notNil ifTrue:[
+        self computeShape.
+    ].
+    ^ super sizeChanged: how.
 ! !
 
 !TransparentBox methodsFor:'initialization'!
 
-initialize
-
-    super initialize.
+realize
     self computeShape.
-    self viewBackground: Color green.
-
-
-"
-| tv |
-
-tv := TopView new.
-
-gbox := GBOX origin:0.0@0.0 corner: 1.0@1.0 in: tv.
-gbox viewBackground: Color green.
-
-tv open
-
-"
-
-
-
-
-
+    super realize.
 ! !
 
 !TransparentBox methodsFor:'queries'!
@@ -59,35 +53,47 @@
 
 specClass
     ^ TransparentBoxSpec
+!
+
+windowStyle
+    ^ #undecorated
 ! !
 
 !TransparentBox methodsFor:'shape computation'!
 
+addSubView:aView
+    super addSubView:aView.
+    shapeForm notNil ifTrue:[
+        self computeShape
+    ].
+!
+
 computeShape
-    | borderForm subViews w h |
+    | subViews w h |
 
     device supportsArbitraryShapedViews ifFalse:[^self].
 
     w := self extent x.
     h := self extent y.
-    borderForm := Form width:w height:h.
-    borderForm fill:(Color colorId:0).
+    shapeForm := Form width:w height:h.
+    shapeForm fill:(Color colorId:0).
 
-    borderForm foreground:(Color colorId:1).
+    shapeForm foreground:(Color colorId:1).
 
     subViews := self subViews.
     subViews isEmptyOrNil ifTrue:[
-       self fillFormWithBorderShape:borderForm.
+       self fillFormWithBorderShape:shapeForm.
     ] ifFalse:[
         subViews do:[:aSubView|
-            aSubView fillFormWithBorderShape:borderForm.
+            aSubView fillFormWithBorderShape:shapeForm.
         ]
     ].
-    self borderShape:borderForm.
+    "/ self viewShape:shapeForm.
+    self borderShape:shapeForm.
 ! !
 
 !TransparentBox class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/TransparentBox.st,v 1.1 2004-04-07 14:07:50 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/TransparentBox.st,v 1.2 2004-07-16 14:40:32 cg Exp $'
 ! !