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