author | ps |
Fri, 19 Nov 1999 15:37:34 +0100 | |
changeset 3033 | 2d910a68668f |
parent 2938 | 898d40365e5f |
child 3145 | be28f5978253 |
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' |
2031
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
16 |
classVariableNames:'White Black DefaultFont DrawingOnClosedDrawableSignal' |
519 | 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 |
||
2031
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
342 |
DrawingOnClosedDrawableSignal isNil ifTrue:[ |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
343 |
DrawingOnClosedDrawableSignal := Signal new mayProceed:true. |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
344 |
DrawingOnClosedDrawableSignal nameClass:self message:#drawingOnClosedDrawableSignal. |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
345 |
DrawingOnClosedDrawableSignal notifierString:'drawing attempt on closed drawable'. |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
346 |
]. |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
347 |
|
134 | 348 |
White isNil ifTrue:[ |
2764 | 349 |
Color initialize. |
2762 | 350 |
|
351 |
White := Color white. |
|
352 |
Black := Color black. |
|
353 |
||
2763 | 354 |
Display notNil ifTrue:[ |
2764 | 355 |
White := White onDevice:Display. |
356 |
Black := Black onDevice:Display. |
|
2763 | 357 |
]. |
0 | 358 |
|
2031
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
359 |
Font initialize. |
2765 | 360 |
DefaultFont := Font family:'courier' face:'medium' style:'roman' size:12. |
2764 | 361 |
Display notNil ifTrue:[ |
362 |
DefaultFont := DefaultFont onDevice:Display |
|
363 |
] |
|
134 | 364 |
] |
2031
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
365 |
|
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
366 |
"Modified: / 29.1.1998 / 12:56:18 / cg" |
0 | 367 |
! ! |
368 |
||
1203
49dd13574c7d
dont use Black/White when drawing;
Claus Gittinger <cg@exept.de>
parents:
952
diff
changeset
|
369 |
!GraphicsContext class methodsFor:'instance creation'! |
0 | 370 |
|
519 | 371 |
new |
372 |
"return a new instance of myself. Redefined to initialize |
|
373 |
the new thingy" |
|
12 | 374 |
|
519 | 375 |
^ self basicNew initialize |
376 |
! ! |
|
377 |
||
2031
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
378 |
!GraphicsContext class methodsFor:'Signal constants'! |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
379 |
|
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
380 |
drawingOnClosedDrawableSignal |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
381 |
"return the signal which is raised, if drawing is attempted |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
382 |
on a closed drawable. |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
383 |
This is especially useful, if a forked thread animates |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
384 |
a view in the background, and is not properly synchronized |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
385 |
with the window thread - i.e. the window gets closed by the user, |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
386 |
and the background process continues to draw. |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
387 |
In this case, the background thread should handle this signal |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
388 |
and terminate itself in the handler." |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
389 |
|
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
390 |
^ DrawingOnClosedDrawableSignal |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
391 |
|
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
392 |
"demonstration1: (error if closed by the windowManager): |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
393 |
|
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
394 |
|v| |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
395 |
|
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
396 |
v := StandardSystemView new openAndWait. |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
397 |
[ |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
398 |
[true] whileTrue:[ |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
399 |
|x y| |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
400 |
|
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
401 |
x := Random nextIntegerBetween:0 and:(v width). |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
402 |
y := Random nextIntegerBetween:0 and:(v height). |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
403 |
v displayString:'hello' x:x y:y. |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
404 |
Delay waitForSeconds:0.5. |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
405 |
] |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
406 |
] fork. |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
407 |
" |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
408 |
"demonstration2: (no error if closed by the windowManager): |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
409 |
|
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
410 |
|v| |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
411 |
|
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
412 |
v := StandardSystemView new openAndWait. |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
413 |
[ |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
414 |
v class drawingOnClosedDrawableSignal handle:[:ex | |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
415 |
ex return |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
416 |
] do:[ |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
417 |
[true] whileTrue:[ |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
418 |
|x y| |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
419 |
|
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
420 |
x := Random nextIntegerBetween:0 and:(v width). |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
421 |
y := Random nextIntegerBetween:0 and:(v height). |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
422 |
v displayString:'hello' x:x y:y. |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
423 |
Delay waitForSeconds:0.5. |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
424 |
] |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
425 |
] |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
426 |
] fork. |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
427 |
" |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
428 |
|
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
429 |
"Created: / 29.1.1998 / 13:10:41 / cg" |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
430 |
"Modified: / 29.1.1998 / 13:11:14 / cg" |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
431 |
! ! |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2017
diff
changeset
|
432 |
|
1203
49dd13574c7d
dont use Black/White when drawing;
Claus Gittinger <cg@exept.de>
parents:
952
diff
changeset
|
433 |
!GraphicsContext class methodsFor:'accessing defaults'! |
0 | 434 |
|
435 |
defaultFont |
|
12 | 436 |
"get the default font used for drawing" |
437 |
||
71 | 438 |
DefaultFont isNil ifTrue:[ |
439 |
DefaultFont := Font family:'courier' face:'medium' style:'roman' size:12 |
|
440 |
]. |
|
0 | 441 |
^ DefaultFont |
519 | 442 |
! |
443 |
||
444 |
defaultFont:aFont |
|
445 |
"set the default font used for drawing" |
|
446 |
||
447 |
DefaultFont := aFont |
|
0 | 448 |
! ! |
449 |
||
1203
49dd13574c7d
dont use Black/White when drawing;
Claus Gittinger <cg@exept.de>
parents:
952
diff
changeset
|
450 |
!GraphicsContext class methodsFor:'constants'! |
0 | 451 |
|
519 | 452 |
capButt |
453 |
"return a constant to specify butt cap" |
|
0 | 454 |
|
519 | 455 |
^ #butt |
0 | 456 |
! |
457 |
||
458 |
capNotLast |
|
459 |
"return a constant to specify not-last cap" |
|
460 |
||
461 |
^ #notLast |
|
462 |
! |
|
463 |
||
464 |
capProjecting |
|
465 |
"return a constant to specify projecting cap" |
|
466 |
||
467 |
^ #projecting |
|
468 |
! |
|
469 |
||
470 |
capRound |
|
471 |
"return a constant to specify round cap" |
|
472 |
||
473 |
^ #round |
|
474 |
! |
|
475 |
||
519 | 476 |
joinBevel |
477 |
"return a constant to specify bevel join" |
|
478 |
||
479 |
^ #bevel |
|
480 |
! |
|
0 | 481 |
|
519 | 482 |
joinMiter |
483 |
"return a constant to specify miter join" |
|
484 |
||
485 |
^ #miter |
|
486 |
! |
|
487 |
||
488 |
joinRound |
|
489 |
"return a constant to specify round join" |
|
490 |
||
491 |
^ #round |
|
0 | 492 |
! ! |
493 |
||
2807 | 494 |
!GraphicsContext methodsFor:'Compatibility - ST-80'! |
519 | 495 |
|
496 |
displayArc:origin radius:radius from:startAngle angle:angle |
|
497 |
"draw an arc around a point" |
|
498 |
||
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
499 |
self |
1956 | 500 |
displayArcX:(origin x - radius) |
501 |
y:(origin y - radius) |
|
502 |
width:(radius * 2) |
|
503 |
height:(radius * 2) |
|
504 |
from:startAngle |
|
505 |
angle:angle |
|
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
506 |
|
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
507 |
"Modified: 8.5.1996 / 08:34:43 / cg" |
519 | 508 |
! |
0 | 509 |
|
1956 | 510 |
displayArcBoundedBy:boundingBox startAngle:startAngle sweepAngle:sweepAngle |
511 |
"draw an arc/circle/ellipse - ST-80 compatibility" |
|
512 |
||
513 |
^ self displayArcX:(boundingBox left) |
|
514 |
y:(boundingBox top) |
|
515 |
width:(boundingBox width) |
|
516 |
height:(boundingBox height) |
|
517 |
from:startAngle |
|
518 |
angle:sweepAngle |
|
519 |
||
520 |
"Created: / 14.11.1997 / 21:04:19 / cg" |
|
521 |
! |
|
522 |
||
519 | 523 |
displayArcBoundedBy:boundingBox startAngle:startAngle sweepAngle:sweepAngle at:origin |
524 |
"draw an arc/circle/ellipse - ST-80 compatibility" |
|
525 |
||
526 |
^ self displayArcX:(boundingBox left + origin x) |
|
527 |
y:(boundingBox top + origin y) |
|
528 |
width:(boundingBox width) |
|
529 |
height:(boundingBox height) |
|
530 |
from:startAngle |
|
531 |
angle:sweepAngle |
|
532 |
! |
|
533 |
||
534 |
displayLineFrom:startPoint to:endPoint translateBy:anOffset |
|
535 |
"draw a line - ST-80 compatibility" |
|
0 | 536 |
|
519 | 537 |
self displayLineFrom:(startPoint + anOffset) |
538 |
to:(endPoint + anOffset) |
|
539 |
! |
|
540 |
||
541 |
displayPolyline:aPolygon |
|
542 |
"draw a polygon - ST-80 compatibility" |
|
543 |
||
544 |
^ self displayPolygon:aPolygon |
|
545 |
! |
|
546 |
||
547 |
displayRectangularBorder:aRectangle at:aPoint |
|
548 |
"draw a rectangle - ST-80 compatibility" |
|
0 | 549 |
|
519 | 550 |
self displayRectangle:(aRectangle translateBy:aPoint) |
551 |
! |
|
552 |
||
1280 | 553 |
displayWedgeBoundedBy:boundingBox startAngle:startAngle sweepAngle:sweepAngle |
554 |
"fill an arc/circle/ellipse - ST-80 compatibility" |
|
555 |
||
556 |
^ self fillArcX:(boundingBox left) |
|
1956 | 557 |
y:(boundingBox top) |
558 |
width:(boundingBox width) |
|
559 |
height:(boundingBox height) |
|
560 |
from:startAngle |
|
561 |
angle:sweepAngle |
|
1280 | 562 |
|
563 |
"Created: 27.1.1997 / 15:50:14 / cg" |
|
564 |
! |
|
565 |
||
519 | 566 |
displayWedgeBoundedBy:boundingBox startAngle:startAngle sweepAngle:sweepAngle at:origin |
567 |
"fill an arc/circle/ellipse - ST-80 compatibility" |
|
2 | 568 |
|
519 | 569 |
^ self fillArcX:(boundingBox left + origin x) |
570 |
y:(boundingBox top + origin y) |
|
571 |
width:(boundingBox width) |
|
572 |
height:(boundingBox height) |
|
573 |
from:startAngle |
|
574 |
angle:sweepAngle |
|
2807 | 575 |
! |
576 |
||
577 |
findFont:aFontDescription |
|
578 |
"given a fontDescription, return a device font for it |
|
579 |
on my device." |
|
580 |
||
2827 | 581 |
^ aFontDescription onDevice:device |
2807 | 582 |
|
583 |
"Modified: 28.5.1996 / 20:22:29 / cg" |
|
584 |
! |
|
585 |
||
586 |
phase |
|
587 |
"return the origin within the mask (used to draw with patterns). |
|
588 |
This is an alias for ST/X's #maskOrigin" |
|
589 |
||
590 |
^ self maskOrigin |
|
591 |
! |
|
592 |
||
593 |
phase:aPoint |
|
594 |
"set the origin within the mask (used to draw with patterns). |
|
595 |
This is an alias for ST/X's #maskOrigin:" |
|
596 |
||
597 |
^ self maskOrigin:aPoint |
|
598 |
! |
|
599 |
||
600 |
setDevicePattern:aColorOrMask |
|
601 |
"ST/X can paint in any color or image" |
|
602 |
||
603 |
self paint:aColorOrMask |
|
604 |
! |
|
605 |
||
606 |
tilePhase |
|
607 |
"return the origin within the mask (used to draw with patterns). |
|
608 |
This is an alias for ST/X's #maskOrigin" |
|
609 |
||
610 |
^ self maskOrigin |
|
611 |
||
612 |
"Created: 4.6.1996 / 15:26:39 / cg" |
|
613 |
! |
|
614 |
||
615 |
tilePhase:aPoint |
|
616 |
"set the origin within the mask (used to draw with patterns). |
|
617 |
This is an alias for ST/X's #maskOrigin" |
|
618 |
||
619 |
^ self maskOrigin:aPoint |
|
620 |
||
621 |
"Created: 4.6.1996 / 15:26:49 / cg" |
|
622 |
! |
|
623 |
||
624 |
widthOfString:aString |
|
625 |
"given a string, return its width in pixels if |
|
626 |
drawn on the receivers device." |
|
627 |
||
2827 | 628 |
^ (font onDevice:device) widthOf:aString |
2807 | 629 |
|
630 |
"Modified: 28.5.1996 / 20:22:22 / cg" |
|
631 |
! |
|
632 |
||
633 |
widthOfString:aString from:start to:stop |
|
634 |
"given a string, return the width in pixels if |
|
635 |
a substring is drawn on the receivers device." |
|
636 |
||
2827 | 637 |
^ (font onDevice:device) widthOf:aString from:start to:stop |
2807 | 638 |
|
639 |
"Modified: 28.5.1996 / 20:22:18 / cg" |
|
2 | 640 |
! ! |
641 |
||
2807 | 642 |
!GraphicsContext methodsFor:'Compatibility - Squeak'! |
2806 | 643 |
|
2938 | 644 |
fill:aRectangle fillColor:aColor |
645 |
"fill a rectangle with the given color color" |
|
646 |
||
647 |
|savedPaint| |
|
648 |
||
649 |
savedPaint := paint. |
|
650 |
self paint:aColor. |
|
651 |
self fillRectangle:aRectangle. |
|
652 |
self paint:savedPaint |
|
653 |
! |
|
654 |
||
2806 | 655 |
fillWhite |
2938 | 656 |
"fill all of the receiver with the white color" |
657 |
||
2806 | 658 |
self fill:Color white |
659 |
! ! |
|
660 |
||
0 | 661 |
!GraphicsContext methodsFor:'accessing'! |
662 |
||
663 |
backgroundPaint |
|
664 |
"return the background paint color. |
|
665 |
(used for opaqueForms and opaqueStrings)" |
|
666 |
||
667 |
^ bgPaint |
|
668 |
! |
|
669 |
||
670 |
backgroundPaint:aColor |
|
671 |
"set the background painting color (which is used for |
|
672 |
opaqueForms and opaqueStrings). aColor can be a dithered one." |
|
673 |
||
678 | 674 |
bgPaint := aColor |
675 |
||
676 |
"Modified: 12.5.1996 / 22:25:17 / cg" |
|
0 | 677 |
! |
678 |
||
679 |
capStyle |
|
680 |
"return the current cap-style for line-drawing" |
|
681 |
||
682 |
^ capStyle |
|
683 |
! |
|
684 |
||
685 |
capStyle:aStyleSymbol |
|
686 |
"set the cap-style for line-drawing; |
|
687 |
possible styles are: #notLast, #butt, #round, #projecting" |
|
688 |
||
678 | 689 |
aStyleSymbol isNil ifTrue:[ |
1956 | 690 |
capStyle := #butt |
678 | 691 |
] ifFalse:[ |
1956 | 692 |
capStyle := aStyleSymbol |
678 | 693 |
] |
694 |
||
695 |
"Modified: 12.5.1996 / 22:24:30 / cg" |
|
0 | 696 |
! |
697 |
||
76 | 698 |
clipRect |
719
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
699 |
"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
|
700 |
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
|
701 |
displaySurfaces (i.e. views) bounds. Added for ST-80 compatibility." |
76 | 702 |
|
719
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
703 |
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
|
704 |
^ self clippingBounds. |
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
705 |
|
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
706 |
"Modified: 28.5.1996 / 14:14:53 / cg" |
76 | 707 |
! |
708 |
||
0 | 709 |
clipRect:aRectangle |
710 |
"set the drawing clip-rectangle" |
|
711 |
||
719
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
712 |
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
|
713 |
^ 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
|
714 |
|
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
715 |
"Modified: 28.5.1996 / 14:13:09 / cg" |
0 | 716 |
! |
717 |
||
76 | 718 |
clippingBounds |
719
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
719 |
"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
|
720 |
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
|
721 |
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
|
722 |
|
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
723 |
|rect| |
76 | 724 |
|
719
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
725 |
clipRect isNil ifTrue:[ |
1956 | 726 |
rect := 0@0 extent:(self medium extent). |
727 |
transformation notNil ifTrue:[ |
|
728 |
rect := transformation applyInverseTo:rect. |
|
729 |
]. |
|
730 |
^ rect |
|
719
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
731 |
]. |
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
732 |
^ clipRect |
563 | 733 |
|
719
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
734 |
"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
|
735 |
! |
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
736 |
|
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
737 |
clippingRectangle:aRectangleOrNil |
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
738 |
"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
|
739 |
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
|
740 |
|
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
741 |
clipRect := aRectangleOrNil |
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
742 |
|
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
743 |
"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
|
744 |
"Created: 28.5.1996 / 14:09:27 / cg" |
76 | 745 |
! |
746 |
||
561
3c1ec7798f77
added #clippingRectangleOrNil for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
519
diff
changeset
|
747 |
clippingRectangleOrNil |
719
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
748 |
"return the clipping rectangle for drawing, nil if there is none." |
563 | 749 |
|
719
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
750 |
^ clipRect |
561
3c1ec7798f77
added #clippingRectangleOrNil for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
519
diff
changeset
|
751 |
|
719
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
752 |
"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
|
753 |
"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
|
754 |
! |
3c1ec7798f77
added #clippingRectangleOrNil for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
519
diff
changeset
|
755 |
|
786 | 756 |
dashStyle:aDashList offset:dashOffset |
757 |
"define dashes. Each element of the dashList specifies the length |
|
758 |
of a corresponding dash. For example, setting it to [4 4] |
|
759 |
defines 4on-4off dashing; |
|
760 |
Setting it to [1 2 4 2] defines 1on-2off-4on-2off dashes. |
|
761 |
The dashOffset specifies where in the dashList the dashing starts. |
|
762 |
Ignored here - this may not be supported by all graphics devices." |
|
763 |
||
764 |
^ self |
|
765 |
||
766 |
"Created: 4.6.1996 / 18:59:34 / cg" |
|
767 |
"Modified: 4.6.1996 / 19:03:38 / cg" |
|
768 |
! |
|
769 |
||
519 | 770 |
font |
771 |
"return the current drawing font" |
|
772 |
||
773 |
^ font |
|
774 |
! |
|
775 |
||
776 |
font:aFont |
|
777 |
"set the drawing font" |
|
778 |
||
779 |
^ self subclassResponsibility |
|
780 |
! |
|
781 |
||
782 |
function |
|
783 |
"return the current drawing function" |
|
784 |
||
785 |
^ function |
|
786 |
! |
|
787 |
||
788 |
function:aFunctionSymbol |
|
789 |
"set the drawing function" |
|
790 |
||
791 |
^ self subclassResponsibility |
|
792 |
! |
|
793 |
||
735 | 794 |
graphicsContext |
795 |
"for ST-80 compatibility" |
|
796 |
||
797 |
^ self |
|
798 |
! |
|
799 |
||
727
bf23a306b6f2
renamed PseudoView to DisplaySurface
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
800 |
graphicsDevice |
bf23a306b6f2
renamed PseudoView to DisplaySurface
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
801 |
"same as #device, for ST-80 compatibility" |
bf23a306b6f2
renamed PseudoView to DisplaySurface
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
802 |
|
bf23a306b6f2
renamed PseudoView to DisplaySurface
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
803 |
^ device |
bf23a306b6f2
renamed PseudoView to DisplaySurface
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
804 |
! |
bf23a306b6f2
renamed PseudoView to DisplaySurface
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
805 |
|
519 | 806 |
joinStyle |
807 |
"return the current join-style for polygon-drawing" |
|
808 |
||
809 |
^ joinStyle |
|
810 |
! |
|
12 | 811 |
|
519 | 812 |
joinStyle:aStyleSymbol |
813 |
"set the join-style of lines in polygon-drawing; |
|
814 |
possible styles are: #miter, #bevel, #round" |
|
815 |
||
678 | 816 |
aStyleSymbol isNil ifTrue:[ |
1956 | 817 |
joinStyle := #miter |
678 | 818 |
] ifFalse:[ |
1956 | 819 |
joinStyle := aStyleSymbol |
678 | 820 |
] |
821 |
||
822 |
"Modified: 12.5.1996 / 22:24:14 / cg" |
|
519 | 823 |
! |
824 |
||
825 |
lineStyle |
|
826 |
"return the current line-drawing-style" |
|
827 |
||
828 |
^ lineStyle |
|
2 | 829 |
! |
830 |
||
519 | 831 |
lineStyle:aStyleSymbol |
832 |
"set the line-drawing-style; |
|
2360 | 833 |
possible styles are: #solid, #dashed, #doubleDashed, |
834 |
#dotted, #dashDot or #dashDotDot." |
|
151 | 835 |
|
678 | 836 |
aStyleSymbol isNil ifTrue:[ |
2360 | 837 |
lineStyle := #solid |
678 | 838 |
] ifFalse:[ |
2360 | 839 |
lineStyle := aStyleSymbol |
678 | 840 |
] |
841 |
||
842 |
"Modified: 12.5.1996 / 22:19:25 / cg" |
|
519 | 843 |
! |
844 |
||
845 |
lineWidth |
|
846 |
"return the current drawing linewidth" |
|
847 |
||
848 |
^ lineWidth |
|
151 | 849 |
! |
850 |
||
519 | 851 |
lineWidth:aNumber |
852 |
"set the line drawing width in pixels" |
|
853 |
||
854 |
lineWidth := aNumber |
|
855 |
! |
|
151 | 856 |
|
519 | 857 |
mask |
858 |
"return the current drawing mask" |
|
859 |
||
860 |
^ mask |
|
861 |
! |
|
862 |
||
863 |
mask:aForm |
|
864 |
"set the drawing mask" |
|
865 |
||
866 |
^ self subclassResponsibility |
|
151 | 867 |
! |
868 |
||
869 |
maskOrigin |
|
870 |
"return the origin within the mask (used to draw with patterns). |
|
871 |
Should be redefined in classes which support it. |
|
872 |
This is an alias for ST-80's #phase" |
|
873 |
||
874 |
^ maskOrigin |
|
875 |
! |
|
876 |
||
877 |
maskOrigin:aPoint |
|
878 |
"set the origin within the mask (used to draw with patterns). |
|
879 |
Should be redefined in classes which support it. |
|
880 |
This is an alias for ST-80's #phase:" |
|
881 |
||
2017 | 882 |
maskOrigin := aPoint. |
883 |
^ self |
|
884 |
||
885 |
"Modified: / 26.1.1998 / 18:59:18 / cg" |
|
151 | 886 |
! |
887 |
||
888 |
maskOriginX:x y:y |
|
889 |
"set the origin within the mask (used to draw with patterns). |
|
890 |
Should be redefined in classes which support it. |
|
891 |
This is an alias for ST-80's #phase:" |
|
109 | 892 |
|
2017 | 893 |
^ self maskOrigin:(x @ y) |
894 |
||
895 |
"Modified: / 26.1.1998 / 18:59:56 / cg" |
|
12 | 896 |
! |
897 |
||
719
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
898 |
medium |
1346 | 899 |
"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
|
900 |
|
727
bf23a306b6f2
renamed PseudoView to DisplaySurface
Claus Gittinger <cg@exept.de>
parents:
726
diff
changeset
|
901 |
^ device |
719
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
902 |
|
720 | 903 |
"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
|
904 |
! |
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
905 |
|
519 | 906 |
paint |
907 |
"return the current paint drawing color" |
|
908 |
||
909 |
^ paint |
|
910 |
! |
|
911 |
||
912 |
paint:aColor |
|
913 |
"set the drawing painting color, aColor can be a dithered one" |
|
914 |
||
915 |
paint := aColor |
|
916 |
! |
|
917 |
||
918 |
paint:fgColor on:bgColor |
|
563 | 919 |
"set the paint and backgroundPaint, used for text and bitmaps. |
920 |
Both colors may be dithered colors" |
|
519 | 921 |
|
671 | 922 |
fgColor ~~ paint ifTrue:[ |
1956 | 923 |
self paint:fgColor. |
671 | 924 |
]. |
519 | 925 |
bgPaint := bgColor |
563 | 926 |
|
671 | 927 |
"Modified: 12.5.1996 / 19:40:43 / cg" |
519 | 928 |
! |
929 |
||
151 | 930 |
setMaskOrigin:aPoint |
931 |
"set the origin within the mask (used to draw with patterns). |
|
932 |
OBSOLETE: use #maskOrigin: or #phase:" |
|
933 |
||
2017 | 934 |
^ self maskOriginX:aPoint x y:aPoint y |
935 |
||
936 |
"Modified: / 26.1.1998 / 18:54:14 / cg" |
|
151 | 937 |
! |
938 |
||
2 | 939 |
setMaskOriginX:x y:y |
109 | 940 |
"set the origin within the mask (used to draw with patterns). |
151 | 941 |
OBSOLETE: use #maskOriginX:y: or #phase:" |
109 | 942 |
|
151 | 943 |
^ self maskOriginX:x y:y |
2 | 944 |
! |
945 |
||
519 | 946 |
viewOrigin |
947 |
"return the drawables visible origin (for scrolling)" |
|
948 |
||
949 |
^ 0@0 |
|
418
0e10e256d5b2
scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
950 |
! ! |
0e10e256d5b2
scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
951 |
|
0e10e256d5b2
scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
952 |
!GraphicsContext methodsFor:'accessing-transformation'! |
0e10e256d5b2
scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
953 |
|
0e10e256d5b2
scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
954 |
scale |
0e10e256d5b2
scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
955 |
"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
|
956 |
|
707 | 957 |
transformation isNil ifTrue:[^ 1@1]. |
418
0e10e256d5b2
scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
958 |
^ transformation scale |
707 | 959 |
|
960 |
"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
|
961 |
! |
0e10e256d5b2
scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
962 |
|
0e10e256d5b2
scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
963 |
scale:aPoint |
0e10e256d5b2
scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
964 |
"set the scale factor of the transformation" |
0e10e256d5b2
scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
965 |
|
0e10e256d5b2
scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
966 |
transformation isNil ifTrue:[ |
1956 | 967 |
aPoint = 1 ifTrue:[^ self]. |
968 |
transformation := WindowingTransformation scale:aPoint translation:0 |
|
619 | 969 |
] ifFalse:[ |
1956 | 970 |
transformation scale:aPoint. |
619 | 971 |
] |
418
0e10e256d5b2
scale access methods moved from SimpleView
Claus Gittinger <cg@exept.de>
parents:
386
diff
changeset
|
972 |
|
619 | 973 |
"Modified: 27.4.1996 / 18:47:38 / cg" |
76 | 974 |
! |
975 |
||
976 |
transformation |
|
977 |
"return the transformation" |
|
978 |
||
979 |
^ transformation |
|
980 |
! |
|
981 |
||
982 |
transformation:aTransformation |
|
983 |
"set the transformation" |
|
984 |
||
985 |
transformation := aTransformation |
|
619 | 986 |
! |
987 |
||
1319 | 988 |
translateBy:aPoint |
989 |
"add to the translation offset of the transformation" |
|
990 |
||
991 |
transformation isNil ifTrue:[ |
|
1956 | 992 |
aPoint = 0 ifTrue:[^ self]. |
993 |
transformation := WindowingTransformation scale:1 translation:aPoint |
|
1319 | 994 |
] ifFalse:[ |
1956 | 995 |
transformation translateBy:aPoint |
1319 | 996 |
] |
997 |
||
998 |
"Created: 10.2.1997 / 13:50:22 / cg" |
|
999 |
! |
|
1000 |
||
619 | 1001 |
translation |
1002 |
"return the translation factor (as point) of the transformation" |
|
1003 |
||
1004 |
transformation isNil ifTrue:[^ 0@0]. |
|
1005 |
^ transformation translation |
|
1006 |
||
1007 |
"Created: 27.4.1996 / 18:46:41 / cg" |
|
1008 |
! |
|
1009 |
||
1010 |
translation:aPoint |
|
1011 |
"set the translation offset of the transformation" |
|
1012 |
||
1013 |
transformation isNil ifTrue:[ |
|
1956 | 1014 |
aPoint = 0 ifTrue:[^ self]. |
1015 |
transformation := WindowingTransformation scale:1 translation:aPoint |
|
619 | 1016 |
] ifFalse:[ |
1956 | 1017 |
transformation translation:aPoint. |
619 | 1018 |
] |
1019 |
||
1020 |
"Created: 27.4.1996 / 18:47:28 / cg" |
|
0 | 1021 |
! ! |
1022 |
||
755 | 1023 |
!GraphicsContext methodsFor:'backward compatibility'! |
1024 |
||
1025 |
withPattern:aPattern do:aBlock |
|
1026 |
|old| |
|
1027 |
||
1028 |
aPattern isColor ifTrue:[ |
|
1956 | 1029 |
old := paint. |
1030 |
self paint:aPattern. |
|
1031 |
aBlock value. |
|
1032 |
self paint:old |
|
755 | 1033 |
] ifFalse:[ |
1956 | 1034 |
old := mask. |
1035 |
self mask:aPattern. |
|
1036 |
aBlock value. |
|
1037 |
self mask:old |
|
755 | 1038 |
] |
1039 |
||
1040 |
"Modified: 28.5.1996 / 22:45:40 / cg" |
|
1041 |
! ! |
|
1042 |
||
71 | 1043 |
!GraphicsContext methodsFor:'basic displaying'! |
0 | 1044 |
|
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1045 |
displayArcX:x y:y width:width height:height from:startAngle angle:angle |
0 | 1046 |
"draw an arc in a box |
1047 |
- this could be recoded to draw using displayLine" |
|
1048 |
||
1049 |
^ self subclassResponsibility |
|
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1050 |
|
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1051 |
"Created: 8.5.1996 / 08:47:06 / cg" |
0 | 1052 |
! |
1053 |
||
2354
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1054 |
displayDottedRectangleX:x y:y width:w height:h |
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1055 |
"draw a dotted-line rectangle |
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1056 |
A general implementation is found here; deviceGC's |
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1057 |
may reimplement this if directly supported by the device" |
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1058 |
|
2747
04c41d416186
draw dotted line faster if display supports it.
Claus Gittinger <cg@exept.de>
parents:
2460
diff
changeset
|
1059 |
|lastX lastY x0 y0 oldStyle| |
04c41d416186
draw dotted line faster if display supports it.
Claus Gittinger <cg@exept.de>
parents:
2460
diff
changeset
|
1060 |
|
04c41d416186
draw dotted line faster if display supports it.
Claus Gittinger <cg@exept.de>
parents:
2460
diff
changeset
|
1061 |
((device platformName ~= 'WIN32') |
04c41d416186
draw dotted line faster if display supports it.
Claus Gittinger <cg@exept.de>
parents:
2460
diff
changeset
|
1062 |
or:[OperatingSystem isMSWINDOWSNTlike]) ifTrue:[ |
04c41d416186
draw dotted line faster if display supports it.
Claus Gittinger <cg@exept.de>
parents:
2460
diff
changeset
|
1063 |
oldStyle := lineStyle. |
04c41d416186
draw dotted line faster if display supports it.
Claus Gittinger <cg@exept.de>
parents:
2460
diff
changeset
|
1064 |
self lineStyle:#dotted. |
04c41d416186
draw dotted line faster if display supports it.
Claus Gittinger <cg@exept.de>
parents:
2460
diff
changeset
|
1065 |
self displayRectangleX:x y:y width:w height:h. |
04c41d416186
draw dotted line faster if display supports it.
Claus Gittinger <cg@exept.de>
parents:
2460
diff
changeset
|
1066 |
self lineStyle:oldStyle. |
04c41d416186
draw dotted line faster if display supports it.
Claus Gittinger <cg@exept.de>
parents:
2460
diff
changeset
|
1067 |
^ self. |
04c41d416186
draw dotted line faster if display supports it.
Claus Gittinger <cg@exept.de>
parents:
2460
diff
changeset
|
1068 |
]. |
2354
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1069 |
|
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1070 |
1 to:w-1 by:2 do:[:o | |
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1071 |
lastX := x + o. |
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1072 |
self displayPointX:lastX y:y. |
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1073 |
]. |
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1074 |
y0 := 1. |
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1075 |
lastX == (x+w-1) ifTrue:[ |
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1076 |
y0 := 0 |
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1077 |
]. |
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1078 |
y0 to:h-1 by:2 do:[:o | |
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1079 |
lastY := y+o. |
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1080 |
self displayPointX:x+w-1 y:lastY. |
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1081 |
]. |
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1082 |
x0 := w-2. |
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1083 |
lastY == (y+h-1) ifTrue:[ |
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1084 |
x0:= w-1 |
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1085 |
]. |
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1086 |
x0 to:0 by:-2 do:[:o | |
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1087 |
lastX := x+o. |
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1088 |
self displayPointX:lastX y:y+h-1. |
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1089 |
]. |
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1090 |
y0 := h-1. |
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1091 |
lastX == 0 ifTrue:[ |
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1092 |
y0 := h-1 |
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1093 |
]. |
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1094 |
y0 to:0 by:-2 do:[:o | |
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1095 |
self displayPointX:x y:y+o. |
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1096 |
]. |
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1097 |
|
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1098 |
"Modified: / 18.9.1998 / 16:31:09 / cg" |
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1099 |
! |
2755d3d1addd
added #displayDottedRectangle... (for win95)
Claus Gittinger <cg@exept.de>
parents:
2273
diff
changeset
|
1100 |
|
2392
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1101 |
displayHorizontalWavelineFromX:x0 y:y0 toX:x1 |
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1102 |
"draw a horizontal wave-line from x0/y0 to x1/y0" |
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1103 |
|
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1104 |
|w h pattern form x oldClip| |
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1105 |
|
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1106 |
"/ pattern := #[ |
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1107 |
"/ 2r00000000 2r00111100 |
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1108 |
"/ 2r00000000 2r11000011 |
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1109 |
"/ 2r11000011 2r00000000 |
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1110 |
"/ 2r00111100 2r00000000 |
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1111 |
"/ ]. |
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1112 |
"/ h := 4. |
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1113 |
"/ w := 16. |
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1114 |
|
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1115 |
"/ pattern := #[ |
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1116 |
"/ 2r00000000 2r01111000 |
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1117 |
"/ 2r00000000 2r10000100 |
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1118 |
"/ 2r10000001 2r00000000 |
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1119 |
"/ 2r01000010 2r00000000 |
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1120 |
"/ 2r00111100 2r00000000 |
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1121 |
"/ ]. |
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1122 |
"/ h := 5. |
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1123 |
"/ w := 14. |
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1124 |
|
2782 | 1125 |
"/ pattern := #[ |
1126 |
"/ 2r00000001 2r11100000 |
|
1127 |
"/ 2r00000010 2r00010000 |
|
1128 |
"/ 2r10000100 2r00000000 |
|
1129 |
"/ 2r01111000 2r00000000 |
|
1130 |
"/ ]. |
|
1131 |
"/ h := 4. |
|
1132 |
"/ w := 12. |
|
1133 |
"/ |
|
1134 |
"/ pattern := #[ |
|
1135 |
"/ 2r00000011 |
|
1136 |
"/ 2r11001100 |
|
1137 |
"/ 2r00110000 |
|
1138 |
"/ ]. |
|
1139 |
"/ h := 3. |
|
1140 |
"/ w := 8. |
|
1141 |
||
2392
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1142 |
pattern := #[ |
2782 | 1143 |
2r11000000 |
1144 |
2r00110000 |
|
2392
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1145 |
]. |
2782 | 1146 |
h := 2. |
1147 |
w := 4. |
|
1148 |
||
1149 |
form := Form width:w height:h fromArray:pattern. |
|
2392
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1150 |
|
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1151 |
oldClip := self clippingRectangleOrNil. |
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1152 |
self clippingRectangle:((x0 @ y0) corner:(x1 @ (y0+h))). |
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1153 |
|
2783
665caca8506e
care to use the same waveline origin
Claus Gittinger <cg@exept.de>
parents:
2782
diff
changeset
|
1154 |
x := x0 truncateTo:w. |
2392
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1155 |
[x <= x1] whileTrue:[ |
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1156 |
self displayForm:form x:x y:y0. |
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1157 |
x := x + w. |
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1158 |
]. |
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1159 |
self clippingRectangle:oldClip |
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1160 |
|
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1161 |
"Created: / 28.10.1998 / 15:31:41 / cg" |
2782 | 1162 |
"Modified: / 7.7.1999 / 00:08:30 / cg" |
2392
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1163 |
! |
5664d81a3ea4
added support for wave-line underlining
Claus Gittinger <cg@exept.de>
parents:
2360
diff
changeset
|
1164 |
|
726 | 1165 |
displayLineFromX:x0 y:y0 toX:x1 y:y1 |
1166 |
"draw a line from x0/y0 to x1/y1" |
|
0 | 1167 |
|
726 | 1168 |
^ self subclassResponsibility |
71 | 1169 |
|
726 | 1170 |
"Created: 28.5.1996 / 17:12:37 / cg" |
0 | 1171 |
! |
1172 |
||
26 | 1173 |
displayOpaqueForm:aForm x:x y:y |
0 | 1174 |
"draw a form at x/y; if the form has depth 1, 1's in the form are |
1175 |
drawn in current fg, 0's in current bg color. |
|
1176 |
If the form has depth ~~ 1, it is copied as is onto the receiver" |
|
1177 |
||
1178 |
^ self subclassResponsibility |
|
1179 |
! |
|
1180 |
||
1181 |
displayOpaqueString:aString from:index1 to:index2 x:x y:y |
|
1182 |
"draw part of a string with both fg and bg at x/y in current font" |
|
1183 |
||
1184 |
^ self subclassResponsibility |
|
1185 |
! |
|
1186 |
||
519 | 1187 |
displayPolygon:aPolygon |
1188 |
"draw a polygon |
|
1189 |
- this could be recoded to draw using displayLine" |
|
1190 |
||
1191 |
^ self subclassResponsibility |
|
1192 |
! |
|
1193 |
||
1194 |
displayRectangleX:x y:y width:w height:h |
|
1195 |
"draw a rectangle |
|
1196 |
- this could be recoded to draw using displayLine" |
|
1197 |
||
1198 |
^ self subclassResponsibility |
|
1199 |
! |
|
1200 |
||
0 | 1201 |
displayString:aString from:index1 to:index2 x:x y:y |
1202 |
"draw part of a string with fg at x/y in current font" |
|
1203 |
||
1204 |
^ self subclassResponsibility |
|
1205 |
! ! |
|
1206 |
||
519 | 1207 |
!GraphicsContext methodsFor:'basic filling'! |
0 | 1208 |
|
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1209 |
fillArcX:x y:y width:w height:h from:start angle:angle |
519 | 1210 |
"fill an arc with current paint color" |
0 | 1211 |
|
519 | 1212 |
^ self subclassResponsibility |
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1213 |
|
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1214 |
"Created: 8.5.1996 / 08:47:44 / cg" |
0 | 1215 |
! |
1216 |
||
519 | 1217 |
fillPolygon:points |
1218 |
"fill a polygon with current paint color" |
|
0 | 1219 |
|
519 | 1220 |
^ self subclassResponsibility |
157 | 1221 |
! |
1222 |
||
519 | 1223 |
fillRectangleX:x y:y width:w height:h |
1224 |
"fill a rectangle with current paint color" |
|
0 | 1225 |
|
519 | 1226 |
^ self subclassResponsibility |
1227 |
! ! |
|
0 | 1228 |
|
519 | 1229 |
!GraphicsContext methodsFor:'bit blitting'! |
0 | 1230 |
|
519 | 1231 |
copyFrom:aGC toX:dstX y:dstY |
1232 |
"copy from a drawable - maybe self" |
|
0 | 1233 |
|
519 | 1234 |
self copyFrom:aGC x:0 y:0 toX:dstX y:dstY width:aGC width height:aGC height |
0 | 1235 |
! |
1236 |
||
519 | 1237 |
copyFrom:aGC x:srcX y:srcY toX:dstX y:dstY width:w height:h |
1238 |
"copy from a drawable - maybe self" |
|
0 | 1239 |
|
519 | 1240 |
^ self subclassResponsibility |
0 | 1241 |
! |
1242 |
||
519 | 1243 |
copyFrom:aGC x:dstX y:dstY width:w height:h |
1244 |
"copy from a drawable - maybe self" |
|
0 | 1245 |
|
519 | 1246 |
self copyFrom:aGC x:0 y:0 toX:dstX y:dstY width:w height:h |
1247 |
! ! |
|
0 | 1248 |
|
519 | 1249 |
!GraphicsContext methodsFor:'drawing'! |
0 | 1250 |
|
719
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
1251 |
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
|
1252 |
"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
|
1253 |
|
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
1254 |
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
|
1255 |
|
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
1256 |
"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
|
1257 |
! |
62f1217f0084
prepare for separation of the view hierarchy; moved clipStuff up into here
Claus Gittinger <cg@exept.de>
parents:
717
diff
changeset
|
1258 |
|
12 | 1259 |
displayArcIn:aRectangle from:startAngle angle:angle |
1260 |
"draw an arc in a box" |
|
0 | 1261 |
|
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1262 |
self |
1956 | 1263 |
displayArcX:(aRectangle left) |
1264 |
y:(aRectangle top) |
|
1265 |
width:(aRectangle width) |
|
1266 |
height:(aRectangle height) |
|
1267 |
from:startAngle |
|
1268 |
angle:angle |
|
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1269 |
|
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1270 |
"Modified: 8.5.1996 / 08:35:00 / cg" |
0 | 1271 |
! |
1272 |
||
12 | 1273 |
displayArcOrigin:origin corner:corner from:startAngle angle:angle |
1274 |
"draw an arc in a box" |
|
0 | 1275 |
|
1276 |
|left top right bot| |
|
1277 |
||
1278 |
left := origin x. |
|
1279 |
top := origin y. |
|
1280 |
right := corner x. |
|
1281 |
bot := corner y. |
|
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1282 |
self |
1956 | 1283 |
displayArcX:left |
1284 |
y:top |
|
1285 |
width:(right - left + 1) |
|
1286 |
height:(bot - top + 1) |
|
1287 |
from:startAngle |
|
1288 |
angle:angle |
|
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1289 |
|
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1290 |
"Modified: 8.5.1996 / 08:35:25 / cg" |
0 | 1291 |
! |
1292 |
||
726 | 1293 |
displayArcX:x y:y w:w h:h from:startAngle angle:angle |
1294 |
"draw an arc; apply transformation if nonNil" |
|
1295 |
||
1296 |
self obsoleteMethodWarning:'use #displayArcX:y:width:height:from:angle:'. |
|
1297 |
self displayArcX:x y:y width:w height:h from:startAngle angle:angle |
|
1298 |
||
1299 |
"Modified: 8.5.1996 / 08:46:56 / cg" |
|
1300 |
! |
|
1301 |
||
519 | 1302 |
displayCircle:aPoint radius:r |
1303 |
"draw a circle around a center point" |
|
1304 |
||
1305 |
self displayCircleX:(aPoint x) y:(aPoint y) radius:r |
|
1306 |
! |
|
1307 |
||
12 | 1308 |
displayCircleIn:aRectangle |
0 | 1309 |
"draw a circle in a box" |
1310 |
||
1311 |
self |
|
1956 | 1312 |
displayArcX:(aRectangle left) |
1313 |
y:(aRectangle top) |
|
1314 |
width:(aRectangle width) |
|
1315 |
height:(aRectangle height) |
|
1316 |
from:0 |
|
1317 |
angle:360 |
|
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1318 |
|
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1319 |
"Modified: 8.5.1996 / 08:35:40 / cg" |
0 | 1320 |
! |
1321 |
||
12 | 1322 |
displayCircleX:x y:y radius:r |
1323 |
"draw a circle around a center point" |
|
0 | 1324 |
|
1325 |
|d| |
|
1326 |
d := 2 * r. |
|
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1327 |
self |
1956 | 1328 |
displayArcX:(x - r) |
1329 |
y:(y - r) |
|
1330 |
width:d |
|
1331 |
height:d |
|
1332 |
from:0 |
|
1333 |
angle:360 |
|
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1334 |
|
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
1335 |
"Modified: 8.5.1996 / 08:36:03 / cg" |
519 | 1336 |
! |
1337 |
||
1953 | 1338 |
displayForm:aFormOrImage |
1339 |
"draw a form (or image) at the origin" |
|
1340 |
||
1341 |
self displayForm:aFormOrImage x:0 y:0 |
|
1342 |
||
1343 |
"Modified: / 24.4.1997 / 16:00:11 / cg" |
|
1344 |
"Created: / 9.11.1997 / 00:50:52 / cg" |
|
1345 |
! |
|
1346 |
||
1654
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1347 |
displayForm:aFormOrImage at:aPoint |
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1348 |
"draw a form (or image)" |
519 | 1349 |
|
1654
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1350 |
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
|
1351 |
|
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1352 |
"Modified: 24.4.1997 / 16:00:11 / cg" |
519 | 1353 |
! |
1354 |
||
1654
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1355 |
displayForm:aFormOrImage x:x y:y |
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1356 |
"draw a form (or image) at x/y; |
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1357 |
if the form has depth 1, 1's in the form are |
726 | 1358 |
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
|
1359 |
If the form has depth ~~ 1, the current fg color setting is ignored." |
726 | 1360 |
|
1361 |
|fg bg f noColor| |
|
1362 |
||
1654
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1363 |
aFormOrImage depth > 1 ifTrue:[ |
1956 | 1364 |
self displayOpaqueForm:aFormOrImage x:x y:y. |
1365 |
^ self. |
|
1654
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1366 |
]. |
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1367 |
|
726 | 1368 |
fg := paint. |
1369 |
bg := bgPaint. |
|
1370 |
f := function. |
|
1371 |
||
1372 |
f ~~ #copy ifTrue:[ |
|
1956 | 1373 |
self error:'function not supported'. |
1374 |
^ self |
|
726 | 1375 |
]. |
1376 |
||
1377 |
noColor := Color noColor. |
|
1654
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1378 |
|
726 | 1379 |
" |
1380 |
stamp out fg-pixels |
|
1381 |
" |
|
1382 |
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
|
1383 |
self displayOpaqueForm:aFormOrImage x:x y:y. |
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1384 |
|
726 | 1385 |
" |
1386 |
or-in fg-pixels |
|
1387 |
" |
|
1388 |
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
|
1389 |
self displayOpaqueForm:aFormOrImage x:x y:y. |
726 | 1390 |
self paint:fg on:fg function:f. |
1391 |
||
1654
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1392 |
"Modified: 24.4.1997 / 16:01:43 / cg" |
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1393 |
! |
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1394 |
|
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1395 |
displayImage:aFormOrImage at:aPoint |
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1396 |
"draw an image (or form). |
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1397 |
Provided for ST-80 compatibilty; |
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1398 |
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
|
1399 |
|
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1400 |
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
|
1401 |
|
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1402 |
"Modified: 24.4.1997 / 16:02:43 / cg" |
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1403 |
! |
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1404 |
|
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1405 |
displayImage:aFormOrImage x:x y:y |
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1406 |
"draw an image (or form). |
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1407 |
Provided for ST-80 compatibilty; |
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1408 |
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
|
1409 |
|
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1410 |
self displayForm:aFormOrImage x:x y:y |
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1411 |
|
93c6430368d7
added #displayImage for ST-80 compatibility
Claus Gittinger <cg@exept.de>
parents:
1651
diff
changeset
|
1412 |
"Created: 24.4.1997 / 16:03:03 / cg" |
726 | 1413 |
! |
1414 |
||
519 | 1415 |
displayLineFrom:point1 to:point2 |
1416 |
"draw a line" |
|
1417 |
||
1418 |
self displayLineFromX:(point1 x) y:(point1 y) |
|
1419 |
toX:(point2 x) y:(point2 y) |
|
1420 |
! |
|
1421 |
||
1506
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1422 |
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
|
1423 |
"draw a line using a brush. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1424 |
Here, a slow fallback is used, drawing into a |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1425 |
temporary bitmap first, which is then displayed" |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1426 |
|
2436 | 1427 |
|deltaX deltaY dx dy px py destX destY p tempForm |
1506
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1428 |
xMin xMax yMin yMax x1 x2 y1 y2| |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1429 |
|
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1430 |
xStart < xEnd ifTrue:[ |
1956 | 1431 |
xMin := xStart. |
1432 |
xMax := xEnd. |
|
1506
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1433 |
] ifFalse:[ |
1956 | 1434 |
xMin := xEnd. |
1435 |
xMax := xStart |
|
1506
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1436 |
]. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1437 |
yStart < yEnd ifTrue:[ |
1956 | 1438 |
yMin := yStart. |
1439 |
yMax := yEnd. |
|
1506
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1440 |
] ifFalse:[ |
1956 | 1441 |
yMin := yEnd. |
1442 |
yMax := yStart |
|
1506
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1443 |
]. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1444 |
|
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1445 |
tempForm := Form width:(xMax-xMin+1+aForm width) |
1956 | 1446 |
height:(yMax-yMin+1+aForm height) |
1447 |
depth:aForm depth |
|
1448 |
on:device. |
|
1506
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1449 |
tempForm clear. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1450 |
tempForm paint:(Color colorId:1) on:(Color colorId:0). |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1451 |
tempForm function:#or. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1452 |
|
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1453 |
((yStart = yEnd and:[xStart < xEnd]) |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1454 |
or: [yStart < yEnd]) ifTrue:[ |
1956 | 1455 |
x1 := xStart. y1 := yStart. |
1456 |
x2 := xEnd. y2 := yEnd. |
|
1506
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1457 |
] ifFalse:[ |
1956 | 1458 |
x1 := xEnd. y1 := yEnd. |
1459 |
x2 := xStart. y2 := yStart. |
|
1506
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1460 |
]. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1461 |
|
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1462 |
x1 := x1 - xMin. x2 := x2 - xMin. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1463 |
y1 := y1 - yMin. y2 := y2 - yMin. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1464 |
|
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1465 |
destX := x1. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1466 |
destY := y1. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1467 |
|
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1468 |
"/ bresenham ... |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1469 |
|
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1470 |
deltaX := x2 - x1. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1471 |
deltaY := y2 - y1. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1472 |
|
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1473 |
dx := deltaX sign. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1474 |
dy := deltaY sign. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1475 |
px := deltaY abs. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1476 |
py := deltaX abs. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1477 |
|
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1478 |
tempForm displayForm:aForm x:destX y:destY. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1479 |
|
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1480 |
py > px ifTrue:[ |
1956 | 1481 |
"horizontal" |
2436 | 1482 |
p := py // 2. |
1956 | 1483 |
py timesRepeat:[ |
1484 |
destX := destX + dx. |
|
2436 | 1485 |
(p := p - px) < 0 ifTrue:[ |
1956 | 1486 |
destY := destY + dy. |
2436 | 1487 |
p := p + py |
1956 | 1488 |
]. |
1489 |
tempForm displayForm:aForm x:destX y:destY. |
|
1490 |
] |
|
1506
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1491 |
] ifFalse:[ |
1956 | 1492 |
"vertical" |
2436 | 1493 |
p := px // 2. |
1956 | 1494 |
px timesRepeat:[ |
1495 |
destY := destY + dy. |
|
2436 | 1496 |
(p := p - py) < 0 ifTrue:[ |
1956 | 1497 |
destX := destX + dx. |
2436 | 1498 |
p := p + px |
1956 | 1499 |
]. |
1500 |
tempForm displayForm:aForm x:destX y:destY |
|
1501 |
] |
|
1506
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1502 |
]. |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1503 |
self displayForm:tempForm |
1956 | 1504 |
x:xMin-aForm offset x |
1505 |
y:yMin-aForm offset y. |
|
1506
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1506 |
tempForm close |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1507 |
|
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1508 |
"Modified: 1.4.1997 / 21:29:06 / cg" |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1509 |
! |
1b6c39325902
added lineDraw with a brush.
Claus Gittinger <cg@exept.de>
parents:
1443
diff
changeset
|
1510 |
|
519 | 1511 |
displayOpaqueString:aString at:aPoint |
1512 |
"draw a string with both fg and bg" |
|
1513 |
||
1514 |
self displayOpaqueString:aString x:(aPoint x) y:(aPoint y) |
|
1515 |
! |
|
1516 |
||
1517 |
displayOpaqueString:aString from:start to:stop at:aPoint |
|
1518 |
"draw part of a string - drawing both fg and bg" |
|
1519 |
||
1520 |
^ self displayOpaqueString:aString from:start to:stop x:aPoint x y:aPoint y |
|
1521 |
! |
|
1522 |
||
1523 |
displayOpaqueString:aString x:x y:y |
|
1524 |
"draw a string with both fg and bg" |
|
1525 |
||
1526 |
self displayOpaqueString:aString from:1 to:(aString size) x:x y:y |
|
1527 |
! |
|
1528 |
||
1647
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1529 |
displayOpaqueString:aString x:x y:y angle:drawAngle |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1530 |
"draw a string along a (possibly non-horizontal) line, |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1531 |
drawing both fg and bg pixels. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1532 |
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
|
1533 |
a horizontal draw. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1534 |
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
|
1535 |
which is rotated and finally drawn as usual. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1536 |
NOTICE: due to the rotation of the temporary bitmap, this is a slow |
1956 | 1537 |
operation - not to be used with cillions of strings ..." |
1647
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1538 |
|
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1539 |
self |
1956 | 1540 |
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
|
1541 |
|
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1542 |
" |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1543 |
|v| |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1544 |
|
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1545 |
v := View new. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1546 |
v extent:300@200. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1547 |
v openAndWait. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1548 |
0 to:360 by:45 do:[:a | |
1956 | 1549 |
v paint:Color black on:Color red. |
1550 |
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
|
1551 |
]. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1552 |
" |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1553 |
|
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1554 |
"in contrast to non-opaque draw: |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1555 |
|v| |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1556 |
|
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1557 |
v := View new. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1558 |
v extent:300@200. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1559 |
v openAndWait. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1560 |
0 to:360 by:45 do:[:a | |
1956 | 1561 |
v paint:Color black on:Color red. |
1562 |
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
|
1563 |
]. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1564 |
" |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1565 |
|
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1566 |
"Modified: 23.4.1997 / 17:50:23 / cg" |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1567 |
! |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1568 |
|
519 | 1569 |
displayPoint:aPoint |
1570 |
"draw a pixel" |
|
1571 |
||
1572 |
self displayPointX:(aPoint x) y:(aPoint y) |
|
1573 |
! |
|
1574 |
||
1575 |
displayPointX:x y:y |
|
1576 |
"draw a point at x/y" |
|
1577 |
||
1578 |
self displayLineFromX:x y:y toX:x y:y |
|
1579 |
! |
|
1580 |
||
1581 |
displayRectangle:aRectangle |
|
1582 |
"draw a rectangle" |
|
1583 |
||
1584 |
self displayRectangleX:(aRectangle left) |
|
1585 |
y:(aRectangle top) |
|
1586 |
width:(aRectangle width) |
|
1587 |
height:(aRectangle height) |
|
1588 |
! |
|
1589 |
||
1590 |
displayRectangleOrigin:origin corner:corner |
|
1591 |
"draw a rectangle" |
|
1592 |
||
1593 |
|top left| |
|
1594 |
||
1595 |
left := origin x. |
|
1596 |
top := origin y. |
|
1597 |
self displayRectangleX:left y:top |
|
1956 | 1598 |
width:(corner x - left) |
1599 |
height:(corner y - top) |
|
563 | 1600 |
|
1601 |
"Modified: 13.4.1996 / 20:58:31 / cg" |
|
519 | 1602 |
! |
1603 |
||
2069 | 1604 |
displayRectangleOrigin:origin extent:extent |
1605 |
"draw a rectangle" |
|
1606 |
||
1607 |
self displayRectangleX:(origin x) y:(origin y) |
|
1608 |
width:(extent x) |
|
1609 |
height:(extent y) |
|
1610 |
||
1611 |
"Modified: 13.4.1996 / 20:58:31 / cg" |
|
1612 |
! |
|
1613 |
||
519 | 1614 |
displayString:aString at:aPoint |
1615 |
"draw a string - drawing fg only" |
|
1616 |
||
1617 |
self displayString:aString x:aPoint x y:aPoint y |
|
1618 |
! |
|
1619 |
||
2460
a1c5c2053f42
added #displayString:centeredAtX:y:
Claus Gittinger <cg@exept.de>
parents:
2436
diff
changeset
|
1620 |
displayString:aString centeredAtX:x y:y |
a1c5c2053f42
added #displayString:centeredAtX:y:
Claus Gittinger <cg@exept.de>
parents:
2436
diff
changeset
|
1621 |
"draw a string - drawing fg only" |
a1c5c2053f42
added #displayString:centeredAtX:y:
Claus Gittinger <cg@exept.de>
parents:
2436
diff
changeset
|
1622 |
|
a1c5c2053f42
added #displayString:centeredAtX:y:
Claus Gittinger <cg@exept.de>
parents:
2436
diff
changeset
|
1623 |
|w h| |
a1c5c2053f42
added #displayString:centeredAtX:y:
Claus Gittinger <cg@exept.de>
parents:
2436
diff
changeset
|
1624 |
|
a1c5c2053f42
added #displayString:centeredAtX:y:
Claus Gittinger <cg@exept.de>
parents:
2436
diff
changeset
|
1625 |
w := aString widthOn:self. |
a1c5c2053f42
added #displayString:centeredAtX:y:
Claus Gittinger <cg@exept.de>
parents:
2436
diff
changeset
|
1626 |
h := aString heightOn:self. |
a1c5c2053f42
added #displayString:centeredAtX:y:
Claus Gittinger <cg@exept.de>
parents:
2436
diff
changeset
|
1627 |
self displayString:aString x:x-(w/2) y:y-(h/2) |
a1c5c2053f42
added #displayString:centeredAtX:y:
Claus Gittinger <cg@exept.de>
parents:
2436
diff
changeset
|
1628 |
! |
a1c5c2053f42
added #displayString:centeredAtX:y:
Claus Gittinger <cg@exept.de>
parents:
2436
diff
changeset
|
1629 |
|
519 | 1630 |
displayString:aString from:start to:stop at:aPoint |
1631 |
"draw part of a string - drawing fg only" |
|
1632 |
||
1633 |
^ self displayString:aString from:start to:stop x:aPoint x y:aPoint y |
|
1634 |
! |
|
1635 |
||
1636 |
displayString:aString x:x y:y |
|
1637 |
"draw a string - drawing fg only" |
|
1638 |
||
1639 |
self displayString:aString from:1 to:(aString size) x:x y:y |
|
726 | 1640 |
! |
1641 |
||
1641
b7c128be3394
added #displayString:x:y:angle:
Claus Gittinger <cg@exept.de>
parents:
1506
diff
changeset
|
1642 |
displayString:aString x:x y:y angle:drawAngle |
b7c128be3394
added #displayString:x:y:angle:
Claus Gittinger <cg@exept.de>
parents:
1506
diff
changeset
|
1643 |
"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
|
1644 |
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
|
1645 |
a horizontal draw. |
b7c128be3394
added #displayString:x:y:angle:
Claus Gittinger <cg@exept.de>
parents:
1506
diff
changeset
|
1646 |
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
|
1647 |
which is rotated and finally drawn as usual. |
1647
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1648 |
NOTICE: due to the rotation of the temporary bitmap, this is a slow |
1956 | 1649 |
operation - not to be used with cillions of strings ..." |
1647
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1650 |
|
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1651 |
self |
1956 | 1652 |
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
|
1653 |
|
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1654 |
" |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1655 |
|v| |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1656 |
|
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1657 |
v := View new. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1658 |
v extent:300@200. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1659 |
v openAndWait. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1660 |
0 to:360 by:90 do:[:a | |
1956 | 1661 |
v paint:Color black. |
1662 |
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
|
1663 |
]. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1664 |
" |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1665 |
" |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1666 |
|v| |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1667 |
|
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1668 |
v := View new. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1669 |
v extent:400@400. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1670 |
v openAndWait. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1671 |
0 to:360 by:5 do:[:a | |
1956 | 1672 |
v paint:Color black. |
1673 |
v displayString:'.........hello' x:200 y:200 angle:a. |
|
1647
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1674 |
]. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1675 |
" |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1676 |
" |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1677 |
|v| |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1678 |
|
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1679 |
v := View new. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1680 |
v extent:200@100. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1681 |
v openAndWait. |
1651
85f2b72134f1
can now also draw opaqueStrings with arbitrary angle
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
1682 |
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
|
1683 |
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
|
1684 |
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
|
1685 |
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
|
1686 |
v displayString:' hello' x:90 y:50 angle:270. |
1647
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1687 |
" |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1688 |
" |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1689 |
|v| |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1690 |
|
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1691 |
v := View new. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1692 |
v extent:200@100. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1693 |
v openAndWait. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1694 |
v displayString:'hello' x:50 y:50 angle:0. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1695 |
v displayString:'hello' x:50 y:50 angle:45. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1696 |
v displayString:'hello' x:50 y:50 angle:90. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1697 |
v displayString:'hello' x:50 y:50 angle:135. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1698 |
v displayString:'hello' x:50 y:50 angle:180. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1699 |
v displayString:'hello' x:50 y:50 angle:225. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1700 |
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
|
1701 |
v displayString:'hello' x:50 y:50 angle:315. |
1647
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1702 |
" |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1703 |
|
1651
85f2b72134f1
can now also draw opaqueStrings with arbitrary angle
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
1704 |
"Modified: 24.4.1997 / 12:51:25 / cg" |
1647
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1705 |
! |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1706 |
|
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1707 |
displayString:aString x:x y:y angle:drawAngle opaque:opaque |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1708 |
"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
|
1709 |
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
|
1710 |
a horizontal draw. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1711 |
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
|
1712 |
which is rotated and finally drawn as usual. |
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1713 |
NOTICE: due to the rotation of the temporary bitmap, this is a slow |
2032
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1714 |
operation - not to be used with cillions of strings ... |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1715 |
CAVEAT: if the string is not a real string (i.e. a LabelAndIcon), |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1716 |
this can (currently) only be done opaque" |
1641
b7c128be3394
added #displayString:x:y:angle:
Claus Gittinger <cg@exept.de>
parents:
1506
diff
changeset
|
1717 |
|
2436 | 1718 |
|angle tempForm tempImage w h asc desc a xN yN p r |
1651
85f2b72134f1
can now also draw opaqueStrings with arbitrary angle
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
1719 |
dX dY sin cos m| |
1641
b7c128be3394
added #displayString:x:y:angle:
Claus Gittinger <cg@exept.de>
parents:
1506
diff
changeset
|
1720 |
|
b7c128be3394
added #displayString:x:y:angle:
Claus Gittinger <cg@exept.de>
parents:
1506
diff
changeset
|
1721 |
angle := drawAngle. |
b7c128be3394
added #displayString:x:y:angle:
Claus Gittinger <cg@exept.de>
parents:
1506
diff
changeset
|
1722 |
angle >= 360 ifTrue:[ |
2032
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1723 |
angle := angle - (((angle // 360)) * 360) |
1641
b7c128be3394
added #displayString:x:y:angle:
Claus Gittinger <cg@exept.de>
parents:
1506
diff
changeset
|
1724 |
] ifFalse:[ |
2032
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1725 |
angle < 0 ifTrue:[ |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1726 |
angle := angle - (((angle // 360)) * 360). |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1727 |
angle := angle + 360 |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1728 |
]. |
1641
b7c128be3394
added #displayString:x:y:angle:
Claus Gittinger <cg@exept.de>
parents:
1506
diff
changeset
|
1729 |
]. |
b7c128be3394
added #displayString:x:y:angle:
Claus Gittinger <cg@exept.de>
parents:
1506
diff
changeset
|
1730 |
|
b7c128be3394
added #displayString:x:y:angle:
Claus Gittinger <cg@exept.de>
parents:
1506
diff
changeset
|
1731 |
angle = 0 ifTrue:[ |
2032
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1732 |
opaque ifTrue:[ |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1733 |
^ self displayOpaqueString:aString x:x y:y |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1734 |
]. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1735 |
^ self displayString:aString x:x y:y |
1641
b7c128be3394
added #displayString:x:y:angle:
Claus Gittinger <cg@exept.de>
parents:
1506
diff
changeset
|
1736 |
]. |
b7c128be3394
added #displayString:x:y:angle:
Claus Gittinger <cg@exept.de>
parents:
1506
diff
changeset
|
1737 |
|
2032
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1738 |
aString isString ifTrue:[ |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1739 |
"/ a real string; |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1740 |
"/ do it in a monochrome form (for speed) |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1741 |
|
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1742 |
w := font widthOf:aString. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1743 |
h := font height. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1744 |
asc := font ascent. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1745 |
desc := h - asc. |
1641
b7c128be3394
added #displayString:x:y:angle:
Claus Gittinger <cg@exept.de>
parents:
1506
diff
changeset
|
1746 |
|
2032
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1747 |
tempForm := Form |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1748 |
width:w |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1749 |
height:h |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1750 |
on:device. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1751 |
|
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1752 |
tempForm clear. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1753 |
tempForm font:font. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1754 |
tempForm displayString:aString x:0 y:asc. |
1641
b7c128be3394
added #displayString:x:y:angle:
Claus Gittinger <cg@exept.de>
parents:
1506
diff
changeset
|
1755 |
|
2032
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1756 |
tempImage := (Depth1Image fromForm:tempForm) rotated:angle. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1757 |
] ifFalse:[ |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1758 |
"/ something wierd (labelAndIcon ..) |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1759 |
"/ do it in a deep form. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1760 |
"/ CAVEAT: this can only be done opaque ... |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1761 |
|
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1762 |
w := aString widthOn:self. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1763 |
h := aString heightOn:self. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1764 |
asc := font ascent. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1765 |
desc := h - asc. |
1641
b7c128be3394
added #displayString:x:y:angle:
Claus Gittinger <cg@exept.de>
parents:
1506
diff
changeset
|
1766 |
|
2032
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1767 |
tempForm := Form |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1768 |
width:w |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1769 |
height:h |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1770 |
depth:(device depth) |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1771 |
on:device. |
1641
b7c128be3394
added #displayString:x:y:angle:
Claus Gittinger <cg@exept.de>
parents:
1506
diff
changeset
|
1772 |
|
2032
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1773 |
tempForm paint:bgPaint. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1774 |
tempForm fillRectangleX:0 y:0 width:w height:h. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1775 |
tempForm paint:paint on:bgPaint. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1776 |
tempForm font:font. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1777 |
aString displayOn:tempForm x:0 y:asc opaque:true. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1778 |
tempImage := ((Image implementorForDepth:(device depth)) fromForm:tempForm) rotated:angle. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1779 |
]. |
1651
85f2b72134f1
can now also draw opaqueStrings with arbitrary angle
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
1780 |
opaque ifTrue:[ |
2032
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1781 |
m := ImageMask width:w height:h. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1782 |
m bits:(ByteArray new:(h * m bytesPerRow) withAll:16rFF). |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1783 |
m := m rotated:angle |
1651
85f2b72134f1
can now also draw opaqueStrings with arbitrary angle
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
1784 |
]. |
85f2b72134f1
can now also draw opaqueStrings with arbitrary angle
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
1785 |
|
2032
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1786 |
"/ compute final position of rotated form |
1641
b7c128be3394
added #displayString:x:y:angle:
Claus Gittinger <cg@exept.de>
parents:
1506
diff
changeset
|
1787 |
"/ adjust position for baseline. |
b7c128be3394
added #displayString:x:y:angle:
Claus Gittinger <cg@exept.de>
parents:
1506
diff
changeset
|
1788 |
|
b7c128be3394
added #displayString:x:y:angle:
Claus Gittinger <cg@exept.de>
parents:
1506
diff
changeset
|
1789 |
angle = 90 ifTrue:[ |
2032
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1790 |
xN := x - desc. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1791 |
yN := y. |
1641
b7c128be3394
added #displayString:x:y:angle:
Claus Gittinger <cg@exept.de>
parents:
1506
diff
changeset
|
1792 |
] ifFalse:[ |
2032
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1793 |
angle = 180 ifTrue:[ |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1794 |
xN := x - w. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1795 |
yN := y - desc "+ h - asc". |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1796 |
] ifFalse:[ |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1797 |
angle = 270 ifTrue:[ |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1798 |
xN := x - asc. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1799 |
yN := y - w. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1800 |
] ifFalse:[ |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1801 |
"/ sigh: since the new image has different dimensions, |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1802 |
"/ the computation is somewhat more difficult here. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1803 |
"/ remember: the image has been rotated around its center, |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1804 |
"/ then shifted towards the top-left origin. |
1647
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1805 |
|
2032
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1806 |
p := (w@h) / 2. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1807 |
r := p r. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1808 |
a := p angle. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1809 |
sin := angle degreesToRadians sin. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1810 |
cos := angle degreesToRadians cos. |
1647
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1811 |
|
2032
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1812 |
angle < 90 ifTrue:[ |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1813 |
dX := desc * sin. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1814 |
dY := asc * cos. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1815 |
xN := x - dX. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1816 |
yN := y - dY |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1817 |
] ifFalse:[ |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1818 |
angle < 180 ifTrue:[ |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1819 |
dX := asc * sin. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1820 |
dY := desc * cos. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1821 |
xN := x + dX - (tempImage width). |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1822 |
yN := y + dY. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1823 |
] ifFalse:[ |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1824 |
angle < 270 ifTrue:[ |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1825 |
dX := desc * sin. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1826 |
dY := asc * cos. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1827 |
xN := x - dX - (tempImage width). |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1828 |
yN := y - dY - (tempImage height) |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1829 |
] ifFalse:[ |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1830 |
dX := asc * sin. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1831 |
dY := desc * cos. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1832 |
xN := x + dX. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1833 |
yN := y + dY - (tempImage height). |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1834 |
] |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1835 |
] |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1836 |
]. |
1641
b7c128be3394
added #displayString:x:y:angle:
Claus Gittinger <cg@exept.de>
parents:
1506
diff
changeset
|
1837 |
|
2032
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1838 |
tempImage mask:nil. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1839 |
] |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1840 |
]. |
1641
b7c128be3394
added #displayString:x:y:angle:
Claus Gittinger <cg@exept.de>
parents:
1506
diff
changeset
|
1841 |
]. |
2032
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1842 |
|
1647
2be7ad21d324
displayString - with angle finished
Claus Gittinger <cg@exept.de>
parents:
1643
diff
changeset
|
1843 |
opaque ifTrue:[ |
2032
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1844 |
p := paint. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1845 |
self paint:bgPaint. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1846 |
self displayForm:m x:xN y:yN. |
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1847 |
self paint:p. |
1651
85f2b72134f1
can now also draw opaqueStrings with arbitrary angle
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
1848 |
]. |
85f2b72134f1
can now also draw opaqueStrings with arbitrary angle
Claus Gittinger <cg@exept.de>
parents:
1647
diff
changeset
|
1849 |
self displayForm:tempImage x:xN y:yN. |
1641
b7c128be3394
added #displayString:x:y:angle:
Claus Gittinger <cg@exept.de>
parents:
1506
diff
changeset
|
1850 |
|
2032
cc11a2c3918d
partial fix for angleDrawing of non-strings (with labelAndIcons)
Claus Gittinger <cg@exept.de>
parents:
2031
diff
changeset
|
1851 |
"Modified: / 29.1.1998 / 13:23:23 / cg" |
1641
b7c128be3394
added #displayString:x:y:angle:
Claus Gittinger <cg@exept.de>
parents:
1506
diff
changeset
|
1852 |
! |
b7c128be3394
added #displayString:x:y:angle:
Claus Gittinger <cg@exept.de>
parents:
1506
diff
changeset
|
1853 |
|
726 | 1854 |
fillArcX:x y:y w:w h:h from:startAngle angle:angle |
1855 |
"draw a filled arc; apply transformation if nonNil" |
|
1856 |
||
1857 |
self obsoleteMethodWarning:'use #fillArcX:y:width:height:from:angle:'. |
|
1858 |
self fillArcX:x y:y width:w height:h from:startAngle angle:angle |
|
1859 |
||
1860 |
"Modified: 8.5.1996 / 08:47:52 / cg" |
|
0 | 1861 |
! ! |
519 | 1862 |
|
1863 |
!GraphicsContext methodsFor:'drawing in device coordinates'! |
|
1864 |
||
1865 |
displayDeviceLineFromX:x1 y:y1 toX:x2 y:y2 |
|
1866 |
"draw a line in device coordinates" |
|
1867 |
||
1868 |
|sav| |
|
1869 |
||
1870 |
sav := transformation. |
|
1871 |
transformation := nil. |
|
1872 |
self displayLineFromX:x1 y:y1 toX:x2 y:y2. |
|
1873 |
transformation := sav |
|
1874 |
! |
|
1875 |
||
1876 |
fillDeviceRectangleX:x y:y width:w height:h |
|
1877 |
"fill a rectangle with current paint color (device coordinates)" |
|
1878 |
||
1879 |
|sav| |
|
1880 |
||
1881 |
sav := transformation. |
|
1882 |
transformation := nil. |
|
1883 |
self fillRectangleX:x y:y width:w height:h. |
|
1884 |
transformation := sav |
|
1885 |
! ! |
|
1886 |
||
713 | 1887 |
!GraphicsContext methodsFor:'edge drawing'! |
1888 |
||
1889 |
drawEdgesForX:x y:y width:w height:h level:l |
|
2255
d53b5e22b82b
added edgeStyle: #softWin95 (draws grey)
Claus Gittinger <cg@exept.de>
parents:
2069
diff
changeset
|
1890 |
shadow:shadowColor light:lightColor |
d53b5e22b82b
added edgeStyle: #softWin95 (draws grey)
Claus Gittinger <cg@exept.de>
parents:
2069
diff
changeset
|
1891 |
halfShadow:halfShadowColor halfLight:halfLightColor |
d53b5e22b82b
added edgeStyle: #softWin95 (draws grey)
Claus Gittinger <cg@exept.de>
parents:
2069
diff
changeset
|
1892 |
style:edgeStyle |
713 | 1893 |
|
1894 |
"draw 3D edges into a rectangle" |
|
1895 |
||
1896 |
|topLeftFg botRightFg topLeftHalfFg botRightHalfFg |
|
1897 |
count "{ Class: SmallInteger }" |
|
1898 |
r "{ Class: SmallInteger }" |
|
1899 |
b "{ Class: SmallInteger }" |
|
1900 |
xi "{ Class: SmallInteger }" |
|
1901 |
yi "{ Class: SmallInteger }" |
|
1902 |
run paint| |
|
1903 |
||
1904 |
count := l. |
|
1905 |
(count < 0) ifTrue:[ |
|
2255
d53b5e22b82b
added edgeStyle: #softWin95 (draws grey)
Claus Gittinger <cg@exept.de>
parents:
2069
diff
changeset
|
1906 |
topLeftFg := shadowColor. |
d53b5e22b82b
added edgeStyle: #softWin95 (draws grey)
Claus Gittinger <cg@exept.de>
parents:
2069
diff
changeset
|
1907 |
botRightFg := lightColor. |
d53b5e22b82b
added edgeStyle: #softWin95 (draws grey)
Claus Gittinger <cg@exept.de>
parents:
2069
diff
changeset
|
1908 |
topLeftHalfFg := halfShadowColor. |
d53b5e22b82b
added edgeStyle: #softWin95 (draws grey)
Claus Gittinger <cg@exept.de>
parents:
2069
diff
changeset
|
1909 |
botRightHalfFg := halfLightColor. |
d53b5e22b82b
added edgeStyle: #softWin95 (draws grey)
Claus Gittinger <cg@exept.de>
parents:
2069
diff
changeset
|
1910 |
count := count negated |
713 | 1911 |
] ifFalse:[ |
2255
d53b5e22b82b
added edgeStyle: #softWin95 (draws grey)
Claus Gittinger <cg@exept.de>
parents:
2069
diff
changeset
|
1912 |
topLeftFg := lightColor. |
d53b5e22b82b
added edgeStyle: #softWin95 (draws grey)
Claus Gittinger <cg@exept.de>
parents:
2069
diff
changeset
|
1913 |
botRightFg := shadowColor. |
d53b5e22b82b
added edgeStyle: #softWin95 (draws grey)
Claus Gittinger <cg@exept.de>
parents:
2069
diff
changeset
|
1914 |
topLeftHalfFg := halfLightColor. |
d53b5e22b82b
added edgeStyle: #softWin95 (draws grey)
Claus Gittinger <cg@exept.de>
parents:
2069
diff
changeset
|
1915 |
botRightHalfFg := halfShadowColor. |
713 | 1916 |
]. |
1917 |
topLeftHalfFg isNil ifTrue:[ |
|
2255
d53b5e22b82b
added edgeStyle: #softWin95 (draws grey)
Claus Gittinger <cg@exept.de>
parents:
2069
diff
changeset
|
1918 |
topLeftHalfFg := topLeftFg |
713 | 1919 |
]. |
1920 |
botRightHalfFg isNil ifTrue:[ |
|
2255
d53b5e22b82b
added edgeStyle: #softWin95 (draws grey)
Claus Gittinger <cg@exept.de>
parents:
2069
diff
changeset
|
1921 |
botRightHalfFg := botRightFg |
713 | 1922 |
]. |
1923 |
||
1924 |
r := x + w - 1. "right" |
|
1925 |
b := y + h - 1. "bottom" |
|
1926 |
||
1927 |
self lineWidth:0. |
|
1928 |
||
1929 |
"top and left edges" |
|
2255
d53b5e22b82b
added edgeStyle: #softWin95 (draws grey)
Claus Gittinger <cg@exept.de>
parents:
2069
diff
changeset
|
1930 |
((edgeStyle == #soft or:[edgeStyle == #softWin95]) and:["l" count > 0]) ifTrue:[ |
d53b5e22b82b
added edgeStyle: #softWin95 (draws grey)
Claus Gittinger <cg@exept.de>
parents:
2069
diff
changeset
|
1931 |
paint := topLeftHalfFg |
713 | 1932 |
] ifFalse:[ |
2255
d53b5e22b82b
added edgeStyle: #softWin95 (draws grey)
Claus Gittinger <cg@exept.de>
parents:
2069
diff
changeset
|
1933 |
paint := topLeftFg |
713 | 1934 |
]. |
1935 |
self paint:paint. |
|
1936 |
||
1937 |
0 to:(count - 1) do:[:i | |
|
2255
d53b5e22b82b
added edgeStyle: #softWin95 (draws grey)
Claus Gittinger <cg@exept.de>
parents:
2069
diff
changeset
|
1938 |
run := y + i. |
d53b5e22b82b
added edgeStyle: #softWin95 (draws grey)
Claus Gittinger <cg@exept.de>
parents:
2069
diff
changeset
|
1939 |
run < b ifTrue:[ |
d53b5e22b82b
added edgeStyle: #softWin95 (draws grey)
Claus Gittinger <cg@exept.de>
parents:
2069
diff
changeset
|
1940 |
self displayDeviceLineFromX:x y:run toX:r y:run. "top" |
d53b5e22b82b
added edgeStyle: #softWin95 (draws grey)
Claus Gittinger <cg@exept.de>
parents:
2069
diff
changeset
|
1941 |
]. |
d53b5e22b82b
added edgeStyle: #softWin95 (draws grey)
Claus Gittinger <cg@exept.de>
parents:
2069
diff
changeset
|
1942 |
run := x + i. |
d53b5e22b82b
added edgeStyle: #softWin95 (draws grey)
Claus Gittinger <cg@exept.de>
parents:
2069
diff
changeset
|
1943 |
self displayDeviceLineFromX:run y:y toX:run y:b "left" |
713 | 1944 |
]. |
2255
d53b5e22b82b
added edgeStyle: #softWin95 (draws grey)
Claus Gittinger <cg@exept.de>
parents:
2069
diff
changeset
|
1945 |
(edgeStyle == #soft or:[edgeStyle == #softWin95]) ifTrue:[ |
713 | 1946 |
" |
2255
d53b5e22b82b
added edgeStyle: #softWin95 (draws grey)
Claus Gittinger <cg@exept.de>
parents:
2069
diff
changeset
|
1947 |
self paint:topLeftFg. |
d53b5e22b82b
added edgeStyle: #softWin95 (draws grey)
Claus Gittinger <cg@exept.de>
parents:
2069
diff
changeset
|
1948 |
self displayDeviceLineFromX:x y:y toX:r y:y. |
d53b5e22b82b
added edgeStyle: #softWin95 (draws grey)
Claus Gittinger <cg@exept.de>
parents:
2069
diff
changeset
|
1949 |
self displayDeviceLineFromX:x y:y toX:x y:b |
713 | 1950 |
" |
2255
d53b5e22b82b
added edgeStyle: #softWin95 (draws grey)
Claus Gittinger <cg@exept.de>
parents:
2069
diff
changeset
|
1951 |
(l > 1) ifTrue:[ |
d53b5e22b82b
added edgeStyle: #softWin95 (draws grey)
Claus Gittinger <cg@exept.de>
parents:
2069
diff
changeset
|
1952 |
edgeStyle == #softWin95 ifTrue:[ |
d53b5e22b82b
added edgeStyle: #softWin95 (draws grey)
Claus Gittinger <cg@exept.de>
parents:
2069
diff
changeset
|
1953 |
self paint:(Color veryLightGrey). |
d53b5e22b82b
added edgeStyle: #softWin95 (draws grey)
Claus Gittinger <cg@exept.de>
parents:
2069
diff
changeset
|
1954 |
] ifFalse:[ |
2273 | 1955 |
(l > 2 and:[edgeStyle == #soft]) ifTrue:[ |
1956 |
self paint:(device blackColor). |
|
1957 |
] ifFalse:[ |
|
1958 |
self paint:halfLightColor. |
|
1959 |
] |
|
2255
d53b5e22b82b
added edgeStyle: #softWin95 (draws grey)
Claus Gittinger <cg@exept.de>
parents:
2069
diff
changeset
|
1960 |
]. |
d53b5e22b82b
added edgeStyle: #softWin95 (draws grey)
Claus Gittinger <cg@exept.de>
parents:
2069
diff
changeset
|
1961 |
self displayDeviceLineFromX:x y:y toX:r y:y. |
d53b5e22b82b
added edgeStyle: #softWin95 (draws grey)
Claus Gittinger <cg@exept.de>
parents:
2069
diff
changeset
|
1962 |
self displayDeviceLineFromX:x y:y toX:x y:b. |
d53b5e22b82b
added edgeStyle: #softWin95 (draws grey)
Claus Gittinger <cg@exept.de>
parents:
2069
diff
changeset
|
1963 |
] |
713 | 1964 |
]. |
1965 |
||
1966 |
xi := x + 1. |
|
1967 |
yi := y + 1. |
|
1968 |
||
1969 |
"/ does not look good |
|
1970 |
"/ style == #st80 iftrue:[ |
|
1971 |
"/ yi := yi + 1 |
|
1972 |
"/ ]. |
|
1973 |
||
1974 |
"bottom and right edges" |
|
2255
d53b5e22b82b
added edgeStyle: #softWin95 (draws grey)
Claus Gittinger <cg@exept.de>
parents:
2069
diff
changeset
|
1975 |
((edgeStyle == #soft or:[edgeStyle == #softWin95]) |
d53b5e22b82b
added edgeStyle: #softWin95 (draws grey)
Claus Gittinger <cg@exept.de>
parents:
2069
diff
changeset
|
1976 |
"new:" and:[count > 1]) ifTrue:[ |
d53b5e22b82b
added edgeStyle: #softWin95 (draws grey)
Claus Gittinger <cg@exept.de>
parents:
2069
diff
changeset
|
1977 |
paint := botRightHalfFg |
713 | 1978 |
] ifFalse:[ |
2255
d53b5e22b82b
added edgeStyle: #softWin95 (draws grey)
Claus Gittinger <cg@exept.de>
parents:
2069
diff
changeset
|
1979 |
paint := botRightFg |
713 | 1980 |
]. |
1981 |
||
1982 |
self paint:paint. |
|
1983 |
0 to:(count - 1) do:[:i | |
|
2255
d53b5e22b82b
added edgeStyle: #softWin95 (draws grey)
Claus Gittinger <cg@exept.de>
parents:
2069
diff
changeset
|
1984 |
run := b - i. |
d53b5e22b82b
added edgeStyle: #softWin95 (draws grey)
Claus Gittinger <cg@exept.de>
parents:
2069
diff
changeset
|
1985 |
run > y ifTrue:[ |
d53b5e22b82b
added edgeStyle: #softWin95 (draws grey)
Claus Gittinger <cg@exept.de>
parents:
2069
diff
changeset
|
1986 |
self displayDeviceLineFromX:xi-1 y:run toX:r y:run. "bottom" |
d53b5e22b82b
added edgeStyle: #softWin95 (draws grey)
Claus Gittinger <cg@exept.de>
parents:
2069
diff
changeset
|
1987 |
]. |
d53b5e22b82b
added edgeStyle: #softWin95 (draws grey)
Claus Gittinger <cg@exept.de>
parents:
2069
diff
changeset
|
1988 |
run := r - i. |
d53b5e22b82b
added edgeStyle: #softWin95 (draws grey)
Claus Gittinger <cg@exept.de>
parents:
2069
diff
changeset
|
1989 |
self displayDeviceLineFromX:run y:yi-1 toX:run y:b. "right" |
d53b5e22b82b
added edgeStyle: #softWin95 (draws grey)
Claus Gittinger <cg@exept.de>
parents:
2069
diff
changeset
|
1990 |
xi := xi + 1. |
d53b5e22b82b
added edgeStyle: #softWin95 (draws grey)
Claus Gittinger <cg@exept.de>
parents:
2069
diff
changeset
|
1991 |
yi := yi + 1 |
713 | 1992 |
]. |
2255
d53b5e22b82b
added edgeStyle: #softWin95 (draws grey)
Claus Gittinger <cg@exept.de>
parents:
2069
diff
changeset
|
1993 |
((edgeStyle == #soft or:[edgeStyle == #softWin95]) |
d53b5e22b82b
added edgeStyle: #softWin95 (draws grey)
Claus Gittinger <cg@exept.de>
parents:
2069
diff
changeset
|
1994 |
and:[l > 1]) ifTrue:[ |
d53b5e22b82b
added edgeStyle: #softWin95 (draws grey)
Claus Gittinger <cg@exept.de>
parents:
2069
diff
changeset
|
1995 |
self paint:(device blackColor) "shadowColor". |
d53b5e22b82b
added edgeStyle: #softWin95 (draws grey)
Claus Gittinger <cg@exept.de>
parents:
2069
diff
changeset
|
1996 |
self displayDeviceLineFromX:x y:b toX:r y:b. |
d53b5e22b82b
added edgeStyle: #softWin95 (draws grey)
Claus Gittinger <cg@exept.de>
parents:
2069
diff
changeset
|
1997 |
self displayDeviceLineFromX:r y:y toX:r y:b |
1443 | 1998 |
]. |
1999 |
||
2000 |
self edgeDrawn:#all |
|
2001 |
||
2273 | 2002 |
"Modified: / 24.8.1998 / 18:23:02 / cg" |
1443 | 2003 |
! |
713 | 2004 |
|
1443 | 2005 |
edgeDrawn:whichOne |
2006 |
"a redefinable hook for views which like to draw |
|
2007 |
over their edges (some checkToggles do). |
|
2008 |
Nothing done here." |
|
2009 |
||
2010 |
"Created: 7.3.1997 / 17:59:07 / cg" |
|
713 | 2011 |
! ! |
2012 |
||
519 | 2013 |
!GraphicsContext methodsFor:'filling'! |
2014 |
||
2015 |
fillArc:origin radius:r from:startAngle angle:angle |
|
2016 |
"draw a filled arc around a point" |
|
2017 |
||
2018 |
|d| |
|
2019 |
d := 2 * r. |
|
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
2020 |
self |
1956 | 2021 |
fillArcX:(origin x - r) |
2022 |
y:(origin y - r) |
|
2023 |
width:d |
|
2024 |
height:d |
|
2025 |
from:startAngle |
|
2026 |
angle:angle |
|
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
2027 |
|
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
2028 |
"Modified: 8.5.1996 / 08:41:54 / cg" |
519 | 2029 |
! |
2030 |
||
563 | 2031 |
fillArcIn:aRectangle from:startAngle angle:angle |
2032 |
"draw a filled arc in a box" |
|
2033 |
||
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
2034 |
self |
1956 | 2035 |
fillArcX:(aRectangle left) |
2036 |
y:(aRectangle top) |
|
2037 |
width:(aRectangle width) |
|
2038 |
height:(aRectangle height) |
|
2039 |
from:startAngle |
|
2040 |
angle:angle |
|
563 | 2041 |
|
2042 |
"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
|
2043 |
"Modified: 8.5.1996 / 08:42:13 / cg" |
563 | 2044 |
! |
2045 |
||
2046 |
fillArcOrigin:origin corner:corner from:startAngle angle:angle |
|
2047 |
"draw a filled arc in a box" |
|
2048 |
||
2049 |
|left top right bot| |
|
2050 |
||
2051 |
left := origin x. |
|
2052 |
top := origin y. |
|
2053 |
right := corner x. |
|
2054 |
bot := corner y. |
|
2055 |
self |
|
1956 | 2056 |
fillArcX:left |
2057 |
y:top |
|
2058 |
width:(right - left + 1) |
|
2059 |
height:(bot - top + 1) |
|
2060 |
from:startAngle |
|
2061 |
angle:angle |
|
563 | 2062 |
|
2063 |
"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
|
2064 |
"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
|
2065 |
! |
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
2066 |
|
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
2067 |
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
|
2068 |
"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
|
2069 |
|
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
2070 |
self |
1956 | 2071 |
fillArcX:x |
2072 |
y:y |
|
2073 |
width:w |
|
2074 |
height:h |
|
2075 |
from:startAngle |
|
2076 |
angle:(endAngle - startAngle) |
|
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
2077 |
|
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
2078 |
"Created: 8.5.1996 / 08:52:41 / cg" |
563 | 2079 |
! |
2080 |
||
519 | 2081 |
fillCircle:aPoint radius:aNumber |
2082 |
"draw a filled circle around aPoint" |
|
2083 |
||
2084 |
self fillCircleX:(aPoint x) y:(aPoint y) radius:aNumber |
|
2085 |
! |
|
2086 |
||
563 | 2087 |
fillCircleIn:aRectangle |
2088 |
"draw a filled circle in a box" |
|
2089 |
||
2090 |
self |
|
1956 | 2091 |
fillArcX:(aRectangle left) |
2092 |
y:(aRectangle top) |
|
2093 |
width:(aRectangle width) |
|
2094 |
height:(aRectangle height) |
|
2095 |
from:0 |
|
2096 |
angle:360 |
|
563 | 2097 |
|
2098 |
"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
|
2099 |
"Modified: 8.5.1996 / 08:42:38 / cg" |
563 | 2100 |
! |
2101 |
||
519 | 2102 |
fillCircleX:x y:y radius:r |
2103 |
"draw a filled circle around x@y" |
|
2104 |
||
2105 |
|d| |
|
2106 |
||
2107 |
d := 2 * r. |
|
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
2108 |
self |
1956 | 2109 |
fillArcX:(x - r) |
2110 |
y:(y - r) |
|
2111 |
width:d |
|
2112 |
height:d |
|
2113 |
from:0 |
|
2114 |
angle:360 |
|
653
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
2115 |
|
0ad3de022f8b
fill/drawArc..w:h:.. renamed to ...width:height:...
Claus Gittinger <cg@exept.de>
parents:
619
diff
changeset
|
2116 |
"Modified: 8.5.1996 / 08:43:02 / cg" |
519 | 2117 |
! |
2118 |
||
2119 |
fillRectangle:aRectangle |
|
2120 |
"fill a rectangle with current paint color" |
|
2121 |
||
2122 |
self fillRectangleX:(aRectangle left) |
|
2123 |
y:(aRectangle top) |
|
2124 |
width:(aRectangle width) |
|
2125 |
height:(aRectangle height) |
|
563 | 2126 |
! |
2127 |
||
2128 |
fillRectangleOrigin:origin corner:corner |
|
2129 |
"draw a filled rectangle" |
|
2130 |
||
2131 |
|top left| |
|
2132 |
||
2133 |
left := origin x. |
|
2134 |
top := origin y. |
|
2135 |
self fillRectangleX:left y:top |
|
1956 | 2136 |
width:(corner x - left) |
2137 |
height:(corner y - top) |
|
563 | 2138 |
|
2139 |
"Created: 13.4.1996 / 20:58:16 / cg" |
|
519 | 2140 |
! ! |
2141 |
||
2142 |
!GraphicsContext methodsFor:'initialization'! |
|
2143 |
||
2144 |
initialize |
|
2145 |
"set up some useful default values" |
|
2146 |
||
952 | 2147 |
paint isNil ifTrue:[paint := Black]. |
2148 |
bgPaint isNil ifTrue:[bgPaint := White]. |
|
519 | 2149 |
function := #copy. |
2150 |
lineWidth := 1. |
|
2151 |
lineStyle := #solid. |
|
2152 |
joinStyle := #miter. |
|
2153 |
capStyle := #butt. |
|
2154 |
font := DefaultFont. |
|
952 | 2155 |
|
2156 |
"Modified: 17.7.1996 / 13:00:12 / cg" |
|
519 | 2157 |
! ! |
2158 |
||
2159 |
!GraphicsContext methodsFor:'misc'! |
|
2160 |
||
3033 | 2161 |
clippedTo:aRectangle do:aBlock |
2162 |
|oldClip| |
|
2163 |
||
2164 |
oldClip := clipRect. |
|
2165 |
self clippingRectangle:aRectangle. |
|
2166 |
||
2167 |
aBlock value. |
|
2168 |
||
2169 |
self clippingRectangle:oldClip |
|
2170 |
||
2171 |
! |
|
2172 |
||
519 | 2173 |
flush |
585 | 2174 |
"send all buffered drawing to the device." |
519 | 2175 |
|
742 | 2176 |
device flush |
585 | 2177 |
|
742 | 2178 |
"Modified: 28.5.1996 / 20:22:26 / cg" |
519 | 2179 |
! ! |
2180 |
||
1203
49dd13574c7d
dont use Black/White when drawing;
Claus Gittinger <cg@exept.de>
parents:
952
diff
changeset
|
2181 |
!GraphicsContext class methodsFor:'documentation'! |
519 | 2182 |
|
2183 |
version |
|
3033 | 2184 |
^ '$Header: /cvs/stx/stx/libview/GraphicsContext.st,v 1.85 1999-11-19 14:37:34 ps Exp $' |
519 | 2185 |
! ! |
2186 |
GraphicsContext initialize! |