author | Patrik Svestka <patrik.svestka@gmail.com> |
Wed, 14 Nov 2018 12:13:31 +0100 | |
branch | jv |
changeset 4213 | 8127ef0ff47d |
parent 3855 | 1db7742d33ad |
permissions | -rw-r--r-- |
2633 | 1 |
" |
2 |
COPYRIGHT (c) 2009 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 |
"{ Package: 'stx:libview2' }" |
|
13 |
||
3855
1db7742d33ad
Win32: Build libjpeg in its own directory, out-of-source-tree.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2633
diff
changeset
|
14 |
"{ NameSpace: Smalltalk }" |
1db7742d33ad
Win32: Build libjpeg in its own directory, out-of-source-tree.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2633
diff
changeset
|
15 |
|
2633 | 16 |
GeometricWrapper subclass:#StrokingOrFillingWrapper |
17 |
instanceVariableNames:'lineWidth lineStyle capStyle joinStyle fill' |
|
18 |
classVariableNames:'' |
|
19 |
poolDictionaries:'' |
|
20 |
category:'Compatibility-ST80-Graphics-Display Objects' |
|
21 |
! |
|
22 |
||
23 |
!StrokingOrFillingWrapper class methodsFor:'documentation'! |
|
24 |
||
25 |
copyright |
|
26 |
" |
|
27 |
COPYRIGHT (c) 2009 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 |
documentation |
|
40 |
" |
|
41 |
combines stroking and fillingwrapper into one. |
|
42 |
||
43 |
[see also:] |
|
44 |
FillingWrapper Geometric GraphicsContext |
|
45 |
||
46 |
[author:] |
|
47 |
Claus Gittinger |
|
48 |
" |
|
49 |
! |
|
50 |
||
51 |
examples |
|
52 |
" |
|
53 |
wrap an ellipticArc and display it |
|
54 |
(notice, that no automatic redraw is performed): |
|
55 |
[exBegin] |
|
56 |
|v e component| |
|
57 |
||
58 |
v := (StandardSystemView extent:250@250) openAndWait. |
|
59 |
||
60 |
e := EllipticalArc boundingBox:(10@10 corner:90@90) |
|
61 |
startAngle:0 |
|
62 |
sweepAngle:270. |
|
63 |
component := StrokingWrapper on:e. |
|
64 |
||
65 |
component displayOn:v. |
|
66 |
[exEnd] |
|
67 |
||
68 |
wrap a rectangle and an ellipticArc, |
|
69 |
and add them as components to a View |
|
70 |
(notice, that doing so makes the redraw automatic): |
|
71 |
[exBegin] |
|
72 |
|v e component| |
|
73 |
||
74 |
v := StandardSystemView extent:250@250. |
|
75 |
||
76 |
e := Rectangle origin:10@10 corner:90@90. |
|
77 |
component := FillingWrapper on:e. |
|
78 |
component foregroundColor:Color red. |
|
79 |
||
80 |
v addComponent:component. |
|
81 |
||
82 |
e := EllipticalArc boundingBox:(10@10 corner:90@90) |
|
83 |
startAngle:0 sweepAngle:360. |
|
84 |
component := StrokingWrapper on:e. |
|
85 |
component lineWidth:5. |
|
86 |
||
87 |
v addComponent:component. |
|
88 |
||
89 |
v addComponent:(Button label:'hello'). |
|
90 |
||
91 |
v open |
|
92 |
[exEnd] |
|
93 |
with lineWidth & style: |
|
94 |
(notice, that the redraw is automatic): |
|
95 |
[exBegin] |
|
96 |
|v e| |
|
97 |
||
98 |
v := StandardSystemView extent:250@250. |
|
99 |
||
100 |
e := EllipticalArc boundingBox:(10@10 corner:90@90) |
|
101 |
startAngle:0 |
|
102 |
sweepAngle:270. |
|
103 |
v addComponent:((StrokingWrapper on:e) |
|
104 |
lineWidth:5; |
|
105 |
lineStyle:#dashed; |
|
106 |
foregroundColor:(Color red)). |
|
107 |
||
108 |
e := EllipticalArc boundingBox:(30@30 corner:70@70) |
|
109 |
startAngle:90 |
|
110 |
sweepAngle:270. |
|
111 |
v addComponent:((StrokingWrapper on:e) |
|
112 |
lineWidth:5; |
|
113 |
lineStyle:#doubleDashed; |
|
114 |
foregroundColor:(Color red); |
|
115 |
backgroundColor:(Color green)). |
|
116 |
v open. |
|
117 |
[exEnd] |
|
118 |
||
119 |
scrolling: |
|
120 |
[exBegin] |
|
121 |
|t s v e component| |
|
122 |
||
123 |
t := StandardSystemView extent:250@200. |
|
124 |
s := HVScrollableView for:View miniScroller:true in:t. |
|
125 |
s origin:0.0@0.0 corner:1.0@1.0. |
|
126 |
v := s scrolledView. |
|
127 |
||
128 |
e := Rectangle origin:10@10 corner:90@90. |
|
129 |
component := FillingWrapper on:e. |
|
130 |
component foregroundColor:Color red. |
|
131 |
v addComponent:component. |
|
132 |
||
133 |
e := EllipticalArc boundingBox:(10@10 corner:90@90) |
|
134 |
startAngle:0 sweepAngle:360. |
|
135 |
component := StrokingWrapper on:e. |
|
136 |
component lineWidth:5. |
|
137 |
v addComponent:component. |
|
138 |
||
139 |
e := Arrow from:100@100 to:150@250. |
|
140 |
component := StrokingWrapper on:e. |
|
141 |
component lineWidth:2. |
|
142 |
v addComponent:component. |
|
143 |
||
144 |
v addComponent:(Button label:'hello'). |
|
145 |
||
146 |
t open |
|
147 |
[exEnd] |
|
148 |
||
149 |
" |
|
150 |
! ! |
|
151 |
||
152 |
!StrokingOrFillingWrapper methodsFor:'accessing'! |
|
153 |
||
154 |
bounds |
|
155 |
"return the boundary rectangle - here, must take care of the lineWidth" |
|
156 |
||
157 |
^ (component bounds insetBy:(lineWidth // 2 + 1) negated) rounded |
|
158 |
||
159 |
"Created: 8.5.1996 / 23:22:43 / cg" |
|
160 |
"Modified: 5.6.1996 / 20:30:39 / cg" |
|
161 |
! |
|
162 |
||
163 |
capStyle |
|
164 |
"return the capStyle" |
|
165 |
||
166 |
^ capStyle |
|
167 |
||
168 |
"Created: 8.5.1996 / 23:22:04 / cg" |
|
169 |
"Modified: 9.5.1996 / 00:09:12 / cg" |
|
170 |
! |
|
171 |
||
172 |
capStyle:aSymbol |
|
173 |
"set the capStyle" |
|
174 |
||
175 |
capStyle := aSymbol |
|
176 |
||
177 |
"Created: 8.5.1996 / 23:22:13 / cg" |
|
178 |
"Modified: 9.5.1996 / 00:09:17 / cg" |
|
179 |
! |
|
180 |
||
181 |
joinStyle |
|
182 |
"return the joinStyle" |
|
183 |
||
184 |
^ joinStyle |
|
185 |
||
186 |
"Created: 8.5.1996 / 23:22:04 / cg" |
|
187 |
"Modified: 9.5.1996 / 00:09:12 / cg" |
|
188 |
! |
|
189 |
||
190 |
joinStyle:aSymbol |
|
191 |
"set the joinStyle" |
|
192 |
||
193 |
joinStyle := aSymbol |
|
194 |
||
195 |
"Created: 8.5.1996 / 23:22:13 / cg" |
|
196 |
"Modified: 9.5.1996 / 00:09:17 / cg" |
|
197 |
! |
|
198 |
||
199 |
lineStyle |
|
200 |
"return the lineStyle" |
|
201 |
||
202 |
^ lineStyle |
|
203 |
||
204 |
"Created: 8.5.1996 / 23:22:04 / cg" |
|
205 |
"Modified: 9.5.1996 / 00:09:12 / cg" |
|
206 |
! |
|
207 |
||
208 |
lineStyle:aSymbol |
|
209 |
"set the lineStyle" |
|
210 |
||
211 |
lineStyle := aSymbol |
|
212 |
||
213 |
"Created: 8.5.1996 / 23:22:13 / cg" |
|
214 |
"Modified: 9.5.1996 / 00:09:17 / cg" |
|
215 |
! |
|
216 |
||
217 |
lineWidth |
|
218 |
"return the lineWidth" |
|
219 |
||
220 |
^ lineWidth |
|
221 |
||
222 |
"Created: 8.5.1996 / 23:22:04 / cg" |
|
223 |
"Modified: 9.5.1996 / 00:09:12 / cg" |
|
224 |
! |
|
225 |
||
226 |
lineWidth:aNumber |
|
227 |
"set the lineWidth" |
|
228 |
||
229 |
lineWidth := aNumber |
|
230 |
||
231 |
"Created: 8.5.1996 / 23:22:13 / cg" |
|
232 |
"Modified: 9.5.1996 / 00:09:17 / cg" |
|
233 |
! |
|
234 |
||
235 |
preferredBounds |
|
236 |
"return the components bounds as preferredBounds" |
|
237 |
||
238 |
^ (component bounds insetBy:(lineWidth / 2 + 1) negated) rounded |
|
239 |
||
240 |
"Created: 8.5.1996 / 23:23:00 / cg" |
|
241 |
"Modified: 5.6.1996 / 20:32:36 / cg" |
|
242 |
! ! |
|
243 |
||
244 |
!StrokingOrFillingWrapper methodsFor:'displaying'! |
|
245 |
||
246 |
displayFilledOn:aGC |
|
247 |
"display myself - here, display the geometric object asFilled" |
|
248 |
||
249 |
|prevFg prevBg| |
|
250 |
||
251 |
prevFg := aGC paint. |
|
252 |
prevBg := aGC backgroundPaint. |
|
253 |
||
254 |
aGC paint:foregroundColor on:backgroundColor. |
|
255 |
||
256 |
component displayFilledOn:aGC. |
|
257 |
||
258 |
aGC paint:prevFg on:prevBg. |
|
259 |
||
260 |
"Created: 8.5.1996 / 23:54:06 / cg" |
|
261 |
"Modified: 10.2.1997 / 14:21:41 / cg" |
|
262 |
! |
|
263 |
||
264 |
displayOn:aGC |
|
265 |
"display myself - here, display the geometric object asStroked" |
|
266 |
||
267 |
fill ifTrue:[ |
|
268 |
self displayFilledOn:aGC |
|
269 |
] ifFalse:[ |
|
270 |
self displayStrokedOn:aGC |
|
271 |
] |
|
272 |
! |
|
273 |
||
274 |
displayStrokedOn:aGC |
|
275 |
"display myself - here, display the geometric object asStroked or asFilled" |
|
276 |
||
277 |
|prevLineWidth prevLineStyle prevCapStyle prevJoinStyle |
|
278 |
prevFg prevBg| |
|
279 |
||
280 |
prevLineWidth := aGC lineWidth. |
|
281 |
prevLineStyle := aGC lineStyle. |
|
282 |
prevJoinStyle := aGC joinStyle. |
|
283 |
prevCapStyle := aGC capStyle. |
|
284 |
prevFg := aGC paint. |
|
285 |
prevBg := aGC backgroundPaint. |
|
286 |
||
287 |
aGC lineWidth:lineWidth. |
|
288 |
aGC lineStyle:lineStyle. |
|
289 |
aGC joinStyle:joinStyle. |
|
290 |
aGC capStyle:capStyle. |
|
291 |
aGC paint:foregroundColor on:backgroundColor. |
|
292 |
||
293 |
component displayStrokedOn:aGC. |
|
294 |
||
295 |
aGC lineWidth:prevLineWidth. |
|
296 |
aGC lineStyle:prevLineStyle. |
|
297 |
aGC joinStyle:prevJoinStyle. |
|
298 |
aGC capStyle:prevCapStyle. |
|
299 |
aGC paint:prevFg on:prevBg. |
|
300 |
||
301 |
"Created: 8.5.1996 / 23:24:04 / cg" |
|
302 |
"Modified: 10.2.1997 / 14:21:33 / cg" |
|
303 |
! ! |
|
304 |
||
305 |
!StrokingOrFillingWrapper methodsFor:'initialization'! |
|
306 |
||
307 |
initialize |
|
308 |
"default my lineWidth to one pixel" |
|
309 |
||
310 |
super initialize. |
|
311 |
lineWidth := 1. |
|
312 |
||
313 |
"Created: 8.5.1996 / 23:49:27 / cg" |
|
314 |
"Modified: 9.5.1996 / 00:11:51 / cg" |
|
315 |
! ! |
|
316 |
||
317 |
!StrokingOrFillingWrapper class methodsFor:'documentation'! |
|
318 |
||
319 |
version |
|
320 |
^ '$Header: /cvs/stx/stx/libview2/StrokingOrFillingWrapper.st,v 1.1 2009-05-06 07:29:31 cg Exp $' |
|
321 |
! ! |
|
3855
1db7742d33ad
Win32: Build libjpeg in its own directory, out-of-source-tree.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
2633
diff
changeset
|
322 |