597
|
1 |
SimpleView subclass:#VisualRegion
|
|
2 |
instanceVariableNames:'isElliptical isOpaque'
|
|
3 |
classVariableNames:''
|
|
4 |
poolDictionaries:''
|
|
5 |
category:'Views-Special'
|
|
6 |
!
|
|
7 |
|
|
8 |
!VisualRegion class methodsFor:'documentation'!
|
|
9 |
|
|
10 |
documentation
|
|
11 |
"
|
|
12 |
VisualRegion is a passive visual component which provides a rectangular or elliptical
|
|
13 |
shape. It can take an arbitrary border line thicknesses and can be defined as opaque
|
|
14 |
with a background color or non opaque.
|
|
15 |
|
|
16 |
- it may not be complete or compatible to the corresponding ST-80 class.
|
|
17 |
If you encounter any incompatibilities, please forward a note
|
|
18 |
describing the incompatibility verbal (i.e. no code) to the ST/X team.
|
|
19 |
"
|
|
20 |
!
|
|
21 |
|
|
22 |
examples
|
|
23 |
"
|
|
24 |
|top s1 s2 s3 s4 v1 rd|
|
|
25 |
|
|
26 |
top := StandardSystemView new extent:250@250.
|
|
27 |
|
|
28 |
rd := false.
|
|
29 |
|
|
30 |
v1 := View origin:25@25 extent:50@50 in:top.
|
|
31 |
v1 viewBackground:(Color blue).
|
|
32 |
|
|
33 |
s1 := VisualRegion origin:10@10 extent:30@30 in:top.
|
|
34 |
s1 lineWidth:0.
|
|
35 |
s1 viewBackground:(Color gray:90).
|
|
36 |
s1 isElliptical:rd.
|
|
37 |
|
|
38 |
s2 := VisualRegion origin:60@10 extent:30@30 in:top.
|
|
39 |
s2 viewBackground:(Color gray:80).
|
|
40 |
s2 lineWidth:1.
|
|
41 |
s2 isElliptical:rd.
|
|
42 |
|
|
43 |
s3 := VisualRegion origin:10@60 extent:100@30 in:top.
|
|
44 |
s3 viewBackground:(Color gray:70).
|
|
45 |
s3 lineWidth:0.
|
|
46 |
s3 isOpaque:false.
|
|
47 |
s3 isElliptical:rd.
|
|
48 |
|
|
49 |
s4 := VisualRegion origin:60@60 extent:30@30 in:top.
|
|
50 |
s4 viewBackground:(Color gray:60).
|
|
51 |
s4 lineWidth:1.
|
|
52 |
s4 isOpaque:false.
|
|
53 |
s4 isElliptical:rd.
|
|
54 |
|
|
55 |
top open
|
|
56 |
"
|
|
57 |
! !
|
|
58 |
|
|
59 |
!VisualRegion methodsFor:'accessing'!
|
|
60 |
|
|
61 |
isElliptical
|
|
62 |
"get the outline of the region; elliptical or rectangle
|
|
63 |
"
|
|
64 |
^ isElliptical
|
|
65 |
|
|
66 |
!
|
|
67 |
|
|
68 |
isElliptical:aBoolean
|
|
69 |
"set the outline of the region; elliptical or rectangle
|
|
70 |
"
|
|
71 |
(isElliptical ~~ aBoolean) ifTrue:[
|
|
72 |
isElliptical := aBoolean.
|
|
73 |
self layoutChanged
|
|
74 |
].
|
|
75 |
!
|
|
76 |
|
|
77 |
isOpaque
|
|
78 |
"get opaque mode concerning the inner background of the region
|
|
79 |
"
|
|
80 |
^ isOpaque
|
|
81 |
|
|
82 |
|
|
83 |
!
|
|
84 |
|
|
85 |
isOpaque:aBoolean
|
|
86 |
"set opaque mode concerning the inner background of the region
|
|
87 |
"
|
|
88 |
(isOpaque ~~ aBoolean) ifTrue:[
|
|
89 |
isOpaque := aBoolean.
|
|
90 |
self layoutChanged
|
|
91 |
].
|
|
92 |
|
|
93 |
|
|
94 |
!
|
|
95 |
|
|
96 |
lineWidth:aNumber
|
|
97 |
"set the border drawing width in pixels
|
|
98 |
"
|
|
99 |
lineWidth ~~ aNumber ifTrue:[
|
|
100 |
super lineWidth:aNumber.
|
|
101 |
self layoutChanged
|
|
102 |
]
|
|
103 |
|
|
104 |
!
|
|
105 |
|
|
106 |
setLineWidth:aNumber
|
|
107 |
"set the line drawing width in pixels without recomputation of the shape
|
|
108 |
"
|
|
109 |
super lineWidth:aNumber
|
|
110 |
|
|
111 |
! !
|
|
112 |
|
|
113 |
!VisualRegion methodsFor:'change & update'!
|
|
114 |
|
|
115 |
sizeChanged:how
|
|
116 |
"must compute a new shape, when size is changed
|
|
117 |
"
|
|
118 |
self computeShape.
|
|
119 |
super sizeChanged:how
|
|
120 |
|
|
121 |
|
|
122 |
! !
|
|
123 |
|
|
124 |
!VisualRegion methodsFor:'initialization'!
|
|
125 |
|
|
126 |
initialize
|
|
127 |
"setup default configuration
|
|
128 |
"
|
|
129 |
super initialize.
|
|
130 |
isElliptical := false.
|
|
131 |
isOpaque := true.
|
|
132 |
self computeShape
|
|
133 |
|
|
134 |
|
|
135 |
! !
|
|
136 |
|
|
137 |
!VisualRegion methodsFor:'private'!
|
|
138 |
|
|
139 |
layoutChanged
|
|
140 |
"recompute shape and change to invalidate
|
|
141 |
"
|
|
142 |
self computeShape.
|
|
143 |
self invalidate
|
|
144 |
|
|
145 |
! !
|
|
146 |
|
|
147 |
!VisualRegion methodsFor:'queries'!
|
|
148 |
|
|
149 |
specClass
|
|
150 |
^ RegionSpec
|
|
151 |
|
|
152 |
|
|
153 |
! !
|
|
154 |
|
|
155 |
!VisualRegion methodsFor:'shape computation'!
|
|
156 |
|
|
157 |
computeShape
|
|
158 |
"computes 2 forms, one for the border, the other for the inside area. The border
|
|
159 |
form is borderwidth*2 pixels larger. Each form gets filled with an ellipse of
|
|
160 |
1-pixels, to define the shapes (take a look at the XShape spec, for more info)
|
|
161 |
"
|
|
162 |
|border shape extent form|
|
|
163 |
|
|
164 |
extent := self extent.
|
|
165 |
border := Form extent:extent.
|
|
166 |
shape := Form extent:extent.
|
|
167 |
|
|
168 |
isElliptical ifTrue:[
|
|
169 |
border fillArcX:0 y:0
|
|
170 |
width:(border width)
|
|
171 |
height:(border height)
|
|
172 |
from:0
|
|
173 |
angle:360.
|
|
174 |
] ifFalse:[
|
|
175 |
border fillRectangleX:0 y:0
|
|
176 |
width:(border width)
|
|
177 |
height:(border height)
|
|
178 |
].
|
|
179 |
|
|
180 |
isOpaque ifFalse:[
|
|
181 |
form := border.
|
|
182 |
border foreground:(Color colorId:0).
|
|
183 |
] ifTrue:[
|
|
184 |
form := shape.
|
|
185 |
shape foreground:(Color colorId:1).
|
|
186 |
].
|
|
187 |
|
|
188 |
isElliptical ifTrue:[
|
|
189 |
form fillArcX:lineWidth y:lineWidth
|
|
190 |
width:(border width) - (lineWidth * 2)
|
|
191 |
height:(border height) - (lineWidth * 2)
|
|
192 |
from:0
|
|
193 |
angle:360.
|
|
194 |
] ifFalse:[
|
|
195 |
form fillRectangleX:lineWidth y:lineWidth
|
|
196 |
width:(border width) - (lineWidth * 2)
|
|
197 |
height:(border height) - (lineWidth * 2).
|
|
198 |
].
|
|
199 |
self borderShape:border.
|
|
200 |
self viewShape:shape.
|
|
201 |
|
|
202 |
! !
|
|
203 |
|
|
204 |
!VisualRegion class methodsFor:'documentation'!
|
|
205 |
|
|
206 |
version
|
|
207 |
^ '$Header: /cvs/stx/stx/libview2/VisualRegion.st,v 1.1 1997-06-16 09:32:57 ca Exp $'
|
|
208 |
! !
|