SimpleView subclass:#VisualRegion
instanceVariableNames:'isElliptical isOpaque'
classVariableNames:''
poolDictionaries:''
category:'Views-Special'
!
!VisualRegion class methodsFor:'documentation'!
documentation
"
VisualRegion is a passive visual component which provides a rectangular or elliptical
shape. It can take an arbitrary border line thicknesses and can be defined as opaque
with a background color or non opaque.
- 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.
"
!
examples
"
|top s1 s2 s3 s4 v1 rd|
top := StandardSystemView new extent:250@250.
rd := false.
v1 := View origin:25@25 extent:50@50 in:top.
v1 viewBackground:(Color blue).
s1 := VisualRegion origin:10@10 extent:30@30 in:top.
s1 lineWidth:0.
s1 viewBackground:(Color gray:90).
s1 isElliptical:rd.
s2 := VisualRegion origin:60@10 extent:30@30 in:top.
s2 viewBackground:(Color gray:80).
s2 lineWidth:1.
s2 isElliptical:rd.
s3 := VisualRegion origin:10@60 extent:100@30 in:top.
s3 viewBackground:(Color gray:70).
s3 lineWidth:0.
s3 isOpaque:false.
s3 isElliptical:rd.
s4 := VisualRegion origin:60@60 extent:30@30 in:top.
s4 viewBackground:(Color gray:60).
s4 lineWidth:1.
s4 isOpaque:false.
s4 isElliptical:rd.
top open
"
! !
!VisualRegion methodsFor:'accessing'!
isElliptical
"get the outline of the region; elliptical or rectangle
"
^ isElliptical
!
isElliptical:aBoolean
"set the outline of the region; elliptical or rectangle
"
(isElliptical ~~ aBoolean) ifTrue:[
isElliptical := aBoolean.
self layoutChanged
].
!
isOpaque
"get opaque mode concerning the inner background of the region
"
^ isOpaque
!
isOpaque:aBoolean
"set opaque mode concerning the inner background of the region
"
(isOpaque ~~ aBoolean) ifTrue:[
isOpaque := aBoolean.
self layoutChanged
].
!
lineWidth:aNumber
"set the border drawing width in pixels
"
lineWidth ~~ aNumber ifTrue:[
super lineWidth:aNumber.
self layoutChanged
]
!
setLineWidth:aNumber
"set the line drawing width in pixels without recomputation of the shape
"
super lineWidth:aNumber
! !
!VisualRegion methodsFor:'change & update'!
sizeChanged:how
"must compute a new shape, when size is changed
"
self computeShape.
super sizeChanged:how
! !
!VisualRegion methodsFor:'initialization'!
initialize
"setup default configuration
"
super initialize.
isElliptical := false.
isOpaque := true.
self computeShape
! !
!VisualRegion methodsFor:'private'!
layoutChanged
"recompute shape and change to invalidate
"
self computeShape.
self invalidate
! !
!VisualRegion methodsFor:'queries'!
specClass
^ RegionSpec
! !
!VisualRegion methodsFor:'shape computation'!
computeShape
"computes 2 forms, one for the border, the other for the inside area. The border
form is borderwidth*2 pixels larger. Each form gets filled with an ellipse of
1-pixels, to define the shapes (take a look at the XShape spec, for more info)
"
|border shape extent form|
extent := self extent.
border := Form extent:extent.
shape := Form extent:extent.
isElliptical ifTrue:[
border fillArcX:0 y:0
width:(border width)
height:(border height)
from:0
angle:360.
] ifFalse:[
border fillRectangleX:0 y:0
width:(border width)
height:(border height)
].
isOpaque ifFalse:[
form := border.
border foreground:(Color colorId:0).
] ifTrue:[
form := shape.
shape foreground:(Color colorId:1).
].
isElliptical ifTrue:[
form fillArcX:lineWidth y:lineWidth
width:(border width) - (lineWidth * 2)
height:(border height) - (lineWidth * 2)
from:0
angle:360.
] ifFalse:[
form fillRectangleX:lineWidth y:lineWidth
width:(border width) - (lineWidth * 2)
height:(border height) - (lineWidth * 2).
].
self borderShape:border.
self viewShape:shape.
! !
!VisualRegion class methodsFor:'documentation'!
version
^ '$Header: /cvs/stx/stx/libview2/VisualRegion.st,v 1.1 1997-06-16 09:32:57 ca Exp $'
! !