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