author | Claus Gittinger <cg@exept.de> |
Sat, 05 Jun 1999 21:43:56 +0200 | |
changeset 1183 | 8dff9008b5c7 |
parent 954 | e59f70e01541 |
child 1184 | 6bdcc3a40103 |
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 |
" |
|
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. |
|
954 | 143 |
shown ifTrue:[ |
144 |
self invalidate |
|
145 |
] |
|
597 | 146 |
|
954 | 147 |
"Modified: / 6.6.1998 / 19:52:41 / cg" |
597 | 148 |
! ! |
149 |
||
150 |
!VisualRegion methodsFor:'queries'! |
|
151 |
||
152 |
specClass |
|
153 |
^ RegionSpec |
|
154 |
||
155 |
||
156 |
! ! |
|
157 |
||
158 |
!VisualRegion methodsFor:'shape computation'! |
|
159 |
||
160 |
computeShape |
|
161 |
"computes 2 forms, one for the border, the other for the inside area. The border |
|
162 |
form is borderwidth*2 pixels larger. Each form gets filled with an ellipse of |
|
163 |
1-pixels, to define the shapes (take a look at the XShape spec, for more info) |
|
164 |
" |
|
165 |
isElliptical ifTrue:[ |
|
1183
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
166 |
self makeRoundViewShapeWithBorder:lineWidth. |
597 | 167 |
] ifFalse:[ |
1183
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
168 |
self borderShape:nil. |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
169 |
self viewShape:nil. |
597 | 170 |
]. |
1183
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
171 |
^ self. |
597 | 172 |
|
1183
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
173 |
"/ |border shape extent form| |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
174 |
"/ |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
175 |
"/ extent := self extent. |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
176 |
"/ border := Form extent:extent. |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
177 |
"/ shape := Form extent:extent. |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
178 |
"/ |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
179 |
"/ isElliptical ifTrue:[ |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
180 |
"/ border fillArcX:0 y:0 |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
181 |
"/ width:(border width) |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
182 |
"/ height:(border height) |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
183 |
"/ from:0 |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
184 |
"/ angle:360. |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
185 |
"/ ] ifFalse:[ |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
186 |
"/ border fillRectangleX:0 y:0 |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
187 |
"/ width:(border width) |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
188 |
"/ height:(border height) |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
189 |
"/ ]. |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
190 |
"/ |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
191 |
"/ isOpaque ifFalse:[ |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
192 |
"/ form := border. |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
193 |
"/ border foreground:(Color colorId:0). |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
194 |
"/ ] ifTrue:[ |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
195 |
"/ form := shape. |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
196 |
"/ shape foreground:(Color colorId:1). |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
197 |
"/ ]. |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
198 |
"/ |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
199 |
"/ isElliptical ifTrue:[ |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
200 |
"/ form fillArcX:lineWidth y:lineWidth |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
201 |
"/ width:(border width) - (lineWidth * 2) |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
202 |
"/ height:(border height) - (lineWidth * 2) |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
203 |
"/ from:0 |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
204 |
"/ angle:360. |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
205 |
"/ ] ifFalse:[ |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
206 |
"/ form fillRectangleX:lineWidth y:lineWidth |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
207 |
"/ width:(border width) - (lineWidth * 2) |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
208 |
"/ height:(border height) - (lineWidth * 2). |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
209 |
"/ ]. |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
210 |
"/ self borderShape:border. |
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
211 |
"/ self viewShape:shape. |
597 | 212 |
|
1183
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
213 |
"Modified: / 5.6.1999 / 21:28:54 / cg" |
597 | 214 |
! ! |
215 |
||
216 |
!VisualRegion class methodsFor:'documentation'! |
|
217 |
||
218 |
version |
|
1183
8dff9008b5c7
use common roundShape computer
Claus Gittinger <cg@exept.de>
parents:
954
diff
changeset
|
219 |
^ '$Header: /cvs/stx/stx/libview2/VisualRegion.st,v 1.3 1999-06-05 19:43:56 cg Exp $' |
597 | 220 |
! ! |