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