author | Claus Gittinger <cg@exept.de> |
Tue, 27 Jul 1999 17:00:02 +0200 | |
changeset 1210 | 376e329af91d |
parent 1186 | eb94ab8ac18c |
child 1241 | 414114cfc5cc |
permissions | -rw-r--r-- |
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 |
" |
|
1186 | 24 |
some regions; the blue one has its own cursor, |
25 |
the light-grey and red ones havea popupMenu, |
|
26 |
however, the red one is almost completely covered by an invisible inputView |
|
27 |
which provides its own menu (only the far left edge of the red region |
|
28 |
shows the red-menu) |
|
29 |
[exBegin] |
|
30 |
|top s1 s2 s3 s4 v1 rd i vh| |
|
597 | 31 |
|
32 |
top := StandardSystemView new extent:250@250. |
|
33 |
||
1186 | 34 |
rd := true. |
597 | 35 |
|
36 |
v1 := View origin:25@25 extent:50@50 in:top. |
|
37 |
v1 viewBackground:(Color blue). |
|
1186 | 38 |
v1 cursor:(Cursor thumbsUp). |
39 |
vh := ValueHolder new. |
|
40 |
vh onChangeSend:#value to:[ v1 viewBackground:vh value. v1 clear ]. |
|
41 |
vh inspect. |
|
597 | 42 |
|
43 |
s1 := VisualRegion origin:10@10 extent:30@30 in:top. |
|
44 |
s1 lineWidth:0. |
|
45 |
s1 viewBackground:(Color gray:90). |
|
46 |
s1 isElliptical:rd. |
|
1186 | 47 |
s1 middleButtonMenu:(PopUpMenu labels:#('foo' 'bar')). |
597 | 48 |
|
49 |
s2 := VisualRegion origin:60@10 extent:30@30 in:top. |
|
1186 | 50 |
s2 viewBackground:(Color green). |
597 | 51 |
s2 lineWidth:1. |
52 |
s2 isElliptical:rd. |
|
53 |
||
54 |
s3 := VisualRegion origin:10@60 extent:100@30 in:top. |
|
55 |
s3 viewBackground:(Color gray:70). |
|
56 |
s3 lineWidth:0. |
|
57 |
s3 isOpaque:false. |
|
58 |
s3 isElliptical:rd. |
|
59 |
||
1186 | 60 |
s4 := VisualRegion origin:60@60 extent:60@30 in:top. |
61 |
s4 viewBackground:(Color red). |
|
62 |
s4 lineWidth:3. |
|
597 | 63 |
s4 isOpaque:false. |
64 |
s4 isElliptical:rd. |
|
1186 | 65 |
s4 middleButtonMenu:(PopUpMenu labels:#('foo1' 'bar1')). |
66 |
||
67 |
i := InputView origin:70@60 extent:60@30 in:top. |
|
68 |
i middleButtonMenu:(PopUpMenu labels:#('foo2' 'bar2')). |
|
597 | 69 |
|
70 |
top open |
|
1186 | 71 |
[exEnd] |
597 | 72 |
" |
73 |
! ! |
|
74 |
||
75 |
!VisualRegion methodsFor:'accessing'! |
|
76 |
||
77 |
isElliptical |
|
78 |
"get the outline of the region; elliptical or rectangle |
|
79 |
" |
|
80 |
^ isElliptical |
|
81 |
||
82 |
! |
|
83 |
||
84 |
isElliptical:aBoolean |
|
85 |
"set the outline of the region; elliptical or rectangle |
|
86 |
" |
|
87 |
(isElliptical ~~ aBoolean) ifTrue:[ |
|
88 |
isElliptical := aBoolean. |
|
89 |
self layoutChanged |
|
90 |
]. |
|
91 |
! |
|
92 |
||
93 |
isOpaque |
|
94 |
"get opaque mode concerning the inner background of the region |
|
95 |
" |
|
96 |
^ isOpaque |
|
97 |
||
98 |
||
99 |
! |
|
100 |
||
101 |
isOpaque:aBoolean |
|
102 |
"set opaque mode concerning the inner background of the region |
|
103 |
" |
|
104 |
(isOpaque ~~ aBoolean) ifTrue:[ |
|
105 |
isOpaque := aBoolean. |
|
106 |
self layoutChanged |
|
107 |
]. |
|
108 |
||
109 |
||
110 |
! |
|
111 |
||
112 |
lineWidth:aNumber |
|
113 |
"set the border drawing width in pixels |
|
114 |
" |
|
115 |
lineWidth ~~ aNumber ifTrue:[ |
|
116 |
super lineWidth:aNumber. |
|
117 |
self layoutChanged |
|
118 |
] |
|
119 |
||
120 |
! |
|
121 |
||
122 |
setLineWidth:aNumber |
|
123 |
"set the line drawing width in pixels without recomputation of the shape |
|
124 |
" |
|
125 |
super lineWidth:aNumber |
|
126 |
||
127 |
! ! |
|
128 |
||
129 |
!VisualRegion methodsFor:'change & update'! |
|
130 |
||
131 |
sizeChanged:how |
|
132 |
"must compute a new shape, when size is changed |
|
133 |
" |
|
134 |
self computeShape. |
|
135 |
super sizeChanged:how |
|
136 |
||
137 |
||
138 |
! ! |
|
139 |
||
140 |
!VisualRegion methodsFor:'initialization'! |
|
141 |
||
142 |
initialize |
|
143 |
"setup default configuration |
|
144 |
" |
|
145 |
super initialize. |
|
146 |
isElliptical := false. |
|
147 |
isOpaque := true. |
|
148 |
self computeShape |
|
149 |
||
150 |
||
151 |
! ! |
|
152 |
||
153 |
!VisualRegion methodsFor:'private'! |
|
154 |
||
155 |
layoutChanged |
|
156 |
"recompute shape and change to invalidate |
|
157 |
" |
|
158 |
self computeShape. |
|
954 | 159 |
shown ifTrue:[ |
160 |
self invalidate |
|
161 |
] |
|
597 | 162 |
|
954 | 163 |
"Modified: / 6.6.1998 / 19:52:41 / cg" |
597 | 164 |
! ! |
165 |
||
166 |
!VisualRegion methodsFor:'queries'! |
|
167 |
||
168 |
specClass |
|
169 |
^ RegionSpec |
|
170 |
||
171 |
||
172 |
! ! |
|
173 |
||
174 |
!VisualRegion methodsFor:'shape computation'! |
|
175 |
||
176 |
computeShape |
|
177 |
"computes 2 forms, one for the border, the other for the inside area. The border |
|
178 |
form is borderwidth*2 pixels larger. Each form gets filled with an ellipse of |
|
179 |
1-pixels, to define the shapes (take a look at the XShape spec, for more info) |
|
180 |
" |
|
181 |
isElliptical ifTrue:[ |
|
1183
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
182 |
self makeRoundViewShapeWithBorder:lineWidth. |
597 | 183 |
] ifFalse:[ |
1183
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
184 |
self borderShape:nil. |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
185 |
self viewShape:nil. |
1184 | 186 |
self borderWidth:lineWidth. |
597 | 187 |
]. |
1183
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
188 |
^ self. |
597 | 189 |
|
1183
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
190 |
"/ |border shape extent form| |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
191 |
"/ |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
192 |
"/ extent := self extent. |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
193 |
"/ border := Form extent:extent. |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
194 |
"/ shape := Form extent:extent. |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
195 |
"/ |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
196 |
"/ isElliptical ifTrue:[ |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
197 |
"/ border fillArcX:0 y:0 |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
198 |
"/ width:(border width) |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
199 |
"/ height:(border height) |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
200 |
"/ from:0 |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
201 |
"/ angle:360. |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
202 |
"/ ] ifFalse:[ |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
203 |
"/ border fillRectangleX:0 y:0 |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
204 |
"/ width:(border width) |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
205 |
"/ height:(border height) |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
206 |
"/ ]. |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
207 |
"/ |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
208 |
"/ isOpaque ifFalse:[ |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
209 |
"/ form := border. |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
210 |
"/ border foreground:(Color colorId:0). |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
211 |
"/ ] ifTrue:[ |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
212 |
"/ form := shape. |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
213 |
"/ shape foreground:(Color colorId:1). |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
214 |
"/ ]. |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
215 |
"/ |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
216 |
"/ isElliptical ifTrue:[ |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
217 |
"/ form fillArcX:lineWidth y:lineWidth |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
218 |
"/ width:(border width) - (lineWidth * 2) |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
219 |
"/ height:(border height) - (lineWidth * 2) |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
220 |
"/ from:0 |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
221 |
"/ angle:360. |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
222 |
"/ ] ifFalse:[ |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
223 |
"/ form fillRectangleX:lineWidth y:lineWidth |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
224 |
"/ width:(border width) - (lineWidth * 2) |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
225 |
"/ height:(border height) - (lineWidth * 2). |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
226 |
"/ ]. |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
227 |
"/ self borderShape:border. |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
228 |
"/ self viewShape:shape. |
597 | 229 |
|
1183
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
230 |
"Modified: / 5.6.1999 / 21:28:54 / cg" |
597 | 231 |
! ! |
232 |
||
233 |
!VisualRegion class methodsFor:'documentation'! |
|
234 |
||
235 |
version |
|
1186 | 236 |
^ '$Header: /cvs/stx/stx/libview2/VisualRegion.st,v 1.5 1999-06-05 22:16:36 cg Exp $' |
597 | 237 |
! ! |