author | Claus Gittinger <cg@exept.de> |
Thu, 22 Dec 2005 17:55:14 +0100 | |
changeset 2074 | 043bdbb49ef4 |
parent 1789 | f52f0a0d8448 |
child 2634 | 487acf365da5 |
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 |
||
1789 | 14 |
"{ Package: 'stx:libview2' }" |
15 |
||
280 | 16 |
GeometricWrapper subclass:#StrokingWrapper |
17 |
instanceVariableNames:'lineWidth lineStyle capStyle joinStyle' |
|
245 | 18 |
classVariableNames:'' |
19 |
poolDictionaries:'' |
|
1789 | 20 |
category:'Compatibility-ST80-Graphics-Display Objects' |
245 | 21 |
! |
22 |
||
280 | 23 |
!StrokingWrapper class methodsFor:'documentation'! |
245 | 24 |
|
25 |
copyright |
|
26 |
" |
|
27 |
COPYRIGHT (c) 1996 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 |
! |
|
39 |
||
40 |
documentation |
|
41 |
" |
|
280 | 42 |
a wrapper for a geometric object, which is to be drawn stroked. |
43 |
This allows any geometric thingy to be used as a component in a view. |
|
44 |
||
45 |
(background info: geometrics are mathematical objects - they do not |
|
46 |
keep any color or lineStyle attributes. Wrappers add this information |
|
47 |
and can also be used as components of a view) |
|
254 | 48 |
|
265 | 49 |
Notice: |
50 |
this class was implemented using protocol information |
|
365 | 51 |
from alpha testers, from reading PD programs and |
52 |
from the Hopkins/Horan book. |
|
265 | 53 |
- it may not be complete or compatible to the corresponding ST-80 class. |
54 |
If you encounter any incompatibilities, please forward a note |
|
55 |
describing the incompatibility verbal (i.e. no code) to the ST/X team. |
|
56 |
||
248 | 57 |
[see also:] |
280 | 58 |
FillingWrapper Geometric GraphicsContext |
248 | 59 |
|
245 | 60 |
[author:] |
61 |
Claus Gittinger |
|
62 |
" |
|
63 |
! |
|
64 |
||
65 |
examples |
|
66 |
" |
|
280 | 67 |
wrap an ellipticArc and display it |
68 |
(notice, that no automatic redraw is performed): |
|
69 |
[exBegin] |
|
70 |
|v e component| |
|
71 |
||
72 |
v := (StandardSystemView extent:250@250) openAndWait. |
|
73 |
||
74 |
e := EllipticalArc boundingBox:(10@10 corner:90@90) |
|
75 |
startAngle:0 |
|
76 |
sweepAngle:270. |
|
77 |
component := StrokingWrapper on:e. |
|
78 |
||
79 |
component displayOn:v. |
|
80 |
[exEnd] |
|
81 |
||
82 |
wrap a rectangle and an ellipticArc, |
|
83 |
and add them as components to a View |
|
84 |
(notice, that doing so makes the redraw automatic): |
|
85 |
[exBegin] |
|
86 |
|v e component| |
|
87 |
||
88 |
v := StandardSystemView extent:250@250. |
|
89 |
||
90 |
e := Rectangle origin:10@10 corner:90@90. |
|
91 |
component := FillingWrapper on:e. |
|
92 |
component foregroundColor:Color red. |
|
93 |
||
94 |
v addComponent:component. |
|
95 |
||
96 |
e := EllipticalArc boundingBox:(10@10 corner:90@90) |
|
97 |
startAngle:0 sweepAngle:360. |
|
98 |
component := StrokingWrapper on:e. |
|
99 |
component lineWidth:5. |
|
100 |
||
101 |
v addComponent:component. |
|
102 |
||
103 |
v addComponent:(Button label:'hello'). |
|
104 |
||
105 |
v open |
|
106 |
[exEnd] |
|
107 |
with lineWidth & style: |
|
108 |
(notice, that the redraw is automatic): |
|
109 |
[exBegin] |
|
110 |
|v e| |
|
111 |
||
112 |
v := StandardSystemView extent:250@250. |
|
113 |
||
114 |
e := EllipticalArc boundingBox:(10@10 corner:90@90) |
|
115 |
startAngle:0 |
|
116 |
sweepAngle:270. |
|
117 |
v addComponent:((StrokingWrapper on:e) |
|
118 |
lineWidth:5; |
|
119 |
lineStyle:#dashed; |
|
120 |
foregroundColor:(Color red)). |
|
121 |
||
122 |
e := EllipticalArc boundingBox:(30@30 corner:70@70) |
|
123 |
startAngle:90 |
|
124 |
sweepAngle:270. |
|
125 |
v addComponent:((StrokingWrapper on:e) |
|
126 |
lineWidth:5; |
|
127 |
lineStyle:#doubleDashed; |
|
128 |
foregroundColor:(Color red); |
|
129 |
backgroundColor:(Color green)). |
|
130 |
v open. |
|
131 |
[exEnd] |
|
132 |
||
133 |
scrolling: |
|
273 | 134 |
[exBegin] |
135 |
|t s v e component| |
|
136 |
||
137 |
t := StandardSystemView extent:250@200. |
|
138 |
s := HVScrollableView for:View miniScroller:true in:t. |
|
139 |
s origin:0.0@0.0 corner:1.0@1.0. |
|
140 |
v := s scrolledView. |
|
141 |
||
142 |
e := Rectangle origin:10@10 corner:90@90. |
|
143 |
component := FillingWrapper on:e. |
|
144 |
component foregroundColor:Color red. |
|
145 |
v addComponent:component. |
|
146 |
||
147 |
e := EllipticalArc boundingBox:(10@10 corner:90@90) |
|
148 |
startAngle:0 sweepAngle:360. |
|
149 |
component := StrokingWrapper on:e. |
|
150 |
component lineWidth:5. |
|
151 |
v addComponent:component. |
|
152 |
||
153 |
e := Arrow from:100@100 to:150@250. |
|
154 |
component := StrokingWrapper on:e. |
|
155 |
component lineWidth:2. |
|
156 |
v addComponent:component. |
|
157 |
||
280 | 158 |
v addComponent:(Button label:'hello'). |
273 | 159 |
|
160 |
t open |
|
161 |
[exEnd] |
|
162 |
||
245 | 163 |
" |
164 |
! ! |
|
165 |
||
280 | 166 |
!StrokingWrapper methodsFor:'accessing'! |
167 |
||
168 |
bounds |
|
169 |
"return the boundary rectangle - here, must take care of the lineWidth" |
|
170 |
||
295 | 171 |
^ (component bounds insetBy:(lineWidth // 2 + 1) negated) rounded |
245 | 172 |
|
280 | 173 |
"Created: 8.5.1996 / 23:22:43 / cg" |
295 | 174 |
"Modified: 5.6.1996 / 20:30:39 / cg" |
280 | 175 |
! |
245 | 176 |
|
280 | 177 |
capStyle |
178 |
"return the capStyle" |
|
179 |
||
180 |
^ capStyle |
|
262
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
181 |
|
280 | 182 |
"Created: 8.5.1996 / 23:22:04 / cg" |
183 |
"Modified: 9.5.1996 / 00:09:12 / cg" |
|
184 |
! |
|
262
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
185 |
|
280 | 186 |
capStyle:aSymbol |
187 |
"set the capStyle" |
|
188 |
||
189 |
capStyle := aSymbol |
|
262
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
190 |
|
280 | 191 |
"Created: 8.5.1996 / 23:22:13 / cg" |
192 |
"Modified: 9.5.1996 / 00:09:17 / cg" |
|
193 |
! |
|
262
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
194 |
|
280 | 195 |
joinStyle |
196 |
"return the joinStyle" |
|
262
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
197 |
|
280 | 198 |
^ joinStyle |
199 |
||
200 |
"Created: 8.5.1996 / 23:22:04 / cg" |
|
201 |
"Modified: 9.5.1996 / 00:09:12 / cg" |
|
262
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
202 |
! |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
203 |
|
280 | 204 |
joinStyle:aSymbol |
205 |
"set the joinStyle" |
|
262
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
206 |
|
280 | 207 |
joinStyle := aSymbol |
262
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
208 |
|
280 | 209 |
"Created: 8.5.1996 / 23:22:13 / cg" |
210 |
"Modified: 9.5.1996 / 00:09:17 / cg" |
|
211 |
! |
|
262
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
212 |
|
280 | 213 |
lineStyle |
214 |
"return the lineStyle" |
|
262
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
215 |
|
280 | 216 |
^ lineStyle |
217 |
||
218 |
"Created: 8.5.1996 / 23:22:04 / cg" |
|
219 |
"Modified: 9.5.1996 / 00:09:12 / cg" |
|
262
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
220 |
! |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
221 |
|
280 | 222 |
lineStyle:aSymbol |
223 |
"set the lineStyle" |
|
224 |
||
225 |
lineStyle := aSymbol |
|
226 |
||
227 |
"Created: 8.5.1996 / 23:22:13 / cg" |
|
228 |
"Modified: 9.5.1996 / 00:09:17 / cg" |
|
229 |
! |
|
230 |
||
231 |
lineWidth |
|
232 |
"return the lineWidth" |
|
246 | 233 |
|
280 | 234 |
^ lineWidth |
235 |
||
236 |
"Created: 8.5.1996 / 23:22:04 / cg" |
|
237 |
"Modified: 9.5.1996 / 00:09:12 / cg" |
|
238 |
! |
|
239 |
||
240 |
lineWidth:aNumber |
|
241 |
"set the lineWidth" |
|
242 |
||
243 |
lineWidth := aNumber |
|
244 |
||
245 |
"Created: 8.5.1996 / 23:22:13 / cg" |
|
246 |
"Modified: 9.5.1996 / 00:09:17 / cg" |
|
245 | 247 |
! |
248 |
||
249 |
preferredBounds |
|
280 | 250 |
"return the components bounds as preferredBounds" |
246 | 251 |
|
295 | 252 |
^ (component bounds insetBy:(lineWidth / 2 + 1) negated) rounded |
280 | 253 |
|
254 |
"Created: 8.5.1996 / 23:23:00 / cg" |
|
295 | 255 |
"Modified: 5.6.1996 / 20:32:36 / cg" |
245 | 256 |
! ! |
257 |
||
280 | 258 |
!StrokingWrapper methodsFor:'displaying'! |
245 | 259 |
|
260 |
displayOn:aGC |
|
280 | 261 |
"display myself - here, display the geometric object asStroked" |
262 |
||
263 |
|prevLineWidth prevLineStyle prevCapStyle prevJoinStyle |
|
264 |
prevFg prevBg| |
|
245 | 265 |
|
280 | 266 |
prevLineWidth := aGC lineWidth. |
267 |
prevLineStyle := aGC lineStyle. |
|
268 |
prevJoinStyle := aGC joinStyle. |
|
269 |
prevCapStyle := aGC capStyle. |
|
270 |
prevFg := aGC paint. |
|
271 |
prevBg := aGC backgroundPaint. |
|
245 | 272 |
|
280 | 273 |
aGC lineWidth:lineWidth. |
274 |
aGC lineStyle:lineStyle. |
|
275 |
aGC joinStyle:joinStyle. |
|
276 |
aGC capStyle:capStyle. |
|
405
4acab6da7d82
fgColor/bgColor -> foregroundColor/backgroundColor
Claus Gittinger <cg@exept.de>
parents:
365
diff
changeset
|
277 |
aGC paint:foregroundColor on:backgroundColor. |
245 | 278 |
|
280 | 279 |
component displayStrokedOn:aGC. |
245 | 280 |
|
280 | 281 |
aGC lineWidth:prevLineWidth. |
282 |
aGC lineStyle:prevLineStyle. |
|
283 |
aGC joinStyle:prevJoinStyle. |
|
284 |
aGC capStyle:prevCapStyle. |
|
285 |
aGC paint:prevFg on:prevBg. |
|
245 | 286 |
|
280 | 287 |
"Created: 8.5.1996 / 23:24:04 / cg" |
405
4acab6da7d82
fgColor/bgColor -> foregroundColor/backgroundColor
Claus Gittinger <cg@exept.de>
parents:
365
diff
changeset
|
288 |
"Modified: 10.2.1997 / 14:21:33 / cg" |
245 | 289 |
! ! |
290 |
||
280 | 291 |
!StrokingWrapper methodsFor:'initialization'! |
245 | 292 |
|
280 | 293 |
initialize |
294 |
"default my lineWidth to one pixel" |
|
246 | 295 |
|
280 | 296 |
super initialize. |
297 |
lineWidth := 1. |
|
245 | 298 |
|
280 | 299 |
"Created: 8.5.1996 / 23:49:27 / cg" |
300 |
"Modified: 9.5.1996 / 00:11:51 / cg" |
|
245 | 301 |
! ! |
302 |
||
280 | 303 |
!StrokingWrapper class methodsFor:'documentation'! |
245 | 304 |
|
305 |
version |
|
1789 | 306 |
^ '$Header: /cvs/stx/stx/libview2/StrokingWrapper.st,v 1.15 2003-08-18 12:12:39 cg Exp $' |
245 | 307 |
! ! |