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