author | Claus Gittinger <cg@exept.de> |
Sun, 12 May 1996 22:35:18 +0200 | |
changeset 263 | 091fa4a2f558 |
parent 262 | 55b430276719 |
child 265 | 45c83acd7562 |
permissions | -rw-r--r-- |
245 | 1 |
" |
2 |
COPYRIGHT (c) 1996 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 |
||
13 |
||
253 | 14 |
GeometricWrapper subclass:#StrokingWrapper |
262
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
15 |
instanceVariableNames:'lineWidth lineStyle capStyle joinStyle' |
245 | 16 |
classVariableNames:'' |
17 |
poolDictionaries:'' |
|
18 |
category:'Graphics-Display Objects' |
|
19 |
! |
|
20 |
||
21 |
!StrokingWrapper class methodsFor:'documentation'! |
|
22 |
||
23 |
copyright |
|
24 |
" |
|
25 |
COPYRIGHT (c) 1996 by Claus Gittinger |
|
26 |
All Rights Reserved |
|
27 |
||
28 |
This software is furnished under a license and may be used |
|
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
34 |
" |
|
35 |
||
36 |
! |
|
37 |
||
38 |
documentation |
|
39 |
" |
|
40 |
a wrapper for a geometric object, which is to be drawn stroked. |
|
41 |
This allows any geometric thingy to be used as a component in a view. |
|
42 |
||
254 | 43 |
(background info: geometrics are mathematical objects - they do not |
44 |
keep any color or lineStyle attributes. Wrappers add this information |
|
45 |
and can also be used as components of a view) |
|
46 |
||
248 | 47 |
[see also:] |
48 |
FillingWrapper Geometric GraphicsContext |
|
49 |
||
245 | 50 |
[author:] |
51 |
Claus Gittinger |
|
52 |
" |
|
53 |
! |
|
54 |
||
55 |
examples |
|
56 |
" |
|
254 | 57 |
wrap an ellipticArc and display it |
58 |
(notice, that no automatic redraw is performed): |
|
245 | 59 |
[exBegin] |
248 | 60 |
|v e component| |
245 | 61 |
|
248 | 62 |
v := (View extent:250@250) openAndWait. |
245 | 63 |
|
248 | 64 |
e := EllipticalArc boundingBox:(10@10 corner:90@90) |
65 |
startAngle:0 |
|
66 |
sweepAngle:270. |
|
67 |
component := StrokingWrapper on:e. |
|
245 | 68 |
|
248 | 69 |
component displayOn:v. |
245 | 70 |
[exEnd] |
71 |
||
254 | 72 |
wrap a rectangle and an ellipticArc, |
73 |
and add them as components to a View |
|
74 |
(notice, that doing so makes the redraw automatic): |
|
245 | 75 |
[exBegin] |
248 | 76 |
|v e component| |
245 | 77 |
|
248 | 78 |
v := View new. |
79 |
v extent:250@250. |
|
245 | 80 |
|
248 | 81 |
e := Rectangle origin:10@10 corner:90@90. |
82 |
component := FillingWrapper on:e. |
|
83 |
component foregroundColor:Color red. |
|
245 | 84 |
|
248 | 85 |
v addComponent:component. |
245 | 86 |
|
248 | 87 |
e := EllipticalArc boundingBox:(10@10 corner:90@90) |
88 |
startAngle:0 sweepAngle:360. |
|
89 |
component := StrokingWrapper on:e. |
|
90 |
component lineWidth:5. |
|
245 | 91 |
|
248 | 92 |
v addComponent:component. |
245 | 93 |
|
248 | 94 |
v addComponent:(Button label:'hello'). |
245 | 95 |
|
248 | 96 |
v open |
245 | 97 |
[exEnd] |
263 | 98 |
with lineWidth & style: |
99 |
(notice, that no automatic redraw is performed): |
|
100 |
[exBegin] |
|
101 |
|v e| |
|
102 |
||
103 |
v := View extent:250@250. |
|
104 |
||
105 |
e := EllipticalArc boundingBox:(10@10 corner:90@90) |
|
106 |
startAngle:0 |
|
107 |
sweepAngle:270. |
|
108 |
v addComponent:((StrokingWrapper on:e) |
|
109 |
lineWidth:5; |
|
110 |
lineStyle:#dashed; |
|
111 |
foregroundColor:(Color red)). |
|
112 |
||
113 |
e := EllipticalArc boundingBox:(30@30 corner:70@70) |
|
114 |
startAngle:90 |
|
115 |
sweepAngle:270. |
|
116 |
v addComponent:((StrokingWrapper on:e) |
|
117 |
lineWidth:5; |
|
118 |
lineStyle:#doubleDashed; |
|
119 |
foregroundColor:(Color red); |
|
120 |
backgroundColor:(Color green)). |
|
121 |
v open. |
|
122 |
[exEnd] |
|
123 |
||
245 | 124 |
" |
125 |
! ! |
|
126 |
||
127 |
!StrokingWrapper methodsFor:'accessing'! |
|
128 |
||
129 |
bounds |
|
246 | 130 |
"return the boundary rectangle - here, must take care of the lineWidth" |
131 |
||
245 | 132 |
^ component bounds + (lineWidth - 1) |
133 |
||
134 |
"Created: 8.5.1996 / 23:22:43 / cg" |
|
246 | 135 |
"Modified: 9.5.1996 / 00:09:06 / cg" |
245 | 136 |
! |
137 |
||
262
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
138 |
capStyle |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
139 |
"return the capStyle" |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
140 |
|
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
141 |
^ capStyle |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
142 |
|
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
143 |
"Created: 8.5.1996 / 23:22:04 / cg" |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
144 |
"Modified: 9.5.1996 / 00:09:12 / cg" |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
145 |
! |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
146 |
|
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
147 |
capStyle:aSymbol |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
148 |
"set the capStyle" |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
149 |
|
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
150 |
capStyle := aSymbol |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
151 |
|
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
152 |
"Created: 8.5.1996 / 23:22:13 / cg" |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
153 |
"Modified: 9.5.1996 / 00:09:17 / cg" |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
154 |
! |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
155 |
|
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
156 |
joinStyle |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
157 |
"return the joinStyle" |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
158 |
|
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
159 |
^ joinStyle |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
160 |
|
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
161 |
"Created: 8.5.1996 / 23:22:04 / cg" |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
162 |
"Modified: 9.5.1996 / 00:09:12 / cg" |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
163 |
! |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
164 |
|
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
165 |
joinStyle:aSymbol |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
166 |
"set the joinStyle" |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
167 |
|
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
168 |
joinStyle := aSymbol |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
169 |
|
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
170 |
"Created: 8.5.1996 / 23:22:13 / cg" |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
171 |
"Modified: 9.5.1996 / 00:09:17 / cg" |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
172 |
! |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
173 |
|
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
174 |
lineStyle |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
175 |
"return the lineStyle" |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
176 |
|
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
177 |
^ lineStyle |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
178 |
|
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
179 |
"Created: 8.5.1996 / 23:22:04 / cg" |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
180 |
"Modified: 9.5.1996 / 00:09:12 / cg" |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
181 |
! |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
182 |
|
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
183 |
lineStyle:aSymbol |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
184 |
"set the lineStyle" |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
185 |
|
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
186 |
lineStyle := aSymbol |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
187 |
|
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
188 |
"Created: 8.5.1996 / 23:22:13 / cg" |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
189 |
"Modified: 9.5.1996 / 00:09:17 / cg" |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
190 |
! |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
191 |
|
245 | 192 |
lineWidth |
246 | 193 |
"return the lineWidth" |
194 |
||
245 | 195 |
^ lineWidth |
196 |
||
197 |
"Created: 8.5.1996 / 23:22:04 / cg" |
|
246 | 198 |
"Modified: 9.5.1996 / 00:09:12 / cg" |
245 | 199 |
! |
200 |
||
201 |
lineWidth:aNumber |
|
246 | 202 |
"set the lineWidth" |
203 |
||
245 | 204 |
lineWidth := aNumber |
205 |
||
206 |
"Created: 8.5.1996 / 23:22:13 / cg" |
|
246 | 207 |
"Modified: 9.5.1996 / 00:09:17 / cg" |
245 | 208 |
! |
209 |
||
210 |
preferredBounds |
|
246 | 211 |
"return the components bounds as preferredBounds" |
212 |
||
245 | 213 |
^ self bounds |
214 |
||
215 |
"Created: 8.5.1996 / 23:23:00 / cg" |
|
246 | 216 |
"Modified: 9.5.1996 / 00:09:31 / cg" |
245 | 217 |
! ! |
218 |
||
219 |
!StrokingWrapper methodsFor:'displaying'! |
|
220 |
||
221 |
displayOn:aGC |
|
246 | 222 |
"display myself - here, display the geometric object asStroked" |
223 |
||
262
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
224 |
|prevLineWidth prevLineStyle prevCapStyle prevJoinStyle |
263 | 225 |
prevFg prevBg| |
245 | 226 |
|
227 |
prevLineWidth := aGC lineWidth. |
|
262
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
228 |
prevLineStyle := aGC lineStyle. |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
229 |
prevJoinStyle := aGC joinStyle. |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
230 |
prevCapStyle := aGC capStyle. |
245 | 231 |
prevFg := aGC paint. |
263 | 232 |
prevBg := aGC backgroundPaint. |
245 | 233 |
|
234 |
aGC lineWidth:lineWidth. |
|
262
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
235 |
aGC lineStyle:lineStyle. |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
236 |
aGC joinStyle:joinStyle. |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
237 |
aGC capStyle:capStyle. |
263 | 238 |
aGC paint:fgColor on:bgColor. |
245 | 239 |
|
240 |
component displayStrokedOn:aGC. |
|
241 |
||
242 |
aGC lineWidth:prevLineWidth. |
|
262
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
243 |
aGC lineStyle:prevLineStyle. |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
244 |
aGC joinStyle:prevJoinStyle. |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
245 |
aGC capStyle:prevCapStyle. |
263 | 246 |
aGC paint:prevFg on:prevBg. |
245 | 247 |
|
248 |
"Created: 8.5.1996 / 23:24:04 / cg" |
|
246 | 249 |
"Modified: 9.5.1996 / 00:11:17 / cg" |
245 | 250 |
! ! |
251 |
||
252 |
!StrokingWrapper methodsFor:'initialization'! |
|
253 |
||
254 |
initialize |
|
246 | 255 |
"default my lineWidth to one pixel" |
256 |
||
245 | 257 |
super initialize. |
258 |
lineWidth := 1. |
|
259 |
||
260 |
"Created: 8.5.1996 / 23:49:27 / cg" |
|
246 | 261 |
"Modified: 9.5.1996 / 00:11:51 / cg" |
245 | 262 |
! ! |
263 |
||
264 |
!StrokingWrapper class methodsFor:'documentation'! |
|
265 |
||
266 |
version |
|
263 | 267 |
^ '$Header: /cvs/stx/stx/libview2/StrokingWrapper.st,v 1.7 1996-05-12 20:35:18 cg Exp $' |
245 | 268 |
! ! |