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