author | Claus Gittinger <cg@exept.de> |
Tue, 01 Apr 1997 23:12:40 +0200 | |
changeset 1506 | 1b6c39325902 |
parent 1443 | 67acc199f123 |
child 1641 | b7c128be3394 |
permissions | -rw-r--r-- |
0 | 1 |
" |
6 | 2 |
COPYRIGHT (c) 1992 by Claus Gittinger |
71 | 3 |
All Rights Reserved |
0 | 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 |
Object subclass:#GraphicsContext |
|
727
bf23a306b6f2
renamed PseudoView to DisplaySurface
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
14 |
instanceVariableNames:'device paint bgPaint function font lineStyle lineWidth joinStyle |
716
b83fee8ff1b3
moved clipRect up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
15 |
capStyle mask maskOrigin transformation clipRect' |
519 | 16 |
classVariableNames:'White Black DefaultFont' |
17 |
poolDictionaries:'' |
|
18 |
category:'Graphics-Support' |
|
0 | 19 |
! |
20 |
||
1203
49dd13574c7d
dont use Black/White when drawing;
Claus Gittinger <cg@exept.de>
parents:
952
diff
changeset
|
21 |
!GraphicsContext class methodsFor:'documentation'! |
46 | 22 |
|
23 |
copyright |
|
24 |
" |
|
25 |
COPYRIGHT (c) 1992 by Claus Gittinger |
|
71 | 26 |
All Rights Reserved |
46 | 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 |
documentation |
|
38 |
" |
|
39 |
this is an abstract superclass for all kinds of graphic drawables - |
|
40 |
both windows and printed pages (i.e. printers) are inheriting from |
|
41 |
this class (even drawables not at all associated with any device would do so). |
|
42 |
||
76 | 43 |
Drawing is done in paint/bgPaint colors, which can be true colors (i.e. |
44 |
directly supported by the underlying hardware) or simulated colors |
|
45 |
(i.e. dithered colors or images). |
|
46 |
The paint/bgPaint instance variables are set to the logical colors, |
|
47 |
device specific drawable may like to keep actual colors in addition. |
|
71 | 48 |
|
49 |
The transformation instance variable is typically nil, for a 1-to-1 |
|
50 |
coordinate mapping (i.e. x/y coordinates are pixels in the drawable). |
|
51 |
If nonNil, the transformation must be an instance of WindowingTransformation |
|
52 |
and offers both a scale-factor and a translation. |
|
53 |
Also, drawing in metric- or inch-units can be done using transformations. |
|
54 |
(see instance creation methods of WindowingTransformation, and examples |
|
55 |
in 'doc/coding'). |
|
46 | 56 |
|
57 |
All drawing is defined upon a few basic drawing methods, which must be |
|
58 |
implemented by subclasses (some subclasses also redefine the others for |
|
59 |
more performance) |
|
60 |
||
611 | 61 |
[Instance variables:] |
46 | 62 |
|
611 | 63 |
paint <Color> the paint used for drawing |
64 |
bgPaint <Color> the background used for drawing texts and bitmaps |
|
65 |
function <Symbol> the drawing function (i.e. #copy, #or, #xor ...) |
|
66 |
- not all Drawables support every function |
|
67 |
(i.e. paper only allows #copy) |
|
68 |
font <Font> the current font to be used for drawing |
|
69 |
lineStyle <Symbol> the lineStyle (i.e. #solid, #dashed, #doubleDashed) |
|
70 |
lineWidth <SmallInteger> the lineWidth (device dependent, usually pixels) |
|
71 |
joinStyle <Symbol> the style in which lines (in polygons) |
|
72 |
are joined (i.e. #miter, #bevel, #round) |
|
73 |
capStyle <Symbol> the style in which the last point of a line is drawn |
|
74 |
(i.e. #notLast, #butt, #round, #projecting) |
|
75 |
mask <Form> a mask used for drawing |
|
76 |
- not all Drawables support it |
|
77 |
maskOrigin <Point> the origin of the mask relative to |
|
78 |
the drawables origin |
|
716
b83fee8ff1b3
moved clipRect up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
79 |
transformation |
b83fee8ff1b3
moved clipRect up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
80 |
<WindowingTransformation> |
b83fee8ff1b3
moved clipRect up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
81 |
controls scale & translation of nonNil |
b83fee8ff1b3
moved clipRect up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
82 |
|
b83fee8ff1b3
moved clipRect up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
83 |
clipRect <Rectangle> a clip rectangle (device dep. usually pixels or inches) |
b83fee8ff1b3
moved clipRect up in the hierarchy
Claus Gittinger <cg@exept.de>
parents:
713
diff
changeset
|
84 |
or nil. |
46 | 85 |
|
611 | 86 |
[Class variables:[ |
87 |
||
88 |
White <Color> cached white color - its needed so often |
|
89 |
Black <Color> cached black color - its needed so often |
|
46 | 90 |
|
611 | 91 |
DefaultFont <Font> default font to use |
46 | 92 |
|
611 | 93 |
[author:] |
94 |
Claus Gittinger |
|
657 | 95 |
|
96 |
[see also:] |
|
97 |
Color Font Form Image |
|
98 |
Geometric |
|
99 |
DeviceWorkstation |
|
46 | 100 |
" |
563 | 101 |
! |
102 |
||
103 |
examples |
|
104 |
" |
|
105 |
drawing uses a paint color (which may be a dithered one) which is |
|
106 |
used like a `pen'. |
|
107 |
A few drawing operations (opaqueForm and opaqueString drawing) |
|
108 |
use two colors, the paint and a backgroundPaint. For example, |
|
109 |
normal string drawing (#displayString:...) only draws the fonts |
|
110 |
on-pixels in the current paint, leaving off-pixels unchanged. |
|
111 |
In contrast, #drawOpaqueString:.. also changes these to the bgPaint color. |
|
112 |
The bgPaint can be changed with #backgroundPaint: or #paint:on: (which modifies both). |
|
113 |
||
114 |
lets try it in a view: |
|
619 | 115 |
[exBegin] |
563 | 116 |
|v| |
117 |
||
118 |
v := View new. |
|
119 |
v openAndWait. |
|
120 |
||
121 |
v paint:(Color red). |
|
122 |
v displayString:'hello' x:10 y:50 |
|
619 | 123 |
[exEnd] |
563 | 124 |
|
125 |
the same using opaque drawing: |
|
619 | 126 |
[exBegin] |
563 | 127 |
|v| |
128 |
||
129 |
v := View new. |
|
130 |
v openAndWait. |
|
131 |
||
132 |
v paint:(Color red) on:(Color yellow). |
|
133 |
v displayOpaqueString:'hello' x:10 y:50 |
|
619 | 134 |
[exEnd] |
563 | 135 |
|
136 |
||
137 |
||
138 |
Lines are drawn using the paint color (if solid) or both paint and bgPaint |
|
139 |
(dashed lines). The look of the line is controlled by joinStyle, capStyle, |
|
140 |
lineWidth and lineStyle. |
|
141 |
`lineStyle' can be one of #solid, #dashed, #doubleDashed |
|
142 |
where: #solid - is for solid lines, drawn with the current paint color |
|
143 |
||
144 |
#dashed - for dashed lines, where only the on-dashes are drawn |
|
145 |
with the current paint color |
|
146 |
||
147 |
#doubleDashed - dashed lines, draws on-dashes with paint color, |
|
148 |
off-dashes with bgPaint |
|
149 |
||
150 |
for example: |
|
619 | 151 |
[exBegin] |
563 | 152 |
|v| |
153 |
||
154 |
v := View new. |
|
155 |
v openAndWait. |
|
156 |
||
157 |
v paint:(Color red) on:(Color blue). |
|
158 |
v displayLineFrom:(10@10) to:(90@90). |
|
159 |
||
160 |
v lineStyle:#dashed. |
|
161 |
v displayLineFrom:(90@10) to:(10@90). |
|
162 |
||
163 |
v lineStyle:#doubleDashed. |
|
164 |
v displayRectangle:((5@5) corner:(95@95)). |
|
619 | 165 |
[exEnd] |
563 | 166 |
|
167 |
changing the line-width: |
|
619 | 168 |
[exBegin] |
563 | 169 |
|v| |
170 |
||
171 |
v := View new. |
|
172 |
v openAndWait. |
|
173 |
||
174 |
v paint:(Color red). |
|
175 |
v displayLineFrom:(20@20) to:(80@80). |
|
176 |
||
177 |
v lineWidth:5. |
|
178 |
v displayLineFrom:(80@20) to:(20@80). |
|
179 |
||
180 |
v lineWidth:8. |
|
181 |
v displayRectangle:((5@5) corner:(95@95)). |
|
619 | 182 |
[exEnd] |
563 | 183 |
|
184 |
with wide lines, the corners (of polygons or rectangles) can be |
|
185 |
one of the joinStyles: #miter, #bevel, #round. The default is #miter. |
|
619 | 186 |
[exBegin] |
563 | 187 |
|v| |
188 |
||
189 |
v := View new extent:200@200. |
|
190 |
v openAndWait. |
|
191 |
||
192 |
v lineWidth:15. |
|
193 |
v paint:(Color red). |
|
194 |
||
195 |
v displayRectangle:((65@65) corner:(135@135)). |
|
196 |
||
197 |
v joinStyle:#bevel. |
|
198 |
v displayRectangle:((45@45) corner:(155@155)). |
|
199 |
||
200 |
v joinStyle:#round. |
|
201 |
v displayRectangle:((25@25) corner:(175@175)). |
|
619 | 202 |
[exEnd] |
563 | 203 |
|
204 |
||
205 |
the endPoints look is controlled with capStyle; |
|
206 |
possible values are: #notLast, #butt, #round, #projecting. |
|
207 |
The default is #butt. |
|
208 |
#notLast is mostly useful when exoring (inverting): it will not draw the |
|
209 |
endPoint, to allow another line to join the previous line without inverting |
|
210 |
this point twice. (See the X manual for more info). |
|
619 | 211 |
[exBegin] |
563 | 212 |
|v| |
213 |
||
214 |
v := View new extent:200@200. |
|
215 |
v openAndWait. |
|
216 |
||
217 |
v lineWidth:15. |
|
218 |
v paint:(Color red). |
|
219 |
||
220 |
v displayLineFrom:(25@25) to:(175@25). |
|
221 |
||
222 |
v capStyle:#round. |
|
223 |
v displayLineFrom:(25@55) to:(175@55). |
|
224 |
||
225 |
v capStyle:#projecting. |
|
226 |
v displayLineFrom:(25@85) to:(175@85). |
|
619 | 227 |
[exEnd] |
563 | 228 |
|
229 |
||
230 |
You can use a bitmap as a point color: |
|
231 |
(this may be slow on some graphics devices, though) |
|
619 | 232 |
[exBegin] |
563 | 233 |
|v| |
234 |
||
235 |
v := View new extent:200@200. |
|
236 |
v openAndWait. |
|
237 |
||
238 |
v lineWidth:15. |
|
239 |
v paint:(Image fromFile:'granite_small.tiff'). |
|
240 |
||
241 |
v displayLineFrom:(25@25) to:(175@25). |
|
242 |
||
243 |
v capStyle:#round. |
|
244 |
v displayLineFrom:(25@55) to:(175@55). |
|
245 |
||
246 |
v capStyle:#projecting. |
|
247 |
v displayLineFrom:(25@85) to:(175@85). |
|
619 | 248 |
[exEnd] |
563 | 249 |
|
250 |
all views support a translation and scale, so you can draw in another |
|
251 |
coordinate system: |
|
619 | 252 |
[exBegin] |
563 | 253 |
|v| |
254 |
||
255 |
v := View new extent:200@200. |
|
256 |
v openAndWait. |
|
257 |
||
258 |
v displayForm:(Image fromFile:'SBrowser.xbm') x:10 y:10. |
|
259 |
||
260 |
v scale:(2@2); translation:50. |
|
261 |
v displayForm:(Image fromFile:'SBrowser.xbm') x:10 y:10. |
|
262 |
||
263 |
v scale:(0.5@0.5); translation:0. |
|
264 |
v displayForm:(Image fromFile:'SBrowser.xbm') x:10 y:10. |
|
619 | 265 |
[exEnd] |
563 | 266 |
|
267 |
if scaling is on, it is often useful to be able to draw individual |
|
268 |
things unscaled - this still translates the position, but |
|
269 |
uses the unscaled font (for example, to draw strings in a graphic): |
|
619 | 270 |
[exBegin] |
563 | 271 |
|v| |
272 |
||
273 |
v := View new extent:200@200. |
|
274 |
v openAndWait. |
|
275 |
||
276 |
v displayForm:(Image fromFile:'SBrowser.xbm') x:10 y:10. |
|
277 |
v displayString:'hello' x:50 y:40. |
|
278 |
||
279 |
v scale:(2@4). |
|
280 |
v displayForm:(Image fromFile:'SBrowser.xbm') x:10 y:10. |
|
281 |
v displayUnscaledString:'hello' x:50 y:40. |
|
619 | 282 |
[exEnd] |
563 | 283 |
|
284 |
Filled objects are drawin using the #fillXXX methods; for example, |
|
285 |
displayRectangleXXX draws the outline, while fillRectangleXXX draws a |
|
286 |
filled one: |
|
619 | 287 |
[exBegin] |
563 | 288 |
|v| |
289 |
||
290 |
v := View new extent:200@200. |
|
291 |
v openAndWait. |
|
292 |
||
293 |
v displayArcIn:(20@20 corner:50@50) from:0 angle:180. |
|
294 |
v paint:Color yellow. |
|
295 |
v fillArcIn:(120@120 corner:150@150) from:0 angle:180. |
|
296 |
||
297 |
v paint:Color red. |
|
298 |
v displayCircle:150@50 radius:30. |
|
299 |
v paint:Color blue. |
|
300 |
v fillCircle:50@150 radius:30. |
|
619 | 301 |
[exEnd] |
302 |
||
303 |
polygons: |
|
304 |
[exBegin] |
|
305 |
|v poly1 poly2| |
|
306 |
||
307 |
poly1 := OrderedCollection new. |
|
308 |
poly1 add:(10 @ 10). |
|
309 |
poly1 add:(100 @ 50). |
|
310 |
poly1 add:(50 @ 50). |
|
311 |
poly1 add:(20 @ 100). |
|
312 |
poly1 add:(10 @ 100). |
|
313 |
||
314 |
poly2 := poly1 copy. |
|
315 |
poly2 add:(poly2 first). |
|
316 |
||
317 |
v := View new extent:200@200. |
|
318 |
v openAndWait. |
|
319 |
||
320 |
v scale:2. |
|
321 |
v paint:Color red. |
|
322 |
v fillPolygon:poly1. |
|
323 |
||
324 |
v scale:1. |
|
325 |
v paint:Color blue. |
|
326 |
v displayPolygon:poly2. |
|
327 |
||
328 |
v scale:0.5. |
|
329 |
v paint:Color yellow. |
|
330 |
v fillPolygon:poly1. |
|
331 |
||
332 |
[exEnd] |
|
563 | 333 |
" |
46 | 334 |
! ! |
335 |
||
1203
49dd13574c7d
dont use Black/White when drawing;
Claus Gittinger <cg@exept.de>
parents:
952
diff
changeset
|
336 |
!GraphicsContext class methodsFor:'initialization'! |
0 | 337 |
|
338 |
initialize |
|
339 |
"setup some defaults - these are usually redefined |
|
340 |
during startup." |
|
341 |
||
134 | 342 |
White isNil ifTrue:[ |
386 | 343 |
Color isNil ifTrue:[^ self]. |
344 |
Display isNil ifTrue:[^ self]. |
|
345 |
||
134 | 346 |
Color initialize. |
46 | 347 |
|
134 | 348 |
White := Color white on:Display. |
349 |
Black := Color black on:Display. |
|
0 | 350 |
|
134 | 351 |
Font initialize. |
352 |
DefaultFont := Font family:'courier' face:'medium' style:'roman' size:12 |
|
353 |
] |
|
0 | 354 |
! ! |
355 |
||
1203
49dd13574c7d
dont use Black/White when drawing;
Claus Gittinger <cg@exept.de>
parents:
952
diff
changeset
|
356 |
!GraphicsContext class methodsFor:'instance creation'! |
0 | 357 |
|
519 | 358 |
new |
359 |
"return a new instance of myself. Redefined to initialize |
|
360 |
the new thingy" |
|
12 | 361 |
|
519 | 362 |
^ self basicNew initialize |
363 |
! ! |
|
364 |
||
1203
49dd13574c7d
dont use Black/White when drawing;
Claus Gittinger <cg@exept.de>
parents:
952
diff
changeset
|
365 |
!GraphicsContext class methodsFor:'accessing defaults'! |
0 | 366 |
|
367 |
defaultFont |
|
12 | 368 |
"get the default font used for drawing" |
369 |
||
71 | 370 |
DefaultFont isNil ifTrue:[ |
371 |
DefaultFont := Font family:'courier' face:'medium' style:'roman' size:12 |
|
372 |
]. |
|
0 | 373 |
^ DefaultFont |
519 | 374 |
! |
375 |
||
376 |
defaultFont:aFont |
|
377 |
"set the default font used for drawing" |
|
378 |
||
379 |
DefaultFont := aFont |
|
0 | 380 |
! ! |
381 |
||
1203
49dd13574c7d
dont use Black/White when drawing;
Claus Gittinger <cg@exept.de>
parents:
952
diff
changeset
|
382 |
!GraphicsContext class methodsFor:'constants'! |
0 | 383 |
|
519 | 384 |
capButt |
385 |
"return a constant to specify butt cap" |
|
0 | 386 |
|
519 | 387 |
^ #butt |
0 | 388 |
! |
389 |
||
390 |
capNotLast |
|
391 |
"return a constant to specify not-last cap" |
|
392 |
||
393 |
^ #notLast |
|
394 |
! |
|
395 |
||
396 |
capProjecting |
|
397 |
"return a constant to specify projecting cap" |
|
398 |
||
399 |
^ #projecting |
|
400 |
! |
|
401 |
||
402 |
capRound |
|
403 |
"return a constant to specify round cap" |
|
404 |
||
405 |
^ #round |
|
406 |
! |
|
407 |
||
519 | 408 |
joinBevel |
409 |
"return a constant to specify bevel join" |
|
410 |
||
411 |
^ #bevel |
|
412 |
! |
|
0 | 413 |
|
519 | 414 |
joinMiter |
415 |
"return a constant to specify miter join" |
|
416 |
||
417 |
^ #miter |
|
418 |
! |
|
419 |
||
420 |
joinRound |
|
421 |
"return a constant to specify round join" |
|
422 |
||
423 |
^ #round |
|
0 | 424 |
! ! |
425 |
||
519 | 426 |
!GraphicsContext methodsFor:'ST-80 compatibility'! |
427 |
||
428 |
findFont:aFontDescription |
|
585 | 429 |
"given a fontDescription, return a device font for it |
430 |
on my device." |
|
431 |
||
742 | 432 |
^ aFontDescription on:device |
585 | 433 |
|
742 | 434 |
"Modified: 28.5.1996 / 20:22:29 / cg" |
519 | 435 |
! |
0 | 436 |
|
785
6112ccde457f
added #tilePhase / #tilePhase: for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
755
diff
changeset
|
437 |
phase |
6112ccde457f
added #tilePhase / #tilePhase: for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
755
diff
changeset
|
438 |
"return the origin within the mask (used to draw with patterns). |
6112ccde457f
added #tilePhase / #tilePhase: for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
755
diff
changeset
|
439 |
This is an alias for ST/X's #maskOrigin" |
6112ccde457f
added #tilePhase / #tilePhase: for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
755
diff
changeset
|
440 |
|
6112ccde457f
added #tilePhase / #tilePhase: for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
755
diff
changeset
|
441 |
^ self maskOrigin |
6112ccde457f
added #tilePhase / #tilePhase: for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
755
diff
changeset
|
442 |
! |
6112ccde457f
added #tilePhase / #tilePhase: for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
755
diff
changeset
|
443 |
|
6112ccde457f
added #tilePhase / #tilePhase: for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
755
diff
changeset
|
444 |
phase:aPoint |
6112ccde457f
added #tilePhase / #tilePhase: for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
755
diff
changeset
|
445 |
"set the origin within the mask (used to draw with patterns). |
6112ccde457f
added #tilePhase / #tilePhase: for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
755
diff
changeset
|
446 |
This is an alias for ST/X's #maskOrigin:" |
6112ccde457f
added #tilePhase / #tilePhase: for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
755
diff
changeset
|
447 |
|
6112ccde457f
added #tilePhase / #tilePhase: for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
755
diff
changeset
|
448 |
^ self maskOrigin:aPoint |
6112ccde457f
added #tilePhase / #tilePhase: for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
755
diff
changeset
|
449 |
! |
6112ccde457f
added #tilePhase / #tilePhase: for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
755
diff
changeset
|
450 |
|
1431 | 451 |
setDevicePattern:aColorOrMask |
452 |
"ST/X can paint in any color or image" |
|
453 |
||
454 |
self paint:aColorOrMask |
|
455 |
! |
|
456 |
||
785
6112ccde457f
added #tilePhase / #tilePhase: for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
755
diff
changeset
|
457 |
tilePhase |
6112ccde457f
added #tilePhase / #tilePhase: for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
755
diff
changeset
|
458 |
"return the origin within the mask (used to draw with patterns). |
6112ccde457f
added #tilePhase / #tilePhase: for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
755
diff
changeset
|
459 |
This is an alias for ST/X's #maskOrigin" |
6112ccde457f
added #tilePhase / #tilePhase: for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
755
diff
changeset
|
460 |
|
6112ccde457f
added #tilePhase / #tilePhase: for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
755
diff
changeset
|
461 |
^ self maskOrigin |
6112ccde457f
added #tilePhase / #tilePhase: for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
755
diff
changeset
|
462 |
|
6112ccde457f
added #tilePhase / #tilePhase: for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
755
diff
changeset
|
463 |
"Created: 4.6.1996 / 15:26:39 / cg" |
6112ccde457f
added #tilePhase / #tilePhase: for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
755
diff
changeset
|
464 |
! |
6112ccde457f
added #tilePhase / #tilePhase: for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
755
diff
changeset
|
465 |
|
6112ccde457f
added #tilePhase / #tilePhase: for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
755
diff
changeset
|
466 |
tilePhase:aPoint |
6112ccde457f
added #tilePhase / #tilePhase: for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
755
diff
changeset
|
467 |
"set the origin within the mask (used to draw with patterns). |
6112ccde457f
added #tilePhase / #tilePhase: for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
755
diff
changeset
|
468 |
This is an alias for ST/X's #maskOrigin" |
6112ccde457f
added #tilePhase / #tilePhase: for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
755
diff
changeset
|
469 |
|
6112ccde457f
added #tilePhase / #tilePhase: for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
755
diff
changeset
|
470 |
^ self maskOrigin:aPoint |
6112ccde457f
added #tilePhase / #tilePhase: for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
755
diff
changeset
|
471 |
|
6112ccde457f
added #tilePhase / #tilePhase: for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
755
diff
changeset
|
472 |
"Created: 4.6.1996 / 15:26:49 / cg" |
6112ccde457f
added #tilePhase / #tilePhase: for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
755
diff
changeset
|
473 |
! |
6112ccde457f
added #tilePhase / #tilePhase: for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
755
diff
changeset
|
474 |
|
519 | 475 |
widthOfString:aString |
585 | 476 |
"given a string, return its width in pixels if |
477 |
drawn on the receivers device." |
|
478 |
||
742 | 479 |
^ (font on:device) widthOf:aString |
585 | 480 |
|
742 | 481 |
"Modified: 28.5.1996 / 20:22:22 / cg" |
519 | 482 |
! |
109 | 483 |
|
519 | 484 |
widthOfString:aString from:start to:stop |
585 | 485 |
"given a string, return the width in pixels if |
486 |
a substring is drawn on the receivers device." |
|
487 |
||
742 | 488 |
^ (font on:device) widthOf:aString from:start to:stop |
585 | 489 |
|
742 | 490 |
"Modified: 28.5.1996 / 20:22:18 / cg" |
0 | 491 |
! ! |
492 |
||
519 | 493 |
!GraphicsContext methodsFor:'ST-80 displaying'! |
494 |
||
495 |
displayArc:origin radius:radius from:startAngle angle:angle |
|
496 |
"draw an arc around a point" |
|
497 |
||
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
498 |
self |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
499 |
displayArcX:(origin x - radius) |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
500 |
y:(origin y - radius) |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
501 |
width:(radius * 2) |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
502 |
height:(radius * 2) |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
503 |
from:startAngle |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
504 |
angle:angle |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
505 |
|
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
506 |
"Modified: 8.5.1996 / 08:34:43 / cg" |
519 | 507 |
! |
0 | 508 |
|
519 | 509 |
displayArcBoundedBy:boundingBox startAngle:startAngle sweepAngle:sweepAngle at:origin |
510 |
"draw an arc/circle/ellipse - ST-80 compatibility" |
|
511 |
||
512 |
^ self displayArcX:(boundingBox left + origin x) |
|
513 |
y:(boundingBox top + origin y) |
|
514 |
width:(boundingBox width) |
|
515 |
height:(boundingBox height) |
|
516 |
from:startAngle |
|
517 |
angle:sweepAngle |
|
518 |
! |
|
519 |
||
520 |
displayLineFrom:startPoint to:endPoint translateBy:anOffset |
|
521 |
"draw a line - ST-80 compatibility" |
|
0 | 522 |
|
519 | 523 |
self displayLineFrom:(startPoint + anOffset) |
524 |
to:(endPoint + anOffset) |
|
525 |
! |
|
526 |
||
527 |
displayPolyline:aPolygon |
|
528 |
"draw a polygon - ST-80 compatibility" |
|
529 |
||
530 |
^ self displayPolygon:aPolygon |
|
531 |
! |
|
532 |
||
533 |
displayRectangularBorder:aRectangle at:aPoint |
|
534 |
"draw a rectangle - ST-80 compatibility" |
|
0 | 535 |
|
519 | 536 |
self displayRectangle:(aRectangle translateBy:aPoint) |
537 |
! |
|
538 |
||
1280 | 539 |
displayWedgeBoundedBy:boundingBox startAngle:startAngle sweepAngle:sweepAngle |
540 |
"fill an arc/circle/ellipse - ST-80 compatibility" |
|
541 |
||
542 |
^ self fillArcX:(boundingBox left) |
|
543 |
y:(boundingBox top) |
|
544 |
width:(boundingBox width) |
|
545 |
height:(boundingBox height) |
|
546 |
from:startAngle |
|
547 |
angle:sweepAngle |
|
548 |
||
549 |
"Created: 27.1.1997 / 15:50:14 / cg" |
|
550 |
! |
|
551 |
||
519 | 552 |
displayWedgeBoundedBy:boundingBox startAngle:startAngle sweepAngle:sweepAngle at:origin |
553 |
"fill an arc/circle/ellipse - ST-80 compatibility" |
|
2 | 554 |
|
519 | 555 |
^ self fillArcX:(boundingBox left + origin x) |
556 |
y:(boundingBox top + origin y) |
|
557 |
width:(boundingBox width) |
|
558 |
height:(boundingBox height) |
|
559 |
from:startAngle |
|
560 |
angle:sweepAngle |
|
2 | 561 |
! ! |
562 |
||
0 | 563 |
!GraphicsContext methodsFor:'accessing'! |
564 |
||
565 |
backgroundPaint |
|
566 |
"return the background paint color. |
|
567 |
(used for opaqueForms and opaqueStrings)" |
|
568 |
||
569 |
^ bgPaint |
|
570 |
! |
|
571 |
||
572 |
backgroundPaint:aColor |
|
573 |
"set the background painting color (which is used for |
|
574 |
opaqueForms and opaqueStrings). aColor can be a dithered one." |
|
575 |
||
678 | 576 |
bgPaint := aColor |
577 |
||
578 |
"Modified: 12.5.1996 / 22:25:17 / cg" |
|
0 | 579 |
! |
580 |
||
581 |
capStyle |
|
582 |
"return the current cap-style for line-drawing" |
|
583 |
||
584 |
^ capStyle |
|
585 |
! |
|
586 |
||
587 |
capStyle:aStyleSymbol |
|
588 |
"set the cap-style for line-drawing; |
|
589 |
possible styles are: #notLast, #butt, #round, #projecting" |
|
590 |
||
678 | 591 |
aStyleSymbol isNil ifTrue:[ |
592 |
capStyle := #butt |
|
593 |
] ifFalse:[ |
|
594 |
capStyle := aStyleSymbol |
|
595 |
] |
|
596 |
||
597 |
"Modified: 12.5.1996 / 22:24:30 / cg" |
|
0 | 598 |
! |
599 |
||
76 | 600 |
clipRect |
719
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
601 |
"return the clip-rectangle for drawing. |
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
602 |
If there is currently no active clip, return the underlying |
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
603 |
displaySurfaces (i.e. views) bounds. Added for ST-80 compatibility." |
76 | 604 |
|
719
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
605 |
self obsoleteMethodWarning:'use #clippingBounds'. |
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
606 |
^ self clippingBounds. |
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
607 |
|
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
608 |
"Modified: 28.5.1996 / 14:14:53 / cg" |
76 | 609 |
! |
610 |
||
0 | 611 |
clipRect:aRectangle |
612 |
"set the drawing clip-rectangle" |
|
613 |
||
719
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
614 |
self obsoleteMethodWarning:'use #clippingRectangle:'. |
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
615 |
^ self clippingRectangle:aRectangle |
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
616 |
|
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
617 |
"Modified: 28.5.1996 / 14:13:09 / cg" |
0 | 618 |
! |
619 |
||
76 | 620 |
clippingBounds |
719
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
621 |
"return the clip-rectangle for drawing. |
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
622 |
If there is currently no active clip, return the underlying |
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
623 |
displaySurfaces (i.e. views) bounds. Added for ST-80 compatibility." |
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
624 |
|
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
625 |
|rect| |
76 | 626 |
|
719
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
627 |
clipRect isNil ifTrue:[ |
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
628 |
rect := 0@0 extent:(self medium extent). |
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
629 |
transformation notNil ifTrue:[ |
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
630 |
rect := transformation applyInverseTo:rect. |
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
631 |
]. |
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
632 |
^ rect |
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
633 |
]. |
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
634 |
^ clipRect |
563 | 635 |
|
719
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
636 |
"Modified: 28.5.1996 / 14:05:15 / cg" |
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
637 |
! |
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
638 |
|
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
639 |
clippingRectangle:aRectangleOrNil |
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
640 |
"set the clipping rectangle for drawing (in logical coordinates); |
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
641 |
a nil argument turn off clipping (i.e. whole view is drawable)" |
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
642 |
|
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
643 |
clipRect := aRectangleOrNil |
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
644 |
|
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
645 |
"Modified: 22.5.1996 / 13:12:07 / cg" |
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
646 |
"Created: 28.5.1996 / 14:09:27 / cg" |
76 | 647 |
! |
648 |
||
561
3c1ec7798f77
added #clippingRectangleOrNil for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
519
diff
changeset
|
649 |
clippingRectangleOrNil |
719
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
650 |
"return the clipping rectangle for drawing, nil if there is none." |
563 | 651 |
|
719
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
652 |
^ clipRect |
561
3c1ec7798f77
added #clippingRectangleOrNil for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
519
diff
changeset
|
653 |
|
719
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
654 |
"Created: 10.4.1996 / 14:32:02 / cg" |
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
655 |
"Modified: 28.5.1996 / 14:08:19 / cg" |
561
3c1ec7798f77
added #clippingRectangleOrNil for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
519
diff
changeset
|
656 |
! |
3c1ec7798f77
added #clippingRectangleOrNil for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
519
diff
changeset
|
657 |
|
786 | 658 |
dashStyle:aDashList offset:dashOffset |
659 |
"define dashes. Each element of the dashList specifies the length |
|
660 |
of a corresponding dash. For example, setting it to [4 4] |
|
661 |
defines 4on-4off dashing; |
|
662 |
Setting it to [1 2 4 2] defines 1on-2off-4on-2off dashes. |
|
663 |
The dashOffset specifies where in the dashList the dashing starts. |
|
664 |
Ignored here - this may not be supported by all graphics devices." |
|
665 |
||
666 |
^ self |
|
667 |
||
668 |
"Created: 4.6.1996 / 18:59:34 / cg" |
|
669 |
"Modified: 4.6.1996 / 19:03:38 / cg" |
|
670 |
! |
|
671 |
||
519 | 672 |
font |
673 |
"return the current drawing font" |
|
674 |
||
675 |
^ font |
|
676 |
! |
|
677 |
||
678 |
font:aFont |
|
679 |
"set the drawing font" |
|
680 |
||
681 |
^ self subclassResponsibility |
|
682 |
! |
|
683 |
||
684 |
function |
|
685 |
"return the current drawing function" |
|
686 |
||
687 |
^ function |
|
688 |
! |
|
689 |
||
690 |
function:aFunctionSymbol |
|
691 |
"set the drawing function" |
|
692 |
||
693 |
^ self subclassResponsibility |
|
694 |
! |
|
695 |
||
735 | 696 |
graphicsContext |
697 |
"for ST-80 compatibility" |
|
698 |
||
699 |
^ self |
|
700 |
! |
|
701 |
||
727
bf23a306b6f2
renamed PseudoView to DisplaySurface
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
702 |
graphicsDevice |
bf23a306b6f2
renamed PseudoView to DisplaySurface
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
703 |
"same as #device, for ST-80 compatibility" |
bf23a306b6f2
renamed PseudoView to DisplaySurface
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
704 |
|
bf23a306b6f2
renamed PseudoView to DisplaySurface
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
705 |
^ device |
bf23a306b6f2
renamed PseudoView to DisplaySurface
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
706 |
! |
bf23a306b6f2
renamed PseudoView to DisplaySurface
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
707 |
|
519 | 708 |
joinStyle |
709 |
"return the current join-style for polygon-drawing" |
|
710 |
||
711 |
^ joinStyle |
|
712 |
! |
|
12 | 713 |
|
519 | 714 |
joinStyle:aStyleSymbol |
715 |
"set the join-style of lines in polygon-drawing; |
|
716 |
possible styles are: #miter, #bevel, #round" |
|
717 |
||
678 | 718 |
aStyleSymbol isNil ifTrue:[ |
719 |
joinStyle := #miter |
|
720 |
] ifFalse:[ |
|
721 |
joinStyle := aStyleSymbol |
|
722 |
] |
|
723 |
||
724 |
"Modified: 12.5.1996 / 22:24:14 / cg" |
|
519 | 725 |
! |
726 |
||
727 |
lineStyle |
|
728 |
"return the current line-drawing-style" |
|
729 |
||
730 |
^ lineStyle |
|
2 | 731 |
! |
732 |
||
519 | 733 |
lineStyle:aStyleSymbol |
734 |
"set the line-drawing-style; |
|
735 |
possible styles are: #solid, #dashed, #doubleDashed" |
|
151 | 736 |
|
678 | 737 |
aStyleSymbol isNil ifTrue:[ |
738 |
lineStyle := #solid |
|
739 |
] ifFalse:[ |
|
740 |
lineStyle := aStyleSymbol |
|
741 |
] |
|
742 |
||
743 |
"Modified: 12.5.1996 / 22:19:25 / cg" |
|
519 | 744 |
! |
745 |
||
746 |
lineWidth |
|
747 |
"return the current drawing linewidth" |
|
748 |
||
749 |
^ lineWidth |
|
151 | 750 |
! |
751 |
||
519 | 752 |
lineWidth:aNumber |
753 |
"set the line drawing width in pixels" |
|
754 |
||
755 |
lineWidth := aNumber |
|
756 |
! |
|
151 | 757 |
|
519 | 758 |
mask |
759 |
"return the current drawing mask" |
|
760 |
||
761 |
^ mask |
|
762 |
! |
|
763 |
||
764 |
mask:aForm |
|
765 |
"set the drawing mask" |
|
766 |
||
767 |
^ self subclassResponsibility |
|
151 | 768 |
! |
769 |
||
770 |
maskOrigin |
|
771 |
"return the origin within the mask (used to draw with patterns). |
|
772 |
Should be redefined in classes which support it. |
|
773 |
This is an alias for ST-80's #phase" |
|
774 |
||
775 |
^ maskOrigin |
|
776 |
! |
|
777 |
||
778 |
maskOrigin:aPoint |
|
779 |
"set the origin within the mask (used to draw with patterns). |
|
780 |
Should be redefined in classes which support it. |
|
781 |
This is an alias for ST-80's #phase:" |
|
782 |
||
783 |
^ self maskOriginX:aPoint x y:aPoint y |
|
784 |
! |
|
785 |
||
786 |
maskOriginX:x y:y |
|
787 |
"set the origin within the mask (used to draw with patterns). |
|
788 |
Should be redefined in classes which support it. |
|
789 |
This is an alias for ST-80's #phase:" |
|
109 | 790 |
|
12 | 791 |
^ self |
792 |
! |
|
793 |
||
719
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
794 |
medium |
1346 | 795 |
"return the destination medium i.e. the underlying graphics device" |
719
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
796 |
|
727
bf23a306b6f2
renamed PseudoView to DisplaySurface
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
797 |
^ device |
719
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
798 |
|
720 | 799 |
"Modified: 28.5.1996 / 14:26:03 / cg" |
719
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
800 |
! |
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
801 |
|
519 | 802 |
paint |
803 |
"return the current paint drawing color" |
|
804 |
||
805 |
^ paint |
|
806 |
! |
|
807 |
||
808 |
paint:aColor |
|
809 |
"set the drawing painting color, aColor can be a dithered one" |
|
810 |
||
811 |
paint := aColor |
|
812 |
! |
|
813 |
||
814 |
paint:fgColor on:bgColor |
|
563 | 815 |
"set the paint and backgroundPaint, used for text and bitmaps. |
816 |
Both colors may be dithered colors" |
|
519 | 817 |
|
671 | 818 |
fgColor ~~ paint ifTrue:[ |
819 |
self paint:fgColor. |
|
820 |
]. |
|
519 | 821 |
bgPaint := bgColor |
563 | 822 |
|
671 | 823 |
"Modified: 12.5.1996 / 19:40:43 / cg" |
519 | 824 |
! |
825 |
||
151 | 826 |
setMaskOrigin:aPoint |
827 |
"set the origin within the mask (used to draw with patterns). |
|
828 |
OBSOLETE: use #maskOrigin: or #phase:" |
|
829 |
||
830 |
^ self maskOrigin:aPoint |
|
831 |
! |
|
832 |
||
2 | 833 |
setMaskOriginX:x y:y |
109 | 834 |
"set the origin within the mask (used to draw with patterns). |
151 | 835 |
OBSOLETE: use #maskOriginX:y: or #phase:" |
109 | 836 |
|
151 | 837 |
^ self maskOriginX:x y:y |
2 | 838 |
! |
839 |
||
519 | 840 |
viewOrigin |
841 |
"return the drawables visible origin (for scrolling)" |
|
842 |
||
843 |
^ 0@0 |
|
418
0e10e256d5b2
scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
844 |
! ! |
0e10e256d5b2
scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
845 |
|
0e10e256d5b2
scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
846 |
!GraphicsContext methodsFor:'accessing-transformation'! |
0e10e256d5b2
scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
847 |
|
0e10e256d5b2
scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
848 |
scale |
0e10e256d5b2
scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
849 |
"return the scale factor (as point) of the transformation" |
0e10e256d5b2
scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
850 |
|
707 | 851 |
transformation isNil ifTrue:[^ 1@1]. |
418
0e10e256d5b2
scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
852 |
^ transformation scale |
707 | 853 |
|
854 |
"Modified: 21.5.1996 / 21:16:47 / cg" |
|
418
0e10e256d5b2
scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
855 |
! |
0e10e256d5b2
scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
856 |
|
0e10e256d5b2
scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
857 |
scale:aPoint |
0e10e256d5b2
scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
858 |
"set the scale factor of the transformation" |
0e10e256d5b2
scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
859 |
|
0e10e256d5b2
scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
860 |
transformation isNil ifTrue:[ |
619 | 861 |
aPoint = 1 ifTrue:[^ self]. |
862 |
transformation := WindowingTransformation scale:aPoint translation:0 |
|
863 |
] ifFalse:[ |
|
864 |
transformation scale:aPoint. |
|
865 |
] |
|
418
0e10e256d5b2
scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
866 |
|
619 | 867 |
"Modified: 27.4.1996 / 18:47:38 / cg" |
76 | 868 |
! |
869 |
||
870 |
transformation |
|
871 |
"return the transformation" |
|
872 |
||
873 |
^ transformation |
|
874 |
! |
|
875 |
||
876 |
transformation:aTransformation |
|
877 |
"set the transformation" |
|
878 |
||
879 |
transformation := aTransformation |
|
619 | 880 |
! |
881 |
||
1319 | 882 |
translateBy:aPoint |
883 |
"add to the translation offset of the transformation" |
|
884 |
||
885 |
transformation isNil ifTrue:[ |
|
886 |
aPoint = 0 ifTrue:[^ self]. |
|
887 |
transformation := WindowingTransformation scale:1 translation:aPoint |
|
888 |
] ifFalse:[ |
|
889 |
transformation translateBy:aPoint |
|
890 |
] |
|
891 |
||
892 |
"Created: 10.2.1997 / 13:50:22 / cg" |
|
893 |
! |
|
894 |
||
619 | 895 |
translation |
896 |
"return the translation factor (as point) of the transformation" |
|
897 |
||
898 |
transformation isNil ifTrue:[^ 0@0]. |
|
899 |
^ transformation translation |
|
900 |
||
901 |
"Created: 27.4.1996 / 18:46:41 / cg" |
|
902 |
! |
|
903 |
||
904 |
translation:aPoint |
|
905 |
"set the translation offset of the transformation" |
|
906 |
||
907 |
transformation isNil ifTrue:[ |
|
908 |
aPoint = 0 ifTrue:[^ self]. |
|
909 |
transformation := WindowingTransformation scale:1 translation:aPoint |
|
910 |
] ifFalse:[ |
|
911 |
transformation translation:aPoint. |
|
912 |
] |
|
913 |
||
914 |
"Created: 27.4.1996 / 18:47:28 / cg" |
|
0 | 915 |
! ! |
916 |
||
755 | 917 |
!GraphicsContext methodsFor:'backward compatibility'! |
918 |
||
919 |
withPattern:aPattern do:aBlock |
|
920 |
|old| |
|
921 |
||
922 |
aPattern isColor ifTrue:[ |
|
923 |
old := paint. |
|
924 |
self paint:aPattern. |
|
925 |
aBlock value. |
|
926 |
self paint:old |
|
927 |
] ifFalse:[ |
|
928 |
old := mask. |
|
929 |
self mask:aPattern. |
|
930 |
aBlock value. |
|
931 |
self mask:old |
|
932 |
] |
|
933 |
||
934 |
"Modified: 28.5.1996 / 22:45:40 / cg" |
|
935 |
! ! |
|
936 |
||
71 | 937 |
!GraphicsContext methodsFor:'basic displaying'! |
0 | 938 |
|
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
939 |
displayArcX:x y:y width:width height:height from:startAngle angle:angle |
0 | 940 |
"draw an arc in a box |
941 |
- this could be recoded to draw using displayLine" |
|
942 |
||
943 |
^ self subclassResponsibility |
|
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
944 |
|
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
945 |
"Created: 8.5.1996 / 08:47:06 / cg" |
0 | 946 |
! |
947 |
||
726 | 948 |
displayLineFromX:x0 y:y0 toX:x1 y:y1 |
949 |
"draw a line from x0/y0 to x1/y1" |
|
0 | 950 |
|
726 | 951 |
^ self subclassResponsibility |
71 | 952 |
|
726 | 953 |
"Created: 28.5.1996 / 17:12:37 / cg" |
0 | 954 |
! |
955 |
||
26 | 956 |
displayOpaqueForm:aForm x:x y:y |
0 | 957 |
"draw a form at x/y; if the form has depth 1, 1's in the form are |
958 |
drawn in current fg, 0's in current bg color. |
|
959 |
If the form has depth ~~ 1, it is copied as is onto the receiver" |
|
960 |
||
961 |
^ self subclassResponsibility |
|
962 |
! |
|
963 |
||
964 |
displayOpaqueString:aString from:index1 to:index2 x:x y:y |
|
965 |
"draw part of a string with both fg and bg at x/y in current font" |
|
966 |
||
967 |
^ self subclassResponsibility |
|
968 |
! |
|
969 |
||
519 | 970 |
displayPolygon:aPolygon |
971 |
"draw a polygon |
|
972 |
- this could be recoded to draw using displayLine" |
|
973 |
||
974 |
^ self subclassResponsibility |
|
975 |
! |
|
976 |
||
977 |
displayRectangleX:x y:y width:w height:h |
|
978 |
"draw a rectangle |
|
979 |
- this could be recoded to draw using displayLine" |
|
980 |
||
981 |
^ self subclassResponsibility |
|
982 |
! |
|
983 |
||
0 | 984 |
displayString:aString from:index1 to:index2 x:x y:y |
985 |
"draw part of a string with fg at x/y in current font" |
|
986 |
||
987 |
^ self subclassResponsibility |
|
988 |
! ! |
|
989 |
||
519 | 990 |
!GraphicsContext methodsFor:'basic filling'! |
0 | 991 |
|
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
992 |
fillArcX:x y:y width:w height:h from:start angle:angle |
519 | 993 |
"fill an arc with current paint color" |
0 | 994 |
|
519 | 995 |
^ self subclassResponsibility |
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
996 |
|
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
997 |
"Created: 8.5.1996 / 08:47:44 / cg" |
0 | 998 |
! |
999 |
||
519 | 1000 |
fillPolygon:points |
1001 |
"fill a polygon with current paint color" |
|
0 | 1002 |
|
519 | 1003 |
^ self subclassResponsibility |
157 | 1004 |
! |
1005 |
||
519 | 1006 |
fillRectangleX:x y:y width:w height:h |
1007 |
"fill a rectangle with current paint color" |
|
0 | 1008 |
|
519 | 1009 |
^ self subclassResponsibility |
1010 |
! ! |
|
0 | 1011 |
|
519 | 1012 |
!GraphicsContext methodsFor:'bit blitting'! |
0 | 1013 |
|
519 | 1014 |
copyFrom:aGC toX:dstX y:dstY |
1015 |
"copy from a drawable - maybe self" |
|
0 | 1016 |
|
519 | 1017 |
self copyFrom:aGC x:0 y:0 toX:dstX y:dstY width:aGC width height:aGC height |
0 | 1018 |
! |
1019 |
||
519 | 1020 |
copyFrom:aGC x:srcX y:srcY toX:dstX y:dstY width:w height:h |
1021 |
"copy from a drawable - maybe self" |
|
0 | 1022 |
|
519 | 1023 |
^ self subclassResponsibility |
0 | 1024 |
! |
1025 |
||
519 | 1026 |
copyFrom:aGC x:dstX y:dstY width:w height:h |
1027 |
"copy from a drawable - maybe self" |
|
0 | 1028 |
|
519 | 1029 |
self copyFrom:aGC x:0 y:0 toX:dstX y:dstY width:w height:h |
1030 |
! ! |
|
0 | 1031 |
|
519 | 1032 |
!GraphicsContext methodsFor:'drawing'! |
0 | 1033 |
|
719
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
1034 |
display:someObject at:aPoint |
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
1035 |
"draw someObject - this must understand the #displayOn:at: message" |
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
1036 |
|
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
1037 |
someObject displayOn:self at:aPoint |
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
1038 |
|
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
1039 |
"Created: 28.5.1996 / 14:22:57 / cg" |
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
1040 |
! |
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
1041 |
|
12 | 1042 |
displayArcIn:aRectangle from:startAngle angle:angle |
1043 |
"draw an arc in a box" |
|
0 | 1044 |
|
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1045 |
self |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1046 |
displayArcX:(aRectangle left) |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1047 |
y:(aRectangle top) |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1048 |
width:(aRectangle width) |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1049 |
height:(aRectangle height) |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1050 |
from:startAngle |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1051 |
angle:angle |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1052 |
|
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1053 |
"Modified: 8.5.1996 / 08:35:00 / cg" |
0 | 1054 |
! |
1055 |
||
12 | 1056 |
displayArcOrigin:origin corner:corner from:startAngle angle:angle |
1057 |
"draw an arc in a box" |
|
0 | 1058 |
|
1059 |
|left top right bot| |
|
1060 |
||
1061 |
left := origin x. |
|
1062 |
top := origin y. |
|
1063 |
right := corner x. |
|
1064 |
bot := corner y. |
|
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1065 |
self |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1066 |
displayArcX:left |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1067 |
y:top |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1068 |
width:(right - left + 1) |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1069 |
height:(bot - top + 1) |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1070 |
from:startAngle |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1071 |
angle:angle |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1072 |
|
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1073 |
"Modified: 8.5.1996 / 08:35:25 / cg" |
0 | 1074 |
! |
1075 |
||
726 | 1076 |
displayArcX:x y:y w:w h:h from:startAngle angle:angle |
1077 |
"draw an arc; apply transformation if nonNil" |
|
1078 |
||
1079 |
self obsoleteMethodWarning:'use #displayArcX:y:width:height:from:angle:'. |
|
1080 |
self displayArcX:x y:y width:w height:h from:startAngle angle:angle |
|
1081 |
||
1082 |
"Modified: 8.5.1996 / 08:46:56 / cg" |
|
1083 |
! |
|
1084 |
||
519 | 1085 |
displayCircle:aPoint radius:r |
1086 |
"draw a circle around a center point" |
|
1087 |
||
1088 |
self displayCircleX:(aPoint x) y:(aPoint y) radius:r |
|
1089 |
! |
|
1090 |
||
12 | 1091 |
displayCircleIn:aRectangle |
0 | 1092 |
"draw a circle in a box" |
1093 |
||
1094 |
self |
|
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1095 |
displayArcX:(aRectangle left) |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1096 |
y:(aRectangle top) |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1097 |
width:(aRectangle width) |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1098 |
height:(aRectangle height) |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1099 |
from:0 |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1100 |
angle:360 |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1101 |
|
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1102 |
"Modified: 8.5.1996 / 08:35:40 / cg" |
0 | 1103 |
! |
1104 |
||
12 | 1105 |
displayCircleX:x y:y radius:r |
1106 |
"draw a circle around a center point" |
|
0 | 1107 |
|
1108 |
|d| |
|
1109 |
d := 2 * r. |
|
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1110 |
self |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1111 |
displayArcX:(x - r) |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1112 |
y:(y - r) |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1113 |
width:d |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1114 |
height:d |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1115 |
from:0 |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1116 |
angle:360 |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1117 |
|
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1118 |
"Modified: 8.5.1996 / 08:36:03 / cg" |
519 | 1119 |
! |
1120 |
||
1121 |
displayForm:aForm at:aPoint |
|
1122 |
"draw a form" |
|
1123 |
||
1124 |
self displayForm:aForm x:(aPoint x) y:(aPoint y) |
|
1125 |
! |
|
1126 |
||
726 | 1127 |
displayForm:aForm x:x y:y |
1128 |
"draw a form at x/y; if the form has depth 1, 1's in the form are |
|
1129 |
drawn in current paint color, 0's are ignored. |
|
1130 |
If the form has depth ~~ 1, the result is undefined" |
|
1131 |
||
1132 |
|fg bg f noColor| |
|
1133 |
||
1134 |
fg := paint. |
|
1135 |
bg := bgPaint. |
|
1136 |
f := function. |
|
1137 |
||
1138 |
f ~~ #copy ifTrue:[ |
|
1139 |
self error:'function not supported'. |
|
1140 |
^ self |
|
1141 |
]. |
|
1142 |
||
1143 |
noColor := Color noColor. |
|
1144 |
" |
|
1145 |
stamp out fg-pixels |
|
1146 |
" |
|
1147 |
self paint:noColor on:Color allColor function:#and. |
|
1148 |
self displayOpaqueForm:aForm x:x y:y. |
|
1149 |
" |
|
1150 |
or-in fg-pixels |
|
1151 |
" |
|
1152 |
self paint:fg on:Color noColor function:#or. |
|
1153 |
self displayOpaqueForm:aForm x:x y:y. |
|
1154 |
self paint:fg on:fg function:f. |
|
1155 |
||
1156 |
"Modified: 28.5.1996 / 17:10:28 / cg" |
|
1157 |
! |
|
1158 |
||
519 | 1159 |
displayLineFrom:point1 to:point2 |
1160 |
"draw a line" |
|
1161 |
||
1162 |
self displayLineFromX:(point1 x) y:(point1 y) |
|
1163 |
toX:(point2 x) y:(point2 y) |
|
1164 |
! |
|
1165 |
||
1506
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1166 |
displayLineFromX:xStart y:yStart toX:xEnd y:yEnd brush:aForm |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1167 |
"draw a line using a brush. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1168 |
Here, a slow fallback is used, drawing into a |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1169 |
temporary bitmap first, which is then displayed" |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1170 |
|
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1171 |
|deltaX deltaY dx dy px py destX destY P tempForm x0 y0 |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1172 |
xMin xMax yMin yMax x1 x2 y1 y2| |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1173 |
|
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1174 |
xStart < xEnd ifTrue:[ |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1175 |
xMin := xStart. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1176 |
xMax := xEnd. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1177 |
] ifFalse:[ |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1178 |
xMin := xEnd. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1179 |
xMax := xStart |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1180 |
]. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1181 |
yStart < yEnd ifTrue:[ |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1182 |
yMin := yStart. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1183 |
yMax := yEnd. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1184 |
] ifFalse:[ |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1185 |
yMin := yEnd. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1186 |
yMax := yStart |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1187 |
]. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1188 |
|
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1189 |
tempForm := Form width:(xMax-xMin+1+aForm width) |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1190 |
height:(yMax-yMin+1+aForm height) |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1191 |
depth:aForm depth |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1192 |
on:device. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1193 |
tempForm clear. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1194 |
tempForm paint:(Color colorId:1) on:(Color colorId:0). |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1195 |
tempForm function:#or. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1196 |
|
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1197 |
((yStart = yEnd and:[xStart < xEnd]) |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1198 |
or: [yStart < yEnd]) ifTrue:[ |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1199 |
x1 := xStart. y1 := yStart. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1200 |
x2 := xEnd. y2 := yEnd. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1201 |
] ifFalse:[ |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1202 |
x1 := xEnd. y1 := yEnd. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1203 |
x2 := xStart. y2 := yStart. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1204 |
]. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1205 |
|
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1206 |
x1 := x1 - xMin. x2 := x2 - xMin. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1207 |
y1 := y1 - yMin. y2 := y2 - yMin. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1208 |
|
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1209 |
destX := x1. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1210 |
destY := y1. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1211 |
|
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1212 |
"/ bresenham ... |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1213 |
|
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1214 |
deltaX := x2 - x1. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1215 |
deltaY := y2 - y1. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1216 |
|
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1217 |
dx := deltaX sign. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1218 |
dy := deltaY sign. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1219 |
px := deltaY abs. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1220 |
py := deltaX abs. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1221 |
|
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1222 |
tempForm displayForm:aForm x:destX y:destY. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1223 |
|
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1224 |
py > px ifTrue:[ |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1225 |
"horizontal" |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1226 |
P := py // 2. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1227 |
py timesRepeat:[ |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1228 |
destX := destX + dx. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1229 |
(P := P - px) < 0 ifTrue:[ |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1230 |
destY := destY + dy. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1231 |
P := P + py |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1232 |
]. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1233 |
tempForm displayForm:aForm x:destX y:destY. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1234 |
] |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1235 |
] ifFalse:[ |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1236 |
"vertical" |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1237 |
P := px // 2. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1238 |
px timesRepeat:[ |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1239 |
destY := destY + dy. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1240 |
(P := P - py) < 0 ifTrue:[ |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1241 |
destX := destX + dx. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1242 |
P := P + px |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1243 |
]. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1244 |
tempForm displayForm:aForm x:destX y:destY |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1245 |
] |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1246 |
]. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1247 |
self displayForm:tempForm |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1248 |
x:xMin-aForm offset x |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1249 |
y:yMin-aForm offset y. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1250 |
tempForm close |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1251 |
|
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1252 |
"Modified: 1.4.1997 / 21:29:06 / cg" |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1253 |
! |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1254 |
|
519 | 1255 |
displayOpaqueString:aString at:aPoint |
1256 |
"draw a string with both fg and bg" |
|
1257 |
||
1258 |
self displayOpaqueString:aString x:(aPoint x) y:(aPoint y) |
|
1259 |
! |
|
1260 |
||
1261 |
displayOpaqueString:aString from:start to:stop at:aPoint |
|
1262 |
"draw part of a string - drawing both fg and bg" |
|
1263 |
||
1264 |
^ self displayOpaqueString:aString from:start to:stop x:aPoint x y:aPoint y |
|
1265 |
! |
|
1266 |
||
1267 |
displayOpaqueString:aString x:x y:y |
|
1268 |
"draw a string with both fg and bg" |
|
1269 |
||
1270 |
self displayOpaqueString:aString from:1 to:(aString size) x:x y:y |
|
1271 |
! |
|
1272 |
||
1273 |
displayPoint:aPoint |
|
1274 |
"draw a pixel" |
|
1275 |
||
1276 |
self displayPointX:(aPoint x) y:(aPoint y) |
|
1277 |
! |
|
1278 |
||
1279 |
displayPointX:x y:y |
|
1280 |
"draw a point at x/y" |
|
1281 |
||
1282 |
self displayLineFromX:x y:y toX:x y:y |
|
1283 |
! |
|
1284 |
||
1285 |
displayRectangle:aRectangle |
|
1286 |
"draw a rectangle" |
|
1287 |
||
1288 |
self displayRectangleX:(aRectangle left) |
|
1289 |
y:(aRectangle top) |
|
1290 |
width:(aRectangle width) |
|
1291 |
height:(aRectangle height) |
|
1292 |
! |
|
1293 |
||
1294 |
displayRectangleOrigin:origin corner:corner |
|
1295 |
"draw a rectangle" |
|
1296 |
||
1297 |
|top left| |
|
1298 |
||
1299 |
left := origin x. |
|
1300 |
top := origin y. |
|
1301 |
self displayRectangleX:left y:top |
|
563 | 1302 |
width:(corner x - left) |
1303 |
height:(corner y - top) |
|
1304 |
||
1305 |
"Modified: 13.4.1996 / 20:58:31 / cg" |
|
519 | 1306 |
! |
1307 |
||
1308 |
displayString:aString at:aPoint |
|
1309 |
"draw a string - drawing fg only" |
|
1310 |
||
1311 |
self displayString:aString x:aPoint x y:aPoint y |
|
1312 |
! |
|
1313 |
||
1314 |
displayString:aString from:start to:stop at:aPoint |
|
1315 |
"draw part of a string - drawing fg only" |
|
1316 |
||
1317 |
^ self displayString:aString from:start to:stop x:aPoint x y:aPoint y |
|
1318 |
! |
|
1319 |
||
1320 |
displayString:aString x:x y:y |
|
1321 |
"draw a string - drawing fg only" |
|
1322 |
||
1323 |
self displayString:aString from:1 to:(aString size) x:x y:y |
|
726 | 1324 |
! |
1325 |
||
1326 |
fillArcX:x y:y w:w h:h from:startAngle angle:angle |
|
1327 |
"draw a filled arc; apply transformation if nonNil" |
|
1328 |
||
1329 |
self obsoleteMethodWarning:'use #fillArcX:y:width:height:from:angle:'. |
|
1330 |
self fillArcX:x y:y width:w height:h from:startAngle angle:angle |
|
1331 |
||
1332 |
"Modified: 8.5.1996 / 08:47:52 / cg" |
|
0 | 1333 |
! ! |
519 | 1334 |
|
1335 |
!GraphicsContext methodsFor:'drawing in device coordinates'! |
|
1336 |
||
1337 |
displayDeviceLineFromX:x1 y:y1 toX:x2 y:y2 |
|
1338 |
"draw a line in device coordinates" |
|
1339 |
||
1340 |
|sav| |
|
1341 |
||
1342 |
sav := transformation. |
|
1343 |
transformation := nil. |
|
1344 |
self displayLineFromX:x1 y:y1 toX:x2 y:y2. |
|
1345 |
transformation := sav |
|
1346 |
! |
|
1347 |
||
1348 |
fillDeviceRectangleX:x y:y width:w height:h |
|
1349 |
"fill a rectangle with current paint color (device coordinates)" |
|
1350 |
||
1351 |
|sav| |
|
1352 |
||
1353 |
sav := transformation. |
|
1354 |
transformation := nil. |
|
1355 |
self fillRectangleX:x y:y width:w height:h. |
|
1356 |
transformation := sav |
|
1357 |
! ! |
|
1358 |
||
713 | 1359 |
!GraphicsContext methodsFor:'edge drawing'! |
1360 |
||
1361 |
drawEdgesForX:x y:y width:w height:h level:l |
|
1362 |
shadow:shadowColor light:lightColor |
|
1363 |
halfShadow:halfShadowColor halfLight:halfLightColor |
|
1364 |
style:edgeStyle |
|
1365 |
||
1366 |
"draw 3D edges into a rectangle" |
|
1367 |
||
1368 |
|topLeftFg botRightFg topLeftHalfFg botRightHalfFg |
|
1369 |
count "{ Class: SmallInteger }" |
|
1370 |
r "{ Class: SmallInteger }" |
|
1371 |
b "{ Class: SmallInteger }" |
|
1372 |
xi "{ Class: SmallInteger }" |
|
1373 |
yi "{ Class: SmallInteger }" |
|
1374 |
run paint| |
|
1375 |
||
1376 |
count := l. |
|
1377 |
(count < 0) ifTrue:[ |
|
1378 |
topLeftFg := shadowColor. |
|
1379 |
botRightFg := lightColor. |
|
1380 |
topLeftHalfFg := halfShadowColor. |
|
1381 |
botRightHalfFg := halfLightColor. |
|
1382 |
count := count negated |
|
1383 |
] ifFalse:[ |
|
1384 |
topLeftFg := lightColor. |
|
1385 |
botRightFg := shadowColor. |
|
1386 |
topLeftHalfFg := halfLightColor. |
|
1387 |
botRightHalfFg := halfShadowColor. |
|
1388 |
]. |
|
1389 |
topLeftHalfFg isNil ifTrue:[ |
|
1390 |
topLeftHalfFg := topLeftFg |
|
1391 |
]. |
|
1392 |
botRightHalfFg isNil ifTrue:[ |
|
1393 |
botRightHalfFg := botRightFg |
|
1394 |
]. |
|
1395 |
||
1396 |
r := x + w - 1. "right" |
|
1397 |
b := y + h - 1. "bottom" |
|
1398 |
||
1399 |
self lineWidth:0. |
|
1400 |
||
1401 |
"top and left edges" |
|
1402 |
((edgeStyle == #soft) and:["l" count > 0]) ifTrue:[ |
|
1403 |
paint := topLeftHalfFg |
|
1404 |
] ifFalse:[ |
|
1405 |
paint := topLeftFg |
|
1406 |
]. |
|
1407 |
self paint:paint. |
|
1408 |
||
1409 |
0 to:(count - 1) do:[:i | |
|
1410 |
run := y + i. |
|
1411 |
self displayDeviceLineFromX:x y:run toX:r y:run. "top" |
|
1412 |
run := x + i. |
|
1413 |
self displayDeviceLineFromX:run y:y toX:run y:b "left" |
|
1414 |
]. |
|
1415 |
(edgeStyle == #soft) ifTrue:[ |
|
1416 |
" |
|
1417 |
self paint:topLeftFg. |
|
1418 |
self displayDeviceLineFromX:x y:y toX:r y:y. |
|
1419 |
self displayDeviceLineFromX:x y:y toX:x y:b |
|
1420 |
" |
|
1421 |
(l > 2) ifTrue:[ |
|
1203
49dd13574c7d
dont use Black/White when drawing;
Claus Gittinger <cg@exept.de>
parents:
952
diff
changeset
|
1422 |
self paint:(device blackColor). |
713 | 1423 |
self displayDeviceLineFromX:x y:y toX:r y:y. |
1424 |
self displayDeviceLineFromX:x y:y toX:x y:b. |
|
1425 |
] |
|
1426 |
]. |
|
1427 |
||
1428 |
xi := x + 1. |
|
1429 |
yi := y + 1. |
|
1430 |
||
1431 |
"/ does not look good |
|
1432 |
"/ style == #st80 iftrue:[ |
|
1433 |
"/ yi := yi + 1 |
|
1434 |
"/ ]. |
|
1435 |
||
1436 |
"bottom and right edges" |
|
1437 |
(edgeStyle == #soft "new:" and:[count > 1]) ifTrue:[ |
|
1438 |
paint := botRightHalfFg |
|
1439 |
] ifFalse:[ |
|
1440 |
paint := botRightFg |
|
1441 |
]. |
|
1442 |
||
1443 |
self paint:paint. |
|
1444 |
0 to:(count - 1) do:[:i | |
|
1445 |
run := b - i. |
|
1446 |
self displayDeviceLineFromX:xi-1 y:run toX:r y:run. "bottom" |
|
1447 |
run := r - i. |
|
1448 |
self displayDeviceLineFromX:run y:yi-1 toX:run y:b. "right" |
|
1449 |
xi := xi + 1. |
|
1450 |
yi := yi + 1 |
|
1451 |
]. |
|
1452 |
((edgeStyle == #soft) and:[l > 1]) ifTrue:[ |
|
1203
49dd13574c7d
dont use Black/White when drawing;
Claus Gittinger <cg@exept.de>
parents:
952
diff
changeset
|
1453 |
self paint:(device blackColor) "shadowColor". |
713 | 1454 |
self displayDeviceLineFromX:(x + (1 - 1)) y:b toX:r y:b. |
1455 |
self displayDeviceLineFromX:r y:(y + (1 - 1)) toX:r y:b |
|
1443 | 1456 |
]. |
1457 |
||
1458 |
self edgeDrawn:#all |
|
1459 |
||
1460 |
"Modified: 7.3.1997 / 17:59:19 / cg" |
|
1461 |
! |
|
713 | 1462 |
|
1443 | 1463 |
edgeDrawn:whichOne |
1464 |
"a redefinable hook for views which like to draw |
|
1465 |
over their edges (some checkToggles do). |
|
1466 |
Nothing done here." |
|
1467 |
||
1468 |
"Created: 7.3.1997 / 17:59:07 / cg" |
|
713 | 1469 |
! ! |
1470 |
||
519 | 1471 |
!GraphicsContext methodsFor:'filling'! |
1472 |
||
1473 |
fillArc:origin radius:r from:startAngle angle:angle |
|
1474 |
"draw a filled arc around a point" |
|
1475 |
||
1476 |
|d| |
|
1477 |
d := 2 * r. |
|
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1478 |
self |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1479 |
fillArcX:(origin x - r) |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1480 |
y:(origin y - r) |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1481 |
width:d |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1482 |
height:d |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1483 |
from:startAngle |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1484 |
angle:angle |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1485 |
|
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1486 |
"Modified: 8.5.1996 / 08:41:54 / cg" |
519 | 1487 |
! |
1488 |
||
563 | 1489 |
fillArcIn:aRectangle from:startAngle angle:angle |
1490 |
"draw a filled arc in a box" |
|
1491 |
||
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1492 |
self |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1493 |
fillArcX:(aRectangle left) |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1494 |
y:(aRectangle top) |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1495 |
width:(aRectangle width) |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1496 |
height:(aRectangle height) |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1497 |
from:startAngle |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1498 |
angle:angle |
563 | 1499 |
|
1500 |
"Created: 13.4.1996 / 20:56:03 / cg" |
|
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1501 |
"Modified: 8.5.1996 / 08:42:13 / cg" |
563 | 1502 |
! |
1503 |
||
1504 |
fillArcOrigin:origin corner:corner from:startAngle angle:angle |
|
1505 |
"draw a filled arc in a box" |
|
1506 |
||
1507 |
|left top right bot| |
|
1508 |
||
1509 |
left := origin x. |
|
1510 |
top := origin y. |
|
1511 |
right := corner x. |
|
1512 |
bot := corner y. |
|
1513 |
self |
|
1514 |
fillArcX:left |
|
1515 |
y:top |
|
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1516 |
width:(right - left + 1) |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1517 |
height:(bot - top + 1) |
563 | 1518 |
from:startAngle |
1519 |
angle:angle |
|
1520 |
||
1521 |
"Created: 13.4.1996 / 20:56:56 / cg" |
|
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1522 |
"Modified: 8.5.1996 / 08:42:23 / cg" |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1523 |
! |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1524 |
|
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1525 |
fillArcX:x y:y width:w height:h from:startAngle to:endAngle |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1526 |
"draw a filled arc in a box, given startAngle and endAngle." |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1527 |
|
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1528 |
self |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1529 |
fillArcX:x |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1530 |
y:y |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1531 |
width:w |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1532 |
height:h |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1533 |
from:startAngle |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1534 |
angle:(endAngle - startAngle) |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1535 |
|
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1536 |
"Created: 8.5.1996 / 08:52:41 / cg" |
563 | 1537 |
! |
1538 |
||
519 | 1539 |
fillCircle:aPoint radius:aNumber |
1540 |
"draw a filled circle around aPoint" |
|
1541 |
||
1542 |
self fillCircleX:(aPoint x) y:(aPoint y) radius:aNumber |
|
1543 |
! |
|
1544 |
||
563 | 1545 |
fillCircleIn:aRectangle |
1546 |
"draw a filled circle in a box" |
|
1547 |
||
1548 |
self |
|
1549 |
fillArcX:(aRectangle left) |
|
1550 |
y:(aRectangle top) |
|
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1551 |
width:(aRectangle width) |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1552 |
height:(aRectangle height) |
563 | 1553 |
from:0 |
1554 |
angle:360 |
|
1555 |
||
1556 |
"Created: 13.4.1996 / 20:57:41 / cg" |
|
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1557 |
"Modified: 8.5.1996 / 08:42:38 / cg" |
563 | 1558 |
! |
1559 |
||
519 | 1560 |
fillCircleX:x y:y radius:r |
1561 |
"draw a filled circle around x@y" |
|
1562 |
||
1563 |
|d| |
|
1564 |
||
1565 |
d := 2 * r. |
|
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1566 |
self |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1567 |
fillArcX:(x - r) |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1568 |
y:(y - r) |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1569 |
width:d |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1570 |
height:d |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1571 |
from:0 |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1572 |
angle:360 |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1573 |
|
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1574 |
"Modified: 8.5.1996 / 08:43:02 / cg" |
519 | 1575 |
! |
1576 |
||
1577 |
fillRectangle:aRectangle |
|
1578 |
"fill a rectangle with current paint color" |
|
1579 |
||
1580 |
self fillRectangleX:(aRectangle left) |
|
1581 |
y:(aRectangle top) |
|
1582 |
width:(aRectangle width) |
|
1583 |
height:(aRectangle height) |
|
563 | 1584 |
! |
1585 |
||
1586 |
fillRectangleOrigin:origin corner:corner |
|
1587 |
"draw a filled rectangle" |
|
1588 |
||
1589 |
|top left| |
|
1590 |
||
1591 |
left := origin x. |
|
1592 |
top := origin y. |
|
1593 |
self fillRectangleX:left y:top |
|
1594 |
width:(corner x - left) |
|
1595 |
height:(corner y - top) |
|
1596 |
||
1597 |
"Created: 13.4.1996 / 20:58:16 / cg" |
|
519 | 1598 |
! ! |
1599 |
||
1600 |
!GraphicsContext methodsFor:'initialization'! |
|
1601 |
||
1602 |
initialize |
|
1603 |
"set up some useful default values" |
|
1604 |
||
952 | 1605 |
paint isNil ifTrue:[paint := Black]. |
1606 |
bgPaint isNil ifTrue:[bgPaint := White]. |
|
519 | 1607 |
function := #copy. |
1608 |
lineWidth := 1. |
|
1609 |
lineStyle := #solid. |
|
1610 |
joinStyle := #miter. |
|
1611 |
capStyle := #butt. |
|
1612 |
font := DefaultFont. |
|
952 | 1613 |
|
1614 |
"Modified: 17.7.1996 / 13:00:12 / cg" |
|
519 | 1615 |
! ! |
1616 |
||
1617 |
!GraphicsContext methodsFor:'misc'! |
|
1618 |
||
1619 |
flush |
|
585 | 1620 |
"send all buffered drawing to the device." |
519 | 1621 |
|
742 | 1622 |
device flush |
585 | 1623 |
|
742 | 1624 |
"Modified: 28.5.1996 / 20:22:26 / cg" |
519 | 1625 |
! ! |
1626 |
||
1203
49dd13574c7d
dont use Black/White when drawing;
Claus Gittinger <cg@exept.de>
parents:
952
diff
changeset
|
1627 |
!GraphicsContext class methodsFor:'documentation'! |
519 | 1628 |
|
1629 |
version |
|
1506
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1630 |
^ '$Header: /cvs/stx/stx/libview/GraphicsContext.st,v 1.54 1997-04-01 21:12:40 cg Exp $' |
519 | 1631 |
! ! |
1632 |
GraphicsContext initialize! |