author | Claus Gittinger <cg@exept.de> |
Tue, 29 Aug 2017 23:16:03 +0200 | |
changeset 4000 | d39d58494281 |
parent 3464 | 85e229581fd1 |
child 4213 | 8127ef0ff47d |
permissions | -rw-r--r-- |
3464 | 1 |
"{ Encoding: utf8 }" |
2 |
||
1803 | 3 |
" |
4 |
COPYRIGHT (c) 1997 by Claus Gittinger |
|
5 |
All Rights Reserved |
|
6 |
||
7 |
This software is furnished under a license and may be used |
|
8 |
only in accordance with the terms of that license and with the |
|
9 |
inclusion of the above copyright notice. This software may not |
|
10 |
be provided or otherwise made available to, or used by, any |
|
11 |
other person. No title to or ownership of the software is |
|
12 |
hereby transferred. |
|
13 |
" |
|
14 |
"{ Package: 'stx:libview2' }" |
|
15 |
||
3464 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
597 | 18 |
SimpleView subclass:#VisualRegion |
19 |
instanceVariableNames:'isElliptical isOpaque' |
|
20 |
classVariableNames:'' |
|
21 |
poolDictionaries:'' |
|
22 |
category:'Views-Special' |
|
23 |
! |
|
24 |
||
25 |
!VisualRegion class methodsFor:'documentation'! |
|
26 |
||
1803 | 27 |
copyright |
28 |
" |
|
29 |
COPYRIGHT (c) 1997 by Claus Gittinger |
|
30 |
All Rights Reserved |
|
31 |
||
32 |
This software is furnished under a license and may be used |
|
33 |
only in accordance with the terms of that license and with the |
|
34 |
inclusion of the above copyright notice. This software may not |
|
35 |
be provided or otherwise made available to, or used by, any |
|
36 |
other person. No title to or ownership of the software is |
|
37 |
hereby transferred. |
|
38 |
" |
|
39 |
! |
|
40 |
||
597 | 41 |
documentation |
42 |
" |
|
43 |
VisualRegion is a passive visual component which provides a rectangular or elliptical |
|
44 |
shape. It can take an arbitrary border line thicknesses and can be defined as opaque |
|
45 |
with a background color or non opaque. |
|
46 |
||
1241 | 47 |
Notice: |
48 |
This is an ST-80 compatibility class, provided to aid porting |
|
49 |
of ST-80 or VisualWorks code; |
|
50 |
it may be incomplete or incompatible to the corresponding ST-80 class. |
|
597 | 51 |
If you encounter any incompatibilities, please forward a note |
52 |
describing the incompatibility verbal (i.e. no code) to the ST/X team. |
|
53 |
" |
|
54 |
! |
|
55 |
||
56 |
examples |
|
57 |
" |
|
1186 | 58 |
some regions; the blue one has its own cursor, |
59 |
the light-grey and red ones havea popupMenu, |
|
60 |
however, the red one is almost completely covered by an invisible inputView |
|
61 |
which provides its own menu (only the far left edge of the red region |
|
62 |
shows the red-menu) |
|
63 |
[exBegin] |
|
64 |
|top s1 s2 s3 s4 v1 rd i vh| |
|
597 | 65 |
|
66 |
top := StandardSystemView new extent:250@250. |
|
67 |
||
1186 | 68 |
rd := true. |
597 | 69 |
|
70 |
v1 := View origin:25@25 extent:50@50 in:top. |
|
71 |
v1 viewBackground:(Color blue). |
|
1186 | 72 |
v1 cursor:(Cursor thumbsUp). |
73 |
vh := ValueHolder new. |
|
74 |
vh onChangeSend:#value to:[ v1 viewBackground:vh value. v1 clear ]. |
|
75 |
vh inspect. |
|
597 | 76 |
|
77 |
s1 := VisualRegion origin:10@10 extent:30@30 in:top. |
|
78 |
s1 lineWidth:0. |
|
79 |
s1 viewBackground:(Color gray:90). |
|
80 |
s1 isElliptical:rd. |
|
1186 | 81 |
s1 middleButtonMenu:(PopUpMenu labels:#('foo' 'bar')). |
597 | 82 |
|
83 |
s2 := VisualRegion origin:60@10 extent:30@30 in:top. |
|
1186 | 84 |
s2 viewBackground:(Color green). |
597 | 85 |
s2 lineWidth:1. |
86 |
s2 isElliptical:rd. |
|
87 |
||
88 |
s3 := VisualRegion origin:10@60 extent:100@30 in:top. |
|
89 |
s3 viewBackground:(Color gray:70). |
|
90 |
s3 lineWidth:0. |
|
91 |
s3 isOpaque:false. |
|
92 |
s3 isElliptical:rd. |
|
93 |
||
1186 | 94 |
s4 := VisualRegion origin:60@60 extent:60@30 in:top. |
95 |
s4 viewBackground:(Color red). |
|
96 |
s4 lineWidth:3. |
|
597 | 97 |
s4 isOpaque:false. |
98 |
s4 isElliptical:rd. |
|
1186 | 99 |
s4 middleButtonMenu:(PopUpMenu labels:#('foo1' 'bar1')). |
100 |
||
101 |
i := InputView origin:70@60 extent:60@30 in:top. |
|
102 |
i middleButtonMenu:(PopUpMenu labels:#('foo2' 'bar2')). |
|
597 | 103 |
|
104 |
top open |
|
1186 | 105 |
[exEnd] |
597 | 106 |
" |
107 |
! ! |
|
108 |
||
109 |
!VisualRegion methodsFor:'accessing'! |
|
110 |
||
111 |
isElliptical |
|
112 |
"get the outline of the region; elliptical or rectangle |
|
113 |
" |
|
114 |
^ isElliptical |
|
115 |
||
116 |
! |
|
117 |
||
118 |
isElliptical:aBoolean |
|
119 |
"set the outline of the region; elliptical or rectangle |
|
120 |
" |
|
121 |
(isElliptical ~~ aBoolean) ifTrue:[ |
|
122 |
isElliptical := aBoolean. |
|
123 |
self layoutChanged |
|
124 |
]. |
|
125 |
! |
|
126 |
||
127 |
isOpaque |
|
3464 | 128 |
"return true, if the object fully covers its frame (i.e. is rectangular |
129 |
and has no 'holes'. |
|
130 |
Here, get the opaque mode concerning the inner background of the region" |
|
597 | 131 |
|
3464 | 132 |
^ isOpaque |
597 | 133 |
! |
134 |
||
135 |
isOpaque:aBoolean |
|
136 |
"set opaque mode concerning the inner background of the region |
|
137 |
" |
|
138 |
(isOpaque ~~ aBoolean) ifTrue:[ |
|
139 |
isOpaque := aBoolean. |
|
140 |
self layoutChanged |
|
141 |
]. |
|
142 |
||
143 |
||
144 |
! |
|
145 |
||
146 |
lineWidth:aNumber |
|
3290 | 147 |
"set the border drawing width in pixels" |
148 |
||
149 |
gc lineWidth ~~ aNumber ifTrue:[ |
|
597 | 150 |
super lineWidth:aNumber. |
151 |
self layoutChanged |
|
152 |
] |
|
153 |
! |
|
154 |
||
155 |
setLineWidth:aNumber |
|
156 |
"set the line drawing width in pixels without recomputation of the shape |
|
157 |
" |
|
158 |
super lineWidth:aNumber |
|
159 |
||
160 |
! ! |
|
161 |
||
162 |
!VisualRegion methodsFor:'change & update'! |
|
163 |
||
164 |
sizeChanged:how |
|
165 |
"must compute a new shape, when size is changed |
|
166 |
" |
|
167 |
self computeShape. |
|
168 |
super sizeChanged:how |
|
169 |
||
170 |
||
171 |
! ! |
|
172 |
||
173 |
!VisualRegion methodsFor:'initialization'! |
|
174 |
||
175 |
initialize |
|
176 |
"setup default configuration |
|
177 |
" |
|
178 |
super initialize. |
|
179 |
isElliptical := false. |
|
180 |
isOpaque := true. |
|
181 |
self computeShape |
|
182 |
||
183 |
||
184 |
! ! |
|
185 |
||
186 |
!VisualRegion methodsFor:'private'! |
|
187 |
||
188 |
layoutChanged |
|
189 |
"recompute shape and change to invalidate |
|
190 |
" |
|
191 |
self computeShape. |
|
1931
3eeab6c26ca9
invalidate checks itself for shown-flag
Claus Gittinger <cg@exept.de>
parents:
1803
diff
changeset
|
192 |
self invalidate |
597 | 193 |
|
954 | 194 |
"Modified: / 6.6.1998 / 19:52:41 / cg" |
597 | 195 |
! ! |
196 |
||
197 |
!VisualRegion methodsFor:'queries'! |
|
198 |
||
199 |
specClass |
|
200 |
^ RegionSpec |
|
201 |
||
202 |
||
203 |
! ! |
|
204 |
||
205 |
!VisualRegion methodsFor:'shape computation'! |
|
206 |
||
207 |
computeShape |
|
208 |
"computes 2 forms, one for the border, the other for the inside area. The border |
|
209 |
form is borderwidth*2 pixels larger. Each form gets filled with an ellipse of |
|
210 |
1-pixels, to define the shapes (take a look at the XShape spec, for more info) |
|
211 |
" |
|
212 |
isElliptical ifTrue:[ |
|
3290 | 213 |
self makeRoundViewShapeWithBorder:gc lineWidth opaque:isOpaque. |
597 | 214 |
] ifFalse:[ |
1342
acb9e9fe0cb1
fixed round shaped transparent views (Region)
Claus Gittinger <cg@exept.de>
parents:
1241
diff
changeset
|
215 |
isOpaque ifFalse:[ |
3290 | 216 |
self makeTransparentRectangularViewShapeWithBorder:gc lineWidth |
1342
acb9e9fe0cb1
fixed round shaped transparent views (Region)
Claus Gittinger <cg@exept.de>
parents:
1241
diff
changeset
|
217 |
] ifTrue:[ |
acb9e9fe0cb1
fixed round shaped transparent views (Region)
Claus Gittinger <cg@exept.de>
parents:
1241
diff
changeset
|
218 |
self borderShape:nil. |
acb9e9fe0cb1
fixed round shaped transparent views (Region)
Claus Gittinger <cg@exept.de>
parents:
1241
diff
changeset
|
219 |
self viewShape:nil. |
3290 | 220 |
self borderWidth:gc lineWidth. |
1342
acb9e9fe0cb1
fixed round shaped transparent views (Region)
Claus Gittinger <cg@exept.de>
parents:
1241
diff
changeset
|
221 |
] |
597 | 222 |
]. |
223 |
||
1183
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
224 |
"/ |border shape extent form| |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
225 |
"/ |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
226 |
"/ extent := self extent. |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
227 |
"/ border := Form extent:extent. |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
228 |
"/ shape := Form extent:extent. |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
229 |
"/ |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
230 |
"/ isElliptical ifTrue:[ |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
231 |
"/ border fillArcX:0 y:0 |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
232 |
"/ width:(border width) |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
233 |
"/ height:(border height) |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
234 |
"/ from:0 |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
235 |
"/ angle:360. |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
236 |
"/ ] ifFalse:[ |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
237 |
"/ border fillRectangleX:0 y:0 |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
238 |
"/ width:(border width) |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
239 |
"/ height:(border height) |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
240 |
"/ ]. |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
241 |
"/ |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
242 |
"/ isOpaque ifFalse:[ |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
243 |
"/ form := border. |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
244 |
"/ border foreground:(Color colorId:0). |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
245 |
"/ ] ifTrue:[ |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
246 |
"/ form := shape. |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
247 |
"/ shape foreground:(Color colorId:1). |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
248 |
"/ ]. |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
249 |
"/ |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
250 |
"/ isElliptical ifTrue:[ |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
251 |
"/ form fillArcX:lineWidth y:lineWidth |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
252 |
"/ width:(border width) - (lineWidth * 2) |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
253 |
"/ height:(border height) - (lineWidth * 2) |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
254 |
"/ from:0 |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
255 |
"/ angle:360. |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
256 |
"/ ] ifFalse:[ |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
257 |
"/ form fillRectangleX:lineWidth y:lineWidth |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
258 |
"/ width:(border width) - (lineWidth * 2) |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
259 |
"/ height:(border height) - (lineWidth * 2). |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
260 |
"/ ]. |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
261 |
"/ self borderShape:border. |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
262 |
"/ self viewShape:shape. |
597 | 263 |
|
1183
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
264 |
"Modified: / 5.6.1999 / 21:28:54 / cg" |
597 | 265 |
! ! |
266 |
||
267 |
!VisualRegion class methodsFor:'documentation'! |
|
268 |
||
269 |
version |
|
3464 | 270 |
^ '$Header: /cvs/stx/stx/libview2/VisualRegion.st,v 1.11 2015-05-05 11:14:10 cg Exp $' |
597 | 271 |
! ! |
3290 | 272 |