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