AbstractBorder.st
changeset 5407 767945d3ad71
parent 5392 9cc77e8151a4
child 6713 248ef6ff9725
--- a/AbstractBorder.st	Sat Oct 24 11:04:39 2009 +0200
+++ b/AbstractBorder.st	Sat Oct 24 12:07:22 2009 +0200
@@ -1,7 +1,7 @@
 "
  COPYRIGHT (c) 1997 by eXept Software AG
  COPYRIGHT (c) 2009 by eXept Software AG
-              All Rights Reserved
+	      All Rights Reserved
 
  This software is furnished under a license and may be used
  only in accordance with the terms of that license and with the
@@ -13,7 +13,7 @@
 "{ Package: 'stx:libview' }"
 
 Object subclass:#AbstractBorder
-	instanceVariableNames:''
+	instanceVariableNames:'width'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'Graphics-Support'
@@ -25,7 +25,7 @@
 "
  COPYRIGHT (c) 1997 by eXept Software AG
  COPYRIGHT (c) 2009 by eXept Software AG
-              All Rights Reserved
+	      All Rights Reserved
 
  This software is furnished under a license and may be used
  only in accordance with the terms of that license and with the
@@ -44,14 +44,14 @@
     drawn 3D levels (which is ugly, but served me well for almost 20years now).
 
     [author:]
-        Claus Gittinger
+	Claus Gittinger
 "
 ! !
 
 !AbstractBorder class methodsFor:'instance creation'!
 
 width:borderWidth
-    "create a new instance of the receiver with a border of the given width  
+    "create a new instance of the receiver with a border of the given width
      (and default color)."
 
     ^ self new width:borderWidth color:(Color black)
@@ -60,19 +60,43 @@
 !
 
 width:borderWidth color:aColor
-    "create a new instance of the receiver with a border of the given width  
+    "create a new instance of the receiver with a border of the given width
      and color."
 
-    ^ self new setBorderWidth:borderWidth color:aColor
+    ^ self new width:borderWidth color:aColor
 
     "Modified: 10.2.1997 / 15:20:32 / cg"
 ! !
 
 !AbstractBorder methodsFor:'accessing'!
 
-setBorderWidth:aWidth color:aColor
-     self setBorderWidth:aWidth.
-     self setBorderColor:aColor
+color:aColor
+    "set the width"
+
+    "/ self subclassResponsibility
+!
+
+level
+    "get the 3D level"
+
+    ^ 0
+!
+
+width
+    "get the width"
+
+    ^ width
+!
+
+width:aNumber
+    "set the width"
+
+    width := aNumber
+!
+
+width:aWidth color:aColor
+     self width:aWidth.
+     self color:aColor
 
     "Created: 10.2.1997 / 15:21:27 / cg"
 ! !
@@ -83,31 +107,56 @@
     "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
-    self subclassResponsibility
+    "/ self subclassResponsibility
 ! !
 
-!AbstractBorder methodsFor:'private accessing'!
+!AbstractBorder methodsFor:'queries'!
 
-setBorderColor:arg
-    "raise an error: must be redefined in concrete subclass(es)"
+allSidesEqual:aSmallInteger 
+    "true if all four sides have the same border width;
+     always true here - provided for compatibility"
 
-    ^ self subclassResponsibility
+    ^ true
+
+    "Created: 10.2.1997 / 14:53:13 / cg"
 !
 
-setBorderWidth:arg
-    "raise an error: must be redefined in concrete subclass(es)"
+displayBoxFor:aRectangle
+    "return a rectangle representing the overall display box of a component
+     bordered by the receiver, which has bounds of aRectangle.
+     That is, the argument outset by the receivers borders."
+
+    |insetRectangle|
+
+    insetRectangle := aRectangle copy.
+    insetRectangle left:(insetRectangle left - width).
+    insetRectangle right:(insetRectangle right + width).
+    insetRectangle top:(insetRectangle top - width).
+    insetRectangle bottom:(insetRectangle bottom + width).
+    ^ insetRectangle
 
-    ^ self subclassResponsibility
+    "Created: 10.2.1997 / 15:43:00 / cg"
+!
+
+insetDisplayBoxFor:aRectangle
+    "return a rectangle representing the display box of a component
+     bordered by the receiver in the outer bounds, aRectangle.
+     That is, the argument inset by the receivers borders."
+
+    |insetRectangle|
+
+    insetRectangle := aRectangle copy.
+    insetRectangle left:(insetRectangle left + width).
+    insetRectangle right:(insetRectangle right - width).
+    insetRectangle top:(insetRectangle top + width).
+    insetRectangle bottom:(insetRectangle bottom - width).
+    ^ insetRectangle
+
+    "Created: 10.2.1997 / 15:42:06 / cg"
 ! !
 
 !AbstractBorder class methodsFor:'documentation'!
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libview/AbstractBorder.st,v 1.2 2009-10-23 15:23:50 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/AbstractBorder.st,v 1.3 2009-10-24 10:07:22 cg Exp $'
 ! !