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