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