author | Claus Gittinger <cg@exept.de> |
Wed, 08 May 1996 13:51:04 +0200 | |
changeset 653 | 0ad3de022f8b |
parent 619 | a46cb2ef56bf |
child 657 | 1394e675b34d |
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 |
|
519 | 14 |
instanceVariableNames:'paint bgPaint function font lineStyle lineWidth joinStyle |
15 |
capStyle mask maskOrigin transformation' |
|
16 |
classVariableNames:'White Black DefaultFont' |
|
17 |
poolDictionaries:'' |
|
18 |
category:'Graphics-Support' |
|
0 | 19 |
! |
20 |
||
46 | 21 |
!GraphicsContext class methodsFor:'documentation'! |
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 |
|
46 | 79 |
|
611 | 80 |
[Class variables:[ |
81 |
||
82 |
White <Color> cached white color - its needed so often |
|
83 |
Black <Color> cached black color - its needed so often |
|
46 | 84 |
|
611 | 85 |
DefaultFont <Font> default font to use |
46 | 86 |
|
611 | 87 |
[author:] |
88 |
Claus Gittinger |
|
46 | 89 |
" |
563 | 90 |
! |
91 |
||
92 |
examples |
|
93 |
" |
|
94 |
drawing uses a paint color (which may be a dithered one) which is |
|
95 |
used like a `pen'. |
|
96 |
A few drawing operations (opaqueForm and opaqueString drawing) |
|
97 |
use two colors, the paint and a backgroundPaint. For example, |
|
98 |
normal string drawing (#displayString:...) only draws the fonts |
|
99 |
on-pixels in the current paint, leaving off-pixels unchanged. |
|
100 |
In contrast, #drawOpaqueString:.. also changes these to the bgPaint color. |
|
101 |
The bgPaint can be changed with #backgroundPaint: or #paint:on: (which modifies both). |
|
102 |
||
103 |
lets try it in a view: |
|
619 | 104 |
[exBegin] |
563 | 105 |
|v| |
106 |
||
107 |
v := View new. |
|
108 |
v openAndWait. |
|
109 |
||
110 |
v paint:(Color red). |
|
111 |
v displayString:'hello' x:10 y:50 |
|
619 | 112 |
[exEnd] |
563 | 113 |
|
114 |
the same using opaque drawing: |
|
619 | 115 |
[exBegin] |
563 | 116 |
|v| |
117 |
||
118 |
v := View new. |
|
119 |
v openAndWait. |
|
120 |
||
121 |
v paint:(Color red) on:(Color yellow). |
|
122 |
v displayOpaqueString:'hello' x:10 y:50 |
|
619 | 123 |
[exEnd] |
563 | 124 |
|
125 |
||
126 |
||
127 |
Lines are drawn using the paint color (if solid) or both paint and bgPaint |
|
128 |
(dashed lines). The look of the line is controlled by joinStyle, capStyle, |
|
129 |
lineWidth and lineStyle. |
|
130 |
`lineStyle' can be one of #solid, #dashed, #doubleDashed |
|
131 |
where: #solid - is for solid lines, drawn with the current paint color |
|
132 |
||
133 |
#dashed - for dashed lines, where only the on-dashes are drawn |
|
134 |
with the current paint color |
|
135 |
||
136 |
#doubleDashed - dashed lines, draws on-dashes with paint color, |
|
137 |
off-dashes with bgPaint |
|
138 |
||
139 |
for example: |
|
619 | 140 |
[exBegin] |
563 | 141 |
|v| |
142 |
||
143 |
v := View new. |
|
144 |
v openAndWait. |
|
145 |
||
146 |
v paint:(Color red) on:(Color blue). |
|
147 |
v displayLineFrom:(10@10) to:(90@90). |
|
148 |
||
149 |
v lineStyle:#dashed. |
|
150 |
v displayLineFrom:(90@10) to:(10@90). |
|
151 |
||
152 |
v lineStyle:#doubleDashed. |
|
153 |
v displayRectangle:((5@5) corner:(95@95)). |
|
619 | 154 |
[exEnd] |
563 | 155 |
|
156 |
changing the line-width: |
|
619 | 157 |
[exBegin] |
563 | 158 |
|v| |
159 |
||
160 |
v := View new. |
|
161 |
v openAndWait. |
|
162 |
||
163 |
v paint:(Color red). |
|
164 |
v displayLineFrom:(20@20) to:(80@80). |
|
165 |
||
166 |
v lineWidth:5. |
|
167 |
v displayLineFrom:(80@20) to:(20@80). |
|
168 |
||
169 |
v lineWidth:8. |
|
170 |
v displayRectangle:((5@5) corner:(95@95)). |
|
619 | 171 |
[exEnd] |
563 | 172 |
|
173 |
with wide lines, the corners (of polygons or rectangles) can be |
|
174 |
one of the joinStyles: #miter, #bevel, #round. The default is #miter. |
|
619 | 175 |
[exBegin] |
563 | 176 |
|v| |
177 |
||
178 |
v := View new extent:200@200. |
|
179 |
v openAndWait. |
|
180 |
||
181 |
v lineWidth:15. |
|
182 |
v paint:(Color red). |
|
183 |
||
184 |
v displayRectangle:((65@65) corner:(135@135)). |
|
185 |
||
186 |
v joinStyle:#bevel. |
|
187 |
v displayRectangle:((45@45) corner:(155@155)). |
|
188 |
||
189 |
v joinStyle:#round. |
|
190 |
v displayRectangle:((25@25) corner:(175@175)). |
|
619 | 191 |
[exEnd] |
563 | 192 |
|
193 |
||
194 |
the endPoints look is controlled with capStyle; |
|
195 |
possible values are: #notLast, #butt, #round, #projecting. |
|
196 |
The default is #butt. |
|
197 |
#notLast is mostly useful when exoring (inverting): it will not draw the |
|
198 |
endPoint, to allow another line to join the previous line without inverting |
|
199 |
this point twice. (See the X manual for more info). |
|
619 | 200 |
[exBegin] |
563 | 201 |
|v| |
202 |
||
203 |
v := View new extent:200@200. |
|
204 |
v openAndWait. |
|
205 |
||
206 |
v lineWidth:15. |
|
207 |
v paint:(Color red). |
|
208 |
||
209 |
v displayLineFrom:(25@25) to:(175@25). |
|
210 |
||
211 |
v capStyle:#round. |
|
212 |
v displayLineFrom:(25@55) to:(175@55). |
|
213 |
||
214 |
v capStyle:#projecting. |
|
215 |
v displayLineFrom:(25@85) to:(175@85). |
|
619 | 216 |
[exEnd] |
563 | 217 |
|
218 |
||
219 |
You can use a bitmap as a point color: |
|
220 |
(this may be slow on some graphics devices, though) |
|
619 | 221 |
[exBegin] |
563 | 222 |
|v| |
223 |
||
224 |
v := View new extent:200@200. |
|
225 |
v openAndWait. |
|
226 |
||
227 |
v lineWidth:15. |
|
228 |
v paint:(Image fromFile:'granite_small.tiff'). |
|
229 |
||
230 |
v displayLineFrom:(25@25) to:(175@25). |
|
231 |
||
232 |
v capStyle:#round. |
|
233 |
v displayLineFrom:(25@55) to:(175@55). |
|
234 |
||
235 |
v capStyle:#projecting. |
|
236 |
v displayLineFrom:(25@85) to:(175@85). |
|
619 | 237 |
[exEnd] |
563 | 238 |
|
239 |
all views support a translation and scale, so you can draw in another |
|
240 |
coordinate system: |
|
619 | 241 |
[exBegin] |
563 | 242 |
|v| |
243 |
||
244 |
v := View new extent:200@200. |
|
245 |
v openAndWait. |
|
246 |
||
247 |
v displayForm:(Image fromFile:'SBrowser.xbm') x:10 y:10. |
|
248 |
||
249 |
v scale:(2@2); translation:50. |
|
250 |
v displayForm:(Image fromFile:'SBrowser.xbm') x:10 y:10. |
|
251 |
||
252 |
v scale:(0.5@0.5); translation:0. |
|
253 |
v displayForm:(Image fromFile:'SBrowser.xbm') x:10 y:10. |
|
619 | 254 |
[exEnd] |
563 | 255 |
|
256 |
if scaling is on, it is often useful to be able to draw individual |
|
257 |
things unscaled - this still translates the position, but |
|
258 |
uses the unscaled font (for example, to draw strings in a graphic): |
|
619 | 259 |
[exBegin] |
563 | 260 |
|v| |
261 |
||
262 |
v := View new extent:200@200. |
|
263 |
v openAndWait. |
|
264 |
||
265 |
v displayForm:(Image fromFile:'SBrowser.xbm') x:10 y:10. |
|
266 |
v displayString:'hello' x:50 y:40. |
|
267 |
||
268 |
v scale:(2@4). |
|
269 |
v displayForm:(Image fromFile:'SBrowser.xbm') x:10 y:10. |
|
270 |
v displayUnscaledString:'hello' x:50 y:40. |
|
619 | 271 |
[exEnd] |
563 | 272 |
|
273 |
Filled objects are drawin using the #fillXXX methods; for example, |
|
274 |
displayRectangleXXX draws the outline, while fillRectangleXXX draws a |
|
275 |
filled one: |
|
619 | 276 |
[exBegin] |
563 | 277 |
|v| |
278 |
||
279 |
v := View new extent:200@200. |
|
280 |
v openAndWait. |
|
281 |
||
282 |
v displayArcIn:(20@20 corner:50@50) from:0 angle:180. |
|
283 |
v paint:Color yellow. |
|
284 |
v fillArcIn:(120@120 corner:150@150) from:0 angle:180. |
|
285 |
||
286 |
v paint:Color red. |
|
287 |
v displayCircle:150@50 radius:30. |
|
288 |
v paint:Color blue. |
|
289 |
v fillCircle:50@150 radius:30. |
|
619 | 290 |
[exEnd] |
291 |
||
292 |
polygons: |
|
293 |
[exBegin] |
|
294 |
|v poly1 poly2| |
|
295 |
||
296 |
poly1 := OrderedCollection new. |
|
297 |
poly1 add:(10 @ 10). |
|
298 |
poly1 add:(100 @ 50). |
|
299 |
poly1 add:(50 @ 50). |
|
300 |
poly1 add:(20 @ 100). |
|
301 |
poly1 add:(10 @ 100). |
|
302 |
||
303 |
poly2 := poly1 copy. |
|
304 |
poly2 add:(poly2 first). |
|
305 |
||
306 |
v := View new extent:200@200. |
|
307 |
v openAndWait. |
|
308 |
||
309 |
v scale:2. |
|
310 |
v paint:Color red. |
|
311 |
v fillPolygon:poly1. |
|
312 |
||
313 |
v scale:1. |
|
314 |
v paint:Color blue. |
|
315 |
v displayPolygon:poly2. |
|
316 |
||
317 |
v scale:0.5. |
|
318 |
v paint:Color yellow. |
|
319 |
v fillPolygon:poly1. |
|
320 |
||
321 |
[exEnd] |
|
563 | 322 |
" |
46 | 323 |
! ! |
324 |
||
0 | 325 |
!GraphicsContext class methodsFor:'initialization'! |
326 |
||
327 |
initialize |
|
328 |
"setup some defaults - these are usually redefined |
|
329 |
during startup." |
|
330 |
||
134 | 331 |
White isNil ifTrue:[ |
386 | 332 |
Color isNil ifTrue:[^ self]. |
333 |
Display isNil ifTrue:[^ self]. |
|
334 |
||
134 | 335 |
Color initialize. |
46 | 336 |
|
134 | 337 |
White := Color white on:Display. |
338 |
Black := Color black on:Display. |
|
0 | 339 |
|
134 | 340 |
Font initialize. |
341 |
DefaultFont := Font family:'courier' face:'medium' style:'roman' size:12 |
|
342 |
] |
|
0 | 343 |
! ! |
344 |
||
519 | 345 |
!GraphicsContext class methodsFor:'instance creation'! |
0 | 346 |
|
519 | 347 |
new |
348 |
"return a new instance of myself. Redefined to initialize |
|
349 |
the new thingy" |
|
12 | 350 |
|
519 | 351 |
^ self basicNew initialize |
352 |
! ! |
|
353 |
||
354 |
!GraphicsContext class methodsFor:'accessing defaults'! |
|
0 | 355 |
|
356 |
defaultFont |
|
12 | 357 |
"get the default font used for drawing" |
358 |
||
71 | 359 |
DefaultFont isNil ifTrue:[ |
360 |
DefaultFont := Font family:'courier' face:'medium' style:'roman' size:12 |
|
361 |
]. |
|
0 | 362 |
^ DefaultFont |
519 | 363 |
! |
364 |
||
365 |
defaultFont:aFont |
|
366 |
"set the default font used for drawing" |
|
367 |
||
368 |
DefaultFont := aFont |
|
0 | 369 |
! ! |
370 |
||
371 |
!GraphicsContext class methodsFor:'constants'! |
|
372 |
||
519 | 373 |
capButt |
374 |
"return a constant to specify butt cap" |
|
0 | 375 |
|
519 | 376 |
^ #butt |
0 | 377 |
! |
378 |
||
379 |
capNotLast |
|
380 |
"return a constant to specify not-last cap" |
|
381 |
||
382 |
^ #notLast |
|
383 |
! |
|
384 |
||
385 |
capProjecting |
|
386 |
"return a constant to specify projecting cap" |
|
387 |
||
388 |
^ #projecting |
|
389 |
! |
|
390 |
||
391 |
capRound |
|
392 |
"return a constant to specify round cap" |
|
393 |
||
394 |
^ #round |
|
395 |
! |
|
396 |
||
519 | 397 |
joinBevel |
398 |
"return a constant to specify bevel join" |
|
399 |
||
400 |
^ #bevel |
|
401 |
! |
|
0 | 402 |
|
519 | 403 |
joinMiter |
404 |
"return a constant to specify miter join" |
|
405 |
||
406 |
^ #miter |
|
407 |
! |
|
408 |
||
409 |
joinRound |
|
410 |
"return a constant to specify round join" |
|
411 |
||
412 |
^ #round |
|
0 | 413 |
! ! |
414 |
||
519 | 415 |
!GraphicsContext methodsFor:'ST-80 compatibility'! |
416 |
||
417 |
findFont:aFontDescription |
|
585 | 418 |
"given a fontDescription, return a device font for it |
419 |
on my device." |
|
420 |
||
519 | 421 |
^ aFontDescription on:self device |
585 | 422 |
|
423 |
"Modified: 22.4.1996 / 19:45:41 / cg" |
|
519 | 424 |
! |
0 | 425 |
|
519 | 426 |
widthOfString:aString |
585 | 427 |
"given a string, return its width in pixels if |
428 |
drawn on the receivers device." |
|
429 |
||
519 | 430 |
^ (font on:self device) widthOf:aString |
585 | 431 |
|
432 |
"Modified: 22.4.1996 / 19:46:10 / cg" |
|
519 | 433 |
! |
109 | 434 |
|
519 | 435 |
widthOfString:aString from:start to:stop |
585 | 436 |
"given a string, return the width in pixels if |
437 |
a substring is drawn on the receivers device." |
|
438 |
||
519 | 439 |
^ (font on:self device) widthOf:aString from:start to:stop |
585 | 440 |
|
441 |
"Modified: 22.4.1996 / 19:46:25 / cg" |
|
0 | 442 |
! ! |
443 |
||
519 | 444 |
!GraphicsContext methodsFor:'ST-80 displaying'! |
445 |
||
446 |
displayArc:origin radius:radius from:startAngle angle:angle |
|
447 |
"draw an arc around a point" |
|
448 |
||
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
449 |
self |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
450 |
displayArcX:(origin x - radius) |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
451 |
y:(origin y - radius) |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
452 |
width:(radius * 2) |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
453 |
height:(radius * 2) |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
454 |
from:startAngle |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
455 |
angle:angle |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
456 |
|
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
457 |
"Modified: 8.5.1996 / 08:34:43 / cg" |
519 | 458 |
! |
0 | 459 |
|
519 | 460 |
displayArcBoundedBy:boundingBox startAngle:startAngle sweepAngle:sweepAngle at:origin |
461 |
"draw an arc/circle/ellipse - ST-80 compatibility" |
|
462 |
||
463 |
^ self displayArcX:(boundingBox left + origin x) |
|
464 |
y:(boundingBox top + origin y) |
|
465 |
width:(boundingBox width) |
|
466 |
height:(boundingBox height) |
|
467 |
from:startAngle |
|
468 |
angle:sweepAngle |
|
469 |
! |
|
470 |
||
471 |
displayLineFrom:startPoint to:endPoint translateBy:anOffset |
|
472 |
"draw a line - ST-80 compatibility" |
|
0 | 473 |
|
519 | 474 |
self displayLineFrom:(startPoint + anOffset) |
475 |
to:(endPoint + anOffset) |
|
476 |
! |
|
477 |
||
478 |
displayPolyline:aPolygon |
|
479 |
"draw a polygon - ST-80 compatibility" |
|
480 |
||
481 |
^ self displayPolygon:aPolygon |
|
482 |
! |
|
483 |
||
484 |
displayRectangularBorder:aRectangle at:aPoint |
|
485 |
"draw a rectangle - ST-80 compatibility" |
|
0 | 486 |
|
519 | 487 |
self displayRectangle:(aRectangle translateBy:aPoint) |
488 |
! |
|
489 |
||
490 |
displayWedgeBoundedBy:boundingBox startAngle:startAngle sweepAngle:sweepAngle at:origin |
|
491 |
"fill an arc/circle/ellipse - ST-80 compatibility" |
|
2 | 492 |
|
519 | 493 |
^ self fillArcX:(boundingBox left + origin x) |
494 |
y:(boundingBox top + origin y) |
|
495 |
width:(boundingBox width) |
|
496 |
height:(boundingBox height) |
|
497 |
from:startAngle |
|
498 |
angle:sweepAngle |
|
2 | 499 |
! ! |
500 |
||
0 | 501 |
!GraphicsContext methodsFor:'accessing'! |
502 |
||
503 |
backgroundPaint |
|
504 |
"return the background paint color. |
|
505 |
(used for opaqueForms and opaqueStrings)" |
|
506 |
||
507 |
^ bgPaint |
|
508 |
! |
|
509 |
||
510 |
backgroundPaint:aColor |
|
511 |
"set the background painting color (which is used for |
|
512 |
opaqueForms and opaqueStrings). aColor can be a dithered one." |
|
513 |
||
514 |
^ self subclassResponsibility |
|
515 |
! |
|
516 |
||
517 |
capStyle |
|
518 |
"return the current cap-style for line-drawing" |
|
519 |
||
520 |
^ capStyle |
|
521 |
! |
|
522 |
||
523 |
capStyle:aStyleSymbol |
|
524 |
"set the cap-style for line-drawing; |
|
525 |
possible styles are: #notLast, #butt, #round, #projecting" |
|
526 |
||
527 |
^ self subclassResponsibility |
|
528 |
! |
|
529 |
||
76 | 530 |
clipRect |
531 |
"return the drawing clip-rectangle" |
|
532 |
||
533 |
^ self subclassResponsibility |
|
534 |
! |
|
535 |
||
0 | 536 |
clipRect:aRectangle |
537 |
"set the drawing clip-rectangle" |
|
538 |
||
539 |
^ self subclassResponsibility |
|
540 |
! |
|
541 |
||
76 | 542 |
clippingBounds |
563 | 543 |
"return the drawing clip-rectangle - name alias ST-80 compatibility" |
76 | 544 |
|
545 |
^ self clipRect |
|
563 | 546 |
|
547 |
"Modified: 13.4.1996 / 20:13:04 / cg" |
|
76 | 548 |
! |
549 |
||
561
3c1ec7798f77
added #clippingRectangleOrNil for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
519
diff
changeset
|
550 |
clippingRectangleOrNil |
563 | 551 |
"return the drawing clip-rectangle, or nil if there is none" |
552 |
||
561
3c1ec7798f77
added #clippingRectangleOrNil for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
519
diff
changeset
|
553 |
^ self subclassResponsibility |
3c1ec7798f77
added #clippingRectangleOrNil for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
519
diff
changeset
|
554 |
|
3c1ec7798f77
added #clippingRectangleOrNil for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
519
diff
changeset
|
555 |
"Created: 10.4.1996 / 14:31:19 / cg" |
563 | 556 |
"Modified: 13.4.1996 / 20:12:43 / cg" |
561
3c1ec7798f77
added #clippingRectangleOrNil for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
519
diff
changeset
|
557 |
! |
3c1ec7798f77
added #clippingRectangleOrNil for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
519
diff
changeset
|
558 |
|
519 | 559 |
font |
560 |
"return the current drawing font" |
|
561 |
||
562 |
^ font |
|
563 |
! |
|
564 |
||
565 |
font:aFont |
|
566 |
"set the drawing font" |
|
567 |
||
568 |
^ self subclassResponsibility |
|
569 |
! |
|
570 |
||
571 |
function |
|
572 |
"return the current drawing function" |
|
573 |
||
574 |
^ function |
|
575 |
! |
|
576 |
||
577 |
function:aFunctionSymbol |
|
578 |
"set the drawing function" |
|
579 |
||
580 |
^ self subclassResponsibility |
|
581 |
! |
|
582 |
||
0 | 583 |
graphicsContext |
584 |
"for ST-80 compatibility" |
|
585 |
||
586 |
^ self |
|
2 | 587 |
! |
588 |
||
519 | 589 |
joinStyle |
590 |
"return the current join-style for polygon-drawing" |
|
591 |
||
592 |
^ joinStyle |
|
593 |
! |
|
12 | 594 |
|
519 | 595 |
joinStyle:aStyleSymbol |
596 |
"set the join-style of lines in polygon-drawing; |
|
597 |
possible styles are: #miter, #bevel, #round" |
|
598 |
||
599 |
^ self subclassResponsibility |
|
600 |
! |
|
601 |
||
602 |
lineStyle |
|
603 |
"return the current line-drawing-style" |
|
604 |
||
605 |
^ lineStyle |
|
2 | 606 |
! |
607 |
||
519 | 608 |
lineStyle:aStyleSymbol |
609 |
"set the line-drawing-style; |
|
610 |
possible styles are: #solid, #dashed, #doubleDashed" |
|
151 | 611 |
|
519 | 612 |
lineStyle := aStyleSymbol |
613 |
! |
|
614 |
||
615 |
lineWidth |
|
616 |
"return the current drawing linewidth" |
|
617 |
||
618 |
^ lineWidth |
|
151 | 619 |
! |
620 |
||
519 | 621 |
lineWidth:aNumber |
622 |
"set the line drawing width in pixels" |
|
623 |
||
624 |
lineWidth := aNumber |
|
625 |
! |
|
151 | 626 |
|
519 | 627 |
mask |
628 |
"return the current drawing mask" |
|
629 |
||
630 |
^ mask |
|
631 |
! |
|
632 |
||
633 |
mask:aForm |
|
634 |
"set the drawing mask" |
|
635 |
||
636 |
^ self subclassResponsibility |
|
151 | 637 |
! |
638 |
||
639 |
maskOrigin |
|
640 |
"return the origin within the mask (used to draw with patterns). |
|
641 |
Should be redefined in classes which support it. |
|
642 |
This is an alias for ST-80's #phase" |
|
643 |
||
644 |
^ maskOrigin |
|
645 |
! |
|
646 |
||
647 |
maskOrigin:aPoint |
|
648 |
"set the origin within the mask (used to draw with patterns). |
|
649 |
Should be redefined in classes which support it. |
|
650 |
This is an alias for ST-80's #phase:" |
|
651 |
||
652 |
^ self maskOriginX:aPoint x y:aPoint y |
|
653 |
! |
|
654 |
||
655 |
maskOriginX:x y:y |
|
656 |
"set the origin within the mask (used to draw with patterns). |
|
657 |
Should be redefined in classes which support it. |
|
658 |
This is an alias for ST-80's #phase:" |
|
109 | 659 |
|
12 | 660 |
^ self |
661 |
! |
|
662 |
||
519 | 663 |
paint |
664 |
"return the current paint drawing color" |
|
665 |
||
666 |
^ paint |
|
667 |
! |
|
668 |
||
669 |
paint:aColor |
|
670 |
"set the drawing painting color, aColor can be a dithered one" |
|
671 |
||
672 |
paint := aColor |
|
673 |
! |
|
674 |
||
675 |
paint:fgColor on:bgColor |
|
563 | 676 |
"set the paint and backgroundPaint, used for text and bitmaps. |
677 |
Both colors may be dithered colors" |
|
519 | 678 |
|
679 |
self paint:fgColor. |
|
680 |
bgPaint := bgColor |
|
563 | 681 |
|
682 |
"Modified: 13.4.1996 / 20:20:24 / cg" |
|
519 | 683 |
! |
684 |
||
685 |
phase |
|
686 |
"return the origin within the mask (used to draw with patterns). |
|
687 |
This is an alias for ST/X's #maskOrigin" |
|
688 |
||
689 |
^ self maskOrigin |
|
690 |
! |
|
691 |
||
692 |
phase:aPoint |
|
693 |
"set the origin within the mask (used to draw with patterns). |
|
694 |
This is an alias for ST/X's #maskOrigin:" |
|
695 |
||
696 |
^ self maskOrigin:aPoint |
|
697 |
! |
|
698 |
||
151 | 699 |
setMaskOrigin:aPoint |
700 |
"set the origin within the mask (used to draw with patterns). |
|
701 |
OBSOLETE: use #maskOrigin: or #phase:" |
|
702 |
||
703 |
^ self maskOrigin:aPoint |
|
704 |
! |
|
705 |
||
2 | 706 |
setMaskOriginX:x y:y |
109 | 707 |
"set the origin within the mask (used to draw with patterns). |
151 | 708 |
OBSOLETE: use #maskOriginX:y: or #phase:" |
109 | 709 |
|
151 | 710 |
^ self maskOriginX:x y:y |
2 | 711 |
! |
712 |
||
519 | 713 |
viewOrigin |
714 |
"return the drawables visible origin (for scrolling)" |
|
715 |
||
716 |
^ 0@0 |
|
717 |
! |
|
718 |
||
2 | 719 |
withPattern:aForm do:aBlock |
109 | 720 |
"draw with a pattern. |
721 |
Should be redefined in classes which support it" |
|
722 |
||
519 | 723 |
'GC: pattern drawing not implemented' infoPrintNL. |
71 | 724 |
|
2 | 725 |
aBlock value |
519 | 726 |
|
727 |
"Modified: 7.3.1996 / 19:17:05 / cg" |
|
418
0e10e256d5b2
scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
728 |
! ! |
0e10e256d5b2
scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
729 |
|
0e10e256d5b2
scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
730 |
!GraphicsContext methodsFor:'accessing-transformation'! |
0e10e256d5b2
scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
731 |
|
0e10e256d5b2
scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
732 |
scale |
0e10e256d5b2
scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
733 |
"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
|
734 |
|
0e10e256d5b2
scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
735 |
transformation isNil ifTrue:[^ 1]. |
0e10e256d5b2
scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
736 |
^ transformation scale |
0e10e256d5b2
scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
737 |
! |
0e10e256d5b2
scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
738 |
|
0e10e256d5b2
scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
739 |
scale:aPoint |
0e10e256d5b2
scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
740 |
"set the scale factor of the transformation" |
0e10e256d5b2
scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
741 |
|
0e10e256d5b2
scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
742 |
transformation isNil ifTrue:[ |
619 | 743 |
aPoint = 1 ifTrue:[^ self]. |
744 |
transformation := WindowingTransformation scale:aPoint translation:0 |
|
745 |
] ifFalse:[ |
|
746 |
transformation scale:aPoint. |
|
747 |
] |
|
418
0e10e256d5b2
scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
748 |
|
619 | 749 |
"Modified: 27.4.1996 / 18:47:38 / cg" |
76 | 750 |
! |
751 |
||
752 |
transformation |
|
753 |
"return the transformation" |
|
754 |
||
755 |
^ transformation |
|
756 |
! |
|
757 |
||
758 |
transformation:aTransformation |
|
759 |
"set the transformation" |
|
760 |
||
761 |
transformation := aTransformation |
|
619 | 762 |
! |
763 |
||
764 |
translation |
|
765 |
"return the translation factor (as point) of the transformation" |
|
766 |
||
767 |
transformation isNil ifTrue:[^ 0@0]. |
|
768 |
^ transformation translation |
|
769 |
||
770 |
"Created: 27.4.1996 / 18:46:41 / cg" |
|
771 |
! |
|
772 |
||
773 |
translation:aPoint |
|
774 |
"set the translation offset of the transformation" |
|
775 |
||
776 |
transformation isNil ifTrue:[ |
|
777 |
aPoint = 0 ifTrue:[^ self]. |
|
778 |
transformation := WindowingTransformation scale:1 translation:aPoint |
|
779 |
] ifFalse:[ |
|
780 |
transformation translation:aPoint. |
|
781 |
] |
|
782 |
||
783 |
"Created: 27.4.1996 / 18:47:28 / cg" |
|
0 | 784 |
! ! |
785 |
||
71 | 786 |
!GraphicsContext methodsFor:'basic displaying'! |
0 | 787 |
|
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
788 |
displayArcX:x y:y w:w h:h from:startAngle angle:angle |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
789 |
"draw an arc; apply transformation if nonNil" |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
790 |
|
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
791 |
self obsoleteMethodWarning:'use #displayArcX:y:width:height:from:angle:'. |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
792 |
self displayArcX:x y:y width:w height:h from:startAngle angle:angle |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
793 |
|
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
794 |
"Modified: 8.5.1996 / 08:46:56 / cg" |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
795 |
! |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
796 |
|
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
797 |
displayArcX:x y:y width:width height:height from:startAngle angle:angle |
0 | 798 |
"draw an arc in a box |
799 |
- this could be recoded to draw using displayLine" |
|
800 |
||
801 |
^ self subclassResponsibility |
|
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
802 |
|
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
803 |
"Created: 8.5.1996 / 08:47:06 / cg" |
0 | 804 |
! |
805 |
||
26 | 806 |
displayForm:aForm x:x y:y |
0 | 807 |
"draw a form at x/y; if the form has depth 1, 1's in the form are |
808 |
drawn in current fg, 0's are ignored. |
|
24 | 809 |
If the form has depth ~~ 1, the result is undefined" |
810 |
||
71 | 811 |
|fg bg f noColor| |
24 | 812 |
|
71 | 813 |
fg := paint. |
814 |
bg := bgPaint. |
|
24 | 815 |
f := function. |
0 | 816 |
|
71 | 817 |
f ~~ #copy ifTrue:[ |
818 |
self error:'function not supported'. |
|
819 |
^ self |
|
820 |
]. |
|
821 |
||
822 |
noColor := Color noColor. |
|
823 |
" |
|
824 |
stamp out fg-pixels |
|
825 |
" |
|
826 |
self paint:noColor on:Color allColor function:#and. |
|
26 | 827 |
self displayOpaqueForm:aForm x:x y:y. |
71 | 828 |
" |
829 |
or-in fg-pixels |
|
830 |
" |
|
831 |
self paint:fg on:Color noColor function:#or. |
|
26 | 832 |
self displayOpaqueForm:aForm x:x y:y. |
71 | 833 |
self paint:fg on:fg function:f. |
0 | 834 |
! |
835 |
||
26 | 836 |
displayOpaqueForm:aForm x:x y:y |
0 | 837 |
"draw a form at x/y; if the form has depth 1, 1's in the form are |
838 |
drawn in current fg, 0's in current bg color. |
|
839 |
If the form has depth ~~ 1, it is copied as is onto the receiver" |
|
840 |
||
841 |
^ self subclassResponsibility |
|
842 |
! |
|
843 |
||
844 |
displayOpaqueString:aString from:index1 to:index2 x:x y:y |
|
845 |
"draw part of a string with both fg and bg at x/y in current font" |
|
846 |
||
847 |
^ self subclassResponsibility |
|
848 |
! |
|
849 |
||
519 | 850 |
displayPolygon:aPolygon |
851 |
"draw a polygon |
|
852 |
- this could be recoded to draw using displayLine" |
|
853 |
||
854 |
^ self subclassResponsibility |
|
855 |
! |
|
856 |
||
857 |
displayRectangleX:x y:y width:w height:h |
|
858 |
"draw a rectangle |
|
859 |
- this could be recoded to draw using displayLine" |
|
860 |
||
861 |
^ self subclassResponsibility |
|
862 |
! |
|
863 |
||
0 | 864 |
displayString:aString from:index1 to:index2 x:x y:y |
865 |
"draw part of a string with fg at x/y in current font" |
|
866 |
||
867 |
^ self subclassResponsibility |
|
868 |
! ! |
|
869 |
||
519 | 870 |
!GraphicsContext methodsFor:'basic filling'! |
0 | 871 |
|
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
872 |
fillArcX:x y:y w:w h:h from:startAngle angle:angle |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
873 |
"draw a filled arc; apply transformation if nonNil" |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
874 |
|
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
875 |
self obsoleteMethodWarning:'use #fillArcX:y:width:height:from:angle:'. |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
876 |
self fillArcX:x y:y width:w height:h from:startAngle angle:angle |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
877 |
|
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
878 |
"Modified: 8.5.1996 / 08:47:52 / cg" |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
879 |
! |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
880 |
|
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
881 |
fillArcX:x y:y width:w height:h from:start angle:angle |
519 | 882 |
"fill an arc with current paint color" |
0 | 883 |
|
519 | 884 |
^ self subclassResponsibility |
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
885 |
|
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
886 |
"Created: 8.5.1996 / 08:47:44 / cg" |
0 | 887 |
! |
888 |
||
519 | 889 |
fillPolygon:points |
890 |
"fill a polygon with current paint color" |
|
0 | 891 |
|
519 | 892 |
^ self subclassResponsibility |
157 | 893 |
! |
894 |
||
519 | 895 |
fillRectangleX:x y:y width:w height:h |
896 |
"fill a rectangle with current paint color" |
|
0 | 897 |
|
519 | 898 |
^ self subclassResponsibility |
899 |
! ! |
|
0 | 900 |
|
519 | 901 |
!GraphicsContext methodsFor:'bit blitting'! |
0 | 902 |
|
519 | 903 |
copyFrom:aGC toX:dstX y:dstY |
904 |
"copy from a drawable - maybe self" |
|
0 | 905 |
|
519 | 906 |
self copyFrom:aGC x:0 y:0 toX:dstX y:dstY width:aGC width height:aGC height |
0 | 907 |
! |
908 |
||
519 | 909 |
copyFrom:aGC x:srcX y:srcY toX:dstX y:dstY width:w height:h |
910 |
"copy from a drawable - maybe self" |
|
0 | 911 |
|
519 | 912 |
^ self subclassResponsibility |
0 | 913 |
! |
914 |
||
519 | 915 |
copyFrom:aGC x:dstX y:dstY width:w height:h |
916 |
"copy from a drawable - maybe self" |
|
0 | 917 |
|
519 | 918 |
self copyFrom:aGC x:0 y:0 toX:dstX y:dstY width:w height:h |
919 |
! ! |
|
0 | 920 |
|
519 | 921 |
!GraphicsContext methodsFor:'drawing'! |
0 | 922 |
|
12 | 923 |
displayArcIn:aRectangle from:startAngle angle:angle |
924 |
"draw an arc in a box" |
|
0 | 925 |
|
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
926 |
self |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
927 |
displayArcX:(aRectangle left) |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
928 |
y:(aRectangle top) |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
929 |
width:(aRectangle width) |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
930 |
height:(aRectangle height) |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
931 |
from:startAngle |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
932 |
angle:angle |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
933 |
|
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
934 |
"Modified: 8.5.1996 / 08:35:00 / cg" |
0 | 935 |
! |
936 |
||
12 | 937 |
displayArcOrigin:origin corner:corner from:startAngle angle:angle |
938 |
"draw an arc in a box" |
|
0 | 939 |
|
940 |
|left top right bot| |
|
941 |
||
942 |
left := origin x. |
|
943 |
top := origin y. |
|
944 |
right := corner x. |
|
945 |
bot := corner y. |
|
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
946 |
self |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
947 |
displayArcX:left |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
948 |
y:top |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
949 |
width:(right - left + 1) |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
950 |
height:(bot - top + 1) |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
951 |
from:startAngle |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
952 |
angle:angle |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
953 |
|
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
954 |
"Modified: 8.5.1996 / 08:35:25 / cg" |
0 | 955 |
! |
956 |
||
519 | 957 |
displayCircle:aPoint radius:r |
958 |
"draw a circle around a center point" |
|
959 |
||
960 |
self displayCircleX:(aPoint x) y:(aPoint y) radius:r |
|
961 |
! |
|
962 |
||
12 | 963 |
displayCircleIn:aRectangle |
0 | 964 |
"draw a circle in a box" |
965 |
||
966 |
self |
|
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
967 |
displayArcX:(aRectangle left) |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
968 |
y:(aRectangle top) |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
969 |
width:(aRectangle width) |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
970 |
height:(aRectangle height) |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
971 |
from:0 |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
972 |
angle:360 |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
973 |
|
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
974 |
"Modified: 8.5.1996 / 08:35:40 / cg" |
0 | 975 |
! |
976 |
||
12 | 977 |
displayCircleX:x y:y radius:r |
978 |
"draw a circle around a center point" |
|
0 | 979 |
|
980 |
|d| |
|
981 |
d := 2 * r. |
|
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
982 |
self |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
983 |
displayArcX:(x - r) |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
984 |
y:(y - r) |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
985 |
width:d |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
986 |
height:d |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
987 |
from:0 |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
988 |
angle:360 |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
989 |
|
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
990 |
"Modified: 8.5.1996 / 08:36:03 / cg" |
519 | 991 |
! |
992 |
||
993 |
displayForm:aForm at:aPoint |
|
994 |
"draw a form" |
|
995 |
||
996 |
self displayForm:aForm x:(aPoint x) y:(aPoint y) |
|
997 |
! |
|
998 |
||
999 |
displayLineFrom:point1 to:point2 |
|
1000 |
"draw a line" |
|
1001 |
||
1002 |
self displayLineFromX:(point1 x) y:(point1 y) |
|
1003 |
toX:(point2 x) y:(point2 y) |
|
1004 |
! |
|
1005 |
||
1006 |
displayOpaqueString:aString at:aPoint |
|
1007 |
"draw a string with both fg and bg" |
|
1008 |
||
1009 |
self displayOpaqueString:aString x:(aPoint x) y:(aPoint y) |
|
1010 |
! |
|
1011 |
||
1012 |
displayOpaqueString:aString from:start to:stop at:aPoint |
|
1013 |
"draw part of a string - drawing both fg and bg" |
|
1014 |
||
1015 |
^ self displayOpaqueString:aString from:start to:stop x:aPoint x y:aPoint y |
|
1016 |
! |
|
1017 |
||
1018 |
displayOpaqueString:aString x:x y:y |
|
1019 |
"draw a string with both fg and bg" |
|
1020 |
||
1021 |
self displayOpaqueString:aString from:1 to:(aString size) x:x y:y |
|
1022 |
! |
|
1023 |
||
1024 |
displayPoint:aPoint |
|
1025 |
"draw a pixel" |
|
1026 |
||
1027 |
self displayPointX:(aPoint x) y:(aPoint y) |
|
1028 |
! |
|
1029 |
||
1030 |
displayPointX:x y:y |
|
1031 |
"draw a point at x/y" |
|
1032 |
||
1033 |
self displayLineFromX:x y:y toX:x y:y |
|
1034 |
! |
|
1035 |
||
1036 |
displayRectangle:aRectangle |
|
1037 |
"draw a rectangle" |
|
1038 |
||
1039 |
self displayRectangleX:(aRectangle left) |
|
1040 |
y:(aRectangle top) |
|
1041 |
width:(aRectangle width) |
|
1042 |
height:(aRectangle height) |
|
1043 |
! |
|
1044 |
||
1045 |
displayRectangleOrigin:origin corner:corner |
|
1046 |
"draw a rectangle" |
|
1047 |
||
1048 |
|top left| |
|
1049 |
||
1050 |
left := origin x. |
|
1051 |
top := origin y. |
|
1052 |
self displayRectangleX:left y:top |
|
563 | 1053 |
width:(corner x - left) |
1054 |
height:(corner y - top) |
|
1055 |
||
1056 |
"Modified: 13.4.1996 / 20:58:31 / cg" |
|
519 | 1057 |
! |
1058 |
||
1059 |
displayString:aString at:aPoint |
|
1060 |
"draw a string - drawing fg only" |
|
1061 |
||
1062 |
self displayString:aString x:aPoint x y:aPoint y |
|
1063 |
! |
|
1064 |
||
1065 |
displayString:aString from:start to:stop at:aPoint |
|
1066 |
"draw part of a string - drawing fg only" |
|
1067 |
||
1068 |
^ self displayString:aString from:start to:stop x:aPoint x y:aPoint y |
|
1069 |
! |
|
1070 |
||
1071 |
displayString:aString x:x y:y |
|
1072 |
"draw a string - drawing fg only" |
|
1073 |
||
1074 |
self displayString:aString from:1 to:(aString size) x:x y:y |
|
0 | 1075 |
! ! |
519 | 1076 |
|
1077 |
!GraphicsContext methodsFor:'drawing in device coordinates'! |
|
1078 |
||
1079 |
displayDeviceLineFromX:x1 y:y1 toX:x2 y:y2 |
|
1080 |
"draw a line in device coordinates" |
|
1081 |
||
1082 |
|sav| |
|
1083 |
||
1084 |
sav := transformation. |
|
1085 |
transformation := nil. |
|
1086 |
self displayLineFromX:x1 y:y1 toX:x2 y:y2. |
|
1087 |
transformation := sav |
|
1088 |
! |
|
1089 |
||
1090 |
fillDeviceRectangleX:x y:y width:w height:h |
|
1091 |
"fill a rectangle with current paint color (device coordinates)" |
|
1092 |
||
1093 |
|sav| |
|
1094 |
||
1095 |
sav := transformation. |
|
1096 |
transformation := nil. |
|
1097 |
self fillRectangleX:x y:y width:w height:h. |
|
1098 |
transformation := sav |
|
1099 |
! |
|
1100 |
||
1101 |
fillDeviceRectangleX:x y:y width:w height:h with:aPattern |
|
1102 |
"fill the rectangular area in the receiver with aPattern, |
|
1103 |
which may be a Form or Color. Use device coordinates." |
|
1104 |
||
1105 |
self withPattern:aPattern do:[ |
|
1106 |
self fillDeviceRectangleX:x y:y width:w height:h |
|
1107 |
] |
|
1108 |
! ! |
|
1109 |
||
1110 |
!GraphicsContext methodsFor:'filling'! |
|
1111 |
||
1112 |
fillArc:origin radius:r from:startAngle angle:angle |
|
1113 |
"draw a filled arc around a point" |
|
1114 |
||
1115 |
|d| |
|
1116 |
d := 2 * r. |
|
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1117 |
self |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1118 |
fillArcX:(origin x - r) |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1119 |
y:(origin y - r) |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1120 |
width:d |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1121 |
height:d |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1122 |
from:startAngle |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1123 |
angle:angle |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1124 |
|
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1125 |
"Modified: 8.5.1996 / 08:41:54 / cg" |
519 | 1126 |
! |
1127 |
||
563 | 1128 |
fillArcIn:aRectangle from:startAngle angle:angle |
1129 |
"draw a filled arc in a box" |
|
1130 |
||
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1131 |
self |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1132 |
fillArcX:(aRectangle left) |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1133 |
y:(aRectangle top) |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1134 |
width:(aRectangle width) |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1135 |
height:(aRectangle height) |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1136 |
from:startAngle |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1137 |
angle:angle |
563 | 1138 |
|
1139 |
"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
|
1140 |
"Modified: 8.5.1996 / 08:42:13 / cg" |
563 | 1141 |
! |
1142 |
||
1143 |
fillArcOrigin:origin corner:corner from:startAngle angle:angle |
|
1144 |
"draw a filled arc in a box" |
|
1145 |
||
1146 |
|left top right bot| |
|
1147 |
||
1148 |
left := origin x. |
|
1149 |
top := origin y. |
|
1150 |
right := corner x. |
|
1151 |
bot := corner y. |
|
1152 |
self |
|
1153 |
fillArcX:left |
|
1154 |
y:top |
|
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1155 |
width:(right - left + 1) |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1156 |
height:(bot - top + 1) |
563 | 1157 |
from:startAngle |
1158 |
angle:angle |
|
1159 |
||
1160 |
"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
|
1161 |
"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
|
1162 |
! |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1163 |
|
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1164 |
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
|
1165 |
"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
|
1166 |
|
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1167 |
self |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1168 |
fillArcX:x |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1169 |
y:y |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1170 |
width:w |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1171 |
height:h |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1172 |
from:startAngle |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1173 |
angle:(endAngle - startAngle) |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1174 |
|
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1175 |
"Created: 8.5.1996 / 08:52:41 / cg" |
563 | 1176 |
! |
1177 |
||
519 | 1178 |
fillCircle:aPoint radius:aNumber |
1179 |
"draw a filled circle around aPoint" |
|
1180 |
||
1181 |
self fillCircleX:(aPoint x) y:(aPoint y) radius:aNumber |
|
1182 |
! |
|
1183 |
||
563 | 1184 |
fillCircleIn:aRectangle |
1185 |
"draw a filled circle in a box" |
|
1186 |
||
1187 |
self |
|
1188 |
fillArcX:(aRectangle left) |
|
1189 |
y:(aRectangle top) |
|
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1190 |
width:(aRectangle width) |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1191 |
height:(aRectangle height) |
563 | 1192 |
from:0 |
1193 |
angle:360 |
|
1194 |
||
1195 |
"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
|
1196 |
"Modified: 8.5.1996 / 08:42:38 / cg" |
563 | 1197 |
! |
1198 |
||
519 | 1199 |
fillCircleX:x y:y radius:r |
1200 |
"draw a filled circle around x@y" |
|
1201 |
||
1202 |
|d| |
|
1203 |
||
1204 |
d := 2 * r. |
|
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1205 |
self |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1206 |
fillArcX:(x - r) |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1207 |
y:(y - r) |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1208 |
width:d |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1209 |
height:d |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1210 |
from:0 |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1211 |
angle:360 |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1212 |
|
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1213 |
"Modified: 8.5.1996 / 08:43:02 / cg" |
519 | 1214 |
! |
1215 |
||
1216 |
fillRectangle:aRectangle |
|
1217 |
"fill a rectangle with current paint color" |
|
1218 |
||
1219 |
self fillRectangleX:(aRectangle left) |
|
1220 |
y:(aRectangle top) |
|
1221 |
width:(aRectangle width) |
|
1222 |
height:(aRectangle height) |
|
563 | 1223 |
! |
1224 |
||
1225 |
fillRectangleOrigin:origin corner:corner |
|
1226 |
"draw a filled rectangle" |
|
1227 |
||
1228 |
|top left| |
|
1229 |
||
1230 |
left := origin x. |
|
1231 |
top := origin y. |
|
1232 |
self fillRectangleX:left y:top |
|
1233 |
width:(corner x - left) |
|
1234 |
height:(corner y - top) |
|
1235 |
||
1236 |
"Created: 13.4.1996 / 20:58:16 / cg" |
|
519 | 1237 |
! ! |
1238 |
||
1239 |
!GraphicsContext methodsFor:'initialization'! |
|
1240 |
||
1241 |
initialize |
|
1242 |
"set up some useful default values" |
|
1243 |
||
1244 |
paint := Black. |
|
1245 |
bgPaint := White. |
|
1246 |
function := #copy. |
|
1247 |
lineWidth := 1. |
|
1248 |
lineStyle := #solid. |
|
1249 |
joinStyle := #miter. |
|
1250 |
capStyle := #butt. |
|
1251 |
font := DefaultFont. |
|
1252 |
! ! |
|
1253 |
||
1254 |
!GraphicsContext methodsFor:'misc'! |
|
1255 |
||
1256 |
flush |
|
585 | 1257 |
"send all buffered drawing to the device." |
519 | 1258 |
|
1259 |
self device flush |
|
585 | 1260 |
|
1261 |
"Modified: 22.4.1996 / 19:47:19 / cg" |
|
519 | 1262 |
! ! |
1263 |
||
1264 |
!GraphicsContext class methodsFor:'documentation'! |
|
1265 |
||
1266 |
version |
|
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1267 |
^ '$Header: /cvs/stx/stx/libview/GraphicsContext.st,v 1.29 1996-05-08 11:49:52 cg Exp $' |
519 | 1268 |
! ! |
1269 |
GraphicsContext initialize! |