0
|
1 |
"
|
6
|
2 |
COPYRIGHT (c) 1992 by Claus Gittinger
|
0
|
3 |
All Rights Reserved
|
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
|
|
13 |
Object subclass:#GraphicsContext
|
|
14 |
instanceVariableNames:'foreground background paint bgPaint
|
|
15 |
function font
|
|
16 |
lineStyle lineWidth
|
|
17 |
joinStyle capStyle
|
|
18 |
mask maskOrigin'
|
|
19 |
classVariableNames:'White Black'
|
|
20 |
poolDictionaries:''
|
46
|
21 |
category:'Graphics-Support'
|
0
|
22 |
!
|
|
23 |
|
|
24 |
GraphicsContext comment:'
|
6
|
25 |
COPYRIGHT (c) 1992 by Claus Gittinger
|
0
|
26 |
All Rights Reserved
|
54
|
27 |
|
|
28 |
$Header: /cvs/stx/stx/libview/GraphicsContext.st,v 1.10 1994-08-05 01:14:14 claus Exp $
|
0
|
29 |
'!
|
|
30 |
|
|
31 |
GraphicsContext class instanceVariableNames:'DefaultFont'!
|
|
32 |
|
46
|
33 |
!GraphicsContext class methodsFor:'documentation'!
|
|
34 |
|
|
35 |
copyright
|
|
36 |
"
|
|
37 |
COPYRIGHT (c) 1992 by Claus Gittinger
|
|
38 |
All Rights Reserved
|
|
39 |
|
|
40 |
This software is furnished under a license and may be used
|
|
41 |
only in accordance with the terms of that license and with the
|
|
42 |
inclusion of the above copyright notice. This software may not
|
|
43 |
be provided or otherwise made available to, or used by, any
|
|
44 |
other person. No title to or ownership of the software is
|
|
45 |
hereby transferred.
|
|
46 |
"
|
|
47 |
!
|
|
48 |
|
|
49 |
version
|
|
50 |
"
|
54
|
51 |
$Header: /cvs/stx/stx/libview/GraphicsContext.st,v 1.10 1994-08-05 01:14:14 claus Exp $
|
46
|
52 |
"
|
|
53 |
!
|
|
54 |
|
|
55 |
documentation
|
|
56 |
"
|
|
57 |
this is an abstract superclass for all kinds of graphic drawables -
|
|
58 |
both windows and printed pages (i.e. printers) are inheriting from
|
|
59 |
this class (even drawables not at all associated with any device would do so).
|
|
60 |
|
|
61 |
Drawing is done somewhat silly (due to being both backward compatible
|
|
62 |
and supporting ST-80 messages). The paint instance describes the paint
|
|
63 |
color, which can be (on monos) a dither pixmap drawn in foreground/background
|
|
64 |
colors.
|
|
65 |
Foreground and background are the underlying basic-colors, which must be
|
|
66 |
real colors (i.e. non dithered). Direct access to fg/bg is discouraged, since
|
|
67 |
in the future, foreground / background will be totally replaced by
|
|
68 |
paint/bgPaint.
|
|
69 |
|
|
70 |
All drawing is defined upon a few basic drawing methods, which must be
|
|
71 |
implemented by subclasses (some subclasses also redefine the others for
|
|
72 |
more performance)
|
|
73 |
|
|
74 |
Instance variables:
|
|
75 |
|
|
76 |
paint <Color> the paint used for drawing
|
|
77 |
bgPaint <Color> the background used for drawing texts and bitmaps
|
|
78 |
foreground <Color> the device foreground color used for drawing
|
|
79 |
background <Color> the device background color used for drawing
|
|
80 |
function <Symbol> the drawing function (i.e. #copy, #or, #xor ...)
|
|
81 |
- not all Drawables support every function
|
|
82 |
(i.e. paper only allows #copy)
|
|
83 |
font <Font> the font currently used for drawing
|
|
84 |
lineStyle <Symbol> the lineStyle (i.e. #solid, #dashed, #doubleDashed)
|
|
85 |
lineWidth <SmallInteger> the lineWidth (device dependent, usually pixels)
|
|
86 |
joinStyle <Symbol> the style in which lines (in polygons)
|
|
87 |
are joined (i.e. #miter, #bevel, #round)
|
|
88 |
capStyle <Symbol> the style in which the last point
|
|
89 |
of a line is drawn
|
|
90 |
(i.e. #notLast, #butt, #round, #projecting)
|
|
91 |
mask <Form> a mask used for drawing
|
|
92 |
- not all Drawables support it
|
|
93 |
maskOrigin <Point> the origin of the mask relative to
|
|
94 |
the drawables origin
|
|
95 |
|
|
96 |
Class variables:
|
|
97 |
|
|
98 |
White <Color> cached white color - its needed so often
|
|
99 |
Black <Color> cached black color - its needed so often
|
|
100 |
|
|
101 |
Class instance variables:
|
|
102 |
|
|
103 |
DefaultFont <Font> default font to use
|
|
104 |
"
|
|
105 |
! !
|
|
106 |
|
0
|
107 |
!GraphicsContext class methodsFor:'initialization'!
|
|
108 |
|
|
109 |
initialize
|
|
110 |
"setup some defaults - these are usually redefined
|
|
111 |
during startup."
|
|
112 |
|
12
|
113 |
Color isNil ifTrue:[^ self].
|
0
|
114 |
Color initialize.
|
46
|
115 |
|
|
116 |
White := Color white on:Display.
|
|
117 |
Black := Color black on:Display.
|
0
|
118 |
|
|
119 |
Font initialize.
|
|
120 |
DefaultFont := Font family:'courier' face:'medium' style:'roman' size:12
|
|
121 |
! !
|
|
122 |
|
|
123 |
!GraphicsContext class methodsFor:'accessing defaults'!
|
|
124 |
|
|
125 |
defaultFont:aFont
|
12
|
126 |
"set the default font used for drawing"
|
|
127 |
|
0
|
128 |
DefaultFont := aFont
|
|
129 |
!
|
|
130 |
|
|
131 |
defaultFont
|
12
|
132 |
"get the default font used for drawing"
|
|
133 |
|
0
|
134 |
^ DefaultFont
|
|
135 |
! !
|
|
136 |
|
|
137 |
!GraphicsContext class methodsFor:'constants'!
|
|
138 |
|
|
139 |
joinRound
|
|
140 |
"return a constant to specify round join"
|
|
141 |
|
|
142 |
^ #round
|
|
143 |
!
|
|
144 |
|
|
145 |
joinMiter
|
|
146 |
"return a constant to specify miter join"
|
|
147 |
|
|
148 |
^ #miter
|
|
149 |
!
|
|
150 |
|
|
151 |
joinBevel
|
|
152 |
"return a constant to specify bevel join"
|
|
153 |
|
|
154 |
^ #bevel
|
|
155 |
!
|
|
156 |
|
|
157 |
capNotLast
|
|
158 |
"return a constant to specify not-last cap"
|
|
159 |
|
|
160 |
^ #notLast
|
|
161 |
!
|
|
162 |
|
|
163 |
capProjecting
|
|
164 |
"return a constant to specify projecting cap"
|
|
165 |
|
|
166 |
^ #projecting
|
|
167 |
!
|
|
168 |
|
|
169 |
capRound
|
|
170 |
"return a constant to specify round cap"
|
|
171 |
|
|
172 |
^ #round
|
|
173 |
!
|
|
174 |
|
|
175 |
capButt
|
|
176 |
"return a constant to specify butt cap"
|
|
177 |
|
|
178 |
^ #butt
|
|
179 |
! !
|
|
180 |
|
|
181 |
!GraphicsContext class methodsFor:'instance creation'!
|
|
182 |
|
|
183 |
new
|
|
184 |
^ self basicNew initialize
|
|
185 |
! !
|
|
186 |
|
|
187 |
!GraphicsContext methodsFor:'initialization'!
|
|
188 |
|
|
189 |
initialize
|
|
190 |
"set up some useful default values"
|
|
191 |
|
|
192 |
"default is drawing black-on-white;
|
|
193 |
since these two colors are needed very often, cache them here"
|
|
194 |
|
46
|
195 |
"
|
0
|
196 |
White isNil ifTrue:[White := Color white].
|
|
197 |
Black isNil ifTrue:[Black := Color black].
|
46
|
198 |
"
|
0
|
199 |
paint := Black.
|
|
200 |
bgPaint := White.
|
|
201 |
foreground := Black.
|
|
202 |
background := White.
|
|
203 |
function := #copy.
|
|
204 |
lineWidth := 1.
|
|
205 |
lineStyle := #solid.
|
|
206 |
joinStyle := #miter.
|
|
207 |
capStyle := #butt.
|
|
208 |
|
|
209 |
self initFont
|
|
210 |
!
|
|
211 |
|
|
212 |
initFont
|
|
213 |
|aFont|
|
|
214 |
|
|
215 |
aFont := self class defaultFont.
|
|
216 |
"this is a kludge"
|
|
217 |
aFont isNil ifTrue:[
|
|
218 |
self class initialize.
|
|
219 |
aFont := self class defaultFont.
|
|
220 |
].
|
|
221 |
aFont notNil ifTrue:[
|
|
222 |
font := aFont
|
|
223 |
]
|
|
224 |
! !
|
|
225 |
|
2
|
226 |
!GraphicsContext methodsFor:'misc'!
|
|
227 |
|
|
228 |
flush
|
|
229 |
"st-80 compatibility"
|
|
230 |
|
|
231 |
^ self
|
|
232 |
! !
|
|
233 |
|
0
|
234 |
!GraphicsContext methodsFor:'accessing'!
|
|
235 |
|
|
236 |
paint
|
|
237 |
"return the current paint drawing color"
|
|
238 |
|
|
239 |
^ paint
|
|
240 |
!
|
|
241 |
|
|
242 |
paint:aColor
|
|
243 |
"set the drawing painting color, aColor can be a dithered one"
|
|
244 |
|
2
|
245 |
paint := aColor
|
0
|
246 |
!
|
|
247 |
|
|
248 |
paint:fgColor on:bgColor
|
|
249 |
"set the paint used for text and bitmaps, both colors may be
|
|
250 |
dithered colors"
|
|
251 |
|
2
|
252 |
paint := fgColor.
|
|
253 |
bgPaint := bgColor
|
0
|
254 |
!
|
|
255 |
|
|
256 |
backgroundPaint
|
|
257 |
"return the background paint color.
|
|
258 |
(used for opaqueForms and opaqueStrings)"
|
|
259 |
|
|
260 |
^ bgPaint
|
|
261 |
!
|
|
262 |
|
|
263 |
backgroundPaint:aColor
|
|
264 |
"set the background painting color (which is used for
|
|
265 |
opaqueForms and opaqueStrings). aColor can be a dithered one."
|
|
266 |
|
|
267 |
^ self subclassResponsibility
|
|
268 |
!
|
|
269 |
|
|
270 |
foreground
|
|
271 |
"return the current foreground drawing color"
|
|
272 |
|
|
273 |
^ foreground
|
|
274 |
!
|
|
275 |
|
|
276 |
foreground:aColor
|
|
277 |
"set the drawing foreground color.
|
|
278 |
aColor MUST be a real (i.e. device-) color"
|
|
279 |
|
2
|
280 |
foreground := aColor
|
0
|
281 |
!
|
|
282 |
|
|
283 |
background
|
|
284 |
"return the current background drawing color"
|
|
285 |
|
|
286 |
^ background
|
|
287 |
!
|
|
288 |
|
|
289 |
background:aColor
|
|
290 |
"set the drawing background color.
|
|
291 |
aColor MUST be a real (i.e. device-) color"
|
|
292 |
|
2
|
293 |
background := aColor
|
0
|
294 |
!
|
|
295 |
|
|
296 |
function
|
|
297 |
"return the current drawing function"
|
|
298 |
|
|
299 |
^ function
|
|
300 |
!
|
|
301 |
|
|
302 |
function:aFunctionSymbol
|
|
303 |
"set the drawing function"
|
|
304 |
|
|
305 |
^ self subclassResponsibility
|
|
306 |
!
|
|
307 |
|
|
308 |
foreground:fgColor background:bgColor
|
|
309 |
"set both foreground and background colors"
|
|
310 |
|
|
311 |
self foreground:fgColor.
|
|
312 |
self background:bgColor
|
|
313 |
!
|
|
314 |
|
|
315 |
foreground:fgColor background:bgColor function:f
|
|
316 |
"set foreground, background colors and function"
|
|
317 |
|
|
318 |
self foreground:fgColor.
|
|
319 |
self background:bgColor.
|
|
320 |
self function:f
|
|
321 |
!
|
|
322 |
|
|
323 |
lineWidth
|
|
324 |
"return the current drawing linewidth"
|
|
325 |
|
|
326 |
^ lineWidth
|
|
327 |
!
|
|
328 |
|
|
329 |
lineWidth:aNumber
|
|
330 |
"set the line drawing width in pixels"
|
|
331 |
|
2
|
332 |
lineWidth := aNumber
|
0
|
333 |
!
|
|
334 |
|
|
335 |
lineStyle
|
|
336 |
"return the current line-drawing-style"
|
|
337 |
|
|
338 |
^ lineStyle
|
|
339 |
!
|
|
340 |
|
|
341 |
lineStyle:aStyleSymbol
|
|
342 |
"set the line-drawing-style;
|
|
343 |
possible styles are: #solid, #dashed, #doubleDashed"
|
|
344 |
|
2
|
345 |
lineStyle := aStyleSymbol
|
0
|
346 |
!
|
|
347 |
|
|
348 |
capStyle
|
|
349 |
"return the current cap-style for line-drawing"
|
|
350 |
|
|
351 |
^ capStyle
|
|
352 |
!
|
|
353 |
|
|
354 |
capStyle:aStyleSymbol
|
|
355 |
"set the cap-style for line-drawing;
|
|
356 |
possible styles are: #notLast, #butt, #round, #projecting"
|
|
357 |
|
|
358 |
^ self subclassResponsibility
|
|
359 |
!
|
|
360 |
|
|
361 |
joinStyle
|
|
362 |
"return the current join-style for polygon-drawing"
|
|
363 |
|
|
364 |
^ joinStyle
|
|
365 |
!
|
|
366 |
|
|
367 |
joinStyle:aStyleSymbol
|
|
368 |
"set the join-style of lines in polygon-drawing;
|
|
369 |
possible styles are: #miter, #bevel, #round"
|
|
370 |
|
|
371 |
^ self subclassResponsibility
|
|
372 |
!
|
|
373 |
|
|
374 |
mask
|
|
375 |
"return the current drawing mask"
|
|
376 |
|
|
377 |
^ mask
|
|
378 |
!
|
|
379 |
|
|
380 |
mask:aForm
|
|
381 |
"set the drawing mask"
|
|
382 |
|
|
383 |
^ self subclassResponsibility
|
|
384 |
!
|
|
385 |
|
|
386 |
font
|
|
387 |
"return the current drawing font"
|
|
388 |
|
|
389 |
^ font
|
|
390 |
!
|
|
391 |
|
|
392 |
font:aFont
|
|
393 |
"set the drawing font"
|
|
394 |
|
|
395 |
^ self subclassResponsibility
|
|
396 |
!
|
|
397 |
|
|
398 |
clipRect:aRectangle
|
|
399 |
"set the drawing clip-rectangle"
|
|
400 |
|
|
401 |
^ self subclassResponsibility
|
|
402 |
!
|
|
403 |
|
|
404 |
graphicsContext
|
|
405 |
"for ST-80 compatibility"
|
|
406 |
|
|
407 |
^ self
|
2
|
408 |
!
|
|
409 |
|
|
410 |
viewOrigin
|
12
|
411 |
"return the drawables visible origin (for scrolling)"
|
|
412 |
|
2
|
413 |
^ 0@0
|
|
414 |
!
|
|
415 |
|
12
|
416 |
setMaskOrigin:aPoint
|
|
417 |
^ self
|
|
418 |
!
|
|
419 |
|
2
|
420 |
setMaskOriginX:x y:y
|
|
421 |
^ self
|
|
422 |
!
|
|
423 |
|
|
424 |
withPattern:aForm do:aBlock
|
46
|
425 |
'pattern drawing not implemented' errorPrintNewline.
|
2
|
426 |
aBlock value
|
0
|
427 |
! !
|
|
428 |
|
|
429 |
!GraphicsContext methodsFor:'displaying'!
|
|
430 |
|
|
431 |
displayRectangularBorder:aRectangle at:aPoint
|
|
432 |
"draw a rectangle - ST-80 compatibility"
|
|
433 |
|
26
|
434 |
self displayRectangle:(aRectangle translateBy:aPoint)
|
0
|
435 |
!
|
|
436 |
|
|
437 |
displayLineFrom:startPoint to:endPoint translateBy:anOffset
|
|
438 |
"draw a line - ST-80 compatibility"
|
|
439 |
|
|
440 |
self displayLineFrom:(startPoint + anOffset)
|
|
441 |
to:(endPoint + anOffset)
|
|
442 |
!
|
|
443 |
|
|
444 |
displayPolyline:aPolygon
|
|
445 |
"draw a polygon - ST-80 compatibility"
|
|
446 |
|
35
|
447 |
|poly|
|
|
448 |
|
|
449 |
poly := aPolygon collect:[:pount | pount rounded].
|
|
450 |
self displayPolygon:poly
|
|
451 |
!
|
|
452 |
|
|
453 |
displayArcBoundedBy:boundingBox startAngle:startAngle sweepAngle:sweepAngle at:origin
|
|
454 |
"draw an arc/circle/ellipse - ST-80 compatibility"
|
0
|
455 |
|
35
|
456 |
^ self displayArcX:(boundingBox left + origin x)
|
|
457 |
y:(boundingBox top + origin y)
|
|
458 |
width:(boundingBox width)
|
|
459 |
height:(boundingBox height)
|
|
460 |
from:startAngle
|
|
461 |
angle:sweepAngle
|
|
462 |
!
|
|
463 |
|
|
464 |
displayWedgeBoundedBy:boundingBox startAngle:startAngle sweepAngle:sweepAngle at:origin
|
|
465 |
"fill an arc/circle/ellipse - ST-80 compatibility"
|
|
466 |
|
|
467 |
^ self fillArcX:(boundingBox left + origin x)
|
|
468 |
y:(boundingBox top + origin y)
|
|
469 |
width:(boundingBox width)
|
|
470 |
height:(boundingBox height)
|
|
471 |
from:startAngle
|
|
472 |
angle:sweepAngle
|
0
|
473 |
! !
|
|
474 |
|
|
475 |
!GraphicsContext methodsFor:'bit-blitting'!
|
|
476 |
|
|
477 |
copyFrom:aGraphicContext x:srcX y:srcY toX:dstX y:dstY width:w height:h
|
|
478 |
"copy from a drawable - maybe self"
|
|
479 |
|
|
480 |
^ self subclassResponsibility
|
|
481 |
!
|
|
482 |
|
|
483 |
copyFrom:aGraphicContext x:dstX y:dstY width:w height:h
|
|
484 |
"copy from a drawable - maybe self"
|
|
485 |
|
|
486 |
self copyFrom:aGraphicContext x:0 y:0 toX:dstX y:dstY width:w height:h
|
|
487 |
! !
|
|
488 |
|
|
489 |
!GraphicsContext methodsFor:'basic filling'!
|
|
490 |
|
|
491 |
fillPolygon:points
|
|
492 |
"fill a polygon with current paint color"
|
|
493 |
|
|
494 |
^ self subclassResponsibility
|
|
495 |
!
|
|
496 |
|
|
497 |
fillRectangleX:x y:y width:w height:h
|
|
498 |
"fill a rectangle with current paint color"
|
|
499 |
|
|
500 |
^ self subclassResponsibility
|
|
501 |
!
|
|
502 |
|
|
503 |
fillArcX:x y:y w:w h:h from:start angle:angle
|
|
504 |
"fill an arc with current paint color"
|
|
505 |
|
|
506 |
^ self subclassResponsibility
|
|
507 |
! !
|
|
508 |
|
|
509 |
!GraphicsContext methodsFor:'filling'!
|
|
510 |
|
|
511 |
fillRectangle:aRectangle
|
|
512 |
"fill a rectangle with current paint color"
|
|
513 |
|
|
514 |
self fillRectangleX:(aRectangle left)
|
|
515 |
y:(aRectangle top)
|
|
516 |
width:(aRectangle width)
|
|
517 |
height:(aRectangle height)
|
|
518 |
!
|
|
519 |
|
|
520 |
fillCircle:aPoint radius:aNumber
|
|
521 |
"draw a filled circle"
|
|
522 |
|
|
523 |
self fillCircleX:(aPoint x) y:(aPoint y) radius:aNumber
|
|
524 |
!
|
|
525 |
|
|
526 |
fillCircleX:x y:y radius:r
|
|
527 |
"draw a filled circle"
|
|
528 |
|
|
529 |
|d|
|
|
530 |
d := 2 * r.
|
|
531 |
self fillArcX:(x - r) y:(y - r) w:d h:d from:0 angle:360
|
|
532 |
! !
|
|
533 |
|
|
534 |
!GraphicsContext methodsFor:'basic drawing'!
|
|
535 |
|
26
|
536 |
displayPolygon:aPolygon
|
0
|
537 |
"draw a polygon
|
|
538 |
- this could be recoded to draw using displayLine"
|
|
539 |
|
|
540 |
^ self subclassResponsibility
|
|
541 |
!
|
|
542 |
|
12
|
543 |
displayArcX:x y:y w:width h:height from:startAngle angle:angle
|
0
|
544 |
"draw an arc in a box
|
|
545 |
- this could be recoded to draw using displayLine"
|
|
546 |
|
|
547 |
^ self subclassResponsibility
|
|
548 |
!
|
|
549 |
|
26
|
550 |
displayRectangleX:x y:y width:w height:h
|
0
|
551 |
"draw a rectangle
|
|
552 |
- this could be recoded to draw using displayLine"
|
|
553 |
|
|
554 |
^ self subclassResponsibility
|
|
555 |
!
|
|
556 |
|
26
|
557 |
displayForm:aForm x:x y:y
|
0
|
558 |
"draw a form at x/y; if the form has depth 1, 1's in the form are
|
|
559 |
drawn in current fg, 0's are ignored.
|
24
|
560 |
If the form has depth ~~ 1, the result is undefined"
|
|
561 |
|
|
562 |
|fg bg f|
|
|
563 |
|
|
564 |
fg := foreground.
|
|
565 |
bg := background.
|
|
566 |
f := function.
|
0
|
567 |
|
24
|
568 |
self foreground:(Color noColor) background:(Color allColor) function:#and.
|
26
|
569 |
self displayOpaqueForm:aForm x:x y:y.
|
24
|
570 |
self foreground:fg background:(Color noColor) function:#or.
|
26
|
571 |
self displayOpaqueForm:aForm x:x y:y.
|
24
|
572 |
self foreground:fg background:fg function:f.
|
0
|
573 |
!
|
|
574 |
|
26
|
575 |
displayOpaqueForm:aForm x:x y:y
|
0
|
576 |
"draw a form at x/y; if the form has depth 1, 1's in the form are
|
|
577 |
drawn in current fg, 0's in current bg color.
|
|
578 |
If the form has depth ~~ 1, it is copied as is onto the receiver"
|
|
579 |
|
|
580 |
^ self subclassResponsibility
|
|
581 |
!
|
|
582 |
|
|
583 |
displayOpaqueString:aString from:index1 to:index2 x:x y:y
|
|
584 |
"draw part of a string with both fg and bg at x/y in current font"
|
|
585 |
|
|
586 |
^ self subclassResponsibility
|
|
587 |
!
|
|
588 |
|
|
589 |
displayString:aString from:index1 to:index2 x:x y:y
|
|
590 |
"draw part of a string with fg at x/y in current font"
|
|
591 |
|
|
592 |
^ self subclassResponsibility
|
|
593 |
! !
|
|
594 |
|
|
595 |
!GraphicsContext methodsFor:'drawing'!
|
|
596 |
|
|
597 |
displayOpaqueString:aString x:x y:y
|
|
598 |
"draw a string with both fg and bg"
|
|
599 |
|
|
600 |
self displayOpaqueString:aString from:1 to:(aString size) x:x y:y
|
|
601 |
!
|
|
602 |
|
|
603 |
displayOpaqueString:aString at:aPoint
|
|
604 |
"draw a string with both fg and bg"
|
|
605 |
|
|
606 |
self displayOpaqueString:aString x:(aPoint x) y:(aPoint y)
|
|
607 |
!
|
|
608 |
|
|
609 |
displayString:aString x:x y:y
|
|
610 |
"draw a string - drawing fg only"
|
|
611 |
|
|
612 |
self displayString:aString from:1 to:(aString size) x:x y:y
|
|
613 |
!
|
|
614 |
|
|
615 |
displayString:aString at:aPoint
|
|
616 |
"draw a string - drawing fg only"
|
|
617 |
|
|
618 |
self displayString:aString x:aPoint x y:aPoint y
|
|
619 |
!
|
|
620 |
|
24
|
621 |
displayPointX:x y:y
|
0
|
622 |
"draw a point at x/y"
|
|
623 |
|
|
624 |
self displayLineFromX:x y:y toX:x y:y
|
|
625 |
!
|
|
626 |
|
24
|
627 |
displayPoint:aPoint
|
0
|
628 |
"draw a pixel"
|
|
629 |
|
24
|
630 |
self displayPointX:(aPoint x) y:(aPoint y)
|
0
|
631 |
!
|
|
632 |
|
|
633 |
displayLineFrom:point1 to:point2
|
|
634 |
"draw a line"
|
|
635 |
|
|
636 |
self displayLineFromX:(point1 x) y:(point1 y)
|
|
637 |
toX:(point2 x) y:(point2 y)
|
|
638 |
!
|
|
639 |
|
26
|
640 |
displayRectangle:aRectangle
|
0
|
641 |
"draw a rectangle"
|
|
642 |
|
26
|
643 |
self displayRectangleX:(aRectangle left)
|
|
644 |
y:(aRectangle top)
|
|
645 |
width:(aRectangle width)
|
|
646 |
height:(aRectangle height)
|
0
|
647 |
!
|
|
648 |
|
26
|
649 |
displayRectangleOrigin:origin corner:corner
|
0
|
650 |
"draw a rectangle"
|
|
651 |
|
|
652 |
|top left|
|
|
653 |
|
|
654 |
left := origin x.
|
|
655 |
top := origin y.
|
26
|
656 |
self displayRectangleX:left y:top
|
|
657 |
width:(corner x - left)
|
|
658 |
height:(corner y - top)
|
0
|
659 |
!
|
|
660 |
|
26
|
661 |
displayForm:aForm at:aPoint
|
0
|
662 |
"draw a form"
|
|
663 |
|
26
|
664 |
self displayForm:aForm x:(aPoint x) y:(aPoint y)
|
0
|
665 |
!
|
|
666 |
|
12
|
667 |
displayArcIn:aRectangle from:startAngle angle:angle
|
|
668 |
"draw an arc in a box"
|
0
|
669 |
|
12
|
670 |
self displayArcX:(aRectangle left)
|
|
671 |
y:(aRectangle top)
|
|
672 |
w:(aRectangle width)
|
|
673 |
h:(aRectangle height)
|
|
674 |
from:startAngle
|
|
675 |
angle:angle
|
0
|
676 |
!
|
|
677 |
|
12
|
678 |
displayArcOrigin:origin corner:corner from:startAngle angle:angle
|
|
679 |
"draw an arc in a box"
|
0
|
680 |
|
|
681 |
|left top right bot|
|
|
682 |
|
|
683 |
left := origin x.
|
|
684 |
top := origin y.
|
|
685 |
right := corner x.
|
|
686 |
bot := corner y.
|
12
|
687 |
self displayArcX:left y:top
|
|
688 |
w:(right - left + 1) h:(bot - top + 1)
|
|
689 |
from:startAngle angle:angle
|
0
|
690 |
!
|
|
691 |
|
12
|
692 |
displayCircleIn:aRectangle
|
0
|
693 |
"draw a circle in a box"
|
|
694 |
|
|
695 |
self
|
12
|
696 |
displayArcX:(aRectangle left)
|
|
697 |
y:(aRectangle top)
|
|
698 |
w:(aRectangle width)
|
|
699 |
h:(aRectangle height)
|
|
700 |
from:0 angle:360
|
0
|
701 |
!
|
|
702 |
|
12
|
703 |
displayCircle:aPoint radius:r
|
|
704 |
"draw a circle around a center point"
|
0
|
705 |
|
12
|
706 |
self displayCircleX:(aPoint x) y:(aPoint y) radius:r
|
0
|
707 |
!
|
|
708 |
|
12
|
709 |
displayCircleX:x y:y radius:r
|
|
710 |
"draw a circle around a center point"
|
0
|
711 |
|
|
712 |
|d|
|
|
713 |
d := 2 * r.
|
12
|
714 |
self displayArcX:(x - r) y:(y - r)
|
|
715 |
w:d h:d
|
|
716 |
from:0 angle:360
|
0
|
717 |
! !
|