Border.st
changeset 5373 44c47ff50380
parent 5353 9b83c512effa
child 5391 0ef0b272c283
--- a/Border.st	Thu Oct 22 15:37:15 2009 +0200
+++ b/Border.st	Fri Oct 23 14:24:39 2009 +0200
@@ -11,7 +11,7 @@
 "
 "{ Package: 'stx:libview' }"
 
-Object subclass:#Border
+AbstractBorder subclass:#Border
 	instanceVariableNames:'left right top bottom leftColor rightColor topColor bottomColor'
 	classVariableNames:''
 	poolDictionaries:''
@@ -36,9 +36,10 @@
 
 documentation
 "
-    a border holdes the values of a views (or components) border.
+    a border holds the values of a view's (or component's) border.
     It is (currently) not used by ST/X, but provided as a comatibility hook.
     (... however, ST/X is being rewritten to make use of it soon).
+
     Notice: 
         this class was implemented using protocol information
         from alpha testers, from reading PD programs and 
@@ -53,12 +54,11 @@
     [author:]
         Claus Gittinger
 "
-
-
 !
 
 examples
 "
+                                                        [exBegin]
      |v b|
 
      v := StandardSystemView extent:10@10.
@@ -76,9 +76,9 @@
      Delay waitForSeconds:1.
      b setRightColor:Color magenta.
      b displayOn:v forDisplayBox:(0@0 corner:9@9).
-
+                                                        [exEnd]
 
-
+                                                        [exBegin]
      |v b|
 
      v := StandardSystemView extent:100@100.
@@ -99,28 +99,24 @@
      b setRight:1.
      v clear.   
      b displayOn:v forDisplayBox:(0@0 corner:99@99).
-"
-! !
-
-!Border class methodsFor:'instance creation'!
+                                                        [exEnd]
 
-width:borderWidth
-    "create a new instance of the receiver with a border of the given width  
-     (and default color)."
+                                                        [exBegin]
+     |v sub1 sub2 sub3|
 
-    ^ self width:borderWidth color:View defaultBorderColor
+     v := StandardSystemView extent:200@200.
+     v openAndWait.
 
-    "Modified: 10.2.1997 / 15:19:57 / cg"
-!
+     sub1 := (View in:v) origin:10@10; corner:90@90.
+     sub1 border:(SimpleBorder width:1 color:Color red ).
+     sub2 := (View in:v) origin:110@10; corner:190@90.
+     sub2 border:(Border new width:1; color:Color blue; leftColor:Color red rightColor:Color red ).
+     sub3 := (View in:v) origin:110@110; corner:190@190.
+     sub3 border:(SimpleBorder width:1 color:Color green ).
 
-width:borderWidth color:aColor
-    "create a new instance of the receiver with a border of the given width  
-     and color."
-
-    ^ self new
-        setBorderWidth:borderWidth color:aColor
-
-    "Modified: 10.2.1997 / 15:20:32 / cg"
+     v open.
+                                                        [exEnd]
+"
 ! !
 
 !Border methodsFor:'accessing'!
@@ -145,7 +141,7 @@
 color:newColor
     "set all four colors"
 
-    leftColor := rightColor := topColor := bottomColor := newColor
+    self setBorderColor:newColor
 
     "Created: 10.2.1997 / 15:27:01 / cg"
 !
@@ -263,21 +259,18 @@
     ^ topColor
 
     "Created: 10.2.1997 / 14:51:34 / cg"
+!
+
+width:newBorderWidth
+    "set all four widths"
+
+    self setBorderWidth:newBorderWidth
 ! !
 
 !Border methodsFor:'displaying'!
 
-displayOn:aGC forDisplayBox:aRectangle
-    "display the borders represented by the receiver in the specified rectangle.
-     The gc is restored after the draw."
-
-    self displayOn:aGC forDisplayBox:aRectangle using:nil
-
-    "Modified: 10.2.1997 / 14:56:10 / cg"
-!
-
 displayOn:aGC forDisplayBox:aRectangle using:colorSource
-    "display the borders represented by the receiver borders in the given rectangle.
+    "display the border represented by the receiver in the given rectangle.
      colorSource is ignored here, but subclasses (i.e. 3D-borders) may use
      it to ask for shadow/lightColors.
      The gc's state is restored after the drawing."
@@ -406,9 +399,9 @@
 !Border class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/Border.st,v 1.5 2009-09-29 19:33:02 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/Border.st,v 1.6 2009-10-23 12:24:39 cg Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libview/Border.st,v 1.5 2009-09-29 19:33:02 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/Border.st,v 1.6 2009-10-23 12:24:39 cg Exp $'
 ! !