author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Thu, 30 Jun 2016 22:07:40 +0100 | |
branch | jv |
changeset 7399 | 143bc9c1a08e |
parent 7318 | 83b501bbf3b0 |
child 7541 | 39940e2446a5 |
permissions | -rw-r--r-- |
721
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1 |
" |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
3 |
All Rights Reserved |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
4 |
|
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
5 |
This software is furnished under a license and may be used |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
6 |
only in accordance with the terms of that license and with the |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
7 |
inclusion of the above copyright notice. This software may not |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
8 |
be provided or otherwise made available to, or used by, any |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
9 |
other person. No title to or ownership of the software is |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
10 |
hereby transferred. |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
11 |
" |
3339 | 12 |
"{ Package: 'stx:libview' }" |
13 |
||
7285
d047c5fb149a
Compatibility: reintroduce `device` instvar in `GraphicsMedium`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6800
diff
changeset
|
14 |
"{ NameSpace: Smalltalk }" |
d047c5fb149a
Compatibility: reintroduce `device` instvar in `GraphicsMedium`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6800
diff
changeset
|
15 |
|
6472 | 16 |
Object subclass:#GraphicsMedium |
7285
d047c5fb149a
Compatibility: reintroduce `device` instvar in `GraphicsMedium`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6800
diff
changeset
|
17 |
instanceVariableNames:'gc device width height realized' |
721
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
18 |
classVariableNames:'' |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
19 |
poolDictionaries:'' |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
20 |
category:'Graphics-Support' |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
21 |
! |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
22 |
|
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
23 |
!GraphicsMedium class methodsFor:'documentation'! |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
24 |
|
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
25 |
copyright |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
26 |
" |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
27 |
COPYRIGHT (c) 1989 by Claus Gittinger |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
28 |
All Rights Reserved |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
29 |
|
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
30 |
This software is furnished under a license and may be used |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
31 |
only in accordance with the terms of that license and with the |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
32 |
inclusion of the above copyright notice. This software may not |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
33 |
be provided or otherwise made available to, or used by, any |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
34 |
other person. No title to or ownership of the software is |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
35 |
hereby transferred. |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
36 |
" |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
37 |
! |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
38 |
|
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
39 |
documentation |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
40 |
" |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
41 |
this is an abstract superclass for all kinds of drawables which |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
42 |
have a physical representation (i.e. have an extent). Dont use messages |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
43 |
from here - it will vanish soon. |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
44 |
|
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
45 |
[Instance variables:] |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
46 |
|
5321 | 47 |
width <SmallInteger> the width (device dependent, usually pixels or inches) |
48 |
height <SmallInteger> the height (device dependent, usually pixels or inches) |
|
721
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
49 |
|
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
50 |
[author:] |
5321 | 51 |
Claus Gittinger |
721
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
52 |
" |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
53 |
! ! |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
54 |
|
6472 | 55 |
!GraphicsMedium class methodsFor:'instance creation'! |
56 |
||
57 |
new |
|
58 |
"create a new drawable - take the current display as |
|
59 |
its device (for now, this may be changed until the view is |
|
60 |
physically created)" |
|
61 |
||
62 |
" |
|
63 |
'Warning: DeviceGraphicsContext (' print. self name print. ') should not be created with new' printNL. |
|
64 |
" |
|
65 |
^ self onDevice:Screen current. |
|
66 |
! |
|
67 |
||
68 |
on:aDevice |
|
69 |
"create a new drawable on aDevice" |
|
70 |
||
71 |
<resource:#obsolete> |
|
72 |
||
73 |
"/ send out a warning: #on: is typically used to create a view |
|
74 |
"/ operating on a model. |
|
75 |
"/ Please use #onDevice: to avoid confusion. |
|
76 |
||
77 |
self obsoleteMethodWarning:'use #onDevice:'. |
|
78 |
^ self onDevice:aDevice |
|
79 |
||
80 |
"Modified: 5.6.1997 / 21:04:16 / cg" |
|
81 |
! |
|
82 |
||
83 |
onDevice:aDevice |
|
84 |
"create a new drawable on aDevice" |
|
85 |
||
86 |
^ self basicNew initializeForDevice:aDevice. |
|
87 |
! ! |
|
88 |
||
89 |
!GraphicsMedium class methodsFor:'Signal constants'! |
|
90 |
||
91 |
drawingOnClosedDrawableSignal |
|
92 |
"return the signal which is raised, if drawing is attempted |
|
93 |
on a closed drawable. |
|
94 |
This is especially useful, if a forked thread animates |
|
95 |
a view in the background, and is not properly synchronized |
|
96 |
with the window thread - i.e. the window gets closed by the user, |
|
97 |
and the background process continues to draw. |
|
98 |
In this case, the background thread should handle this signal |
|
99 |
and terminate itself in the handler." |
|
100 |
||
101 |
^ GraphicsContext drawingOnClosedDrawableSignal |
|
102 |
||
103 |
"demonstration1: (error if closed by the windowManager): |
|
104 |
||
105 |
|v| |
|
106 |
||
107 |
v := StandardSystemView new openAndWait. |
|
108 |
[ |
|
109 |
[true] whileTrue:[ |
|
110 |
|x y| |
|
111 |
||
112 |
x := Random nextIntegerBetween:0 and:(v width). |
|
113 |
y := Random nextIntegerBetween:0 and:(v height). |
|
114 |
v displayString:'hello' x:x y:y. |
|
115 |
Delay waitForSeconds:0.5. |
|
116 |
] |
|
117 |
] fork. |
|
118 |
" |
|
119 |
"demonstration2: (no error if closed by the windowManager): |
|
120 |
||
121 |
|v| |
|
122 |
||
123 |
v := StandardSystemView new openAndWait. |
|
124 |
[ |
|
125 |
v class drawingOnClosedDrawableSignal handle:[:ex | |
|
126 |
ex return |
|
127 |
] do:[ |
|
128 |
[true] whileTrue:[ |
|
129 |
|x y| |
|
130 |
||
131 |
x := Random nextIntegerBetween:0 and:(v width). |
|
132 |
y := Random nextIntegerBetween:0 and:(v height). |
|
133 |
v displayString:'hello' x:x y:y. |
|
134 |
Delay waitForSeconds:0.5. |
|
135 |
] |
|
136 |
] |
|
137 |
] fork. |
|
138 |
" |
|
139 |
||
140 |
"Created: / 29.1.1998 / 13:10:41 / cg" |
|
141 |
"Modified: / 29.1.1998 / 13:11:14 / cg" |
|
142 |
! ! |
|
143 |
||
144 |
!GraphicsMedium class methodsFor:'accessing-defaults'! |
|
145 |
||
146 |
defaultFont |
|
147 |
"get the default font used for drawing" |
|
148 |
||
149 |
^ GraphicsContext defaultFont |
|
150 |
! |
|
151 |
||
152 |
defaultFont:aFont |
|
153 |
"set the default font used for drawing" |
|
154 |
||
155 |
GraphicsContext defaultFont:aFont |
|
156 |
! ! |
|
157 |
||
158 |
!GraphicsMedium methodsFor:'Compatibility-ST80'! |
|
159 |
||
160 |
displayArc:origin radius:radius from:startAngle angle:angle |
|
161 |
"draw an arc around a point" |
|
162 |
||
163 |
self |
|
164 |
displayArcX:(origin x - radius) |
|
165 |
y:(origin y - radius) |
|
166 |
width:(radius * 2) |
|
167 |
height:(radius * 2) |
|
168 |
from:startAngle |
|
169 |
angle:angle |
|
170 |
||
171 |
"Modified: 8.5.1996 / 08:34:43 / cg" |
|
172 |
! |
|
173 |
||
174 |
displayArcBoundedBy:boundingBox startAngle:startAngle sweepAngle:sweepAngle |
|
175 |
"draw an arc/circle/ellipse - ST-80 compatibility" |
|
176 |
||
177 |
^ self displayArcX:(boundingBox left) |
|
178 |
y:(boundingBox top) |
|
179 |
width:(boundingBox width) |
|
180 |
height:(boundingBox height) |
|
181 |
from:startAngle |
|
182 |
angle:sweepAngle |
|
183 |
||
184 |
"Created: / 14.11.1997 / 21:04:19 / cg" |
|
185 |
! |
|
186 |
||
187 |
displayArcBoundedBy:boundingBox startAngle:startAngle sweepAngle:sweepAngle at:origin |
|
188 |
"draw an arc/circle/ellipse - ST-80 compatibility" |
|
189 |
||
190 |
^ self displayArcX:(boundingBox left + origin x) |
|
191 |
y:(boundingBox top + origin y) |
|
192 |
width:(boundingBox width) |
|
193 |
height:(boundingBox height) |
|
194 |
from:startAngle |
|
195 |
angle:sweepAngle |
|
196 |
! |
|
197 |
||
198 |
displayLineFrom:startPoint to:endPoint translateBy:anOffset |
|
199 |
"draw a line - ST-80 compatibility" |
|
200 |
||
201 |
self displayLineFrom:(startPoint + anOffset) |
|
202 |
to:(endPoint + anOffset) |
|
203 |
! |
|
204 |
||
205 |
displayPolyline:aPolygon |
|
206 |
"draw a polygon - ST-80 compatibility" |
|
207 |
||
208 |
^ self displayPolygon:aPolygon |
|
209 |
! |
|
210 |
||
211 |
displayRectangularBorder:aRectangle |
|
212 |
"draw a rectangle - ST-80 compatibility" |
|
213 |
||
214 |
self displayRectangle:aRectangle |
|
215 |
! |
|
216 |
||
217 |
displayRectangularBorder:aRectangle at:aPoint |
|
218 |
"draw a rectangle - ST-80 compatibility" |
|
219 |
||
220 |
self displayRectangle:(aRectangle translateBy:aPoint) |
|
221 |
! |
|
222 |
||
223 |
displayWedgeBoundedBy:boundingBox startAngle:startAngle sweepAngle:sweepAngle |
|
224 |
"fill an arc/circle/ellipse - ST-80 compatibility" |
|
225 |
||
226 |
^ self fillArcX:(boundingBox left) |
|
227 |
y:(boundingBox top) |
|
228 |
width:(boundingBox width) |
|
229 |
height:(boundingBox height) |
|
230 |
from:startAngle |
|
231 |
angle:sweepAngle |
|
232 |
||
233 |
"Created: 27.1.1997 / 15:50:14 / cg" |
|
234 |
! |
|
235 |
||
236 |
displayWedgeBoundedBy:boundingBox startAngle:startAngle sweepAngle:sweepAngle at:origin |
|
237 |
"fill an arc/circle/ellipse - ST-80 compatibility" |
|
238 |
||
239 |
^ self fillArcX:(boundingBox left + origin x) |
|
240 |
y:(boundingBox top + origin y) |
|
241 |
width:(boundingBox width) |
|
242 |
height:(boundingBox height) |
|
243 |
from:startAngle |
|
244 |
angle:sweepAngle |
|
245 |
! |
|
246 |
||
247 |
findFont:aFontDescription |
|
248 |
"given a fontDescription, return a device font for it |
|
249 |
on my device." |
|
250 |
||
251 |
^ aFontDescription onDevice:self device |
|
252 |
||
253 |
"Modified: 28.5.1996 / 20:22:29 / cg" |
|
254 |
! |
|
255 |
||
256 |
key |
|
257 |
^ self id |
|
258 |
! |
|
259 |
||
260 |
phase |
|
261 |
"return the origin within the mask (used to draw with patterns). |
|
262 |
This is an alias for ST/X's #maskOrigin" |
|
263 |
||
264 |
^ self maskOrigin |
|
265 |
! |
|
266 |
||
267 |
phase:aPoint |
|
268 |
"set the origin within the mask (used to draw with patterns). |
|
269 |
This is an alias for ST/X's #maskOrigin:" |
|
270 |
||
271 |
^ self maskOrigin:aPoint |
|
272 |
! |
|
273 |
||
274 |
setDevicePattern:aColorOrMask |
|
275 |
"ST/X can paint in any color or image" |
|
276 |
||
277 |
self paint:aColorOrMask |
|
278 |
! |
|
279 |
||
280 |
tilePhase |
|
281 |
"return the origin within the mask (used to draw with patterns). |
|
282 |
This is an alias for ST/X's #maskOrigin" |
|
283 |
||
284 |
^ self maskOrigin |
|
285 |
||
286 |
"Created: 4.6.1996 / 15:26:39 / cg" |
|
287 |
! |
|
288 |
||
289 |
tilePhase:aPoint |
|
290 |
"set the origin within the mask (used to draw with patterns). |
|
291 |
This is an alias for ST/X's #maskOrigin" |
|
292 |
||
293 |
^ self maskOrigin:aPoint |
|
294 |
||
295 |
"Created: 4.6.1996 / 15:26:49 / cg" |
|
296 |
! |
|
297 |
||
298 |
widthOfString:aString |
|
299 |
"given a string, return its width in pixels if |
|
300 |
drawn on the receivers device." |
|
301 |
||
302 |
gc == self ifTrue:[ |
|
303 |
^ super widthOfString:aString. |
|
304 |
]. |
|
305 |
^ gc widthOfString:aString. |
|
306 |
||
307 |
"Modified: 28.5.1996 / 20:22:22 / cg" |
|
308 |
! |
|
309 |
||
310 |
widthOfString:aString from:start to:stop |
|
311 |
"given a string, return the width in pixels if |
|
312 |
a substring is drawn on the receivers device." |
|
313 |
||
314 |
gc == self ifTrue:[ |
|
315 |
^ super widthOfString:aString from:start to:stop. |
|
316 |
]. |
|
317 |
^ gc widthOfString:aString from:start to:stop. |
|
318 |
||
319 |
"Modified: 28.5.1996 / 20:22:18 / cg" |
|
320 |
! ! |
|
321 |
||
3880 | 322 |
!GraphicsMedium methodsFor:'Compatibility-Squeak'! |
2947 | 323 |
|
3339 | 324 |
copyBits:aRectangle from:aForm at:srcOrigin clippingBox:clippingBox rule:rule fillColor:fillColor |
325 |
|f oldClip oldFunction| |
|
326 |
||
327 |
(f := rule) isInteger ifTrue:[ |
|
5321 | 328 |
"/ ST-80 compatibility: numeric rule |
6472 | 329 |
f := #(clear and andReverse copy andInverted noop xor or nor equiv invert orInverted copyInverted |
330 |
orReverse nand set) at:(rule + 1). |
|
3339 | 331 |
]. |
332 |
||
6472 | 333 |
oldFunction := gc function. |
334 |
oldClip := gc clippingRectangleOrNil. |
|
335 |
||
336 |
gc clippingRectangle:clippingBox. |
|
337 |
gc function:f. |
|
338 |
||
339 |
gc |
|
5321 | 340 |
copyFrom:aForm |
341 |
x:srcOrigin x y:srcOrigin y |
|
342 |
toX:aRectangle left y:aRectangle top |
|
343 |
width:aRectangle width height:aRectangle height. |
|
3339 | 344 |
|
6472 | 345 |
gc clippingRectangle:oldClip. |
346 |
gc function:oldFunction. |
|
347 |
||
348 |
" |
|
349 |
|dst src| |
|
350 |
||
351 |
dst := Form width:8 height:8 fromArray:#[ |
|
352 |
2r00000000 |
|
353 |
2r00000000 |
|
354 |
2r00000000 |
|
355 |
2r00000000 |
|
356 |
2r11111111 |
|
357 |
2r11111111 |
|
358 |
2r11111111 |
|
359 |
2r11111111 |
|
360 |
]. |
|
361 |
src := Form width:8 height:8 fromArray:#[ |
|
362 |
2r00001111 |
|
363 |
2r00001111 |
|
364 |
2r00001111 |
|
365 |
2r00001111 |
|
366 |
2r00001111 |
|
367 |
2r00001111 |
|
368 |
2r00001111 |
|
369 |
2r00001111 |
|
370 |
]. |
|
371 |
||
372 |
dst copyBits:(0@0 corner:8@8) from:src at:0@0 clippingBox:(0@0 corner:8@8) rule:15 fillColor:Color black. |
|
373 |
dst inspect |
|
374 |
||
375 |
" |
|
376 |
||
377 |
"Modified: / 23.10.2000 / 16:50:44 / martin" |
|
3339 | 378 |
|
379 |
" |
|
380 |
|dst src| |
|
381 |
||
382 |
dst := Form width:8 height:8 fromArray:#[ |
|
5321 | 383 |
2r00000000 |
384 |
2r00000000 |
|
385 |
2r00000000 |
|
386 |
2r00000000 |
|
387 |
2r11111111 |
|
388 |
2r11111111 |
|
389 |
2r11111111 |
|
390 |
2r11111111 |
|
391 |
]. |
|
3339 | 392 |
src := Form width:8 height:8 fromArray:#[ |
5321 | 393 |
2r00001111 |
394 |
2r00001111 |
|
395 |
2r00001111 |
|
396 |
2r00001111 |
|
397 |
2r00001111 |
|
398 |
2r00001111 |
|
399 |
2r00001111 |
|
400 |
2r00001111 |
|
401 |
]. |
|
3339 | 402 |
|
403 |
dst copyBits:(0@0 corner:8@8) from:src at:0@0 clippingBox:(0@0 corner:8@8) rule:15 fillColor:Color black. |
|
404 |
dst inspect |
|
405 |
||
406 |
" |
|
407 |
||
408 |
"Modified: / 23.10.2000 / 16:50:44 / martin" |
|
409 |
! |
|
410 |
||
3396 | 411 |
fill:aRectangle fillColor:aColor |
3022 | 412 |
"fill the rectangular area specified by aRectangle with the black color" |
413 |
||
6472 | 414 |
gc == self ifTrue:[ |
415 |
super fill:aRectangle fillColor:aColor. |
|
416 |
^ self. |
|
417 |
]. |
|
418 |
gc fill:aRectangle fillColor:aColor |
|
3396 | 419 |
! |
3022 | 420 |
|
3396 | 421 |
fillBlack:aRectangle |
422 |
"fill the rectangular area specified by aRectangle with the black color" |
|
423 |
||
6472 | 424 |
self fill:aRectangle fillColor:Color black |
3022 | 425 |
! |
426 |
||
2947 | 427 |
fillColor:something |
428 |
"fill the receiver with something; |
|
429 |
something may be a Form, Color or colorIndex" |
|
430 |
||
431 |
self fill:something |
|
3022 | 432 |
! |
433 |
||
6472 | 434 |
fillRectangle:aRectangle color:aColor |
435 |
"fill a rectangle with the given paint color" |
|
436 |
||
437 |
gc == self ifTrue:[ |
|
438 |
super fillRectangle:aRectangle color:aColor. |
|
439 |
^ self. |
|
440 |
]. |
|
441 |
gc fillRectangle:aRectangle color:aColor |
|
442 |
! |
|
443 |
||
444 |
fillWhite |
|
445 |
"fill all of the receiver with the white color" |
|
446 |
||
447 |
self fill:Color white |
|
448 |
! |
|
449 |
||
3022 | 450 |
fillWhite:aRectangle |
451 |
"fill the rectangular area specified by aRectangle with the white color" |
|
452 |
||
6472 | 453 |
self fill:aRectangle fillColor:Color white |
454 |
! ! |
|
455 |
||
456 |
!GraphicsMedium methodsFor:'Compatibility-VW'! |
|
457 |
||
458 |
displayBackgroundIfNeededOn: aGraphicsContext |
|
459 |
aGraphicsContext clearView. |
|
460 |
! |
|
461 |
||
462 |
inactiveForegroundColor |
|
463 |
"a dummy method to support VW widgets" |
|
464 |
||
465 |
^ self foregroundColor |
|
466 |
! |
|
467 |
||
468 |
selectionBackgroundColor |
|
469 |
"a dummy method to support VW widgets" |
|
470 |
||
471 |
^ self foregroundColor |
|
472 |
! |
|
473 |
||
474 |
selectionForegroundColor |
|
475 |
"a dummy method to support VW widgets" |
|
476 |
||
477 |
^ self backgroundColor |
|
478 |
! |
|
479 |
||
480 |
separatorColor |
|
481 |
"a dummy method to support VW widgets" |
|
482 |
||
483 |
^ self foregroundColor |
|
2947 | 484 |
! ! |
485 |
||
721
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
486 |
!GraphicsMedium methodsFor:'accessing'! |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
487 |
|
6472 | 488 |
at:aPoint |
489 |
"return the pixel at the coordinate given by aPoint" |
|
490 |
||
491 |
^ self atX:aPoint x y:aPoint y |
|
492 |
||
493 |
"Modified: / 29.1.2000 / 12:17:42 / cg" |
|
494 |
! |
|
495 |
||
496 |
at:aPoint put:aPixelColor |
|
497 |
"set a pixel" |
|
498 |
||
499 |
^ self atX:aPoint x y:aPoint y put:aPixelColor |
|
500 |
||
501 |
" |
|
502 |
Display rootView at:(0@0) put:(Color red). |
|
503 |
Display rootView at:(1@1) put:(Color red). |
|
504 |
Display rootView at:(2@2) put:(Color red). |
|
505 |
Display rootView at:(3@3) put:(Color red). |
|
506 |
Display rootView at:(4@4) put:(Color red). |
|
507 |
Display rootView at:(5@5) put:(Color red). |
|
508 |
" |
|
509 |
! |
|
510 |
||
511 |
atX:x y:y |
|
512 |
"return the pixel at the coordinate given by x/y" |
|
513 |
||
514 |
gc == self ifTrue:[ |
|
515 |
^ super atX:x y:y |
|
516 |
]. |
|
517 |
^ gc atX:x y:y |
|
518 |
! |
|
519 |
||
520 |
atX:x y:y put:aPixelColor |
|
521 |
"set a pixel" |
|
522 |
||
523 |
gc == self ifTrue:[ |
|
524 |
super atX:x y:y put:aPixelColor. |
|
525 |
^ self. |
|
526 |
]. |
|
527 |
gc atX:x y:y put:aPixelColor. |
|
528 |
! |
|
529 |
||
530 |
backgroundPaint |
|
531 |
"return the background paint color. |
|
532 |
(used for opaqueForms and opaqueStrings)" |
|
533 |
||
534 |
gc == self ifTrue:[ |
|
535 |
^ super backgroundPaint. |
|
536 |
]. |
|
537 |
^ gc backgroundPaint |
|
538 |
! |
|
539 |
||
540 |
backgroundPaint:aColor |
|
541 |
"set the background-paint color; this is used in opaque-draw |
|
542 |
operations" |
|
543 |
||
544 |
gc == self ifTrue:[ |
|
545 |
super backgroundPaint:aColor. |
|
546 |
^ self. |
|
547 |
]. |
|
548 |
gc backgroundPaint:aColor |
|
549 |
! |
|
550 |
||
551 |
basicFont |
|
552 |
"return the font for drawing" |
|
553 |
||
554 |
gc == self ifTrue:[ |
|
555 |
^ super basicFont. |
|
556 |
]. |
|
557 |
^ gc basicFont |
|
558 |
! |
|
559 |
||
560 |
basicFont:aFont |
|
561 |
"set the font for drawing if it has changed. |
|
562 |
This is a low level entry, which is not to be redefined |
|
563 |
(i.e. it must not imply a redraw operation)" |
|
564 |
||
565 |
gc == self ifTrue:[ |
|
566 |
super basicFont:aFont. |
|
567 |
^ self. |
|
568 |
]. |
|
569 |
gc basicFont:aFont |
|
570 |
! |
|
571 |
||
572 |
blackColor |
|
573 |
gc isNil ifTrue:[ |
|
574 |
^ Color black. |
|
575 |
]. |
|
576 |
gc == self ifTrue:[ |
|
577 |
^ super device blackColor. |
|
578 |
]. |
|
579 |
^ gc device blackColor |
|
580 |
! |
|
581 |
||
721
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
582 |
bottomCenter |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
583 |
"return the topCenter point" |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
584 |
|
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
585 |
^ (self left + (width//2) - 1) @ (self top + height - 1) |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
586 |
! |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
587 |
|
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
588 |
bottomLeft |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
589 |
"return the bottomLeft point" |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
590 |
|
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
591 |
^ (self left) @ (self top + height - 1) |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
592 |
! |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
593 |
|
2947 | 594 |
boundingBox |
5321 | 595 |
^ Rectangle |
596 |
origin: 0 @ 0 |
|
597 |
corner: width @ height |
|
2947 | 598 |
|
599 |
! |
|
600 |
||
6472 | 601 |
capStyle |
602 |
"return the current cap-style for line-drawing. |
|
603 |
possible styles are: #notLast, #butt, #round, #projecting" |
|
604 |
||
605 |
gc == self ifTrue:[ |
|
606 |
^ super capStyle. |
|
607 |
]. |
|
608 |
^ gc capStyle |
|
609 |
! |
|
610 |
||
611 |
capStyle:aStyleSymbol |
|
612 |
"set the cap-style for line-drawing; |
|
613 |
possible styles are: #notLast, #butt, #round, #projecting" |
|
614 |
||
615 |
gc == self ifTrue:[ |
|
616 |
super capStyle:aStyleSymbol. |
|
617 |
^ self. |
|
618 |
]. |
|
619 |
gc capStyle:aStyleSymbol |
|
620 |
||
621 |
"Modified: 12.5.1996 / 22:24:30 / cg" |
|
622 |
! |
|
623 |
||
721
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
624 |
center |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
625 |
"return the point at the center of the receiver" |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
626 |
|
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
627 |
^ (self left + (width // 2)) @ (self top + (height // 2)) |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
628 |
! |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
629 |
|
6472 | 630 |
characterEncoding |
631 |
"returns a symbol describing how the contents is encoded internally. |
|
632 |
For now, this should be the same encoding as my fonts encoding (otherwise, mappings would |
|
633 |
occur when drawing). |
|
634 |
This is (currently) only passed down from the fileBrowser, |
|
635 |
and required when japanese/chinese/korean text is edited. |
|
636 |
(encoding is something like #'iso8859-5' #euc, #sjis, #jis7, #gb, #big5 or #ksc)" |
|
637 |
||
638 |
gc == self ifTrue:[ |
|
639 |
^ super characterEncoding. |
|
640 |
]. |
|
641 |
^ gc characterEncoding |
|
642 |
! |
|
643 |
||
644 |
characterEncoding:encodingArg |
|
645 |
"define how the contents is encoded internally. |
|
646 |
This should normally never be required, as ST/X now assumes |
|
647 |
unicode (of which iso8859-1 is a subset) encoding. |
|
648 |
The possibility to change the characterEncoding is provided as |
|
649 |
a backward compatibility hook for programs which want to use |
|
650 |
another encoding internally. One such view is the CharacterSetView, |
|
651 |
which wants to show character as they are actually present in a font." |
|
652 |
||
653 |
gc == self ifTrue:[ |
|
654 |
super characterEncoding:encodingArg. |
|
655 |
^ self. |
|
656 |
]. |
|
657 |
gc characterEncoding:encodingArg |
|
658 |
! |
|
659 |
||
660 |
clipByChildren |
|
661 |
"drawing shall be done into my view only (default)" |
|
662 |
||
663 |
<resource:#obsolete> |
|
664 |
||
665 |
self obsoleteMethodWarning:'use #clippedByChildren:true'. |
|
666 |
^ self clippedByChildren:true |
|
667 |
||
668 |
"Created: 17.7.1996 / 13:25:55 / cg" |
|
669 |
! |
|
670 |
||
671 |
clipRect |
|
672 |
"return the clip-rectangle for drawing. |
|
673 |
If there is currently no active clip, return the underlying |
|
674 |
displaySurfaces (i.e. views) bounds. Added for ST-80 compatibility." |
|
675 |
||
676 |
<resource:#obsolete> |
|
677 |
||
678 |
self obsoleteMethodWarning:'use #clippingBounds'. |
|
679 |
^ self clippingBounds. |
|
680 |
||
681 |
"Modified: 28.5.1996 / 14:14:53 / cg" |
|
682 |
! |
|
683 |
||
684 |
clipRect:aRectangle |
|
685 |
"set the drawing clip-rectangle" |
|
686 |
||
687 |
<resource:#obsolete> |
|
688 |
||
689 |
self obsoleteMethodWarning:'use #deviceClippingBounds:'. |
|
690 |
^ gc deviceClippingBounds:aRectangle |
|
691 |
||
692 |
"Modified: 28.5.1996 / 14:13:09 / cg" |
|
693 |
! |
|
694 |
||
695 |
clippedByChildren:aBoolean |
|
696 |
"turn on/off drawing over children. |
|
697 |
If on, a superview may draw 'over' its children. |
|
698 |
If off (the default), drawing is 'under' its children. |
|
699 |
Only useful for the rootView, to draw over any visible views. |
|
700 |
(for example, when dragging a rubber-line)" |
|
701 |
||
702 |
gc == self ifTrue:[ |
|
703 |
super clippedByChildren:aBoolean. |
|
704 |
^ self. |
|
705 |
]. |
|
706 |
gc clippedByChildren:aBoolean. |
|
707 |
||
708 |
"Created: 17.7.1996 / 13:25:16 / cg" |
|
709 |
"Modified: 29.4.1997 / 15:33:55 / dq" |
|
710 |
! |
|
711 |
||
6217 | 712 |
clippingBounds |
6472 | 713 |
"return the clipping rectangle for drawing, nil if there is none." |
714 |
||
715 |
gc == self ifTrue:[ |
|
716 |
^ super clippingBounds. |
|
717 |
]. |
|
718 |
^ gc clippingBounds |
|
719 |
! |
|
720 |
||
721 |
clippingBounds:aRectangleOrNil |
|
722 |
"set the clipping rectangle for drawing (in logical coordinates); |
|
723 |
a nil argument turn off clipping (i.e. whole view is drawable)" |
|
724 |
||
725 |
gc == self ifTrue:[ |
|
726 |
super clippingBounds:aRectangleOrNil. |
|
727 |
^ self. |
|
728 |
]. |
|
729 |
gc clippingBounds:aRectangleOrNil |
|
730 |
! |
|
731 |
||
732 |
clippingBoundsOrNil |
|
733 |
"return the clipping rectangle for drawing, nil if there is none." |
|
734 |
||
735 |
gc == self ifTrue:[ |
|
736 |
^ super clippingBoundsOrNil. |
|
6217 | 737 |
]. |
6472 | 738 |
^ gc clippingBoundsOrNil |
739 |
! |
|
740 |
||
741 |
clippingRectangle:aRectangleOrNil |
|
742 |
"set the clipping rectangle for drawing (in logical coordinates); |
|
743 |
a nil argument turn off clipping (i.e. whole view is drawable)" |
|
744 |
||
745 |
<resource: #obsolete> |
|
746 |
||
747 |
self clippingBounds:aRectangleOrNil |
|
748 |
! |
|
749 |
||
750 |
clippingRectangleOrNil |
|
751 |
"return the clipping rectangle for drawing, nil if there is none." |
|
752 |
||
753 |
<resource: #obsolete> |
|
754 |
||
755 |
^ self clippingBoundsOrNil |
|
756 |
! |
|
757 |
||
758 |
colorAt:aPoint |
|
759 |
"return the color of the pixel at the coordinate given by x@y" |
|
760 |
||
761 |
^ self colorAtX:(aPoint x) y:(aPoint y) |
|
762 |
||
763 |
"Modified: 1.8.1997 / 20:01:58 / cg" |
|
764 |
! |
|
765 |
||
766 |
colorAtX:x y:y |
|
767 |
"return the color of the pixel at the coordinate given by aPoint" |
|
768 |
||
769 |
gc == self ifTrue:[ |
|
770 |
^ super colorAtX:x y:y. |
|
771 |
]. |
|
772 |
^ gc colorAtX:x y:y |
|
773 |
! |
|
774 |
||
775 |
container |
|
776 |
"return my container - for protocol compatibility" |
|
777 |
||
778 |
^ nil |
|
6217 | 779 |
! |
780 |
||
721
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
781 |
corner |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
782 |
"return the corner point i.e. the bottom-right point" |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
783 |
|
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
784 |
^ (self left + width - 1) @ (self top + height - 1) |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
785 |
! |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
786 |
|
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
787 |
corner:aPoint |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
788 |
"set the corner point i.e. change extent so that corner will be |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
789 |
aPoint while leaving the origin unchanging " |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
790 |
|
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
791 |
self extent:(aPoint x - self left + 1) |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
792 |
@ |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
793 |
(aPoint y - self top + 1) |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
794 |
! |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
795 |
|
6472 | 796 |
dashStyle:aDashList offset:dashOffset |
797 |
"define dashes. Each element of the dashList specifies the length |
|
798 |
of a corresponding dash. For example, setting it to [4 4] |
|
799 |
defines 4on-4off dashing; |
|
800 |
Setting it to [1 2 4 2] defines 1on-2off-4on-2off dashes. |
|
801 |
The dashOffset specifies where in the dashList the dashing starts. |
|
802 |
Ignored here - this may not be supported by all graphics devices." |
|
803 |
||
804 |
gc == self ifTrue:[ |
|
805 |
^ super dashStyle:aDashList offset:dashOffset. |
|
806 |
]. |
|
807 |
^ gc dashStyle:aDashList offset:dashOffset |
|
808 |
! |
|
809 |
||
810 |
device |
|
811 |
"return the device, the receiver is associated with" |
|
812 |
||
813 |
gc == self ifTrue:[ |
|
814 |
^ super device. |
|
815 |
]. |
|
816 |
gc isNil ifTrue:[ |
|
817 |
^ nil. |
|
818 |
]. |
|
819 |
^ gc device |
|
820 |
! |
|
821 |
||
822 |
device:aDevice |
|
823 |
"set the device" |
|
824 |
||
825 |
aDevice isNil ifTrue:[ |
|
826 |
^ self. |
|
827 |
]. |
|
828 |
||
829 |
gc isNil ifTrue:[ |
|
830 |
gc := aDevice newGraphicsContextFor:self. |
|
7285
d047c5fb149a
Compatibility: reintroduce `device` instvar in `GraphicsMedium`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6800
diff
changeset
|
831 |
device := aDevice. |
6472 | 832 |
^ self. |
833 |
]. |
|
834 |
||
7285
d047c5fb149a
Compatibility: reintroduce `device` instvar in `GraphicsMedium`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6800
diff
changeset
|
835 |
gc device:aDevice. |
d047c5fb149a
Compatibility: reintroduce `device` instvar in `GraphicsMedium`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6800
diff
changeset
|
836 |
device := aDevice. |
d047c5fb149a
Compatibility: reintroduce `device` instvar in `GraphicsMedium`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6800
diff
changeset
|
837 |
|
d047c5fb149a
Compatibility: reintroduce `device` instvar in `GraphicsMedium`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6800
diff
changeset
|
838 |
"Modified: / 03-04-2016 / 16:03:31 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6472 | 839 |
! |
840 |
||
841 |
deviceClippingRectangle:aRectangleOrNil |
|
842 |
"set the clipping rectangle for drawing (in device coordinates); |
|
843 |
a nil argument turns off clipping (i.e. whole view is drawable - incl. margins)" |
|
844 |
||
845 |
gc == self ifTrue:[ |
|
846 |
super deviceClippingRectangle:aRectangleOrNil. |
|
847 |
^ self. |
|
848 |
]. |
|
849 |
gc deviceClippingRectangle:aRectangleOrNil |
|
850 |
! |
|
851 |
||
852 |
drawableId |
|
853 |
"return the id of the drawable on the device" |
|
854 |
||
855 |
gc == self ifTrue:[ |
|
856 |
^ super drawableId. |
|
857 |
]. |
|
858 |
gc isNil ifTrue:[ |
|
859 |
^ nil. |
|
860 |
]. |
|
861 |
^ gc drawableId |
|
862 |
! |
|
863 |
||
721
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
864 |
extent |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
865 |
"return the extent i.e. a point with width as x, height as y |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
866 |
coordinate" |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
867 |
|
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
868 |
^ width @ height |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
869 |
! |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
870 |
|
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
871 |
extent:extent |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
872 |
"set the extent" |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
873 |
|
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
874 |
width := extent x. |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
875 |
height := extent y |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
876 |
! |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
877 |
|
6472 | 878 |
font |
879 |
"return the current drawing font" |
|
880 |
||
881 |
gc == self ifTrue:[ |
|
882 |
^ super font. |
|
883 |
]. |
|
884 |
^ gc font |
|
885 |
! |
|
886 |
||
887 |
font:aFont |
|
888 |
"set the font for drawing if it has changed. |
|
889 |
This should be redefined in some widget to perform an automatic |
|
890 |
redraw. See also: #basicFont:" |
|
891 |
||
892 |
gc == self ifTrue:[ |
|
893 |
super font:aFont. |
|
894 |
] ifFalse:[ |
|
895 |
gc font:aFont. |
|
896 |
]. |
|
897 |
self changed:#font. |
|
898 |
! |
|
899 |
||
900 |
function |
|
901 |
"return the current drawing function" |
|
902 |
||
903 |
gc == self ifTrue:[ |
|
904 |
^ super function. |
|
905 |
]. |
|
906 |
^ gc function |
|
907 |
! |
|
908 |
||
909 |
function:aSymbol |
|
910 |
"set the drawing function if it has changed" |
|
911 |
||
912 |
gc == self ifTrue:[ |
|
913 |
super function:aSymbol. |
|
914 |
^ self. |
|
915 |
]. |
|
916 |
gc function:aSymbol |
|
917 |
! |
|
918 |
||
919 |
gcId |
|
920 |
"return the receivers graphic context id on the device" |
|
921 |
||
922 |
gc == self ifTrue:[ |
|
923 |
^ super gcId. |
|
924 |
]. |
|
925 |
gc isNil ifTrue:[ |
|
926 |
^ nil. |
|
927 |
]. |
|
928 |
^ gc gcId. |
|
929 |
! |
|
930 |
||
931 |
graphicsContext |
|
932 |
"for ST-80 compatibility" |
|
933 |
||
934 |
^ gc |
|
935 |
! |
|
936 |
||
937 |
graphicsDevice |
|
938 |
"same as #device, for ST-80 compatibility" |
|
939 |
||
940 |
gc == self ifTrue:[ |
|
941 |
^ super graphicsDevice. |
|
942 |
]. |
|
943 |
gc isNil ifTrue:[ |
|
944 |
^ nil. |
|
945 |
]. |
|
946 |
^ gc graphicsDevice |
|
947 |
! |
|
948 |
||
721
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
949 |
height |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
950 |
"return the height of the receiver" |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
951 |
|
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
952 |
^ height |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
953 |
! |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
954 |
|
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
955 |
height:anInteger |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
956 |
"set the height of the receiver" |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
957 |
|
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
958 |
height := anInteger |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
959 |
! |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
960 |
|
6472 | 961 |
id |
962 |
"return the id of the drawable on the device" |
|
963 |
||
964 |
^ self drawableId |
|
965 |
! |
|
966 |
||
967 |
joinStyle |
|
968 |
"return the current join-style for polygon-drawing. |
|
969 |
possible styles are: #miter, #bevel, #round" |
|
970 |
||
971 |
gc == self ifTrue:[ |
|
972 |
^ super joinStyle. |
|
973 |
]. |
|
974 |
^ gc joinStyle |
|
975 |
! |
|
976 |
||
977 |
joinStyle:aStyleSymbol |
|
978 |
"set the join-style of lines in polygon-drawing; |
|
979 |
possible styles are: #miter, #bevel, #round" |
|
980 |
||
981 |
gc == self ifTrue:[ |
|
982 |
super joinStyle:aStyleSymbol. |
|
983 |
^ self. |
|
984 |
]. |
|
985 |
gc joinStyle:aStyleSymbol |
|
986 |
! |
|
987 |
||
721
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
988 |
left |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
989 |
"return the left i.e. x-coordinate of top-left of the receiver" |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
990 |
|
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
991 |
^ 0 |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
992 |
! |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
993 |
|
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
994 |
leftCenter |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
995 |
"return the leftCenter point" |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
996 |
|
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
997 |
^ (self left) @ (self top + (height // 2) - 1) |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
998 |
! |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
999 |
|
6472 | 1000 |
lineStyle |
1001 |
"return the current line-drawing-style. |
|
1002 |
possible styles are: #solid, #dashed, #doubleDashed, |
|
1003 |
#dotted, #dashDot or #dashDotDot." |
|
1004 |
||
1005 |
gc == self ifTrue:[ |
|
1006 |
^ super lineStyle. |
|
1007 |
]. |
|
1008 |
^ gc lineStyle |
|
1009 |
! |
|
1010 |
||
1011 |
lineStyle:aStyleSymbol |
|
1012 |
"set the line-drawing-style; |
|
1013 |
possible styles are: #solid, #dashed, #doubleDashed, |
|
1014 |
#dotted, #dashDot or #dashDotDot." |
|
1015 |
||
1016 |
gc == self ifTrue:[ |
|
1017 |
super lineStyle:aStyleSymbol. |
|
1018 |
^ self. |
|
1019 |
]. |
|
1020 |
gc lineStyle:aStyleSymbol |
|
1021 |
! |
|
1022 |
||
1023 |
lineWidth |
|
1024 |
"return the current drawing linewidth" |
|
1025 |
||
1026 |
gc == self ifTrue:[ |
|
1027 |
^ super lineWidth. |
|
1028 |
]. |
|
1029 |
^ gc lineWidth |
|
1030 |
! |
|
1031 |
||
1032 |
lineWidth:aNumber |
|
1033 |
"set the line drawing width in pixels" |
|
1034 |
||
1035 |
gc == self ifTrue:[ |
|
1036 |
super lineWidth:aNumber. |
|
1037 |
^ self. |
|
1038 |
]. |
|
1039 |
gc lineWidth:aNumber |
|
1040 |
! |
|
1041 |
||
1042 |
mask |
|
1043 |
"return the current drawing mask" |
|
1044 |
||
1045 |
gc == self ifTrue:[ |
|
1046 |
^ super mask. |
|
1047 |
]. |
|
1048 |
^ gc mask |
|
1049 |
! |
|
1050 |
||
1051 |
mask:aForm |
|
1052 |
"set the drawing mask" |
|
1053 |
||
1054 |
gc == self ifTrue:[ |
|
1055 |
super mask:aForm. |
|
1056 |
^ self. |
|
1057 |
]. |
|
1058 |
gc mask:aForm |
|
1059 |
! |
|
1060 |
||
1061 |
maskOrigin |
|
1062 |
"return the origin within the mask (used to draw with patterns). |
|
1063 |
Should be redefined in classes which support it. |
|
1064 |
This is an alias for ST-80's #phase" |
|
1065 |
||
1066 |
gc == self ifTrue:[ |
|
1067 |
^ super maskOrigin. |
|
1068 |
]. |
|
1069 |
^ gc maskOrigin |
|
1070 |
! |
|
1071 |
||
1072 |
maskOrigin:aPoint |
|
1073 |
"set the origin within the mask (used to draw with patterns). |
|
1074 |
Should be redefined in classes which support it. |
|
1075 |
This is an alias for ST-80's #phase:" |
|
1076 |
||
1077 |
gc == self ifTrue:[ |
|
1078 |
super maskOrigin:aPoint. |
|
1079 |
^ self. |
|
1080 |
]. |
|
1081 |
gc maskOrigin:aPoint |
|
1082 |
! |
|
1083 |
||
1084 |
maskOriginX:x y:y |
|
1085 |
"set the origin within the mask (used to draw with patterns). |
|
1086 |
Should be redefined in classes which support it. |
|
1087 |
This is an alias for ST-80's #phase:" |
|
1088 |
||
1089 |
self maskOrigin:(x @ y) |
|
1090 |
! |
|
1091 |
||
1092 |
medium |
|
1093 |
"return the destination medium i.e. the underlying graphics device" |
|
1094 |
||
1095 |
gc == self ifTrue:[ |
|
1096 |
^ super graphicsDevice. |
|
1097 |
]. |
|
1098 |
^ gc graphicsDevice |
|
1099 |
! |
|
1100 |
||
1101 |
noClipByChildren |
|
1102 |
"drawing shall also be done into subviews" |
|
1103 |
||
1104 |
<resource:#obsolete> |
|
1105 |
||
1106 |
self obsoleteMethodWarning:'use #clippedByChildren:false'. |
|
1107 |
^ self clippedByChildren:false |
|
1108 |
||
1109 |
"Created: 17.7.1996 / 14:15:54 / cg" |
|
1110 |
! |
|
1111 |
||
721
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1112 |
origin |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1113 |
"return the origin i.e. coordinate of top-left of the receiver" |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1114 |
|
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1115 |
^ 0 @ 0 |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1116 |
! |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1117 |
|
6472 | 1118 |
paint |
1119 |
"return the current paint drawing color" |
|
1120 |
||
1121 |
gc == self ifTrue:[ |
|
1122 |
^ super paint. |
|
1123 |
]. |
|
1124 |
^ gc paint |
|
1125 |
! |
|
1126 |
||
1127 |
paint:aColor |
|
1128 |
"set the drawing painting color, aColor can be a dithered one" |
|
1129 |
||
1130 |
gc == self ifTrue:[ |
|
1131 |
super paint:aColor. |
|
1132 |
^ self. |
|
1133 |
]. |
|
1134 |
gc paint:aColor |
|
1135 |
! |
|
1136 |
||
1137 |
paint:fgColor on:bgColor |
|
1138 |
"set the paint and backgroundPaint, used for text and bitmaps. |
|
1139 |
Both colors may be dithered colors" |
|
1140 |
||
1141 |
gc == self ifTrue:[ |
|
1142 |
super paint:fgColor on:bgColor. |
|
1143 |
^ self. |
|
1144 |
]. |
|
1145 |
gc paint:fgColor on:bgColor |
|
1146 |
! |
|
1147 |
||
1148 |
paint:fgColor on:bgColor function:f |
|
1149 |
"set paint, background-paint and function" |
|
1150 |
||
1151 |
self paint:fgColor on:bgColor. |
|
1152 |
self function:f |
|
1153 |
||
1154 |
"Modified: 16.5.1996 / 15:36:35 / cg" |
|
1155 |
! |
|
1156 |
||
727
bf23a306b6f2
renamed PseudoView to DisplaySurface
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1157 |
realized |
2954 | 1158 |
"return true, if the receiver is realized. |
6472 | 1159 |
The receiver may still be unmapped, if the container is unrealized. |
2955 | 1160 |
Use reallyRealized to make certain that I am really mapped." |
727
bf23a306b6f2
renamed PseudoView to DisplaySurface
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1161 |
|
bf23a306b6f2
renamed PseudoView to DisplaySurface
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1162 |
^ realized |
bf23a306b6f2
renamed PseudoView to DisplaySurface
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1163 |
! |
bf23a306b6f2
renamed PseudoView to DisplaySurface
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1164 |
|
2955 | 1165 |
reallyRealized |
6472 | 1166 |
"return true, if the receiver is realized and all containers |
1167 |
are realized." |
|
2955 | 1168 |
|
1169 |
^ self realized |
|
6472 | 1170 |
|
2955 | 1171 |
! |
1172 |
||
721
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1173 |
rightCenter |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1174 |
"return the leftCenter point" |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1175 |
|
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1176 |
^ (self left + width - 1) @ (self top + (height // 2) - 1) |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1177 |
! |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1178 |
|
6472 | 1179 |
setClippingBounds:aRectangleOrNil |
1180 |
gc == self ifTrue:[ |
|
1181 |
super setClippingBounds:aRectangleOrNil. |
|
1182 |
^ self. |
|
1183 |
]. |
|
1184 |
gc setClippingBounds:aRectangleOrNil |
|
1185 |
! |
|
1186 |
||
1187 |
setGraphicsExposures:aBoolean |
|
1188 |
"want to if aBoolean is true - or don't want to be notified |
|
1189 |
of graphics exposures" |
|
1190 |
||
1191 |
gc == self ifTrue:[ |
|
1192 |
super setGraphicsExposures:aBoolean. |
|
1193 |
^ self. |
|
1194 |
]. |
|
1195 |
gc setGraphicsExposures:aBoolean |
|
1196 |
! |
|
1197 |
||
1198 |
setMaskOrigin:aPoint |
|
1199 |
<resource: #obsolete> |
|
1200 |
"set the origin within the mask (used to draw with patterns). |
|
1201 |
OBSOLETE: use #maskOrigin: or #phase:" |
|
1202 |
||
1203 |
self obsoleteMethodWarning:'use #maskOrigin:'. |
|
1204 |
^ self maskOriginX:aPoint x y:aPoint y |
|
1205 |
||
1206 |
"Modified: / 26.1.1998 / 18:54:14 / cg" |
|
1207 |
! |
|
1208 |
||
1209 |
setMaskOriginX:x y:y |
|
1210 |
<resource: #obsolete> |
|
1211 |
"set the origin within the mask (used to draw with patterns). |
|
1212 |
OBSOLETE: use #maskOriginX:y: or #phase:" |
|
1213 |
||
1214 |
self obsoleteMethodWarning:'use #maskOriginX:y:'. |
|
1215 |
^ self maskOriginX:x y:y |
|
1216 |
! |
|
1217 |
||
721
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1218 |
setWidth:w height:h |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1219 |
"set both width and height - not to be redefined" |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1220 |
|
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1221 |
width := w. |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1222 |
height := h |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1223 |
! |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1224 |
|
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1225 |
top |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1226 |
"return the top i.e. y-coordinate of top-left of the receiver" |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1227 |
|
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1228 |
^ 0 |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1229 |
! |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1230 |
|
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1231 |
topCenter |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1232 |
"return the topCenter point" |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1233 |
|
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1234 |
^ (self left + (width//2) - 1) @ (self top) |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1235 |
! |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1236 |
|
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1237 |
topRight |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1238 |
"return the topRight point" |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1239 |
|
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1240 |
^ (self left + width - 1) @ (self top) |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1241 |
! |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1242 |
|
2030
5b29d7626887
added #viewBackground for protocol compatibility with real views.
ca
parents:
741
diff
changeset
|
1243 |
viewBackground |
5b29d7626887
added #viewBackground for protocol compatibility with real views.
ca
parents:
741
diff
changeset
|
1244 |
"for protocol compatibility with view; return my background paint color here" |
5b29d7626887
added #viewBackground for protocol compatibility with real views.
ca
parents:
741
diff
changeset
|
1245 |
|
6472 | 1246 |
^ self backgroundPaint |
1247 |
! |
|
1248 |
||
1249 |
viewOrigin |
|
1250 |
"return the drawables visible origin (for scrolling)" |
|
1251 |
||
1252 |
^ 0@0 |
|
1253 |
! |
|
1254 |
||
1255 |
whiteColor |
|
1256 |
gc isNil ifTrue:[ |
|
1257 |
^ Color white. |
|
1258 |
]. |
|
1259 |
gc == self ifTrue:[ |
|
1260 |
^ super graphicsDevice whiteColor. |
|
1261 |
]. |
|
1262 |
^ gc graphicsDevice whiteColor |
|
2030
5b29d7626887
added #viewBackground for protocol compatibility with real views.
ca
parents:
741
diff
changeset
|
1263 |
! |
5b29d7626887
added #viewBackground for protocol compatibility with real views.
ca
parents:
741
diff
changeset
|
1264 |
|
721
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1265 |
width |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1266 |
"return the width of the receiver" |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1267 |
|
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1268 |
^ width |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1269 |
! |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1270 |
|
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1271 |
width:anInteger |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1272 |
"set the width of the receiver" |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1273 |
|
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1274 |
width := anInteger |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1275 |
! |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1276 |
|
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1277 |
width:w height:h |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1278 |
"set both width and height of the receiver" |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1279 |
|
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1280 |
width := w. |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1281 |
height := h |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1282 |
! ! |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1283 |
|
6472 | 1284 |
!GraphicsMedium methodsFor:'accessing-internals'! |
1285 |
||
1286 |
background |
|
1287 |
<resource: #obsolete> |
|
1288 |
"return the current background drawing color. |
|
1289 |
OBSOLETE: use #paint: / #backgroundPaint: / #paint:on:" |
|
1290 |
||
1291 |
gc == self ifTrue:[ |
|
1292 |
^ super background. |
|
1293 |
]. |
|
1294 |
^ gc background |
|
1295 |
||
1296 |
"Modified: 12.5.1996 / 22:28:09 / cg" |
|
1297 |
! |
|
1298 |
||
1299 |
background:aColor |
|
1300 |
<resource: #obsolete> |
|
1301 |
"set the internal background color for drawing - aColor must be a real color. |
|
1302 |
OBSOLETE: this method will vanish; use #paint: / #backgroundPaint: / #paint:on:" |
|
1303 |
||
1304 |
gc == self ifTrue:[ |
|
1305 |
super background:aColor. |
|
1306 |
^ self. |
|
1307 |
]. |
|
1308 |
gc background:aColor |
|
1309 |
! |
|
1310 |
||
1311 |
foreground |
|
1312 |
<resource: #obsolete> |
|
1313 |
"return the current foreground drawing color. |
|
1314 |
OBSOLETE: use #paint: / #paint:on:" |
|
1315 |
||
1316 |
gc == self ifTrue:[ |
|
1317 |
^ super foreground. |
|
1318 |
]. |
|
1319 |
^ gc foreground |
|
1320 |
! |
|
1321 |
||
1322 |
foreground:aColor |
|
1323 |
<resource: #obsolete> |
|
1324 |
"set the internal foreground color for drawing - aColor must be a real color. |
|
1325 |
OBSOLETE: this method will vanish; use #paint: / #paint:on:" |
|
1326 |
||
1327 |
gc == self ifTrue:[ |
|
1328 |
super foreground:aColor. |
|
1329 |
^ self. |
|
1330 |
]. |
|
1331 |
gc foreground:aColor |
|
1332 |
! |
|
1333 |
||
1334 |
foreground:fgColor background:bgColor |
|
1335 |
<resource: #obsolete> |
|
1336 |
"set both internal foreground and internal background colors |
|
1337 |
- these must be real colors. |
|
1338 |
OBSOLETE: this method will vanish; use #paint: / #paint:on:" |
|
1339 |
||
1340 |
gc == self ifTrue:[ |
|
1341 |
super foreground:fgColor background:bgColor. |
|
1342 |
^ self. |
|
1343 |
]. |
|
1344 |
gc foreground:fgColor background:bgColor |
|
1345 |
! |
|
1346 |
||
1347 |
foreground:fgColor background:bgColor function:fun |
|
1348 |
<resource: #obsolete> |
|
1349 |
"set foreground, background colors and function. |
|
1350 |
OBSOLETE: this method will vanish; use #paint: / #paint:on:" |
|
1351 |
||
1352 |
self foreground:fgColor background:bgColor. |
|
1353 |
self function:fun |
|
1354 |
||
1355 |
"Modified: 12.5.1996 / 22:28:34 / cg" |
|
1356 |
! |
|
1357 |
||
1358 |
foreground:aColor function:fun |
|
1359 |
<resource: #obsolete> |
|
1360 |
"set the foreground color and function for drawing. |
|
1361 |
OBSOLETE: this method will vanish; use #paint: / #paint:on:" |
|
1362 |
||
1363 |
gc == self ifTrue:[ |
|
1364 |
super foreground:aColor function:fun. |
|
1365 |
^ self. |
|
1366 |
]. |
|
1367 |
gc foreground:aColor function:fun |
|
1368 |
! |
|
1369 |
||
1370 |
setRealized:aBoolean |
|
1371 |
"low level special interface to manipulate the realized state. |
|
1372 |
Non-public interface, only to be used by experts. |
|
1373 |
(use to pretend a view has been realized - for example with alien views)" |
|
1374 |
||
1375 |
realized := aBoolean |
|
1376 |
! ! |
|
1377 |
||
1378 |
!GraphicsMedium methodsFor:'accessing-transformation'! |
|
1379 |
||
1380 |
scale |
|
1381 |
"return the scale factor (as point) of the transformation" |
|
1382 |
||
1383 |
gc == self ifTrue:[ |
|
1384 |
^ super scale. |
|
1385 |
]. |
|
1386 |
^ gc scale |
|
1387 |
! |
|
1388 |
||
1389 |
scale:aPoint |
|
1390 |
"set the scale factor of the transformation" |
|
1391 |
||
1392 |
gc == self ifTrue:[ |
|
1393 |
super scale:aPoint. |
|
1394 |
^ self. |
|
1395 |
]. |
|
1396 |
^ gc scale:aPoint |
|
1397 |
! |
|
1398 |
||
6731
24e7fa5e7f72
Added lost GraphicsMedium>>displayString:centeredAt:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6730
diff
changeset
|
1399 |
transformation |
6472 | 1400 |
"return the transformation" |
1401 |
||
1402 |
gc == self ifTrue:[ |
|
1403 |
^ super transformation. |
|
1404 |
]. |
|
1405 |
^ gc transformation |
|
1406 |
! |
|
1407 |
||
6731
24e7fa5e7f72
Added lost GraphicsMedium>>displayString:centeredAt:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6730
diff
changeset
|
1408 |
transformation:aTransformation |
6472 | 1409 |
"set the transformation" |
1410 |
||
1411 |
gc == self ifTrue:[ |
|
1412 |
super transformation:aTransformation. |
|
1413 |
^ self. |
|
1414 |
]. |
|
1415 |
^ gc transformation:aTransformation |
|
1416 |
! |
|
1417 |
||
1418 |
translateBy:aPoint |
|
1419 |
"add to the translation offset of the transformation" |
|
1420 |
||
1421 |
gc == self ifTrue:[ |
|
1422 |
super translateBy:aPoint. |
|
1423 |
^ self. |
|
1424 |
]. |
|
1425 |
^ gc translateBy:aPoint |
|
1426 |
! |
|
1427 |
||
1428 |
translation |
|
1429 |
"return the translation factor (as point) of the transformation" |
|
1430 |
||
1431 |
gc == self ifTrue:[ |
|
1432 |
^ super translation. |
|
1433 |
]. |
|
1434 |
^ gc translation |
|
1435 |
! |
|
1436 |
||
1437 |
translation:aPoint |
|
1438 |
"set the translation offset of the transformation" |
|
1439 |
||
1440 |
gc == self ifTrue:[ |
|
1441 |
super translation:aPoint. |
|
1442 |
^ self. |
|
1443 |
]. |
|
1444 |
^ gc translation:aPoint |
|
1445 |
! ! |
|
1446 |
||
1447 |
!GraphicsMedium methodsFor:'basic drawing'! |
|
1448 |
||
1449 |
displayArcX:x y:y width:width height:height from:startAngle angle:angle |
|
1450 |
"draw an arc in a box |
|
1451 |
- this could be recoded to draw using displayLine" |
|
1452 |
||
1453 |
gc == self ifTrue:[ |
|
1454 |
super displayArcX:x y:y width:width height:height from:startAngle angle:angle. |
|
1455 |
^ self. |
|
1456 |
]. |
|
1457 |
gc displayArcX:x y:y width:width height:height from:startAngle angle:angle |
|
1458 |
! |
|
1459 |
||
1460 |
displayDottedRectangleX:x y:y width:w height:h |
|
1461 |
"draw a dotted-line rectangle |
|
1462 |
A general implementation is found here; deviceGC's |
|
1463 |
may reimplement this if directly supported by the device" |
|
1464 |
||
1465 |
gc == self ifTrue:[ |
|
1466 |
super displayDottedRectangleX:x y:y width:w height:h. |
|
1467 |
^ self. |
|
1468 |
]. |
|
1469 |
gc displayDottedRectangleX:x y:y width:w height:h |
|
1470 |
! |
|
1471 |
||
1472 |
displayHorizontalWavelineFromX:x0 y:y0 toX:x1 |
|
1473 |
"draw a horizontal wave-line from x0/y0 to x1/y0" |
|
1474 |
||
1475 |
gc == self ifTrue:[ |
|
1476 |
super displayHorizontalWavelineFromX:x0 y:y0 toX:x1. |
|
1477 |
^ self. |
|
1478 |
]. |
|
1479 |
gc displayHorizontalWavelineFromX:x0 y:y0 toX:x1 |
|
1480 |
! |
|
1481 |
||
1482 |
displayLineFromX:x0 y:y0 toX:x1 y:y1 |
|
1483 |
"draw a line from x0/y0 to x1/y1" |
|
1484 |
||
1485 |
gc == self ifTrue:[ |
|
1486 |
super displayLineFromX:x0 y:y0 toX:x1 y:y1. |
|
1487 |
^ self. |
|
1488 |
]. |
|
1489 |
gc displayLineFromX:x0 y:y0 toX:x1 y:y1 |
|
1490 |
! |
|
1491 |
||
1492 |
displayOpaqueForm:aForm x:x y:y |
|
1493 |
"draw a form at x/y; if the form has depth 1, 1's in the form are |
|
1494 |
drawn in current fg, 0's in current bg color. |
|
1495 |
If the form has depth ~~ 1, it is copied as is onto the receiver" |
|
1496 |
||
1497 |
gc == self ifTrue:[ |
|
1498 |
super displayOpaqueForm:aForm x:x y:y. |
|
1499 |
^ self. |
|
1500 |
]. |
|
1501 |
gc displayOpaqueForm:aForm x:x y:y |
|
1502 |
! |
|
1503 |
||
1504 |
displayOpaqueString:aString from:index1 to:index2 x:x y:y |
|
1505 |
"draw part of a string with both fg and bg at x/y in current font" |
|
1506 |
||
1507 |
gc == self ifTrue:[ |
|
1508 |
super displayString:aString from:index1 to:index2 x:x y:y opaque:true maxWidth:self width. |
|
1509 |
^ self. |
|
1510 |
]. |
|
1511 |
gc displayString:aString from:index1 to:index2 x:x y:y opaque:true maxWidth:self width |
|
1512 |
! |
|
1513 |
||
1514 |
displayPolygon:aPolygon |
|
1515 |
"draw a polygon |
|
1516 |
- this could be recoded to draw using displayLine" |
|
1517 |
||
1518 |
gc == self ifTrue:[ |
|
1519 |
super displayPolygon:aPolygon. |
|
1520 |
^ self. |
|
1521 |
]. |
|
1522 |
gc displayPolygon:aPolygon |
|
1523 |
! |
|
1524 |
||
1525 |
displayRectangleX:x y:y width:w height:h |
|
1526 |
"draw a rectangle |
|
1527 |
- this could be recoded to draw using displayLine" |
|
1528 |
||
1529 |
gc == self ifTrue:[ |
|
1530 |
super displayRectangleX:x y:y width:w height:h. |
|
1531 |
^ self. |
|
1532 |
]. |
|
1533 |
gc displayRectangleX:x y:y width:w height:h |
|
1534 |
! |
|
1535 |
||
1536 |
displayString:aString from:index1 to:index2 x:x y:y |
|
1537 |
"draw part of a string with fg at x/y in current font" |
|
1538 |
||
1539 |
gc displayString:aString from:index1 to:index2 x:x y:y opaque:false maxWidth:self width |
|
1540 |
! |
|
1541 |
||
1542 |
displayString:aString from:index1 to:index2 x:x y:y opaque:opaque |
|
1543 |
"draw part of a string with both fg and bg at x/y in current font" |
|
1544 |
||
1545 |
self displayString:aString from:index1 to:index2 x:x y:y opaque:opaque maxWidth:self width. |
|
1546 |
! |
|
1547 |
||
1548 |
displayString:aString from:index1 to:index2 x:x y:y opaque:opaque maxWidth:maxWidth |
|
1549 |
"draw part of a string with both fg and bg at x/y in current font" |
|
1550 |
||
1551 |
gc == self ifTrue:[ |
|
1552 |
super displayString:aString from:index1 to:index2 x:x y:y opaque:opaque maxWidth:maxWidth. |
|
1553 |
^ self. |
|
1554 |
]. |
|
1555 |
gc displayString:aString from:index1 to:index2 x:x y:y opaque:opaque maxWidth:maxWidth |
|
1556 |
! ! |
|
1557 |
||
1558 |
!GraphicsMedium methodsFor:'basic filling'! |
|
1559 |
||
1560 |
fillArcX:x y:y width:w height:h from:start angle:angle |
|
1561 |
"fill an arc with current paint color" |
|
1562 |
||
1563 |
gc == self ifTrue:[ |
|
1564 |
super fillArcX:x y:y width:w height:h from:start angle:angle. |
|
1565 |
^ self. |
|
1566 |
]. |
|
1567 |
gc fillArcX:x y:y width:w height:h from:start angle:angle |
|
1568 |
! |
|
1569 |
||
1570 |
fillPolygon:points |
|
1571 |
"fill a polygon with current paint color" |
|
1572 |
||
1573 |
gc == self ifTrue:[ |
|
1574 |
super fillPolygon:points. |
|
1575 |
^ self. |
|
1576 |
]. |
|
1577 |
gc fillPolygon:points |
|
1578 |
! |
|
1579 |
||
1580 |
fillRectangleX:x y:y width:w height:h |
|
1581 |
"fill a rectangle with current paint color" |
|
1582 |
||
1583 |
gc == self ifTrue:[ |
|
1584 |
super fillRectangleX:x y:y width:w height:h. |
|
1585 |
^ self. |
|
1586 |
]. |
|
1587 |
gc fillRectangleX:x y:y width:w height:h |
|
1588 |
! |
|
1589 |
||
1590 |
fillRectangleX:x y:y width:w height:h color:aColor |
|
1591 |
"fill a rectangle with given color" |
|
1592 |
||
1593 |
gc == self ifTrue:[ |
|
1594 |
super fillRectangleX:x y:y width:w height:h color:aColor. |
|
1595 |
^ self. |
|
1596 |
]. |
|
1597 |
gc fillRectangleX:x y:y width:w height:h color:aColor |
|
1598 |
! ! |
|
1599 |
||
1600 |
!GraphicsMedium methodsFor:'bit blitting'! |
|
1601 |
||
1602 |
copyBitsFrom:aByteArray bitsPerPixel:bpp depth:depth padding:pad width:srcW height:srcH x:srcX y:srcY toX:dstX y:dstY |
|
1603 |
"copy bits from a smalltalk byteArray. |
|
1604 |
The bits found there are supposed to be in the devices native format (i.e. |
|
1605 |
translated to allocated color indices on pseudoColor devices and padded as required. |
|
1606 |
The byteOrder is MSB and will be converted as appropriate by the underlying devices |
|
1607 |
method to whatever the device needs." |
|
1608 |
||
1609 |
gc == self ifTrue:[ |
|
1610 |
super copyBitsFrom:aByteArray bitsPerPixel:bpp depth:depth padding:pad width:srcW height:srcH x:srcX y:srcY toX:dstX y:dstY. |
|
1611 |
^ self. |
|
1612 |
]. |
|
1613 |
gc copyBitsFrom:aByteArray bitsPerPixel:bpp depth:depth padding:pad width:srcW height:srcH x:srcX y:srcY toX:dstX y:dstY |
|
1614 |
! |
|
1615 |
||
1616 |
copyBitsFrom:aByteArray bitsPerPixel:bpp depth:depth width:srcW height:srcH x:srcX y:srcY toX:dstX y:dstY |
|
1617 |
"copy bits from a smalltalk byteArray. |
|
1618 |
The bits found there are supposed to be in the devices native format (i.e. |
|
1619 |
translated to allocated color indices on pseudoColor devices and padded as required. |
|
1620 |
The byteOrder is MSB and will be converted as appropriate by the underlying devices |
|
1621 |
method to whatever the device needs. |
|
1622 |
Assumes the source bits are in ST/X's natural padding (i.e. 8-bit padded)" |
|
1623 |
||
1624 |
gc == self ifTrue:[ |
|
1625 |
super copyBitsFrom:aByteArray bitsPerPixel:bpp depth:depth width:srcW height:srcH x:srcX y:srcY toX:dstX y:dstY. |
|
1626 |
^ self. |
|
1627 |
]. |
|
1628 |
gc copyBitsFrom:aByteArray bitsPerPixel:bpp depth:depth width:srcW height:srcH x:srcX y:srcY toX:dstX y:dstY |
|
1629 |
! |
|
1630 |
||
1631 |
copyFrom:aGC toX:dstX y:dstY |
|
1632 |
"copy from a drawable - maybe self" |
|
1633 |
||
1634 |
gc == self ifTrue:[ |
|
1635 |
super copyFrom:aGC toX:dstX y:dstY. |
|
1636 |
^ self. |
|
1637 |
]. |
|
1638 |
gc copyFrom:aGC toX:dstX y:dstY |
|
1639 |
! |
|
1640 |
||
1641 |
copyFrom:aGC x:srcX y:srcY toX:dstX y:dstY width:w height:h |
|
1642 |
"copy from a drawable - maybe self" |
|
1643 |
||
1644 |
gc == self ifTrue:[ |
|
1645 |
super copyFrom:aGC x:srcX y:srcY toX:dstX y:dstY width:w height:h. |
|
1646 |
^ self. |
|
1647 |
]. |
|
1648 |
gc copyFrom:aGC x:srcX y:srcY toX:dstX y:dstY width:w height:h |
|
1649 |
! |
|
1650 |
||
1651 |
copyFrom:aDrawable x:srcX y:srcY toX:dstX y:dstY width:w height:h async:async |
|
1652 |
"copy from aDrawable into the receiver; |
|
1653 |
the source may be the receiver as well - in this case its a scroll. |
|
1654 |
All coordinates are in device coordinates. |
|
1655 |
If the receiver is a view AND async is true, the call returns immediately |
|
1656 |
- otherwise, it returns when the scroll operation is finished. |
|
1657 |
(not all devices care for this). |
|
1658 |
If the receiver is a pixmap, the call always returns immediately." |
|
1659 |
||
1660 |
|myDevice deviceDrawable asy| |
|
1661 |
||
1662 |
myDevice := gc graphicsDevice. |
|
1663 |
||
1664 |
((aDrawable graphicsDevice ~~ myDevice) |
|
1665 |
or:[aDrawable isImage]) ifTrue:[ |
|
1666 |
deviceDrawable := aDrawable asFormOn:myDevice. |
|
1667 |
] ifFalse:[ |
|
1668 |
deviceDrawable := aDrawable |
|
1669 |
]. |
|
7318
83b501bbf3b0
Issue #84: Can not place widget on...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7297
diff
changeset
|
1670 |
asy := async or:[self isView not or:[ deviceDrawable isForm ]]. |
6472 | 1671 |
asy ifFalse:[ |
1672 |
self catchExpose |
|
1673 |
]. |
|
1674 |
gc == self ifTrue:[ |
|
7318
83b501bbf3b0
Issue #84: Can not place widget on...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7297
diff
changeset
|
1675 |
super copyFrom:deviceDrawable x:srcX y:srcY toX:dstX y:dstY width:w height:h async:true. |
6472 | 1676 |
] ifFalse:[ |
7318
83b501bbf3b0
Issue #84: Can not place widget on...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7297
diff
changeset
|
1677 |
gc copyFrom:deviceDrawable x:srcX y:srcY toX:dstX y:dstY width:w height:h async:true. |
6472 | 1678 |
]. |
1679 |
asy ifFalse:[ |
|
1680 |
myDevice flush. |
|
1681 |
self waitForExpose |
|
1682 |
] |
|
7318
83b501bbf3b0
Issue #84: Can not place widget on...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7297
diff
changeset
|
1683 |
|
83b501bbf3b0
Issue #84: Can not place widget on...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7297
diff
changeset
|
1684 |
"Modified: / 26-04-2016 / 20:30:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6472 | 1685 |
! |
1686 |
||
1687 |
copyFrom:aGC x:dstX y:dstY width:w height:h |
|
1688 |
"copy from a drawable - maybe self" |
|
1689 |
||
1690 |
gc == self ifTrue:[ |
|
1691 |
super copyFrom:aGC x:dstX y:dstY width:w height:h. |
|
1692 |
^ self. |
|
1693 |
]. |
|
1694 |
gc copyFrom:aGC x:dstX y:dstY width:w height:h |
|
1695 |
! |
|
1696 |
||
1697 |
copyPlaneFrom:aDrawable x:srcX y:srcY toX:dstX y:dstY width:w height:h |
|
1698 |
"copy one plane from aDrawable into the receiver. 0's are drawn in |
|
1699 |
background, while 1's are drawn with foreground color. |
|
1700 |
The depth of aDrawable must (should) be 1. |
|
1701 |
The drawable must have been allocated on the same device. |
|
1702 |
All coordinates are in device coordinates." |
|
1703 |
||
1704 |
gc == self ifTrue:[ |
|
1705 |
super copyPlaneFrom:aDrawable x:srcX y:srcY toX:dstX y:dstY width:w height:h. |
|
1706 |
^ self. |
|
1707 |
]. |
|
1708 |
gc copyPlaneFrom:aDrawable x:srcX y:srcY toX:dstX y:dstY width:w height:h |
|
1709 |
! ! |
|
1710 |
||
727
bf23a306b6f2
renamed PseudoView to DisplaySurface
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1711 |
!GraphicsMedium methodsFor:'copying'! |
bf23a306b6f2
renamed PseudoView to DisplaySurface
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1712 |
|
bf23a306b6f2
renamed PseudoView to DisplaySurface
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1713 |
postCopy |
bf23a306b6f2
renamed PseudoView to DisplaySurface
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1714 |
"this may not be enough to allow copying of views ..." |
bf23a306b6f2
renamed PseudoView to DisplaySurface
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1715 |
|
bf23a306b6f2
renamed PseudoView to DisplaySurface
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1716 |
super postCopy. |
bf23a306b6f2
renamed PseudoView to DisplaySurface
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1717 |
realized := false. |
4403 | 1718 |
! |
1719 |
||
1720 |
postDeepCopy |
|
1721 |
super postDeepCopy. |
|
1722 |
realized := false. |
|
727
bf23a306b6f2
renamed PseudoView to DisplaySurface
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1723 |
! ! |
bf23a306b6f2
renamed PseudoView to DisplaySurface
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
1724 |
|
6472 | 1725 |
!GraphicsMedium methodsFor:'drawing'! |
1726 |
||
1727 |
display:someObject at:aPoint |
|
1728 |
"draw someObject - this must understand the #displayOn:at: message" |
|
1729 |
||
1730 |
someObject displayOn:self at:aPoint |
|
1731 |
||
1732 |
"Created: 28.5.1996 / 14:22:57 / cg" |
|
1733 |
! |
|
1734 |
||
1735 |
displayArcIn:aRectangle from:startAngle angle:angle |
|
1736 |
"draw an arc in a box" |
|
1737 |
||
1738 |
self |
|
1739 |
displayArcX:(aRectangle left) |
|
1740 |
y:(aRectangle top) |
|
1741 |
width:(aRectangle width) |
|
1742 |
height:(aRectangle height) |
|
1743 |
from:startAngle |
|
1744 |
angle:angle |
|
1745 |
! |
|
1746 |
||
1747 |
displayArcOrigin:origin corner:corner from:startAngle angle:angle |
|
1748 |
"draw an arc in a box" |
|
1749 |
||
1750 |
|left top right bot| |
|
1751 |
||
1752 |
left := origin x. |
|
1753 |
top := origin y. |
|
1754 |
right := corner x. |
|
1755 |
bot := corner y. |
|
1756 |
self |
|
1757 |
displayArcX:left |
|
1758 |
y:top |
|
1759 |
width:(right - left + 1) |
|
1760 |
height:(bot - top + 1) |
|
1761 |
from:startAngle |
|
1762 |
angle:angle |
|
1763 |
||
1764 |
"Modified: 8.5.1996 / 08:35:25 / cg" |
|
1765 |
! |
|
1766 |
||
1767 |
displayArcX:x y:y w:w h:h from:startAngle angle:angle |
|
1768 |
"draw an arc; apply transformation if nonNil" |
|
1769 |
||
1770 |
<resource:#obsolete> |
|
1771 |
||
1772 |
self obsoleteMethodWarning:'use #displayArcX:y:width:height:from:angle:'. |
|
1773 |
self displayArcX:x y:y width:w height:h from:startAngle angle:angle |
|
1774 |
||
1775 |
"Modified: 8.5.1996 / 08:46:56 / cg" |
|
1776 |
! |
|
1777 |
||
1778 |
displayCircle:aPoint radius:r |
|
1779 |
"draw a circle around a center point" |
|
1780 |
||
1781 |
gc == self ifTrue:[ |
|
1782 |
super displayCircleX:(aPoint x) y:(aPoint y) radius:r. |
|
1783 |
^ self. |
|
1784 |
]. |
|
1785 |
gc displayCircleX:(aPoint x) y:(aPoint y) radius:r |
|
1786 |
! |
|
1787 |
||
1788 |
displayCircleIn:aRectangle |
|
1789 |
"draw a circle in a box" |
|
1790 |
||
1791 |
self |
|
1792 |
displayArcX:(aRectangle left) |
|
1793 |
y:(aRectangle top) |
|
1794 |
width:(aRectangle width) |
|
1795 |
height:(aRectangle height) |
|
1796 |
from:0 |
|
1797 |
angle:360 |
|
1798 |
||
1799 |
"Modified: 8.5.1996 / 08:35:40 / cg" |
|
1800 |
! |
|
1801 |
||
1802 |
displayCircleX:x y:y radius:r |
|
1803 |
"draw a circle around a center point" |
|
1804 |
||
1805 |
|d| |
|
1806 |
d := 2 * r. |
|
1807 |
self |
|
1808 |
displayArcX:(x - r) |
|
1809 |
y:(y - r) |
|
1810 |
width:d |
|
1811 |
height:d |
|
1812 |
from:0 |
|
1813 |
angle:360 |
|
1814 |
||
1815 |
"Modified: 8.5.1996 / 08:36:03 / cg" |
|
1816 |
! |
|
1817 |
||
1818 |
displayForm:aFormOrImage |
|
1819 |
"draw a form (or image) at the origin" |
|
1820 |
||
1821 |
gc == self ifTrue:[ |
|
1822 |
super displayForm:aFormOrImage x:0 y:0. |
|
1823 |
^ self. |
|
1824 |
]. |
|
1825 |
gc displayForm:aFormOrImage x:0 y:0 |
|
1826 |
||
1827 |
"Modified: / 24.4.1997 / 16:00:11 / cg" |
|
1828 |
"Created: / 9.11.1997 / 00:50:52 / cg" |
|
1829 |
! |
|
1830 |
||
1831 |
displayForm:aFormOrImage at:aPoint |
|
1832 |
"draw a form (or image)" |
|
1833 |
||
1834 |
gc == self ifTrue:[ |
|
1835 |
super displayForm:aFormOrImage x:(aPoint x) y:(aPoint y). |
|
1836 |
^ self. |
|
1837 |
]. |
|
1838 |
gc displayForm:aFormOrImage x:(aPoint x) y:(aPoint y) |
|
1839 |
||
1840 |
"Modified: 24.4.1997 / 16:00:11 / cg" |
|
1841 |
! |
|
1842 |
||
1843 |
displayForm:formToDraw x:x y:y |
|
1844 |
"draw a form or image non opaque; |
|
1845 |
if its a 1-plane bitmap, 1-bits are drawn in the |
|
1846 |
current paint-color, leaving pixels with 0-bits unchanged |
|
1847 |
(i.e. only 1-bits are drawn from the form). |
|
1848 |
If its a deep form (i.e. a pixmap) the current paint |
|
1849 |
settings are ignored and the form is drawn as-is. |
|
1850 |
Care must be taken, that the paint color is correctly allocated |
|
1851 |
(by sending #on: to the color) before doing so. |
|
1852 |
Using functions other than #copy only makes sense if you are |
|
1853 |
certain, that the colors are real colors (actually, only for |
|
1854 |
noColor or allColor)." |
|
1855 |
||
1856 |
gc == self ifTrue:[ |
|
1857 |
super displayForm:formToDraw x:x y:y. |
|
1858 |
^ self. |
|
1859 |
]. |
|
1860 |
gc displayForm:formToDraw x:x y:y |
|
1861 |
! |
|
1862 |
||
1863 |
displayForm:aFormOrImage x:x y:y opaque:opaque |
|
1864 |
"draw a form (or image) at x/y; |
|
1865 |
if the form has depth 1, 1's in the form are |
|
1866 |
drawn in current paint color, 0's are ignored. |
|
1867 |
If the form has depth ~~ 1, the current fg color setting is ignored." |
|
1868 |
||
1869 |
opaque ifTrue:[ |
|
1870 |
self displayOpaqueForm:aFormOrImage x:x y:y |
|
1871 |
] ifFalse:[ |
|
1872 |
self displayForm:aFormOrImage x:x y:y |
|
1873 |
]. |
|
1874 |
! |
|
1875 |
||
1876 |
displayImage:aFormOrImage |
|
1877 |
"draw an image (or form). |
|
1878 |
Provided for ST-80 compatibilty; |
|
1879 |
in ST/X, images are also handled by #displayForm:" |
|
1880 |
||
1881 |
gc == self ifTrue:[ |
|
1882 |
super displayForm:aFormOrImage x:0 y:0. |
|
1883 |
^ self. |
|
1884 |
]. |
|
1885 |
gc displayForm:aFormOrImage x:0 y:0 |
|
1886 |
! |
|
1887 |
||
1888 |
displayImage:aFormOrImage at:aPoint |
|
1889 |
"draw an image (or form). |
|
1890 |
Provided for ST-80 compatibilty; |
|
1891 |
in ST/X, images are also handled by #displayForm:" |
|
1892 |
||
1893 |
gc == self ifTrue:[ |
|
1894 |
super displayForm:aFormOrImage x:(aPoint x) y:(aPoint y). |
|
1895 |
^ self. |
|
1896 |
]. |
|
1897 |
gc displayForm:aFormOrImage x:(aPoint x) y:(aPoint y) |
|
1898 |
||
1899 |
"Modified: 24.4.1997 / 16:02:43 / cg" |
|
1900 |
! |
|
1901 |
||
1902 |
displayImage:aFormOrImage x:x y:y |
|
1903 |
"draw an image (or form). |
|
1904 |
Provided for ST-80 compatibilty; |
|
1905 |
in ST/X, images are also handled by #displayForm:" |
|
1906 |
||
1907 |
gc == self ifTrue:[ |
|
1908 |
super displayForm:aFormOrImage x:x y:y. |
|
1909 |
^ self. |
|
1910 |
]. |
|
1911 |
gc displayForm:aFormOrImage x:x y:y |
|
1912 |
||
1913 |
"Created: 24.4.1997 / 16:03:03 / cg" |
|
1914 |
! |
|
1915 |
||
1916 |
displayLineFrom:point1 to:point2 |
|
1917 |
"draw a line" |
|
1918 |
||
1919 |
gc == self ifTrue:[ |
|
1920 |
super displayLineFromX:(point1 x) y:(point1 y) |
|
1921 |
toX:(point2 x) y:(point2 y). |
|
1922 |
^ self. |
|
1923 |
]. |
|
1924 |
gc displayLineFromX:(point1 x) y:(point1 y) |
|
1925 |
toX:(point2 x) y:(point2 y) |
|
1926 |
! |
|
1927 |
||
1928 |
displayLineFromX:xStart y:yStart toX:xEnd y:yEnd brush:aForm |
|
1929 |
"draw a line using a brush. |
|
1930 |
Here, a slow fallback is used, drawing into a |
|
1931 |
temporary bitmap first, which is then displayed" |
|
1932 |
||
1933 |
|deltaX deltaY dx dy px py destX destY p tempForm |
|
1934 |
xMin xMax yMin yMax x1 x2 y1 y2| |
|
1935 |
||
1936 |
xStart < xEnd ifTrue:[ |
|
1937 |
xMin := xStart. |
|
1938 |
xMax := xEnd. |
|
1939 |
] ifFalse:[ |
|
1940 |
xMin := xEnd. |
|
1941 |
xMax := xStart |
|
1942 |
]. |
|
1943 |
yStart < yEnd ifTrue:[ |
|
1944 |
yMin := yStart. |
|
1945 |
yMax := yEnd. |
|
1946 |
] ifFalse:[ |
|
1947 |
yMin := yEnd. |
|
1948 |
yMax := yStart |
|
1949 |
]. |
|
1950 |
||
1951 |
tempForm := Form width:(xMax-xMin+1+aForm width) |
|
1952 |
height:(yMax-yMin+1+aForm height) |
|
1953 |
depth:aForm depth |
|
7287
1e2a3258dd8a
Replace all `self graphicsDevice` with `device`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7285
diff
changeset
|
1954 |
onDevice:device. |
6472 | 1955 |
tempForm clear. |
1956 |
tempForm paint:(Color colorId:1) on:(Color colorId:0). |
|
1957 |
tempForm function:#or. |
|
1958 |
||
1959 |
((yStart = yEnd and:[xStart < xEnd]) |
|
1960 |
or: [yStart < yEnd]) ifTrue:[ |
|
1961 |
x1 := xStart. y1 := yStart. |
|
1962 |
x2 := xEnd. y2 := yEnd. |
|
1963 |
] ifFalse:[ |
|
1964 |
x1 := xEnd. y1 := yEnd. |
|
1965 |
x2 := xStart. y2 := yStart. |
|
1966 |
]. |
|
1967 |
||
1968 |
x1 := x1 - xMin. x2 := x2 - xMin. |
|
1969 |
y1 := y1 - yMin. y2 := y2 - yMin. |
|
1970 |
||
1971 |
destX := x1. |
|
1972 |
destY := y1. |
|
1973 |
||
1974 |
"/ bresenham ... |
|
1975 |
||
1976 |
deltaX := x2 - x1. |
|
1977 |
deltaY := y2 - y1. |
|
1978 |
||
1979 |
dx := deltaX sign. |
|
1980 |
dy := deltaY sign. |
|
1981 |
px := deltaY abs. |
|
1982 |
py := deltaX abs. |
|
1983 |
||
1984 |
tempForm displayForm:aForm x:destX y:destY. |
|
1985 |
||
1986 |
py > px ifTrue:[ |
|
1987 |
"horizontal" |
|
1988 |
p := py // 2. |
|
1989 |
py timesRepeat:[ |
|
1990 |
destX := destX + dx. |
|
1991 |
(p := p - px) < 0 ifTrue:[ |
|
1992 |
destY := destY + dy. |
|
1993 |
p := p + py |
|
1994 |
]. |
|
1995 |
tempForm displayForm:aForm x:destX y:destY. |
|
1996 |
] |
|
1997 |
] ifFalse:[ |
|
1998 |
"vertical" |
|
1999 |
p := px // 2. |
|
2000 |
px timesRepeat:[ |
|
2001 |
destY := destY + dy. |
|
2002 |
(p := p - py) < 0 ifTrue:[ |
|
2003 |
destX := destX + dx. |
|
2004 |
p := p + px |
|
2005 |
]. |
|
2006 |
tempForm displayForm:aForm x:destX y:destY |
|
2007 |
] |
|
2008 |
]. |
|
2009 |
self displayForm:tempForm |
|
2010 |
x:xMin-aForm offset x |
|
2011 |
y:yMin-aForm offset y. |
|
2012 |
tempForm close |
|
2013 |
||
2014 |
"Modified: 1.4.1997 / 21:29:06 / cg" |
|
2015 |
! |
|
2016 |
||
2017 |
displayOpaqueString:aString at:aPoint |
|
2018 |
"draw a string with both fg and bg" |
|
2019 |
||
2020 |
gc == self ifTrue:[ |
|
2021 |
super displayOpaqueString:aString x:(aPoint x) y:(aPoint y). |
|
2022 |
^ self. |
|
2023 |
]. |
|
2024 |
gc displayOpaqueString:aString x:(aPoint x) y:(aPoint y) |
|
2025 |
! |
|
2026 |
||
2027 |
displayOpaqueString:aString from:start to:stop at:aPoint |
|
2028 |
"draw part of a string - drawing both fg and bg" |
|
2029 |
||
2030 |
gc displayString:aString from:start to:stop x:aPoint x y:aPoint x opaque:true maxWidth:self width. |
|
2031 |
! |
|
2032 |
||
2033 |
displayOpaqueString:aString x:x y:y |
|
2034 |
"draw a string at the coordinate x/y - draw foreground pixels in paint-color, |
|
2035 |
background pixels in bgPaint color. If the transformation involves scaling, |
|
2036 |
the fonts point-size is scaled as appropriate. |
|
2037 |
Assuming that device can only draw in device colors, we have to handle |
|
2038 |
the case where paint and/or bgPaint are dithered colors or images." |
|
2039 |
||
2040 |
gc == self ifTrue:[ |
|
2041 |
super displayOpaqueString:aString x:x y:y. |
|
2042 |
^ self. |
|
2043 |
]. |
|
2044 |
gc displayOpaqueString:aString x:x y:y |
|
2045 |
! |
|
2046 |
||
2047 |
displayOpaqueString:aString x:x y:y angle:drawAngle |
|
2048 |
"draw a string along a (possibly non-horizontal) line, |
|
2049 |
drawing both fg and bg pixels. |
|
2050 |
The angle is in degrees, clock-wise, starting with 0 for |
|
2051 |
a horizontal draw. |
|
2052 |
Drawing is done by first drawing the string into a temporary bitmap, |
|
2053 |
which is rotated and finally drawn as usual. |
|
2054 |
NOTICE: due to the rotation of the temporary bitmap, this is a slow |
|
2055 |
operation - not to be used with cillions of strings ..." |
|
2056 |
||
2057 |
gc == self ifTrue:[ |
|
2058 |
super displayString:aString x:x y:y angle:drawAngle opaque:true. |
|
2059 |
^ self. |
|
2060 |
]. |
|
2061 |
gc displayString:aString x:x y:y angle:drawAngle opaque:true |
|
2062 |
||
2063 |
" |
|
2064 |
|v| |
|
2065 |
||
2066 |
v := View new. |
|
2067 |
v extent:300@200. |
|
2068 |
v openAndWait. |
|
2069 |
0 to:360 by:45 do:[:a | |
|
2070 |
v paint:Color black on:Color red. |
|
2071 |
v displayOpaqueString:'hello world' x:100 y:100 angle:a. |
|
2072 |
]. |
|
2073 |
" |
|
2074 |
||
2075 |
"in contrast to non-opaque draw: |
|
2076 |
|v| |
|
2077 |
||
2078 |
v := View new. |
|
2079 |
v extent:300@200. |
|
2080 |
v openAndWait. |
|
2081 |
0 to:360 by:45 do:[:a | |
|
2082 |
v paint:Color black on:Color red. |
|
2083 |
v displayString:'hello world' x:100 y:100 angle:a. |
|
2084 |
]. |
|
2085 |
" |
|
2086 |
||
2087 |
"Modified: 23.4.1997 / 17:50:23 / cg" |
|
2088 |
! |
|
2089 |
||
2090 |
displayPoint:aPoint |
|
2091 |
"draw a pixel" |
|
2092 |
||
2093 |
gc == self ifTrue:[ |
|
2094 |
super displayPointX:(aPoint x) y:(aPoint y). |
|
2095 |
^ self. |
|
2096 |
]. |
|
2097 |
gc displayPointX:(aPoint x) y:(aPoint y) |
|
2098 |
! |
|
2099 |
||
2100 |
displayPointX:x y:y |
|
2101 |
"draw a point (with current paint-color); apply transformation if nonNil" |
|
2102 |
||
2103 |
gc == self ifTrue:[ |
|
2104 |
super displayPointX:x y:y. |
|
2105 |
^ self. |
|
2106 |
]. |
|
2107 |
gc displayPointX:x y:y |
|
2108 |
! |
|
2109 |
||
2110 |
displayRectangle:aRectangle |
|
2111 |
"draw a rectangle" |
|
2112 |
||
2113 |
self displayRectangleX:(aRectangle left) |
|
2114 |
y:(aRectangle top) |
|
2115 |
width:(aRectangle width) |
|
2116 |
height:(aRectangle height) |
|
2117 |
! |
|
2118 |
||
2119 |
displayRectangleOrigin:origin corner:corner |
|
2120 |
"draw a rectangle" |
|
2121 |
||
2122 |
|top left| |
|
2123 |
||
2124 |
left := origin x. |
|
2125 |
top := origin y. |
|
2126 |
self displayRectangleX:left y:top |
|
2127 |
width:(corner x - left) |
|
2128 |
height:(corner y - top) |
|
2129 |
! |
|
2130 |
||
2131 |
displayRectangleOrigin:origin extent:extent |
|
2132 |
"draw a rectangle" |
|
2133 |
||
2134 |
self displayRectangleX:(origin x) y:(origin y) |
|
2135 |
width:(extent x) |
|
2136 |
height:(extent y) |
|
2137 |
! |
|
2138 |
||
6730
73d56dff5532
Delegate GraphicsMedium>>display/fill RoundedRectangleX:... to GraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6472
diff
changeset
|
2139 |
displayRoundRectangleX:x y:y width:w height:h wCorner:wCorn hCorner:hCorn |
73d56dff5532
Delegate GraphicsMedium>>display/fill RoundedRectangleX:... to GraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6472
diff
changeset
|
2140 |
gc displayRoundRectangleX:x y:y width:w height:h wCorner:wCorn hCorner:hCorn |
73d56dff5532
Delegate GraphicsMedium>>display/fill RoundedRectangleX:... to GraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6472
diff
changeset
|
2141 |
|
73d56dff5532
Delegate GraphicsMedium>>display/fill RoundedRectangleX:... to GraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6472
diff
changeset
|
2142 |
"Modified: / 07-01-2015 / 20:17:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6472 | 2143 |
! |
2144 |
||
2145 |
displayString:aString at:aPoint |
|
2146 |
"draw a string - drawing fg only" |
|
2147 |
||
2148 |
self displayString:aString x:aPoint x y:aPoint y |
|
2149 |
! |
|
2150 |
||
6579 | 2151 |
displayString:aString centeredAt:aPoint |
2152 |
"draw a string - drawing fg only" |
|
2153 |
||
2154 |
self displayString:aString centeredAtX:aPoint x y:aPoint y |
|
2155 |
! |
|
2156 |
||
6472 | 2157 |
displayString:aString centeredAtX:x y:y |
2158 |
"draw a string - drawing fg only" |
|
2159 |
||
2160 |
|w h| |
|
2161 |
||
2162 |
w := aString widthOn:self. |
|
2163 |
h := aString heightOn:self. |
|
2164 |
self displayString:aString x:x-(w/2) y:y-(h/2) |
|
2165 |
! |
|
2166 |
||
2167 |
displayString:aString from:start to:stop at:aPoint |
|
2168 |
"draw part of a string - drawing fg only" |
|
2169 |
||
2170 |
^ self displayString:aString from:start to:stop x:aPoint x y:aPoint y |
|
2171 |
! |
|
2172 |
||
2173 |
displayString:aString x:x y:y |
|
2174 |
"draw a string at the coordinate x/y - |
|
2175 |
draw foreground-pixels only (in current paint-color), |
|
2176 |
leaving background as-is. If the transformation involves scaling, |
|
2177 |
the fonts point-size is scaled as appropriate." |
|
2178 |
||
2179 |
self displayString:aString from:1 to:aString size x:x y:y opaque:false maxWidth:self width. |
|
2180 |
! |
|
2181 |
||
2182 |
displayString:aString x:x y:y angle:drawAngle |
|
2183 |
"draw a string along a (possibly non-horizontal) line - drawing fg only. |
|
2184 |
The angle is in degrees, clock-wise, starting with 0 for |
|
2185 |
a horizontal draw. |
|
2186 |
Drawing is done by first drawing the string into a temporary bitmap, |
|
2187 |
which is rotated and finally drawn as usual. |
|
2188 |
NOTICE: due to the rotation of the temporary bitmap, this is a slow |
|
2189 |
operation - not to be used with cillions of strings ..." |
|
2190 |
||
2191 |
self |
|
2192 |
displayString:aString x:x y:y angle:drawAngle opaque:false |
|
2193 |
||
2194 |
" |
|
2195 |
|v| |
|
2196 |
||
2197 |
v := View new. |
|
2198 |
v extent:300@200. |
|
2199 |
v openAndWait. |
|
2200 |
0 to:360 by:90 do:[:a | |
|
2201 |
v paint:Color black. |
|
2202 |
v displayString:'hello world' x:100 y:100 angle:a. |
|
2203 |
]. |
|
2204 |
" |
|
2205 |
" |
|
2206 |
|v| |
|
2207 |
||
2208 |
v := View new. |
|
2209 |
v extent:400@400. |
|
2210 |
v openAndWait. |
|
2211 |
0 to:360 by:5 do:[:a | |
|
2212 |
v paint:Color black. |
|
2213 |
v displayString:'.........hello' x:200 y:200 angle:a. |
|
2214 |
]. |
|
2215 |
" |
|
2216 |
" |
|
2217 |
|v| |
|
2218 |
||
2219 |
v := View new. |
|
2220 |
v extent:200@100. |
|
2221 |
v openAndWait. |
|
2222 |
v displayString:' hello' x:90 y:50 angle:0. |
|
2223 |
v displayString:' hello' x:90 y:50 angle:45. |
|
2224 |
v displayString:' hello' x:90 y:50 angle:90. |
|
2225 |
v displayString:' hello' x:90 y:50 angle:180. |
|
2226 |
v displayString:' hello' x:90 y:50 angle:270. |
|
2227 |
" |
|
2228 |
" |
|
2229 |
|v| |
|
2230 |
||
2231 |
v := View new. |
|
2232 |
v extent:200@100. |
|
2233 |
v openAndWait. |
|
2234 |
v displayString:'hello' x:50 y:50 angle:0. |
|
2235 |
v displayString:'hello' x:50 y:50 angle:45. |
|
2236 |
v displayString:'hello' x:50 y:50 angle:90. |
|
2237 |
v displayString:'hello' x:50 y:50 angle:135. |
|
2238 |
v displayString:'hello' x:50 y:50 angle:180. |
|
2239 |
v displayString:'hello' x:50 y:50 angle:225. |
|
2240 |
v displayString:'hello' x:50 y:50 angle:270. |
|
2241 |
v displayString:'hello' x:50 y:50 angle:315. |
|
2242 |
" |
|
2243 |
||
2244 |
"Modified: 24.4.1997 / 12:51:25 / cg" |
|
2245 |
! |
|
2246 |
||
2247 |
displayString:aString x:x y:y angle:drawAngle opaque:opaque |
|
2248 |
"common code to draw a string along a (possibly non-horizontal) line. |
|
2249 |
The angle is in degrees, clock-wise, starting with 0 for |
|
2250 |
a horizontal draw. |
|
2251 |
Drawing is done by first drawing the string into a temporary bitmap, |
|
2252 |
which is rotated and finally drawn as usual. |
|
2253 |
NOTICE: due to the rotation of the temporary bitmap, this is a slow |
|
2254 |
operation - not to be used with cillions of strings ... |
|
2255 |
CAVEAT: if the string is not a real string (i.e. a LabelAndIcon), |
|
2256 |
this can (currently) only be done opaque" |
|
2257 |
||
2258 |
gc == self ifTrue:[ |
|
2259 |
super displayString:aString x:x y:y angle:drawAngle opaque:opaque. |
|
2260 |
^ self. |
|
2261 |
]. |
|
2262 |
gc displayString:aString x:x y:y angle:drawAngle opaque:opaque |
|
2263 |
! |
|
2264 |
||
2265 |
displayUnscaledForm:formToDraw x:x y:y |
|
2266 |
"draw a form or image non opaque and unscaled; |
|
2267 |
if its a 1-plane bitmap, 1-bits are drawn in the |
|
2268 |
current paint-color, leaving pixels with 0-bits unchanged |
|
2269 |
(i.e. only 1-bits are drawn from the form). |
|
2270 |
If its a deep form (i.e. a pixmap) the current paint |
|
2271 |
settings are ignored and the form is drawn as-is. |
|
2272 |
Care must be taken, that the paint color is correctly allocated |
|
2273 |
(by sending #on: to the color) before doing so. |
|
2274 |
Using functions other than #copy only makes sense if you are |
|
2275 |
certain, that the colors are real colors (actually, only for |
|
2276 |
noColor or allColor). |
|
2277 |
The origins coordinate is transformed, but the image itself is unscaled." |
|
2278 |
||
2279 |
gc == self ifTrue:[ |
|
2280 |
super displayUnscaledForm:formToDraw x:x y:y. |
|
2281 |
^ self. |
|
2282 |
]. |
|
2283 |
gc displayUnscaledForm:formToDraw x:x y:y |
|
2284 |
! |
|
2285 |
||
2286 |
displayUnscaledOpaqueForm:formToDraw x:x y:y |
|
2287 |
"draw a form or image opaque and unscaled; |
|
2288 |
if its a 1-plane bitmap, 1-bits are drawn in the |
|
2289 |
current paint-color, 0 bits in background color. |
|
2290 |
If its a deep form (i.e. a pixmap) the current paint |
|
2291 |
settings are ignored and the form is drawn as-is (opaque). |
|
2292 |
The origins coordinate is transformed, but the image itself is unscaled." |
|
2293 |
||
2294 |
gc == self ifTrue:[ |
|
2295 |
super displayUnscaledOpaqueForm:formToDraw x:x y:y. |
|
2296 |
^ self. |
|
2297 |
]. |
|
2298 |
gc displayUnscaledOpaqueForm:formToDraw x:x y:y |
|
2299 |
! |
|
2300 |
||
2301 |
displayUnscaledOpaqueString:aString from:index1 to:index2 x:x y:y |
|
2302 |
"draw a substring at the transformed coordinate x/y but do not scale the font. |
|
2303 |
Draw foreground pixels in paint-color, background pixels in bgPaint color." |
|
2304 |
||
2305 |
gc == self ifTrue:[ |
|
2306 |
super displayUnscaledOpaqueString:aString from:index1 to:index2 x:x y:y. |
|
2307 |
^ self. |
|
2308 |
]. |
|
2309 |
gc displayUnscaledOpaqueString:aString from:index1 to:index2 x:x y:y |
|
2310 |
! |
|
2311 |
||
2312 |
displayUnscaledOpaqueString:aString x:x y:y |
|
2313 |
"draw a string at the transformed coordinate x/y but do not scale the font. |
|
2314 |
Draw foreground pixels in paint-color, background pixels in bgPaint color." |
|
2315 |
||
2316 |
gc == self ifTrue:[ |
|
2317 |
super displayUnscaledOpaqueString:aString x:x y:y. |
|
2318 |
^ self. |
|
2319 |
]. |
|
2320 |
gc displayUnscaledOpaqueString:aString x:x y:y |
|
2321 |
! |
|
2322 |
||
2323 |
displayUnscaledString:aString from:index1 to:index2 x:x y:y |
|
2324 |
"draw a substring at the transformed coordinate x/y but do not scale the font. |
|
2325 |
draw foreground-pixels only (in current paint-color), leaving background as-is." |
|
2326 |
||
2327 |
gc == self ifTrue:[ |
|
2328 |
super displayUnscaledString:aString from:index1 to:index2 x:x y:y. |
|
2329 |
^ self. |
|
2330 |
]. |
|
2331 |
gc displayUnscaledString:aString from:index1 to:index2 x:x y:y |
|
2332 |
! |
|
2333 |
||
2334 |
displayUnscaledString:aString x:x y:y |
|
2335 |
"draw a string at the transformed coordinate x/y but do not scale the font. |
|
2336 |
draw foreground-pixels only (in current paint-color), leaving background as-is." |
|
2337 |
||
2338 |
gc == self ifTrue:[ |
|
2339 |
super displayUnscaledString:aString x:x y:y. |
|
2340 |
^ self. |
|
2341 |
]. |
|
2342 |
gc displayUnscaledString:aString x:x y:y |
|
2343 |
! ! |
|
2344 |
||
2345 |
!GraphicsMedium methodsFor:'drawing in device coordinates'! |
|
2346 |
||
2347 |
displayDeviceForm:aForm x:x y:y |
|
2348 |
"draw a form or image non opaque (i.e. only foreground color is drawn); |
|
2349 |
If its a 1-plane bitmap, 1-bits are drawn in the |
|
2350 |
current paint-color, leaving pixels with 0-bits unchanged |
|
2351 |
(i.e. only 1-bits are drawn from the form). |
|
2352 |
If its a deep form (i.e. a pixmap) the current paint |
|
2353 |
settings are ignored and the form is drawn as-is; |
|
2354 |
however, the mask is applied if present. |
|
2355 |
||
2356 |
The form should must have been allocated on the same device, |
|
2357 |
otherwise its converted here, which slows down the draw. |
|
2358 |
No transformation or scaling is done. |
|
2359 |
Care must be taken, that the paint color is correctly allocated |
|
2360 |
(by sending #on: to the color) before doing so. |
|
2361 |
Using functions other than #copy only makes sense if you are |
|
2362 |
certain, that the colors are real colors (actually, only for |
|
2363 |
noColor or allColor)." |
|
2364 |
||
2365 |
gc == self ifTrue:[ |
|
2366 |
super displayDeviceForm:aForm x:x y:y. |
|
2367 |
^ self. |
|
2368 |
]. |
|
2369 |
gc displayDeviceForm:aForm x:x y:y |
|
2370 |
! |
|
2371 |
||
2372 |
displayDeviceLineFromX:x1 y:y1 toX:x2 y:y2 |
|
2373 |
"draw a line in device coordinates" |
|
2374 |
||
2375 |
gc == self ifTrue:[ |
|
2376 |
super displayDeviceLineFromX:x1 y:y1 toX:x2 y:y2. |
|
2377 |
^ self. |
|
2378 |
]. |
|
2379 |
gc displayDeviceLineFromX:x1 y:y1 toX:x2 y:y2 |
|
2380 |
! |
|
2381 |
||
2382 |
displayDeviceOpaqueForm:aForm x:x y:y |
|
2383 |
"draw a form or image opaque (i.e. both fg and bg is drawn); |
|
2384 |
If its a 1-plane bitmap, 1-bits are drawn in the |
|
2385 |
current paint-color and 0-bits in the bgPaint color. |
|
2386 |
If its a deep form (i.e. a pixmap) the current paint/bgPaint |
|
2387 |
settings are ignored and the form drawn as-is. |
|
2388 |
Any mask is ignored. |
|
2389 |
In the 1-plane case, special care must be taken if paint and/or bgPaint |
|
2390 |
dithered colors or patterns, since are that the colors are correctly allocated (by sending #on: |
|
2391 |
to the colors) before doing so. |
|
2392 |
The form should have been allocated on the same device; otherwise, |
|
2393 |
its converted here, which slows down the draw. |
|
2394 |
Drawing is in device coordinates; no scaling is done." |
|
2395 |
||
2396 |
gc == self ifTrue:[ |
|
2397 |
super displayDeviceOpaqueForm:aForm x:x y:y. |
|
2398 |
^ self. |
|
2399 |
]. |
|
2400 |
gc displayDeviceOpaqueForm:aForm x:x y:y |
|
2401 |
! |
|
2402 |
||
2403 |
displayDeviceOpaqueString:aString from:index1 to:index2 in:font x:x y:y |
|
2404 |
"draw a substring at the coordinate x/y - draw foreground pixels in |
|
2405 |
paint-color and background pixels in bgPaint-color. |
|
2406 |
Assuming that device can only draw in device colors, we have to handle |
|
2407 |
the case where paint and/or bgPaint are dithered colors. |
|
2408 |
No translation or scaling is done." |
|
2409 |
||
2410 |
gc == self ifTrue:[ |
|
2411 |
super displayDeviceOpaqueString:aString from:index1 to:index2 in:font x:x y:y. |
|
2412 |
^ self. |
|
2413 |
]. |
|
2414 |
gc displayDeviceOpaqueString:aString from:index1 to:index2 in:font x:x y:y |
|
2415 |
! |
|
2416 |
||
2417 |
displayDeviceOpaqueString:aString from:index1 to:index2 x:x y:y |
|
2418 |
"draw a substring at the coordinate x/y - draw foreground pixels in |
|
2419 |
paint-color and background pixels in bgPaint-color. |
|
2420 |
Assuming that device can only draw in device colors, we have to handle |
|
2421 |
the case where paint and/or bgPaint are dithered colors. |
|
2422 |
No translation or scaling is done." |
|
2423 |
||
2424 |
self displayDeviceOpaqueString:aString from:index1 to:index2 in:self font x:x y:y |
|
2425 |
! |
|
2426 |
||
2427 |
displayDeviceOpaqueString:aString x:x y:y |
|
2428 |
"draw a string at the coordinate x/y - draw foreground pixels in |
|
2429 |
paint-color and background pixels in bgPaint-color. |
|
2430 |
No translation or scaling is done" |
|
2431 |
||
2432 |
self displayDeviceOpaqueString:aString from:1 to:(aString size) in:self font x:x y:y |
|
2433 |
! |
|
2434 |
||
2435 |
displayDeviceRectangleX:x y:y width:w height:h |
|
2436 |
"draw a rectangle in device coordinates" |
|
2437 |
||
2438 |
gc == self ifTrue:[ |
|
2439 |
super displayDeviceRectangleX:x y:y width:w height:h. |
|
2440 |
^ self. |
|
2441 |
]. |
|
2442 |
gc displayDeviceRectangleX:x y:y width:w height:h |
|
2443 |
! |
|
2444 |
||
2445 |
displayDeviceString:aString from:index1 to:index2 in:font x:x y:y |
|
2446 |
"draw a substring at the coordinate x/y - |
|
2447 |
draw foreground-pixels only (in current paint-color), leaving background as-is. |
|
2448 |
No translation or scaling is done" |
|
2449 |
||
2450 |
gc == self ifTrue:[ |
|
2451 |
super displayDeviceString:aString from:index1 to:index2 in:font x:x y:y. |
|
2452 |
^ self. |
|
2453 |
]. |
|
2454 |
gc displayDeviceString:aString from:index1 to:index2 in:font x:x y:y |
|
2455 |
! |
|
2456 |
||
2457 |
displayDeviceString:aString from:index1 to:index2 x:x y:y |
|
2458 |
"draw a substring at the coordinate x/y - |
|
2459 |
draw foreground-pixels only (in current paint-color), leaving background as-is. |
|
2460 |
No translation or scaling is done" |
|
2461 |
||
2462 |
self displayDeviceString:aString from:index1 to:index2 in:self font x:x y:y |
|
2463 |
! |
|
2464 |
||
2465 |
displayDeviceString:aString x:x y:y |
|
2466 |
"draw a string at the coordinate x/y - |
|
2467 |
draw foreground-pixels only (in current paint-color), leaving background as-is. |
|
2468 |
No translation or scaling is done" |
|
2469 |
||
2470 |
self displayDeviceString:aString from:1 to:(aString size) in:self font x:x y:y |
|
2471 |
! |
|
2472 |
||
2473 |
fillDeviceRectangleX:x y:y width:w height:h |
|
2474 |
"fill a rectangle with current paint color (device coordinates)" |
|
2475 |
||
2476 |
gc == self ifTrue:[ |
|
2477 |
super fillDeviceRectangleX:x y:y width:w height:h. |
|
2478 |
^ self. |
|
2479 |
]. |
|
2480 |
gc fillDeviceRectangleX:x y:y width:w height:h |
|
2481 |
! ! |
|
2482 |
||
2483 |
!GraphicsMedium methodsFor:'edge drawing'! |
|
2484 |
||
2485 |
drawEdgesForX:x y:y width:w height:h level:l |
|
2486 |
"draw 3D edges into a rectangle" |
|
2487 |
self |
|
2488 |
drawEdgesForX:x y:y width:w height:h level:l |
|
2489 |
shadow:self blackColor light:self whiteColor |
|
2490 |
halfShadow:nil halfLight:nil |
|
2491 |
style:nil |
|
2492 |
! |
|
2493 |
||
2494 |
drawEdgesForX:x y:y width:w height:h level:l |
|
2495 |
shadow:shadowColor light:lightColor |
|
2496 |
halfShadow:halfShadowColor halfLight:halfLightColor |
|
2497 |
style:edgeStyle |
|
2498 |
||
2499 |
"draw 3D edges into a rectangle" |
|
2500 |
||
2501 |
|topLeftFg botRightFg topLeftHalfFg botRightHalfFg |
|
2502 |
count "{ Class: SmallInteger }" |
|
2503 |
r |
|
2504 |
b |
|
2505 |
xi "{ Class: SmallInteger }" |
|
2506 |
yi "{ Class: SmallInteger }" |
|
2507 |
run paint| |
|
2508 |
||
2509 |
count := l. |
|
2510 |
(count < 0) ifTrue:[ |
|
2511 |
topLeftFg := shadowColor. |
|
2512 |
botRightFg := lightColor. |
|
2513 |
topLeftHalfFg := halfShadowColor. |
|
2514 |
botRightHalfFg := halfLightColor. |
|
2515 |
count := count negated |
|
2516 |
] ifFalse:[ |
|
2517 |
topLeftFg := lightColor. |
|
2518 |
botRightFg := shadowColor. |
|
2519 |
topLeftHalfFg := halfLightColor. |
|
2520 |
botRightHalfFg := halfShadowColor. |
|
2521 |
]. |
|
2522 |
topLeftHalfFg isNil ifTrue:[ |
|
2523 |
topLeftHalfFg := topLeftFg |
|
2524 |
]. |
|
2525 |
botRightHalfFg isNil ifTrue:[ |
|
2526 |
botRightHalfFg := botRightFg |
|
2527 |
]. |
|
2528 |
||
2529 |
r := x + w - 1. "right" |
|
2530 |
b := y + h - 1. "bottom" |
|
2531 |
||
2532 |
self lineWidth:0. |
|
2533 |
||
2534 |
"top and left edges" |
|
2535 |
((edgeStyle == #soft or:[edgeStyle == #softWin95]) and:["l" count > 0]) ifTrue:[ |
|
2536 |
paint := topLeftHalfFg |
|
2537 |
] ifFalse:[ |
|
2538 |
paint := topLeftFg |
|
2539 |
]. |
|
2540 |
self paint:paint. |
|
2541 |
||
2542 |
0 to:(count - 1) do:[:i | |
|
2543 |
run := y + i. |
|
2544 |
run < b ifTrue:[ |
|
2545 |
self displayDeviceLineFromX:x y:run toX:r y:run. "top" |
|
2546 |
]. |
|
2547 |
run := x + i. |
|
2548 |
self displayDeviceLineFromX:run y:y toX:run y:b "left" |
|
2549 |
]. |
|
2550 |
(edgeStyle == #soft or:[edgeStyle == #softWin95]) ifTrue:[ |
|
2551 |
" |
|
2552 |
self paint:topLeftFg. |
|
2553 |
self displayDeviceLineFromX:x y:y toX:r y:y. |
|
2554 |
self displayDeviceLineFromX:x y:y toX:x y:b |
|
2555 |
" |
|
2556 |
(l > 1) ifTrue:[ |
|
2557 |
edgeStyle == #softWin95 ifTrue:[ |
|
2558 |
self paint:(Color veryLightGrey). |
|
2559 |
] ifFalse:[ |
|
2560 |
(l > 2 and:[edgeStyle == #soft]) ifTrue:[ |
|
2561 |
self paint:(self device blackColor). |
|
2562 |
] ifFalse:[ |
|
2563 |
self paint:halfLightColor. |
|
2564 |
] |
|
2565 |
]. |
|
2566 |
self displayDeviceLineFromX:x y:y toX:r y:y. |
|
2567 |
self displayDeviceLineFromX:x y:y toX:x y:b. |
|
2568 |
] |
|
2569 |
]. |
|
2570 |
||
2571 |
xi := x + 1. |
|
2572 |
yi := y + 1. |
|
2573 |
||
2574 |
"/ does not look good |
|
2575 |
"/ style == #st80 iftrue:[ |
|
2576 |
"/ yi := yi + 1 |
|
2577 |
"/ ]. |
|
2578 |
||
2579 |
"bottom and right edges" |
|
2580 |
((edgeStyle == #soft or:[edgeStyle == #softWin95]) |
|
2581 |
"new:" and:[count > 1]) ifTrue:[ |
|
2582 |
paint := botRightHalfFg |
|
2583 |
] ifFalse:[ |
|
2584 |
paint := botRightFg |
|
2585 |
]. |
|
2586 |
||
2587 |
self paint:paint. |
|
2588 |
0 to:(count - 1) do:[:i | |
|
2589 |
run := b - i. |
|
2590 |
run > y ifTrue:[ |
|
2591 |
self displayDeviceLineFromX:xi-1 y:run toX:r y:run. "bottom" |
|
2592 |
]. |
|
2593 |
run := r - i. |
|
2594 |
self displayDeviceLineFromX:run y:yi-1 toX:run y:b. "right" |
|
2595 |
xi := xi + 1. |
|
2596 |
yi := yi + 1 |
|
2597 |
]. |
|
2598 |
((edgeStyle == #soft or:[edgeStyle == #softWin95]) |
|
2599 |
and:[l > 1]) ifTrue:[ |
|
2600 |
self paint:(self device blackColor) "shadowColor". |
|
2601 |
self displayDeviceLineFromX:x y:b toX:r y:b. |
|
2602 |
self displayDeviceLineFromX:r y:y toX:r y:b |
|
2603 |
]. |
|
2604 |
||
2605 |
self edgeDrawn:#all |
|
2606 |
||
2607 |
"Modified: / 24.8.1998 / 18:23:02 / cg" |
|
2608 |
! |
|
2609 |
||
2610 |
edgeDrawn:whichOne |
|
2611 |
"a redefinable hook for views which like to draw |
|
2612 |
over their edges (some checkToggles do). |
|
2613 |
Nothing done here." |
|
2614 |
||
2615 |
"Created: 7.3.1997 / 17:59:07 / cg" |
|
2616 |
! ! |
|
2617 |
||
2618 |
!GraphicsMedium methodsFor:'evaluating in another context'! |
|
2619 |
||
2620 |
reverseDo:aBlock |
|
2621 |
"evaluate aBlock with foreground and background interchanged. |
|
2622 |
This can be reimplemented here in a faster way." |
|
2623 |
||
2624 |
gc == self ifTrue:[ |
|
2625 |
super reverseDo:aBlock. |
|
2626 |
^ self. |
|
2627 |
]. |
|
2628 |
gc reverseDo:aBlock |
|
2629 |
! |
|
2630 |
||
2631 |
withBackground:fgColor do:aBlock |
|
2632 |
"evaluate aBlock with changed background." |
|
2633 |
||
2634 |
gc == self ifTrue:[ |
|
2635 |
super withBackground:fgColor do:aBlock. |
|
2636 |
^ self. |
|
2637 |
]. |
|
2638 |
gc withBackground:fgColor do:aBlock |
|
2639 |
! |
|
2640 |
||
2641 |
withForeground:fgColor background:bgColor do:aBlock |
|
2642 |
"evaluate aBlock with changed foreground and background." |
|
2643 |
||
2644 |
gc == self ifTrue:[ |
|
2645 |
super withForeground:fgColor background:bgColor do:aBlock. |
|
2646 |
^ self. |
|
2647 |
]. |
|
2648 |
gc withForeground:fgColor background:bgColor do:aBlock |
|
2649 |
! |
|
2650 |
||
2651 |
withForeground:fgColor background:bgColor function:aFunction do:aBlock |
|
2652 |
"evaluate aBlock with foreground, background and function" |
|
2653 |
||
2654 |
gc == self ifTrue:[ |
|
2655 |
super withForeground:fgColor background:bgColor function:aFunction do:aBlock. |
|
2656 |
^ self. |
|
2657 |
]. |
|
2658 |
gc withForeground:fgColor background:bgColor function:aFunction do:aBlock |
|
2659 |
! |
|
2660 |
||
2661 |
withForeground:fgColor background:bgColor mask:aMask do:aBlock |
|
2662 |
"evaluate aBlock with foreground, background and mask" |
|
2663 |
||
2664 |
gc == self ifTrue:[ |
|
2665 |
super withForeground:fgColor background:bgColor mask:aMask do:aBlock. |
|
2666 |
^ self. |
|
2667 |
]. |
|
2668 |
gc withForeground:fgColor background:bgColor mask:aMask do:aBlock |
|
2669 |
! |
|
2670 |
||
2671 |
withForeground:fgColor do:aBlock |
|
2672 |
"evaluate aBlock with changed foreground." |
|
2673 |
||
2674 |
gc == self ifTrue:[ |
|
2675 |
super withForeground:fgColor do:aBlock. |
|
2676 |
^ self. |
|
2677 |
]. |
|
2678 |
gc withForeground:fgColor do:aBlock |
|
2679 |
! |
|
2680 |
||
2681 |
withForeground:fgColor function:aFunction do:aBlock |
|
2682 |
"evaluate aBlock with changed foreground and function." |
|
2683 |
||
2684 |
gc == self ifTrue:[ |
|
2685 |
super withForeground:fgColor function:aFunction do:aBlock. |
|
2686 |
^ self. |
|
2687 |
]. |
|
2688 |
gc withForeground:fgColor function:aFunction do:aBlock |
|
2689 |
! |
|
2690 |
||
2691 |
xoring:aBlock |
|
2692 |
"evaluate aBlock with function xoring" |
|
2693 |
||
2694 |
gc == self ifTrue:[ |
|
2695 |
super xoring:aBlock. |
|
2696 |
^ self. |
|
2697 |
]. |
|
2698 |
gc xoring:aBlock |
|
2699 |
! ! |
|
2700 |
||
721
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2701 |
!GraphicsMedium methodsFor:'filling'! |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2702 |
|
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2703 |
black |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2704 |
"fill the receiver with black" |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2705 |
|
6472 | 2706 |
self fill:self blackColor |
721
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2707 |
! |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2708 |
|
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2709 |
clear |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2710 |
"clear the receiver with background" |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2711 |
|
4068 | 2712 |
self clearView. |
721
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2713 |
! |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2714 |
|
6472 | 2715 |
clearDeviceRectangleX:x y:y width:w height:h |
2716 |
"clear a rectangular area to viewBackground - |
|
2717 |
redefined since GraphicsMedium fills with background |
|
2718 |
- not viewBackground as we want here." |
|
2719 |
||
2720 |
gc == self ifTrue:[ |
|
2721 |
super clearDeviceRectangleX:x y:y width:w height:h. |
|
2722 |
^ self. |
|
2723 |
]. |
|
2724 |
gc clearDeviceRectangleX:x y:y width:w height:h. |
|
2725 |
! |
|
2726 |
||
721
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2727 |
clearInside |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2728 |
"clear the receiver with background - ST-80 compatibility" |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2729 |
|
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2730 |
^ self clear |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2731 |
! |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2732 |
|
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2733 |
clearRectangle:aRectangle |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2734 |
"clear the rectangular area in the receiver to background" |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2735 |
|
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2736 |
self clearRectangleX:(aRectangle left) |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2737 |
y:(aRectangle top) |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2738 |
width:(aRectangle width) |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2739 |
height:(aRectangle height) |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2740 |
! |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2741 |
|
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2742 |
clearRectangleX:left y:top width:w height:h |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2743 |
"clear the rectangular area in the receiver to background" |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2744 |
|
741 | 2745 |
|oldPaint| |
2746 |
||
6472 | 2747 |
oldPaint := gc paint. |
2748 |
gc paint:gc backgroundPaint. |
|
6045 | 2749 |
gc fillRectangleX:left y:top width:w height:h. |
2750 |
gc paint:oldPaint |
|
741 | 2751 |
|
2752 |
"Modified: 28.5.1996 / 20:14:11 / cg" |
|
721
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2753 |
! |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2754 |
|
4068 | 2755 |
clearView |
2756 |
"clear the receiver with background" |
|
2757 |
||
2758 |
"currently need this kludge for form ..." |
|
6472 | 2759 |
gc transformation isNil ifTrue:[ |
5321 | 2760 |
self clearRectangleX:0 y:0 width:width height:height |
4068 | 2761 |
] ifFalse:[ |
5321 | 2762 |
self clearDeviceRectangleX:0 y:0 width:width height:height |
4068 | 2763 |
] |
2764 |
! |
|
2765 |
||
721
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2766 |
fill:something |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2767 |
"fill the receiver with something; |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2768 |
something may be a Form, Color or colorIndex" |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2769 |
|
736 | 2770 |
|oldPaint| |
721
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2771 |
|
6472 | 2772 |
oldPaint := self paint. |
2773 |
self paint:something. |
|
2774 |
self fillRectangleX:0 y:0 width:width height:height. |
|
2775 |
self paint:oldPaint |
|
721
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2776 |
|
741 | 2777 |
"Modified: 28.5.1996 / 20:13:29 / cg" |
721
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2778 |
! |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2779 |
|
6472 | 2780 |
fillArc:origin radius:r from:startAngle angle:angle |
2781 |
"draw a filled arc around a point" |
|
2782 |
||
2783 |
|d| |
|
2784 |
d := 2 * r. |
|
2785 |
self |
|
2786 |
fillArcX:(origin x - r) |
|
2787 |
y:(origin y - r) |
|
2788 |
width:d |
|
2789 |
height:d |
|
2790 |
from:startAngle |
|
2791 |
angle:angle |
|
2792 |
||
2793 |
"Modified: 8.5.1996 / 08:41:54 / cg" |
|
2794 |
! |
|
2795 |
||
2796 |
fillArcIn:aRectangle from:startAngle angle:angle |
|
2797 |
"draw a filled arc in a box" |
|
2798 |
||
2799 |
self |
|
2800 |
fillArcX:(aRectangle left) |
|
2801 |
y:(aRectangle top) |
|
2802 |
width:(aRectangle width) |
|
2803 |
height:(aRectangle height) |
|
2804 |
from:startAngle |
|
2805 |
angle:angle |
|
2806 |
||
2807 |
"Created: 13.4.1996 / 20:56:03 / cg" |
|
2808 |
"Modified: 8.5.1996 / 08:42:13 / cg" |
|
2809 |
! |
|
2810 |
||
2811 |
fillArcOrigin:origin corner:corner from:startAngle angle:angle |
|
2812 |
"draw a filled arc in a box" |
|
2813 |
||
2814 |
|left top right bot| |
|
2815 |
||
2816 |
left := origin x. |
|
2817 |
top := origin y. |
|
2818 |
right := corner x. |
|
2819 |
bot := corner y. |
|
2820 |
self |
|
2821 |
fillArcX:left |
|
2822 |
y:top |
|
2823 |
width:(right - left + 1) |
|
2824 |
height:(bot - top + 1) |
|
2825 |
from:startAngle |
|
2826 |
angle:angle |
|
2827 |
||
2828 |
"Created: 13.4.1996 / 20:56:56 / cg" |
|
2829 |
"Modified: 8.5.1996 / 08:42:23 / cg" |
|
2830 |
! |
|
2831 |
||
2832 |
fillArcX:x y:y w:w h:h from:startAngle angle:angle |
|
2833 |
"draw a filled arc; apply transformation if nonNil" |
|
2834 |
||
2835 |
<resource:#obsolete> |
|
2836 |
||
2837 |
self obsoleteMethodWarning:'use #fillArcX:y:width:height:from:angle:'. |
|
2838 |
self fillArcX:x y:y width:w height:h from:startAngle angle:angle |
|
2839 |
||
2840 |
"Modified: 8.5.1996 / 08:47:52 / cg" |
|
2841 |
! |
|
2842 |
||
2843 |
fillArcX:x y:y width:w height:h from:startAngle to:endAngle |
|
2844 |
"draw a filled arc in a box, given startAngle and endAngle." |
|
2845 |
||
2846 |
self |
|
2847 |
fillArcX:x |
|
2848 |
y:y |
|
2849 |
width:w |
|
2850 |
height:h |
|
2851 |
from:startAngle |
|
2852 |
angle:(endAngle - startAngle) |
|
2853 |
||
2854 |
"Created: 8.5.1996 / 08:52:41 / cg" |
|
2855 |
! |
|
2856 |
||
2857 |
fillCircle:aPoint radius:aNumber |
|
2858 |
"draw a filled circle around aPoint" |
|
2859 |
||
2860 |
self fillCircleX:(aPoint x) y:(aPoint y) radius:aNumber |
|
2861 |
! |
|
2862 |
||
2863 |
fillCircleIn:aRectangle |
|
2864 |
"draw a filled circle in a box" |
|
2865 |
||
2866 |
self |
|
2867 |
fillArcX:(aRectangle left) |
|
2868 |
y:(aRectangle top) |
|
2869 |
width:(aRectangle width) |
|
2870 |
height:(aRectangle height) |
|
2871 |
from:0 |
|
2872 |
angle:360 |
|
2873 |
||
2874 |
"Created: 13.4.1996 / 20:57:41 / cg" |
|
2875 |
"Modified: 8.5.1996 / 08:42:38 / cg" |
|
2876 |
! |
|
2877 |
||
2878 |
fillCircleX:x y:y radius:r |
|
2879 |
"draw a filled circle around x@y" |
|
2880 |
||
2881 |
|d| |
|
2882 |
||
2883 |
d := 2 * r. |
|
2884 |
self |
|
2885 |
fillArcX:(x - r) |
|
2886 |
y:(y - r) |
|
2887 |
width:d |
|
2888 |
height:d |
|
2889 |
from:0 |
|
2890 |
angle:360 |
|
2891 |
||
2892 |
"Modified: 8.5.1996 / 08:43:02 / cg" |
|
2893 |
! |
|
2894 |
||
2895 |
fillRectangle:aRectangle |
|
2896 |
"fill a rectangle with current paint color" |
|
2897 |
||
2898 |
self fillRectangleX:(aRectangle left) |
|
2899 |
y:(aRectangle top) |
|
2900 |
width:(aRectangle width) |
|
2901 |
height:(aRectangle height) |
|
2902 |
! |
|
2903 |
||
2904 |
fillRectangleLeft:left top:top right:cornerX bottom:cornerY |
|
2905 |
"draw a filled rectangle. |
|
2906 |
Notice: the cornerPoint itself is NOT included" |
|
2907 |
||
2908 |
self fillRectangleX:left y:top width:(cornerX - left) height:(cornerY - top) |
|
2909 |
! |
|
2910 |
||
2911 |
fillRectangleOrigin:origin corner:corner |
|
2912 |
"draw a filled rectangle. |
|
2913 |
Notice: the cornerPoint itself is NOT included" |
|
2914 |
||
2915 |
|top left| |
|
2916 |
||
2917 |
left := origin x. |
|
2918 |
top := origin y. |
|
2919 |
self fillRectangleX:left y:top width:(corner x - left) height:(corner y - top) |
|
2920 |
||
2921 |
"Created: 13.4.1996 / 20:58:16 / cg" |
|
2922 |
! |
|
2923 |
||
2924 |
fillRectangleOrigin:origin extent:extent |
|
2925 |
"draw a filled rectangle. |
|
2926 |
Notice: the cornerPoint itself is NOT included" |
|
2927 |
||
2928 |
self fillRectangleX:(origin x) y:(origin y) width:(extent x) height:(extent y) |
|
2929 |
! |
|
2930 |
||
6730
73d56dff5532
Delegate GraphicsMedium>>display/fill RoundedRectangleX:... to GraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6472
diff
changeset
|
2931 |
fillRoundRectangleX:x y:y width:w height:h wCorner:wCorn hCorner:hCorn |
73d56dff5532
Delegate GraphicsMedium>>display/fill RoundedRectangleX:... to GraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6472
diff
changeset
|
2932 |
gc fillRoundRectangleX:x y:y width:w height:h wCorner:wCorn hCorner:hCorn |
73d56dff5532
Delegate GraphicsMedium>>display/fill RoundedRectangleX:... to GraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6472
diff
changeset
|
2933 |
|
73d56dff5532
Delegate GraphicsMedium>>display/fill RoundedRectangleX:... to GraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6472
diff
changeset
|
2934 |
"Modified: / 07-01-2015 / 20:18:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6472 | 2935 |
! |
2936 |
||
721
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2937 |
invertRectangle:aRectangle |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2938 |
"invert a rectangle in the receiver" |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2939 |
|
6472 | 2940 |
self xoring:[ |
2941 |
self fillRectangle:aRectangle |
|
721
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2942 |
] |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2943 |
! |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2944 |
|
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2945 |
white |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2946 |
"fill the receiver with white" |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2947 |
|
6472 | 2948 |
self fill:Color white |
721
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2949 |
! ! |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2950 |
|
6472 | 2951 |
!GraphicsMedium methodsFor:'initialization & release'! |
2952 |
||
2953 |
close |
|
2954 |
"same as destroy - for ST-80 compatibility" |
|
2955 |
||
2956 |
self destroy |
|
2957 |
||
2958 |
"Created: 2.4.1997 / 19:31:27 / cg" |
|
2959 |
! |
|
2960 |
||
2961 |
destroy |
|
2962 |
"destroy a medium - here the fc is completely destroyed" |
|
2963 |
||
2964 |
gc notNil ifTrue:[ |
|
2965 |
gc destroy. |
|
2966 |
]. |
|
2967 |
realized := false. |
|
2968 |
! |
|
2969 |
||
2970 |
initGC |
|
2971 |
"since we do not need a gc-object for the drawable until something is |
|
2972 |
really drawn, none is created. |
|
2973 |
This method is sent, when the first drawing happens" |
|
2974 |
||
2975 |
gc == self ifTrue:[ |
|
2976 |
super initGC. |
|
2977 |
^ self. |
|
2978 |
]. |
|
2979 |
gc initGC |
|
2980 |
! |
|
721
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2981 |
|
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2982 |
initialize |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2983 |
super initialize. |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2984 |
|
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2985 |
width := 0. |
727
bf23a306b6f2
renamed PseudoView to DisplaySurface
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
2986 |
height := 0. |
bf23a306b6f2
renamed PseudoView to DisplaySurface
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
2987 |
realized := false. |
6472 | 2988 |
! |
2989 |
||
2990 |
initializeForDevice:aDevice |
|
2991 |
"allocate a GraphicsContext for a device" |
|
2992 |
||
2993 |
aDevice notNil ifTrue:[ |
|
2994 |
gc := aDevice newGraphicsContextFor:self. |
|
7285
d047c5fb149a
Compatibility: reintroduce `device` instvar in `GraphicsMedium`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6800
diff
changeset
|
2995 |
device := aDevice. |
6472 | 2996 |
]. |
2997 |
||
2998 |
self initialize. |
|
7285
d047c5fb149a
Compatibility: reintroduce `device` instvar in `GraphicsMedium`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6800
diff
changeset
|
2999 |
|
d047c5fb149a
Compatibility: reintroduce `device` instvar in `GraphicsMedium`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6800
diff
changeset
|
3000 |
"Modified: / 03-04-2016 / 16:03:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
6472 | 3001 |
! |
3002 |
||
3003 |
recreate |
|
3004 |
"reacreate a medium after snapIn" |
|
3005 |
||
3006 |
gc notNil ifTrue:[ |
|
3007 |
gc recreate. |
|
3008 |
]. |
|
3009 |
! |
|
3010 |
||
3011 |
releaseGC |
|
3012 |
"destroy the associated device GC resource - can be done to be nice to the |
|
3013 |
display if you know that you are done with a drawable." |
|
3014 |
||
3015 |
gc == self ifTrue:[ |
|
3016 |
super releaseGC. |
|
3017 |
^ self. |
|
3018 |
]. |
|
3019 |
gc notNil ifTrue:[ |
|
3020 |
gc releaseGC. |
|
3021 |
]. |
|
3022 |
! ! |
|
3023 |
||
3024 |
!GraphicsMedium methodsFor:'misc'! |
|
3025 |
||
3026 |
clippedTo:aRectangle do:aBlock |
|
3027 |
|oldClip| |
|
3028 |
||
3029 |
oldClip := gc deviceClippingBoundsOrNil. |
|
3030 |
gc clippingBounds:aRectangle. |
|
3031 |
||
3032 |
aBlock |
|
3033 |
ensure:[ |
|
3034 |
gc deviceClippingBounds:oldClip |
|
3035 |
] |
|
3036 |
! |
|
3037 |
||
3038 |
flush |
|
3039 |
"send all buffered drawing to the device." |
|
3040 |
||
3041 |
gc == self ifTrue:[ |
|
3042 |
super flush. |
|
3043 |
^ self. |
|
3044 |
]. |
|
3045 |
gc flush |
|
3046 |
! |
|
3047 |
||
3048 |
setDevice:aDevice id:aDrawbleId gcId:aGCId |
|
3049 |
"private" |
|
3050 |
||
3051 |
gc == self ifTrue:[ |
|
3052 |
super setDevice:aDevice id:aDrawbleId gcId:aGCId. |
|
3053 |
^ self. |
|
3054 |
]. |
|
3055 |
gc notNil ifTrue:[ |
|
3056 |
gc setDevice:aDevice id:aDrawbleId gcId:aGCId |
|
3057 |
]. |
|
7297
8061a9b76953
Issue #76: Correctly reset device in GraphicsMedium>>setDevice:...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7287
diff
changeset
|
3058 |
device := aDevice |
8061a9b76953
Issue #76: Correctly reset device in GraphicsMedium>>setDevice:...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
7287
diff
changeset
|
3059 |
|
6472 | 3060 |
! |
3061 |
||
3062 |
setId:aDrawableId |
|
3063 |
"private" |
|
3064 |
||
3065 |
gc == self ifTrue:[ |
|
3066 |
super setId:aDrawableId. |
|
3067 |
^ self. |
|
3068 |
]. |
|
3069 |
gc setId:aDrawableId |
|
3070 |
! |
|
3071 |
||
3072 |
setPaint:fgColor on:bgColor |
|
6731
24e7fa5e7f72
Added lost GraphicsMedium>>displayString:centeredAt:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6730
diff
changeset
|
3073 |
"set the paint and background-paint color. |
6472 | 3074 |
The bg-paint is used in opaque-draw operations. |
3075 |
Only set the variables, but do not send it to the device, |
|
3076 |
Used on initialization." |
|
3077 |
||
3078 |
gc == self ifTrue:[ |
|
3079 |
super setPaint:fgColor on:bgColor. |
|
3080 |
^ self. |
|
3081 |
]. |
|
3082 |
gc setPaint:fgColor on:bgColor |
|
727
bf23a306b6f2
renamed PseudoView to DisplaySurface
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
3083 |
! |
bf23a306b6f2
renamed PseudoView to DisplaySurface
Claus Gittinger <cg@exept.de>
parents:
721
diff
changeset
|
3084 |
|
6472 | 3085 |
sync |
3086 |
"send all buffered drawing to the device and wait until the device responds" |
|
3087 |
||
3088 |
gc == self ifTrue:[ |
|
3089 |
super sync. |
|
3090 |
^ self. |
|
3091 |
]. |
|
3092 |
gc sync |
|
3093 |
! ! |
|
3094 |
||
3095 |
!GraphicsMedium methodsFor:'printing & storing'! |
|
3096 |
||
3097 |
storeOn:aStream |
|
3098 |
"blocked: ascii storeString not possible (recursive - view - subviews - container)" |
|
3099 |
||
3100 |
self shouldNotImplement. |
|
3101 |
"if proceeded from exception..." |
|
3102 |
self printOn:aStream. |
|
721
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
3103 |
! ! |
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
3104 |
|
6472 | 3105 |
!GraphicsMedium methodsFor:'queries'! |
3106 |
||
3107 |
fontAscent |
|
3108 |
"answer the ascent of the current font on the current device" |
|
3109 |
||
3110 |
gc == self ifTrue:[ |
|
3111 |
^ super fontAscent. |
|
3112 |
]. |
|
3113 |
^ gc fontAscent |
|
3114 |
! |
|
3115 |
||
3116 |
horizontalIntegerPixelPerMillimeter |
|
3117 |
"return the (rounded) number of pixels per millimeter" |
|
3118 |
||
3119 |
^ self horizontalPixelPerMillimeter asInteger |
|
3120 |
! |
|
3121 |
||
3122 |
horizontalPixelPerInch |
|
3123 |
"return the number of horizontal pixels per inch of the display" |
|
3124 |
||
3125 |
^ self horizontalPixelPerMillimeter * 25.4 |
|
3126 |
! |
|
3127 |
||
3128 |
horizontalPixelPerMillimeter |
|
3129 |
"return the number of pixels per millimeter (not rounded)" |
|
3130 |
||
3131 |
gc == self ifTrue:[ |
|
3132 |
^ super horizontalPixelPerMillimeter. |
|
3133 |
]. |
|
3134 |
^ gc horizontalPixelPerMillimeter |
|
3135 |
! |
|
3136 |
||
3137 |
horizontalPixelPerMillimeter:millis |
|
3138 |
"return the number of pixels (not rounded) for millis millimeter" |
|
3139 |
||
3140 |
^ self horizontalPixelPerMillimeter * millis |
|
3141 |
! |
|
3142 |
||
3143 |
resolution |
|
3144 |
"return a point consisting of pixel-per-inch horizontally and vertically." |
|
3145 |
||
3146 |
gc == self ifTrue:[ |
|
3147 |
^ super resolution. |
|
3148 |
]. |
|
3149 |
^ gc resolution |
|
3150 |
! |
|
3151 |
||
3152 |
verticalIntegerPixelPerMillimeter |
|
3153 |
"return the (rounded) number of pixels per millimeter" |
|
3154 |
||
3155 |
^ self verticalPixelPerMillimeter rounded |
|
3156 |
! |
|
3157 |
||
3158 |
verticalPixelPerInch |
|
3159 |
"return the number of vertical pixels per inch of the display" |
|
3160 |
||
3161 |
^ self verticalPixelPerMillimeter * 25.4 |
|
3162 |
! |
|
3163 |
||
3164 |
verticalPixelPerMillimeter |
|
3165 |
"return the number of pixels per millimeter (not rounded)" |
|
3166 |
||
3167 |
gc == self ifTrue:[ |
|
3168 |
^ super verticalPixelPerMillimeter. |
|
3169 |
]. |
|
3170 |
^ gc verticalPixelPerMillimeter |
|
3171 |
! |
|
3172 |
||
3173 |
verticalPixelPerMillimeter:millis |
|
3174 |
"return the number of pixels (not rounded) for millis millimeter" |
|
3175 |
||
3176 |
^ self verticalPixelPerMillimeter * millis |
|
721
ba7861418087
renamed DisplayMedium to Graphicsmedium & changed inheritance
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
3177 |
! ! |
6045 | 3178 |
|
6472 | 3179 |
!GraphicsMedium methodsFor:'view creation'! |
3180 |
||
3181 |
createBitmapFromArray:data width:width height:height |
|
3182 |
"create a bitmap from data and set the drawableId" |
|
3183 |
||
3184 |
gc == self ifTrue:[ |
|
3185 |
super createBitmapFromArray:data width:width height:height. |
|
3186 |
^ self. |
|
3187 |
]. |
|
3188 |
gc createBitmapFromArray:data width:width height:height |
|
3189 |
! |
|
3190 |
||
3191 |
createPixmapWidth:w height:h depth:d |
|
3192 |
"create a pixmap and set the drawableId" |
|
6731
24e7fa5e7f72
Added lost GraphicsMedium>>displayString:centeredAt:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6730
diff
changeset
|
3193 |
|
6472 | 3194 |
gc == self ifTrue:[ |
3195 |
super createPixmapWidth:w height:h depth:d. |
|
3196 |
^ self. |
|
3197 |
]. |
|
3198 |
gc createPixmapWidth:w height:h depth:d |
|
3199 |
! |
|
3200 |
||
3201 |
createRootWindow |
|
3202 |
gc == self ifTrue:[ |
|
3203 |
super createRootWindowFor:self. |
|
3204 |
^ self. |
|
3205 |
]. |
|
3206 |
gc createRootWindowFor:self |
|
3207 |
! |
|
3208 |
||
6731
24e7fa5e7f72
Added lost GraphicsMedium>>displayString:centeredAt:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6730
diff
changeset
|
3209 |
createWindowFor:aView type:typeSymbol origin:org extent:ext minExtent:minE maxExtent:maxE borderWidth:bw subViewOf:sv style:styleSymbol inputOnly:inp label:label owner:owner icon:icn iconMask:icnM iconView:icnV |
6472 | 3210 |
"create a window and set the drawableId" |
6731
24e7fa5e7f72
Added lost GraphicsMedium>>displayString:centeredAt:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6730
diff
changeset
|
3211 |
|
6472 | 3212 |
gc == self ifTrue:[ |
3213 |
super createWindowFor:aView type:typeSymbol origin:org extent:ext minExtent:minE maxExtent:maxE borderWidth:bw subViewOf:sv style:styleSymbol inputOnly:inp label:label owner:owner icon:icn iconMask:icnM iconView:icnV. |
|
3214 |
^ self. |
|
3215 |
]. |
|
6731
24e7fa5e7f72
Added lost GraphicsMedium>>displayString:centeredAt:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6730
diff
changeset
|
3216 |
gc createWindowFor:aView type:typeSymbol origin:org extent:ext minExtent:minE maxExtent:maxE borderWidth:bw subViewOf:sv style:styleSymbol inputOnly:inp label:label owner:owner icon:icn iconMask:icnM iconView:icnV |
6472 | 3217 |
! ! |
3218 |
||
7285
d047c5fb149a
Compatibility: reintroduce `device` instvar in `GraphicsMedium`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6800
diff
changeset
|
3219 |
!GraphicsMedium class methodsFor:'documentation'! |
d047c5fb149a
Compatibility: reintroduce `device` instvar in `GraphicsMedium`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6800
diff
changeset
|
3220 |
|
d047c5fb149a
Compatibility: reintroduce `device` instvar in `GraphicsMedium`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6800
diff
changeset
|
3221 |
version_CVS |
d047c5fb149a
Compatibility: reintroduce `device` instvar in `GraphicsMedium`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6800
diff
changeset
|
3222 |
^ '$Header: /cvs/stx/stx/libview/GraphicsMedium.st,v 1.22.2.4 2014-09-26 09:48:32 stefan Exp $' |
d047c5fb149a
Compatibility: reintroduce `device` instvar in `GraphicsMedium`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6800
diff
changeset
|
3223 |
! |
d047c5fb149a
Compatibility: reintroduce `device` instvar in `GraphicsMedium`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6800
diff
changeset
|
3224 |
|
d047c5fb149a
Compatibility: reintroduce `device` instvar in `GraphicsMedium`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6800
diff
changeset
|
3225 |
version_HG |
d047c5fb149a
Compatibility: reintroduce `device` instvar in `GraphicsMedium`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6800
diff
changeset
|
3226 |
|
d047c5fb149a
Compatibility: reintroduce `device` instvar in `GraphicsMedium`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6800
diff
changeset
|
3227 |
^ '$Changeset: <not expanded> $' |
d047c5fb149a
Compatibility: reintroduce `device` instvar in `GraphicsMedium`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6800
diff
changeset
|
3228 |
! ! |
d047c5fb149a
Compatibility: reintroduce `device` instvar in `GraphicsMedium`
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6800
diff
changeset
|
3229 |