BorderedWrapper.st
changeset 283 f28c462b9d13
parent 278 f2382bb48850
child 293 d10ad10d23fa
--- a/BorderedWrapper.st	Wed May 29 10:51:41 1996 +0200
+++ b/BorderedWrapper.st	Wed May 29 11:37:35 1996 +0200
@@ -7,6 +7,30 @@
 
 !BorderedWrapper class methodsFor:'documentation'!
 
+documentation
+"
+    a wrapper which controls the layout (origin & extent)
+    of its wrapped component and also draws a border around.
+
+    If insideColor is nonNil, the area is cleared to that color,
+    making the overall look be opaque.
+
+    Notice: 
+        this class was implemented using protocol information
+        from alpha testers and from the Hopkins/Horan book.
+        - it may not be complete or compatible to the corresponding ST-80 class. 
+        If you encounter any incompatibilities, please forward a note 
+        describing the incompatibility verbal (i.e. no code) to the ST/X team.
+
+    [see also:]
+        Wrapper TranslatingWrapper GeometricWrapper
+
+    [author:]
+        Claus Gittinger
+"
+
+!
+
 examples
 "
                                                                         [exBegin]
@@ -25,8 +49,9 @@
     e := EllipticalArc boundingBox:(0@0 corner:80@80)
                      startAngle:0 sweepAngle:360.
     component := StrokingWrapper on:e.
-    component lineWidth:5.
-    v addComponent:(BorderedWrapper on:component at:10@10).
+    component lineWidth:5; foregroundColor:Color yellow.
+    v addComponent:((BorderedWrapper on:component at:50@50)
+                        insideColor:Color blue).
 
     e := Arrow from:0@0 to:50@150.
     component := StrokingWrapper on:e.
@@ -62,6 +87,30 @@
     border := something.
 
     "Created: 28.5.1996 / 23:15:15 / cg"
+!
+
+insideColor
+    "return the insideColor"
+
+    ^ insideColor
+
+    "Created: 29.5.1996 / 11:09:58 / cg"
+!
+
+insideColor:aColorOrPixmap
+    "set the insideColor"
+
+    insideColor := aColorOrPixmap
+
+    "Created: 29.5.1996 / 11:10:16 / cg"
+! !
+
+!BorderedWrapper methodsFor:'accessing - bounds'!
+
+bounds
+    ^ component bounds + origin
+
+    "Created: 29.5.1996 / 11:09:39 / cg"
 ! !
 
 !BorderedWrapper methodsFor:'displaying'!
@@ -69,14 +118,21 @@
 displayOn:aGC
     |bounds x y w h tX tY|
 
-    super displayOn:aGC.
-
     bounds := self bounds.
     x := bounds left rounded.
     y := bounds top rounded.
     w := bounds width rounded.
     h := bounds height rounded.
 
+    insideColor notNil ifTrue:[
+        aGC paint:insideColor.
+        aGC fillRectangleX:x y:y width:w height:h
+    ].
+
+    super displayOn:aGC.
+
+    "/ drawEdgesForX: draws in deviceCoordinates - have to translate here.
+
     tX := aGC translation x.
     tY := aGC translation y.
 
@@ -91,11 +147,11 @@
             halfLight:Color grey
                 style:#iris
 
-    "Modified: 29.5.1996 / 00:36:00 / cg"
+    "Modified: 29.5.1996 / 11:30:34 / cg"
 ! !
 
 !BorderedWrapper class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview2/BorderedWrapper.st,v 1.1 1996-05-28 22:43:05 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview2/BorderedWrapper.st,v 1.2 1996-05-29 09:36:48 cg Exp $'
 ! !