author | Claus Gittinger <cg@exept.de> |
Sun, 12 May 1996 22:30:21 +0200 | |
changeset 262 | 55b430276719 |
parent 254 | 1286cec58b5d |
child 263 | 091fa4a2f558 |
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] |
98 |
" |
|
99 |
! ! |
|
100 |
||
101 |
!StrokingWrapper methodsFor:'accessing'! |
|
102 |
||
103 |
bounds |
|
246 | 104 |
"return the boundary rectangle - here, must take care of the lineWidth" |
105 |
||
245 | 106 |
^ component bounds + (lineWidth - 1) |
107 |
||
108 |
"Created: 8.5.1996 / 23:22:43 / cg" |
|
246 | 109 |
"Modified: 9.5.1996 / 00:09:06 / cg" |
245 | 110 |
! |
111 |
||
262
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
112 |
capStyle |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
113 |
"return the capStyle" |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
114 |
|
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
115 |
^ capStyle |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
116 |
|
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
117 |
"Created: 8.5.1996 / 23:22:04 / cg" |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
118 |
"Modified: 9.5.1996 / 00:09:12 / cg" |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
119 |
! |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
120 |
|
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
121 |
capStyle:aSymbol |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
122 |
"set the capStyle" |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
123 |
|
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
124 |
capStyle := aSymbol |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
125 |
|
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
126 |
"Created: 8.5.1996 / 23:22:13 / cg" |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
127 |
"Modified: 9.5.1996 / 00:09:17 / cg" |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
128 |
! |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
129 |
|
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
130 |
joinStyle |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
131 |
"return the joinStyle" |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
132 |
|
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
133 |
^ joinStyle |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
134 |
|
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
135 |
"Created: 8.5.1996 / 23:22:04 / cg" |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
136 |
"Modified: 9.5.1996 / 00:09:12 / cg" |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
137 |
! |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
138 |
|
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
139 |
joinStyle:aSymbol |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
140 |
"set the joinStyle" |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
141 |
|
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
142 |
joinStyle := aSymbol |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
143 |
|
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
144 |
"Created: 8.5.1996 / 23:22:13 / cg" |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
145 |
"Modified: 9.5.1996 / 00:09:17 / cg" |
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 |
|
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
148 |
lineStyle |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
149 |
"return the lineStyle" |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
150 |
|
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
151 |
^ lineStyle |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
152 |
|
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
153 |
"Created: 8.5.1996 / 23:22:04 / cg" |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
154 |
"Modified: 9.5.1996 / 00:09:12 / cg" |
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 |
|
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
157 |
lineStyle:aSymbol |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
158 |
"set the lineStyle" |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
159 |
|
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
160 |
lineStyle := aSymbol |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
161 |
|
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
162 |
"Created: 8.5.1996 / 23:22:13 / cg" |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
163 |
"Modified: 9.5.1996 / 00:09:17 / cg" |
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 |
|
245 | 166 |
lineWidth |
246 | 167 |
"return the lineWidth" |
168 |
||
245 | 169 |
^ lineWidth |
170 |
||
171 |
"Created: 8.5.1996 / 23:22:04 / cg" |
|
246 | 172 |
"Modified: 9.5.1996 / 00:09:12 / cg" |
245 | 173 |
! |
174 |
||
175 |
lineWidth:aNumber |
|
246 | 176 |
"set the lineWidth" |
177 |
||
245 | 178 |
lineWidth := aNumber |
179 |
||
180 |
"Created: 8.5.1996 / 23:22:13 / cg" |
|
246 | 181 |
"Modified: 9.5.1996 / 00:09:17 / cg" |
245 | 182 |
! |
183 |
||
184 |
preferredBounds |
|
246 | 185 |
"return the components bounds as preferredBounds" |
186 |
||
245 | 187 |
^ self bounds |
188 |
||
189 |
"Created: 8.5.1996 / 23:23:00 / cg" |
|
246 | 190 |
"Modified: 9.5.1996 / 00:09:31 / cg" |
245 | 191 |
! ! |
192 |
||
193 |
!StrokingWrapper methodsFor:'displaying'! |
|
194 |
||
195 |
displayOn:aGC |
|
246 | 196 |
"display myself - here, display the geometric object asStroked" |
197 |
||
262
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
198 |
|prevLineWidth prevLineStyle prevCapStyle prevJoinStyle |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
199 |
prevFg| |
245 | 200 |
|
201 |
prevLineWidth := aGC lineWidth. |
|
262
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
202 |
prevLineStyle := aGC lineStyle. |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
203 |
prevJoinStyle := aGC joinStyle. |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
204 |
prevCapStyle := aGC capStyle. |
245 | 205 |
prevFg := aGC paint. |
206 |
||
207 |
aGC lineWidth:lineWidth. |
|
262
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
208 |
aGC lineStyle:lineStyle. |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
209 |
aGC joinStyle:joinStyle. |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
210 |
aGC capStyle:capStyle. |
245 | 211 |
aGC paint:fgColor. |
212 |
||
213 |
component displayStrokedOn:aGC. |
|
214 |
||
215 |
aGC lineWidth:prevLineWidth. |
|
262
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
216 |
aGC lineStyle:prevLineStyle. |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
217 |
aGC joinStyle:prevJoinStyle. |
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
218 |
aGC capStyle:prevCapStyle. |
245 | 219 |
aGC paint:prevFg. |
220 |
||
221 |
"Created: 8.5.1996 / 23:24:04 / cg" |
|
246 | 222 |
"Modified: 9.5.1996 / 00:11:17 / cg" |
245 | 223 |
! ! |
224 |
||
225 |
!StrokingWrapper methodsFor:'initialization'! |
|
226 |
||
227 |
initialize |
|
246 | 228 |
"default my lineWidth to one pixel" |
229 |
||
245 | 230 |
super initialize. |
231 |
lineWidth := 1. |
|
232 |
||
233 |
"Created: 8.5.1996 / 23:49:27 / cg" |
|
246 | 234 |
"Modified: 9.5.1996 / 00:11:51 / cg" |
245 | 235 |
! ! |
236 |
||
237 |
!StrokingWrapper class methodsFor:'documentation'! |
|
238 |
||
239 |
version |
|
262
55b430276719
added lineStyle/capStyle & joinStyle
Claus Gittinger <cg@exept.de>
parents:
254
diff
changeset
|
240 |
^ '$Header: /cvs/stx/stx/libview2/StrokingWrapper.st,v 1.6 1996-05-12 20:30:21 cg Exp $' |
245 | 241 |
! ! |