--- a/Border.st Mon Jan 05 21:34:41 2015 +0100
+++ b/Border.st Mon Jan 05 21:34:51 2015 +0100
@@ -11,6 +11,8 @@
"
"{ Package: 'stx:libview' }"
+"{ NameSpace: Smalltalk }"
+
AbstractBorder subclass:#Border
instanceVariableNames:'leftColor rightColor topColor bottomColor'
classVariableNames:''
@@ -51,64 +53,56 @@
examples
"
- [exBegin]
- |v b|
-
- v := StandardSystemView extent:10@10.
- v openAndWait.
-
- b := Border width:2 color:Color red.
- b displayOn:v forDisplayBox:(0@0 corner:9@9).
-
- Delay waitForSeconds:1.
- b setLeftColor:Color blue.
- b displayOn:v forDisplayBox:(0@0 corner:9@9).
- Delay waitForSeconds:1.
- b setTopColor:Color green.
- b displayOn:v forDisplayBox:(0@0 corner:9@9).
- Delay waitForSeconds:1.
- b setRightColor:Color magenta.
- b displayOn:v forDisplayBox:(0@0 corner:9@9).
- [exEnd]
-
- [exBegin]
+ [exBegin]
|v b|
v := StandardSystemView extent:100@100.
v openAndWait.
- b := Border width:2 color:Color red.
- b displayOn:v forDisplayBox:(0@0 corner:99@99).
+ b := Border width:10 color:Color red.
+ b displayOn:v forDisplayBox:(0@0 corner:90@90).
Delay waitForSeconds:1.
- b setLeft:5.
- v clear.
- b displayOn:v forDisplayBox:(0@0 corner:99@99).
+ b leftColor:Color blue.
+ b displayOn:v forDisplayBox:(0@0 corner:90@90).
+ Delay waitForSeconds:1.
+ b topColor:Color green.
+ b displayOn:v forDisplayBox:(0@0 corner:90@90).
Delay waitForSeconds:1.
- b setTop:3.
- v clear.
- b displayOn:v forDisplayBox:(0@0 corner:99@99).
- Delay waitForSeconds:1.
- b setRight:1.
- v clear.
- b displayOn:v forDisplayBox:(0@0 corner:99@99).
- [exEnd]
+ b rightColor:Color yellow.
+ b displayOn:v forDisplayBox:(0@0 corner:90@90).
+ [exEnd]
+
+ [exBegin]
+ |v b|
- [exBegin]
+ v := StandardSystemView extent:100@100.
+ v openAndWait.
+
+ b := Border width:10 color:Color red.
+ v border:b
+ [exEnd]
+
+ [exBegin]
|v sub1 sub2 sub3|
v := StandardSystemView extent:200@200.
v openAndWait.
sub1 := (View in:v) origin:10@10; corner:90@90.
- sub1 border:(SimpleBorder width:1 color:Color red ).
+ sub1 border:(SimpleBorder width:10 color:Color red ).
+ sub1 realize.
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 ).
+ sub2 border:(Border new width:10; color:Color blue; leftColor:Color red; rightColor:Color red ).
+ sub2 realize.
sub3 := (View in:v) origin:110@110; corner:190@190.
- sub3 border:(SimpleBorder width:1 color:Color green ).
+ sub3 border:(SimpleBorder width:10 color:Color green ).
+ sub3 realize.
- v open.
- [exEnd]
+ Delay waitForSeconds:1.
+ sub3 border:(Border new width:10; color:Color yellow; leftColor:Color red; rightColor:Color red ).
+
+ [exEnd]
"
! !
@@ -190,17 +184,13 @@
displayOn:aGC forDisplayBox:aRectangle
"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."
- |paint oldPaint
- t r l b rL rR rT rB rW rH|
+ |oldPaint rL rR rT rB rW rH|
width == 0 ifTrue:[ ^ self ].
oldPaint := aGC paint.
- r := aRectangle copy.
rL := aRectangle left.
rT := aRectangle top.
@@ -211,22 +201,38 @@
leftColor notNil ifTrue:[
aGC paint:leftColor.
- aGC fillRectangleX:rL y:rT width:width height:rH + 1 - b
+ width == 1 ifTrue:[
+ aGC displayLineFromX:rL y:rT toX:rL y:rB-1.
+ ] ifFalse:[
+ aGC fillRectangleX:rL y:rT width:width height:rH
+ ].
].
topColor notNil ifTrue:[
aGC paint:topColor.
- aGC fillRectangleX:(rL + l) y:rT width:rW - l height:width
+ width == 1 ifTrue:[
+ aGC displayLineFromX:rL+1 y:rT toX:rR-1 y:rT.
+ ] ifFalse:[
+ aGC fillRectangleX:(rL + width) y:rT width:rW - width height:width
+ ].
].
rightColor notNil ifTrue:[
aGC paint:rightColor.
- aGC fillRectangleX:(rR - r) y:(rT + t) width:width height:rH + 1 - t
+ width == 1 ifTrue:[
+ aGC displayLineFromX:rR-1 y:rT toX:rR-1 y:rB-1.
+ ] ifFalse:[
+ aGC fillRectangleX:(rR - width) y:(rT + width) width:width height:rH-width
+ ].
].
bottomColor notNil ifTrue:[
- aGC paint:paint.
- aGC fillRectangleX:(rL) y:(rB + 1 - b) width:rW - r height:width
+ aGC paint:bottomColor.
+ width == 1 ifTrue:[
+ aGC displayLineFromX:rL y:rB-1 toX:rR-1 y:rB-1.
+ ] ifFalse:[
+ aGC fillRectangleX:rL y:(rB-width) width:rW - width height:width
+ ].
].
aGC paint: oldPaint
@@ -237,9 +243,10 @@
!Border class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libview/Border.st,v 1.9 2009-11-04 11:23:14 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libview/Border.st,v 1.10 2015-01-05 20:34:51 cg Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libview/Border.st,v 1.9 2009-11-04 11:23:14 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libview/Border.st,v 1.10 2015-01-05 20:34:51 cg Exp $'
! !
+