author | Claus Gittinger <cg@exept.de> |
Wed, 07 May 2003 16:32:08 +0200 | |
changeset 3880 | c4c8268a2d9f |
parent 3666 | 01d7bf1d2333 |
child 3883 | 4e01a59afccb |
permissions | -rw-r--r-- |
732 | 1 |
" |
2 |
COPYRIGHT (c) 1992 by Claus Gittinger |
|
3 |
All Rights Reserved |
|
4 |
||
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
||
3275 | 13 |
"{ Package: 'stx:libview' }" |
14 |
||
732 | 15 |
GraphicsContext subclass:#DeviceGraphicsContext |
16 |
instanceVariableNames:'drawableId gcId deviceFont foreground background' |
|
17 |
classVariableNames:'CachedScaledForms CachedScales Lobby' |
|
18 |
poolDictionaries:'' |
|
19 |
category:'Graphics-Support' |
|
20 |
! |
|
21 |
||
1085
3513a4cae87b
handle depth1-images with a mask
Claus Gittinger <cg@exept.de>
parents:
1064
diff
changeset
|
22 |
!DeviceGraphicsContext class methodsFor:'documentation'! |
732 | 23 |
|
24 |
copyright |
|
25 |
" |
|
26 |
COPYRIGHT (c) 1992 by Claus Gittinger |
|
27 |
All Rights Reserved |
|
28 |
||
29 |
This software is furnished under a license and may be used |
|
30 |
only in accordance with the terms of that license and with the |
|
31 |
inclusion of the above copyright notice. This software may not |
|
32 |
be provided or otherwise made available to, or used by, any |
|
33 |
other person. No title to or ownership of the software is |
|
34 |
hereby transferred. |
|
35 |
" |
|
36 |
! |
|
37 |
||
38 |
documentation |
|
39 |
" |
|
40 |
I provide the common protocol for a graphicsContext which is associated with a particular |
|
41 |
device (i.e. Bitmaps, Pixmaps, RootWindow and Windows in Xs world, but also postscript |
|
42 |
printer pages or fax pages). |
|
43 |
||
44 |
My instance variables are mainly caching device-related stuff (such as font- and color-Ids) |
|
45 |
to avoid needless message traffic. This class is abstract, no direct instances of it |
|
46 |
exist in the system. |
|
47 |
All real work is done by my device, which is accessed via the device instance variable. |
|
48 |
Most drawing requests are simply forwarded to it, others are simulated by using more basic |
|
49 |
drawing functions (see GraphicsContext drawing vs. basic drawing category). |
|
50 |
||
51 |
The added variables foreground/background are the drawing colors actually |
|
52 |
used; these are the real (i.e. non dithered) colors supported by the device. |
|
53 |
Direct access to fg/bg is discouraged, since in the future, these may be |
|
54 |
totally replaced by paint/bgPaint |
|
55 |
(there are some operations and special cases, for which a direct access to |
|
56 |
fg/bg makes sense) |
|
57 |
||
58 |
[Instance variables:] |
|
59 |
||
1029
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
60 |
drawableId <SmallInteger> my drawableId on the device (a device handle) |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
61 |
|
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
62 |
gcId <SmallInteger> my gc's ID on the device (a device handle) |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
63 |
|
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
64 |
deviceFont <Font> the actual font, currently set in the device |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
65 |
|
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
66 |
foreground <Color> the device foreground color used for drawing |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
67 |
|
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
68 |
background <Color> the device background color used for drawing |
732 | 69 |
|
70 |
[see also:] |
|
1029
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
71 |
DeviceWorkstation |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
72 |
Color Font Cursor |
732 | 73 |
|
74 |
[author:] |
|
1029
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
75 |
Claus Gittinger |
732 | 76 |
|
77 |
" |
|
78 |
! ! |
|
79 |
||
1085
3513a4cae87b
handle depth1-images with a mask
Claus Gittinger <cg@exept.de>
parents:
1064
diff
changeset
|
80 |
!DeviceGraphicsContext class methodsFor:'initialization'! |
732 | 81 |
|
82 |
initialize |
|
83 |
Lobby isNil ifTrue:[ |
|
2031
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
84 |
Lobby := Registry new. |
732 | 85 |
] |
2031
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
86 |
|
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
87 |
"Modified: / 29.1.1998 / 12:56:12 / cg" |
732 | 88 |
! ! |
89 |
||
1085
3513a4cae87b
handle depth1-images with a mask
Claus Gittinger <cg@exept.de>
parents:
1064
diff
changeset
|
90 |
!DeviceGraphicsContext class methodsFor:'instance creation'! |
732 | 91 |
|
92 |
new |
|
93 |
"create a new drawable - take the current display as |
|
94 |
its device (for now, this may be changed until the view is |
|
95 |
physically created)" |
|
96 |
||
97 |
" |
|
98 |
'Warning: DeviceGraphicsContext (' print. self name print. ') should not be created with new' printNL. |
|
99 |
" |
|
100 |
^ self onDevice:Screen current "Display" |
|
101 |
! |
|
102 |
||
103 |
on:aDevice |
|
104 |
"create a new drawable on aDevice" |
|
105 |
||
3429 | 106 |
<resource:#obsolete> |
107 |
||
1741 | 108 |
"/ send out a warning: #on: is typically used to create a view |
109 |
"/ operating on a model. |
|
110 |
"/ Please use #onDevice: to avoid confusion. |
|
111 |
||
1255 | 112 |
self obsoleteMethodWarning:'use #onDevice:'. |
732 | 113 |
^ self onDevice:aDevice |
1255 | 114 |
|
1741 | 115 |
"Modified: 5.6.1997 / 21:04:16 / cg" |
732 | 116 |
! |
117 |
||
118 |
onDevice:aDevice |
|
119 |
"create a new drawable on aDevice" |
|
120 |
||
121 |
|newDrawable| |
|
122 |
||
123 |
newDrawable := self basicNew. |
|
124 |
||
125 |
" |
|
126 |
set display before its initialized |
|
127 |
- so it can do something useful (i.e. get font sizes etc.) in its |
|
128 |
intitialize method(s) |
|
129 |
" |
|
130 |
newDrawable device:aDevice. |
|
131 |
newDrawable initialize. |
|
1517
ac751bb3dfdf
no need for registration here;
Claus Gittinger <cg@exept.de>
parents:
1514
diff
changeset
|
132 |
"/ Lobby register:newDrawable. |
732 | 133 |
^ newDrawable |
1517
ac751bb3dfdf
no need for registration here;
Claus Gittinger <cg@exept.de>
parents:
1514
diff
changeset
|
134 |
|
ac751bb3dfdf
no need for registration here;
Claus Gittinger <cg@exept.de>
parents:
1514
diff
changeset
|
135 |
"Modified: 2.4.1997 / 19:19:35 / cg" |
732 | 136 |
! ! |
137 |
||
1085
3513a4cae87b
handle depth1-images with a mask
Claus Gittinger <cg@exept.de>
parents:
1064
diff
changeset
|
138 |
!DeviceGraphicsContext class methodsFor:'cleanup'! |
732 | 139 |
|
140 |
lowSpaceCleanup |
|
141 |
CachedScaledForms := CachedScales := nil |
|
1224
2a2270ec4236
added #releaseResourcesOnDevice:, to allow cleanup when
Claus Gittinger <cg@exept.de>
parents:
1199
diff
changeset
|
142 |
! |
2a2270ec4236
added #releaseResourcesOnDevice:, to allow cleanup when
Claus Gittinger <cg@exept.de>
parents:
1199
diff
changeset
|
143 |
|
2a2270ec4236
added #releaseResourcesOnDevice:, to allow cleanup when
Claus Gittinger <cg@exept.de>
parents:
1199
diff
changeset
|
144 |
releaseResourcesOnDevice:aDevice |
2a2270ec4236
added #releaseResourcesOnDevice:, to allow cleanup when
Claus Gittinger <cg@exept.de>
parents:
1199
diff
changeset
|
145 |
"this is sent when a display connection is closed, |
2a2270ec4236
added #releaseResourcesOnDevice:, to allow cleanup when
Claus Gittinger <cg@exept.de>
parents:
1199
diff
changeset
|
146 |
to release all cached bitmap/window objects from that device" |
2a2270ec4236
added #releaseResourcesOnDevice:, to allow cleanup when
Claus Gittinger <cg@exept.de>
parents:
1199
diff
changeset
|
147 |
|
2a2270ec4236
added #releaseResourcesOnDevice:, to allow cleanup when
Claus Gittinger <cg@exept.de>
parents:
1199
diff
changeset
|
148 |
Lobby unregisterAllForWhich:[:aDrawable | aDrawable graphicsDevice == aDevice] |
2a2270ec4236
added #releaseResourcesOnDevice:, to allow cleanup when
Claus Gittinger <cg@exept.de>
parents:
1199
diff
changeset
|
149 |
|
2a2270ec4236
added #releaseResourcesOnDevice:, to allow cleanup when
Claus Gittinger <cg@exept.de>
parents:
1199
diff
changeset
|
150 |
"Created: 16.1.1997 / 16:43:52 / cg" |
732 | 151 |
! ! |
152 |
||
3880 | 153 |
!DeviceGraphicsContext methodsFor:'Compatibility-ST80'! |
3188 | 154 |
|
155 |
key |
|
156 |
^ self id |
|
157 |
! ! |
|
158 |
||
732 | 159 |
!DeviceGraphicsContext methodsFor:'accessing'! |
160 |
||
161 |
at:aPoint |
|
162 |
"return the pixel at the coordinate given by aPoint" |
|
163 |
||
3160 | 164 |
^ self atX:aPoint x y:aPoint y |
165 |
||
166 |
"Modified: / 29.1.2000 / 12:17:42 / cg" |
|
732 | 167 |
! |
168 |
||
169 |
at:aPoint put:aPixel |
|
170 |
"set a pixel" |
|
171 |
||
3160 | 172 |
^ self atX:aPoint x y:aPoint y put:aPixel |
173 |
||
174 |
"Modified: / 29.1.2000 / 12:17:29 / cg" |
|
732 | 175 |
! |
176 |
||
177 |
atX:x y:y |
|
178 |
"return the pixel at the coordinate given by x/y" |
|
179 |
||
2714
e5d16e41cbab
need gcId-argument in getPixel
Claus Gittinger <cg@exept.de>
parents:
2680
diff
changeset
|
180 |
^ device getPixelX:x y:y from:drawableId with:gcId |
e5d16e41cbab
need gcId-argument in getPixel
Claus Gittinger <cg@exept.de>
parents:
2680
diff
changeset
|
181 |
|
e5d16e41cbab
need gcId-argument in getPixel
Claus Gittinger <cg@exept.de>
parents:
2680
diff
changeset
|
182 |
"Modified: / 22.5.1999 / 01:40:23 / cg" |
732 | 183 |
! |
184 |
||
185 |
atX:x y:y put:aPixel |
|
186 |
"set a pixel" |
|
187 |
||
188 |
|oldFg| |
|
189 |
||
190 |
oldFg := foreground. |
|
191 |
self foreground:aPixel. |
|
192 |
self displayPointX:x y:y. |
|
193 |
self foreground:oldFg |
|
194 |
! |
|
195 |
||
196 |
backgroundPaint:aColor |
|
197 |
"set the background-paint color; this is used in opaque-draw |
|
198 |
operations" |
|
199 |
||
200 |
(aColor ~~ bgPaint) ifTrue:[ |
|
2835 | 201 |
aColor notNil ifTrue:[ |
202 |
bgPaint := aColor. |
|
203 |
gcId notNil ifTrue:[ |
|
204 |
bgPaint isColor ifTrue:[ |
|
205 |
bgPaint := aColor onDevice:device. |
|
206 |
bgPaint colorId notNil ifTrue:[ |
|
207 |
background := bgPaint. |
|
208 |
gcId notNil ifTrue:[ |
|
209 |
device setBackground:(bgPaint colorId) in:gcId. |
|
210 |
]. |
|
211 |
^ self |
|
212 |
] |
|
213 |
]. |
|
214 |
self paint:paint on:aColor |
|
215 |
] |
|
216 |
] |
|
732 | 217 |
]. |
218 |
! |
|
219 |
||
220 |
basicFont |
|
2918
1e777dc8588a
#font answers device font if possible (cg)
Stefan Vogel <sv@exept.de>
parents:
2913
diff
changeset
|
221 |
"return the font for drawing" |
732 | 222 |
|
223 |
^ font |
|
224 |
||
225 |
"Created: 12.5.1996 / 11:17:59 / cg" |
|
226 |
! |
|
227 |
||
228 |
basicFont:aFont |
|
229 |
"set the font for drawing if it has changed. |
|
230 |
This is a low level entry, which is not to be redefined |
|
231 |
(i.e. it must not imply a redraw operation)" |
|
232 |
||
233 |
|id| |
|
234 |
||
235 |
(aFont ~~ font) ifTrue:[ |
|
2835 | 236 |
aFont notNil ifTrue:[ |
237 |
font := aFont. |
|
238 |
gcId notNil ifTrue:[ |
|
239 |
font := font onDevice:device. |
|
240 |
id := font fontId. |
|
241 |
id notNil ifTrue:[ |
|
242 |
device setFont:id in:gcId |
|
243 |
] |
|
244 |
] |
|
245 |
] |
|
732 | 246 |
] |
247 |
||
248 |
"Modified: 23.2.1996 / 17:01:06 / cg" |
|
249 |
"Created: 23.2.1996 / 17:16:51 / cg" |
|
250 |
! |
|
251 |
||
252 |
capStyle:aSymbol |
|
253 |
"set the style in which the endpoints of lines |
|
254 |
are drawn - aSymbol may be #notLast, #butt, #round, #projecting" |
|
255 |
||
256 |
|s| |
|
257 |
||
258 |
(s := aSymbol) isNil ifTrue:[ |
|
1029
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
259 |
s := #butt. |
732 | 260 |
|
261 |
]. |
|
262 |
(s ~~ capStyle) ifTrue:[ |
|
1029
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
263 |
capStyle := s. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
264 |
gcId notNil ifTrue:[ |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
265 |
device setLineWidth:lineWidth |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
266 |
style:lineStyle |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
267 |
cap:s |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
268 |
join:joinStyle |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
269 |
in:gcId |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
270 |
] |
732 | 271 |
] |
272 |
||
273 |
"Modified: 12.5.1996 / 22:23:03 / cg" |
|
274 |
! |
|
275 |
||
950 | 276 |
clipByChildren |
277 |
"drawing shall be done into my view only (default)" |
|
278 |
||
3429 | 279 |
<resource:#obsolete> |
280 |
||
1722 | 281 |
self obsoleteMethodWarning:'use #clippedByChildren:true'. |
950 | 282 |
^ self clippedByChildren:true |
283 |
||
284 |
"Created: 17.7.1996 / 13:25:55 / cg" |
|
285 |
! |
|
286 |
||
732 | 287 |
clipRect |
288 |
"return the clipping rectangle for drawing. If there is currently no clipRect, |
|
289 |
a dummy is created." |
|
290 |
||
291 |
|rect| |
|
292 |
||
2680
78abc6171873
always remember the deviceClipRect internally;
Claus Gittinger <cg@exept.de>
parents:
2572
diff
changeset
|
293 |
(rect := clipRect) isNil ifTrue:[ |
78abc6171873
always remember the deviceClipRect internally;
Claus Gittinger <cg@exept.de>
parents:
2572
diff
changeset
|
294 |
rect := 0@0 extent:(self extent). |
732 | 295 |
]. |
2680
78abc6171873
always remember the deviceClipRect internally;
Claus Gittinger <cg@exept.de>
parents:
2572
diff
changeset
|
296 |
transformation notNil ifTrue:[ |
78abc6171873
always remember the deviceClipRect internally;
Claus Gittinger <cg@exept.de>
parents:
2572
diff
changeset
|
297 |
rect := transformation applyInverseTo:rect. |
78abc6171873
always remember the deviceClipRect internally;
Claus Gittinger <cg@exept.de>
parents:
2572
diff
changeset
|
298 |
]. |
78abc6171873
always remember the deviceClipRect internally;
Claus Gittinger <cg@exept.de>
parents:
2572
diff
changeset
|
299 |
^ rect |
732 | 300 |
|
301 |
"Modified: 10.4.1996 / 14:32:22 / cg" |
|
302 |
! |
|
303 |
||
950 | 304 |
clippedByChildren:aBoolean |
305 |
"turn on/off drawing over children. |
|
306 |
If on, a superview may draw 'over' its children. |
|
307 |
If off (the default), drawing is 'under' its children. |
|
308 |
Only useful for the rootView, to draw over any visible views. |
|
309 |
(for example, when dragging a rubber-line)" |
|
310 |
||
311 |
gcId isNil ifTrue:[ |
|
1680
f47862c358fb
pass both drawableId & gcID to setClipByChildren
Claus Gittinger <cg@exept.de>
parents:
1649
diff
changeset
|
312 |
self initGC |
950 | 313 |
]. |
1715 | 314 |
device noClipIn:drawableId gc:gcId. |
315 |
device setClipByChildren:aBoolean in:drawableId gc:gcId. |
|
1722 | 316 |
"/ device noClipIn:drawableId gc:gcId. |
317 |
||
1714 | 318 |
"/ |
319 |
"/ device setClipX:0 y:0 width:(self width) height:(self height) in:drawableId gc:gcId. |
|
320 |
"/ |
|
950 | 321 |
|
322 |
"Created: 17.7.1996 / 13:25:16 / cg" |
|
1680
f47862c358fb
pass both drawableId & gcID to setClipByChildren
Claus Gittinger <cg@exept.de>
parents:
1649
diff
changeset
|
323 |
"Modified: 29.4.1997 / 15:33:55 / dq" |
950 | 324 |
! |
325 |
||
735 | 326 |
clippingRectangle:aRectangleOrNil |
732 | 327 |
"set the clipping rectangle for drawing (in logical coordinates); |
328 |
a nil argument turn off clipping (i.e. whole view is drawable)" |
|
329 |
||
2680
78abc6171873
always remember the deviceClipRect internally;
Claus Gittinger <cg@exept.de>
parents:
2572
diff
changeset
|
330 |
|x y w h r| |
78abc6171873
always remember the deviceClipRect internally;
Claus Gittinger <cg@exept.de>
parents:
2572
diff
changeset
|
331 |
|
78abc6171873
always remember the deviceClipRect internally;
Claus Gittinger <cg@exept.de>
parents:
2572
diff
changeset
|
332 |
(r := aRectangleOrNil) isNil ifTrue:[ |
78abc6171873
always remember the deviceClipRect internally;
Claus Gittinger <cg@exept.de>
parents:
2572
diff
changeset
|
333 |
clipRect isNil ifTrue:[^ self]. |
78abc6171873
always remember the deviceClipRect internally;
Claus Gittinger <cg@exept.de>
parents:
2572
diff
changeset
|
334 |
gcId notNil ifTrue:[ |
78abc6171873
always remember the deviceClipRect internally;
Claus Gittinger <cg@exept.de>
parents:
2572
diff
changeset
|
335 |
device noClipIn:drawableId gc:gcId |
78abc6171873
always remember the deviceClipRect internally;
Claus Gittinger <cg@exept.de>
parents:
2572
diff
changeset
|
336 |
] |
732 | 337 |
] ifFalse:[ |
2680
78abc6171873
always remember the deviceClipRect internally;
Claus Gittinger <cg@exept.de>
parents:
2572
diff
changeset
|
338 |
clipRect notNil ifTrue:[ |
78abc6171873
always remember the deviceClipRect internally;
Claus Gittinger <cg@exept.de>
parents:
2572
diff
changeset
|
339 |
(clipRect = aRectangleOrNil) ifTrue:[^ self] |
78abc6171873
always remember the deviceClipRect internally;
Claus Gittinger <cg@exept.de>
parents:
2572
diff
changeset
|
340 |
]. |
78abc6171873
always remember the deviceClipRect internally;
Claus Gittinger <cg@exept.de>
parents:
2572
diff
changeset
|
341 |
gcId notNil ifTrue:[ |
78abc6171873
always remember the deviceClipRect internally;
Claus Gittinger <cg@exept.de>
parents:
2572
diff
changeset
|
342 |
x := aRectangleOrNil left. |
78abc6171873
always remember the deviceClipRect internally;
Claus Gittinger <cg@exept.de>
parents:
2572
diff
changeset
|
343 |
y := aRectangleOrNil top. |
78abc6171873
always remember the deviceClipRect internally;
Claus Gittinger <cg@exept.de>
parents:
2572
diff
changeset
|
344 |
w := aRectangleOrNil width. |
78abc6171873
always remember the deviceClipRect internally;
Claus Gittinger <cg@exept.de>
parents:
2572
diff
changeset
|
345 |
h := aRectangleOrNil height. |
78abc6171873
always remember the deviceClipRect internally;
Claus Gittinger <cg@exept.de>
parents:
2572
diff
changeset
|
346 |
transformation notNil ifTrue:[ |
78abc6171873
always remember the deviceClipRect internally;
Claus Gittinger <cg@exept.de>
parents:
2572
diff
changeset
|
347 |
x := transformation applyToX:x. |
78abc6171873
always remember the deviceClipRect internally;
Claus Gittinger <cg@exept.de>
parents:
2572
diff
changeset
|
348 |
y := transformation applyToY:y. |
78abc6171873
always remember the deviceClipRect internally;
Claus Gittinger <cg@exept.de>
parents:
2572
diff
changeset
|
349 |
w := transformation applyScaleX:w. |
78abc6171873
always remember the deviceClipRect internally;
Claus Gittinger <cg@exept.de>
parents:
2572
diff
changeset
|
350 |
h := transformation applyScaleY:h. |
78abc6171873
always remember the deviceClipRect internally;
Claus Gittinger <cg@exept.de>
parents:
2572
diff
changeset
|
351 |
]. |
78abc6171873
always remember the deviceClipRect internally;
Claus Gittinger <cg@exept.de>
parents:
2572
diff
changeset
|
352 |
(x class == SmallInteger) ifFalse:[ |
78abc6171873
always remember the deviceClipRect internally;
Claus Gittinger <cg@exept.de>
parents:
2572
diff
changeset
|
353 |
w := w + (x - x truncated). |
78abc6171873
always remember the deviceClipRect internally;
Claus Gittinger <cg@exept.de>
parents:
2572
diff
changeset
|
354 |
x := x truncated |
78abc6171873
always remember the deviceClipRect internally;
Claus Gittinger <cg@exept.de>
parents:
2572
diff
changeset
|
355 |
]. |
78abc6171873
always remember the deviceClipRect internally;
Claus Gittinger <cg@exept.de>
parents:
2572
diff
changeset
|
356 |
(y class == SmallInteger) ifFalse:[ |
78abc6171873
always remember the deviceClipRect internally;
Claus Gittinger <cg@exept.de>
parents:
2572
diff
changeset
|
357 |
h := h + (y - y truncated). |
78abc6171873
always remember the deviceClipRect internally;
Claus Gittinger <cg@exept.de>
parents:
2572
diff
changeset
|
358 |
y := y truncated |
78abc6171873
always remember the deviceClipRect internally;
Claus Gittinger <cg@exept.de>
parents:
2572
diff
changeset
|
359 |
]. |
78abc6171873
always remember the deviceClipRect internally;
Claus Gittinger <cg@exept.de>
parents:
2572
diff
changeset
|
360 |
(w class == SmallInteger) ifFalse:[ |
78abc6171873
always remember the deviceClipRect internally;
Claus Gittinger <cg@exept.de>
parents:
2572
diff
changeset
|
361 |
w := w truncated + 1 |
78abc6171873
always remember the deviceClipRect internally;
Claus Gittinger <cg@exept.de>
parents:
2572
diff
changeset
|
362 |
]. |
78abc6171873
always remember the deviceClipRect internally;
Claus Gittinger <cg@exept.de>
parents:
2572
diff
changeset
|
363 |
(h class == SmallInteger) ifFalse:[ |
78abc6171873
always remember the deviceClipRect internally;
Claus Gittinger <cg@exept.de>
parents:
2572
diff
changeset
|
364 |
h := h truncated + 1 |
78abc6171873
always remember the deviceClipRect internally;
Claus Gittinger <cg@exept.de>
parents:
2572
diff
changeset
|
365 |
]. |
78abc6171873
always remember the deviceClipRect internally;
Claus Gittinger <cg@exept.de>
parents:
2572
diff
changeset
|
366 |
|
78abc6171873
always remember the deviceClipRect internally;
Claus Gittinger <cg@exept.de>
parents:
2572
diff
changeset
|
367 |
device setClipX:x y:y width:w height:h in:drawableId gc:gcId. |
78abc6171873
always remember the deviceClipRect internally;
Claus Gittinger <cg@exept.de>
parents:
2572
diff
changeset
|
368 |
r := Rectangle left:x top:y width:w height:h |
78abc6171873
always remember the deviceClipRect internally;
Claus Gittinger <cg@exept.de>
parents:
2572
diff
changeset
|
369 |
] |
732 | 370 |
]. |
2680
78abc6171873
always remember the deviceClipRect internally;
Claus Gittinger <cg@exept.de>
parents:
2572
diff
changeset
|
371 |
clipRect := r |
78abc6171873
always remember the deviceClipRect internally;
Claus Gittinger <cg@exept.de>
parents:
2572
diff
changeset
|
372 |
|
78abc6171873
always remember the deviceClipRect internally;
Claus Gittinger <cg@exept.de>
parents:
2572
diff
changeset
|
373 |
"Created: / 28.5.1996 / 19:40:20 / cg" |
78abc6171873
always remember the deviceClipRect internally;
Claus Gittinger <cg@exept.de>
parents:
2572
diff
changeset
|
374 |
"Modified: / 16.5.1999 / 19:40:37 / cg" |
732 | 375 |
! |
376 |
||
1842 | 377 |
colorAt:aPoint |
378 |
"return the color of the pixel at the coordinate given by x@y" |
|
379 |
||
380 |
^ self colorAtX:(aPoint x) y:(aPoint y) |
|
381 |
||
382 |
"Modified: 1.8.1997 / 20:01:58 / cg" |
|
383 |
! |
|
384 |
||
385 |
colorAtX:x y:y |
|
386 |
"return the color of the pixel at the coordinate given by aPoint" |
|
387 |
||
388 |
|pixel| |
|
389 |
||
390 |
pixel := self atX:x y:y. |
|
391 |
device getScaledRGBFrom:pixel into:[:r :g :b | |
|
392 |
^ Color scaledRed:r scaledGreen:g scaledBlue:b |
|
393 |
]. |
|
394 |
||
395 |
"Created: 1.8.1997 / 20:01:32 / cg" |
|
396 |
! |
|
397 |
||
786 | 398 |
dashStyle:aDashList offset:dashOffset |
399 |
"define dashes. Each element of the dashList specifies the length |
|
400 |
of a corresponding dash. For example, setting it to [4 4] |
|
401 |
defines 4on-4off dashing; |
|
402 |
Setting it to [1 2 4 2] defines 1on-2off-4on-2off dashes. |
|
403 |
The dashOffset specifies where in the dashList the dashing starts. |
|
404 |
This may not be supported by all graphics devices." |
|
405 |
||
406 |
gcId notNil ifTrue:[ |
|
1029
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
407 |
device setDashes:(ByteArray withAll:aDashList) |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
408 |
dashOffset:dashOffset |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
409 |
in:gcId |
786 | 410 |
] |
411 |
||
412 |
"Modified: 4.6.1996 / 19:03:06 / cg" |
|
413 |
! |
|
414 |
||
732 | 415 |
device |
416 |
"return the device, the receiver is associated with" |
|
417 |
||
418 |
^ device |
|
419 |
! |
|
420 |
||
421 |
device:aDevice |
|
422 |
"set the device" |
|
423 |
||
424 |
device := aDevice |
|
425 |
! |
|
426 |
||
2343
9e8d62561418
added #deviceClippingRectangle:
Claus Gittinger <cg@exept.de>
parents:
2322
diff
changeset
|
427 |
deviceClippingRectangle:aRectangleOrNil |
9e8d62561418
added #deviceClippingRectangle:
Claus Gittinger <cg@exept.de>
parents:
2322
diff
changeset
|
428 |
"set the clipping rectangle for drawing (in device coordinates); |
3275 | 429 |
a nil argument turns off clipping (i.e. whole view is drawable - incl. margins)" |
2343
9e8d62561418
added #deviceClippingRectangle:
Claus Gittinger <cg@exept.de>
parents:
2322
diff
changeset
|
430 |
|
9e8d62561418
added #deviceClippingRectangle:
Claus Gittinger <cg@exept.de>
parents:
2322
diff
changeset
|
431 |
|x y w h| |
9e8d62561418
added #deviceClippingRectangle:
Claus Gittinger <cg@exept.de>
parents:
2322
diff
changeset
|
432 |
|
9e8d62561418
added #deviceClippingRectangle:
Claus Gittinger <cg@exept.de>
parents:
2322
diff
changeset
|
433 |
aRectangleOrNil isNil ifTrue:[ |
9e8d62561418
added #deviceClippingRectangle:
Claus Gittinger <cg@exept.de>
parents:
2322
diff
changeset
|
434 |
clipRect isNil ifTrue:[^ self]. |
9e8d62561418
added #deviceClippingRectangle:
Claus Gittinger <cg@exept.de>
parents:
2322
diff
changeset
|
435 |
gcId notNil ifTrue:[ |
9e8d62561418
added #deviceClippingRectangle:
Claus Gittinger <cg@exept.de>
parents:
2322
diff
changeset
|
436 |
device noClipIn:drawableId gc:gcId |
9e8d62561418
added #deviceClippingRectangle:
Claus Gittinger <cg@exept.de>
parents:
2322
diff
changeset
|
437 |
] |
9e8d62561418
added #deviceClippingRectangle:
Claus Gittinger <cg@exept.de>
parents:
2322
diff
changeset
|
438 |
] ifFalse:[ |
9e8d62561418
added #deviceClippingRectangle:
Claus Gittinger <cg@exept.de>
parents:
2322
diff
changeset
|
439 |
clipRect notNil ifTrue:[ |
9e8d62561418
added #deviceClippingRectangle:
Claus Gittinger <cg@exept.de>
parents:
2322
diff
changeset
|
440 |
(clipRect = aRectangleOrNil) ifTrue:[^ self] |
9e8d62561418
added #deviceClippingRectangle:
Claus Gittinger <cg@exept.de>
parents:
2322
diff
changeset
|
441 |
]. |
9e8d62561418
added #deviceClippingRectangle:
Claus Gittinger <cg@exept.de>
parents:
2322
diff
changeset
|
442 |
gcId notNil ifTrue:[ |
9e8d62561418
added #deviceClippingRectangle:
Claus Gittinger <cg@exept.de>
parents:
2322
diff
changeset
|
443 |
x := aRectangleOrNil left. |
9e8d62561418
added #deviceClippingRectangle:
Claus Gittinger <cg@exept.de>
parents:
2322
diff
changeset
|
444 |
y := aRectangleOrNil top. |
9e8d62561418
added #deviceClippingRectangle:
Claus Gittinger <cg@exept.de>
parents:
2322
diff
changeset
|
445 |
w := aRectangleOrNil width. |
9e8d62561418
added #deviceClippingRectangle:
Claus Gittinger <cg@exept.de>
parents:
2322
diff
changeset
|
446 |
h := aRectangleOrNil height. |
9e8d62561418
added #deviceClippingRectangle:
Claus Gittinger <cg@exept.de>
parents:
2322
diff
changeset
|
447 |
device setClipX:x y:y width:w height:h in:drawableId gc:gcId |
9e8d62561418
added #deviceClippingRectangle:
Claus Gittinger <cg@exept.de>
parents:
2322
diff
changeset
|
448 |
] |
9e8d62561418
added #deviceClippingRectangle:
Claus Gittinger <cg@exept.de>
parents:
2322
diff
changeset
|
449 |
]. |
9e8d62561418
added #deviceClippingRectangle:
Claus Gittinger <cg@exept.de>
parents:
2322
diff
changeset
|
450 |
clipRect := aRectangleOrNil |
9e8d62561418
added #deviceClippingRectangle:
Claus Gittinger <cg@exept.de>
parents:
2322
diff
changeset
|
451 |
|
9e8d62561418
added #deviceClippingRectangle:
Claus Gittinger <cg@exept.de>
parents:
2322
diff
changeset
|
452 |
"Modified: / 22.5.1996 / 13:12:07 / cg" |
9e8d62561418
added #deviceClippingRectangle:
Claus Gittinger <cg@exept.de>
parents:
2322
diff
changeset
|
453 |
"Created: / 14.9.1998 / 18:50:31 / cg" |
9e8d62561418
added #deviceClippingRectangle:
Claus Gittinger <cg@exept.de>
parents:
2322
diff
changeset
|
454 |
! |
9e8d62561418
added #deviceClippingRectangle:
Claus Gittinger <cg@exept.de>
parents:
2322
diff
changeset
|
455 |
|
2918
1e777dc8588a
#font answers device font if possible (cg)
Stefan Vogel <sv@exept.de>
parents:
2913
diff
changeset
|
456 |
font |
1e777dc8588a
#font answers device font if possible (cg)
Stefan Vogel <sv@exept.de>
parents:
2913
diff
changeset
|
457 |
"return the font for drawing - here, a device font is returned if |
1e777dc8588a
#font answers device font if possible (cg)
Stefan Vogel <sv@exept.de>
parents:
2913
diff
changeset
|
458 |
the GC is realized." |
1e777dc8588a
#font answers device font if possible (cg)
Stefan Vogel <sv@exept.de>
parents:
2913
diff
changeset
|
459 |
|
1e777dc8588a
#font answers device font if possible (cg)
Stefan Vogel <sv@exept.de>
parents:
2913
diff
changeset
|
460 |
device notNil ifTrue:[ |
1e777dc8588a
#font answers device font if possible (cg)
Stefan Vogel <sv@exept.de>
parents:
2913
diff
changeset
|
461 |
^ font onDevice:device |
1e777dc8588a
#font answers device font if possible (cg)
Stefan Vogel <sv@exept.de>
parents:
2913
diff
changeset
|
462 |
]. |
1e777dc8588a
#font answers device font if possible (cg)
Stefan Vogel <sv@exept.de>
parents:
2913
diff
changeset
|
463 |
^ font |
1e777dc8588a
#font answers device font if possible (cg)
Stefan Vogel <sv@exept.de>
parents:
2913
diff
changeset
|
464 |
|
1e777dc8588a
#font answers device font if possible (cg)
Stefan Vogel <sv@exept.de>
parents:
2913
diff
changeset
|
465 |
"Created: 12.5.1996 / 11:17:59 / cg" |
1e777dc8588a
#font answers device font if possible (cg)
Stefan Vogel <sv@exept.de>
parents:
2913
diff
changeset
|
466 |
! |
1e777dc8588a
#font answers device font if possible (cg)
Stefan Vogel <sv@exept.de>
parents:
2913
diff
changeset
|
467 |
|
732 | 468 |
font:aFont |
469 |
"set the font for drawing if it has changed. |
|
470 |
This should be redefined in some widget to perform an automatic |
|
471 |
redraw. See also: #basicFont:" |
|
472 |
||
473 |
(aFont ~~ font) ifTrue:[ |
|
1029
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
474 |
self basicFont:aFont |
732 | 475 |
] |
476 |
||
477 |
"Modified: 6.3.1996 / 18:17:40 / cg" |
|
478 |
! |
|
479 |
||
480 |
function:aSymbol |
|
481 |
"set the drawing function if it has changed" |
|
482 |
||
483 |
(aSymbol ~~ function) ifTrue:[ |
|
484 |
function := aSymbol. |
|
485 |
gcId notNil ifTrue:[ |
|
486 |
device setFunction:aSymbol in:gcId |
|
487 |
] |
|
488 |
] |
|
489 |
! |
|
490 |
||
491 |
gcId |
|
492 |
"return the receivers graphic context id on the device" |
|
493 |
||
494 |
^ gcId |
|
495 |
! |
|
496 |
||
497 |
graphicsDevice |
|
498 |
"return the device, the receiver is associated with. |
|
499 |
Same as #device, for ST-80 compatibility." |
|
500 |
||
501 |
^ device |
|
502 |
||
503 |
"Created: 9.5.1996 / 01:37:58 / cg" |
|
504 |
! |
|
505 |
||
506 |
id |
|
507 |
"return the id of the dravable on the device" |
|
508 |
||
509 |
^ drawableId |
|
510 |
! |
|
511 |
||
512 |
joinStyle:aSymbol |
|
513 |
"set the style in which 2 lines are connected in polygons - |
|
514 |
aSymbol may be #miter, #bevel, #round" |
|
515 |
||
516 |
|s| |
|
517 |
||
518 |
(s := aSymbol) isNil ifTrue:[ |
|
1029
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
519 |
s := #miter |
732 | 520 |
]. |
521 |
(s ~~ joinStyle) ifTrue:[ |
|
1029
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
522 |
joinStyle := s. |
732 | 523 |
|
1029
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
524 |
gcId notNil ifTrue:[ |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
525 |
device setLineWidth:lineWidth |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
526 |
style:lineStyle |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
527 |
cap:capStyle |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
528 |
join:s |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
529 |
in:gcId |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
530 |
] |
732 | 531 |
] |
532 |
||
533 |
"Modified: 12.5.1996 / 22:20:43 / cg" |
|
534 |
! |
|
535 |
||
536 |
lineStyle:aSymbol |
|
537 |
"set the style in which lines are drawn - |
|
2360 | 538 |
aSymbol may be #solid, #dashed, #doubleDashed, |
539 |
#dotted, #dashDot or #dashDotDot." |
|
732 | 540 |
|
541 |
|s| |
|
542 |
||
543 |
(s := aSymbol) isNil ifTrue:[ |
|
2360 | 544 |
s := #solid |
732 | 545 |
]. |
546 |
(s ~~ lineStyle) ifTrue:[ |
|
2360 | 547 |
lineStyle := s. |
548 |
gcId notNil ifTrue:[ |
|
549 |
device setLineWidth:lineWidth |
|
550 |
style:s |
|
551 |
cap:capStyle |
|
552 |
join:joinStyle |
|
553 |
in:gcId |
|
554 |
] |
|
732 | 555 |
] |
556 |
||
557 |
"Modified: 12.5.1996 / 22:21:25 / cg" |
|
558 |
! |
|
559 |
||
560 |
lineWidth:aNumber |
|
561 |
"set the line width for drawing if it has changed" |
|
562 |
||
563 |
|n| |
|
564 |
||
565 |
(aNumber ~~ lineWidth) ifTrue:[ |
|
566 |
lineWidth := aNumber. |
|
567 |
transformation isNil ifTrue:[ |
|
568 |
n := aNumber. |
|
569 |
] ifFalse:[ |
|
570 |
n := transformation applyScaleX:aNumber. |
|
571 |
n := n rounded |
|
572 |
]. |
|
573 |
gcId notNil ifTrue:[ |
|
574 |
device setLineWidth:n |
|
575 |
style:lineStyle |
|
576 |
cap:capStyle |
|
577 |
join:joinStyle |
|
578 |
in:gcId |
|
579 |
] |
|
580 |
] |
|
581 |
! |
|
582 |
||
583 |
mask:aForm |
|
584 |
"set the mask form for drawing" |
|
585 |
||
586 |
|id| |
|
587 |
||
588 |
(aForm ~~ mask) ifTrue:[ |
|
589 |
mask := aForm. |
|
590 |
gcId notNil ifTrue:[ |
|
591 |
(mask == nil) ifTrue:[ |
|
592 |
device setBitmapMask:nil in:gcId |
|
593 |
] ifFalse:[ |
|
1033 | 594 |
mask := mask asFormOn:device. |
732 | 595 |
id := mask id. |
596 |
(mask depth == 1) ifTrue:[ |
|
597 |
device setBitmapMask:id in:gcId |
|
598 |
] ifFalse:[ |
|
599 |
device setPixmapMask:id in:gcId |
|
600 |
] |
|
601 |
] |
|
602 |
] |
|
603 |
] |
|
604 |
! |
|
605 |
||
2018 | 606 |
maskOrigin:aPoint |
607 |
"set the origin of the mask-pattern" |
|
608 |
||
609 |
|x y| |
|
610 |
||
611 |
x := aPoint x. |
|
612 |
y := aPoint y. |
|
613 |
||
614 |
(maskOrigin isNil or:[ |
|
615 |
((x ~= maskOrigin x) or:[y ~= maskOrigin y]) ]) ifTrue:[ |
|
616 |
||
617 |
maskOrigin := aPoint. |
|
618 |
||
619 |
transformation notNil ifTrue:[ |
|
620 |
x := transformation applyToX:x. |
|
621 |
y := transformation applyToY:y. |
|
622 |
]. |
|
623 |
x := x rounded. |
|
624 |
y := y rounded. |
|
625 |
||
626 |
gcId notNil ifTrue:[ |
|
627 |
device setMaskOriginX:x y:y in:gcId |
|
628 |
] |
|
629 |
] |
|
630 |
||
631 |
"Created: / 26.1.1998 / 19:03:02 / cg" |
|
632 |
! |
|
633 |
||
2016 | 634 |
maskOriginX:orgX y:orgY |
635 |
"set the origin of the pattern" |
|
636 |
||
637 |
|x y| |
|
638 |
||
639 |
transformation notNil ifTrue:[ |
|
640 |
x := transformation applyToX:orgX. |
|
641 |
y := transformation applyToY:orgY. |
|
642 |
] ifFalse:[ |
|
643 |
x := orgX. |
|
644 |
y := orgY |
|
645 |
]. |
|
646 |
x := x rounded. |
|
647 |
y := y rounded. |
|
648 |
||
649 |
(maskOrigin isNil or:[ |
|
650 |
((x ~~ maskOrigin x) or:[y ~~ maskOrigin y]) ]) ifTrue:[ |
|
651 |
||
652 |
maskOrigin := x @ y. |
|
653 |
gcId notNil ifTrue:[ |
|
654 |
device setMaskOriginX:x y:y in:gcId |
|
655 |
] |
|
656 |
] |
|
657 |
||
658 |
"Created: / 26.1.1998 / 18:51:18 / cg" |
|
659 |
! |
|
660 |
||
950 | 661 |
noClipByChildren |
662 |
"drawing shall also be done into subviews" |
|
663 |
||
3429 | 664 |
<resource:#obsolete> |
665 |
||
1722 | 666 |
self obsoleteMethodWarning:'use #clippedByChildren:false'. |
950 | 667 |
^ self clippedByChildren:false |
668 |
||
669 |
"Created: 17.7.1996 / 14:15:54 / cg" |
|
670 |
! |
|
671 |
||
732 | 672 |
paint:aColor |
673 |
"set the drawing color, which may be a real color, a dithered one |
|
674 |
or even an image." |
|
675 |
||
676 |
(aColor ~~ paint) ifTrue:[ |
|
1029
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
677 |
aColor notNil ifTrue:[ |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
678 |
paint := aColor. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
679 |
self setGCForPaint. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
680 |
] |
732 | 681 |
] |
682 |
||
683 |
"Modified: 16.5.1996 / 15:35:57 / cg" |
|
684 |
! |
|
685 |
||
686 |
paint:fgColor on:bgColor |
|
687 |
"set the paint and background-paint color. |
|
688 |
The bg-paint is used in opaque-draw operations" |
|
689 |
||
690 |
|fgId bgId| |
|
691 |
||
692 |
((fgColor ~~ paint) or:[bgColor ~~ bgPaint]) ifTrue:[ |
|
1742 | 693 |
fgColor notNil ifTrue:[ |
694 |
paint := fgColor |
|
695 |
]. |
|
696 |
bgColor notNil ifTrue:[ |
|
697 |
bgPaint := bgColor |
|
698 |
]. |
|
699 |
gcId notNil ifTrue:[ |
|
2835 | 700 |
paint := paint onDevice:device. |
1742 | 701 |
paint isColor ifTrue:[ |
702 |
fgId := paint colorId. |
|
703 |
fgId notNil ifTrue:[ |
|
704 |
mask notNil ifTrue:[ |
|
705 |
mask := nil. |
|
706 |
device setBitmapMask:nil in:gcId |
|
707 |
]. |
|
708 |
bgPaint := bgPaint onDevice:device. |
|
709 |
bgPaint isColor ifTrue:[ |
|
710 |
bgId := bgPaint colorId. |
|
711 |
bgId notNil ifTrue:[ |
|
712 |
"the common case, both are real colors" |
|
713 |
(paint ~~ foreground) ifTrue:[ |
|
714 |
foreground := paint. |
|
715 |
(bgPaint ~~ background) ifTrue:[ |
|
716 |
background := bgPaint. |
|
717 |
device setForeground:fgId background:bgId in:gcId. |
|
718 |
^ self |
|
719 |
]. |
|
720 |
device setForeground:fgId in:gcId. |
|
721 |
^ self |
|
722 |
]. |
|
723 |
(bgPaint ~~ background) ifTrue:[ |
|
724 |
background := bgPaint. |
|
725 |
device setBackground:bgId in:gcId. |
|
726 |
]. |
|
727 |
^ self |
|
728 |
]. |
|
729 |
"bgPaint is dithered, setup paint here, leave bgPaint |
|
730 |
till next opaque draw comes around." |
|
731 |
||
732 |
(paint ~~ foreground) ifTrue:[ |
|
733 |
foreground := paint. |
|
734 |
device setForeground:fgId in:gcId |
|
735 |
]. |
|
736 |
^ self |
|
737 |
] |
|
738 |
] |
|
739 |
]. |
|
740 |
"either paint or bgPaint (or both) are dithered colors, |
|
741 |
setup for paint, leave bg-problem till next opaque draw |
|
742 |
comes around. |
|
743 |
" |
|
744 |
self setGCForPaint. |
|
745 |
] |
|
732 | 746 |
] |
747 |
||
1742 | 748 |
"Modified: 6.6.1997 / 12:56:55 / cg" |
732 | 749 |
! |
750 |
||
751 |
paint:fgColor on:bgColor function:f |
|
752 |
"set paint, background-paint and function" |
|
753 |
||
754 |
self paint:fgColor on:bgColor. |
|
755 |
self function:f |
|
756 |
||
757 |
"Modified: 16.5.1996 / 15:36:35 / cg" |
|
758 |
! |
|
759 |
||
760 |
setGraphicsExposures:aBoolean |
|
761 |
"want to if aBoolean is true - or dont want to be notified |
|
762 |
of graphics exposures" |
|
763 |
||
764 |
gcId notNil ifTrue:[ |
|
765 |
device setGraphicsExposures:aBoolean in:gcId |
|
766 |
] |
|
767 |
! ! |
|
768 |
||
1092 | 769 |
!DeviceGraphicsContext methodsFor:'accessing-internals'! |
732 | 770 |
|
771 |
background |
|
772 |
"return the current background drawing color. |
|
773 |
OBSOLETE: use #paint: / #backgroundPaint: / #paint:on:" |
|
774 |
||
775 |
^ background |
|
776 |
||
777 |
"Modified: 12.5.1996 / 22:28:09 / cg" |
|
778 |
! |
|
779 |
||
780 |
background:aColor |
|
781 |
"set the internal background color for drawing - aColor must be a real color. |
|
782 |
OBSOLETE: this method will vanish; use #paint: / #backgroundPaint: / #paint:on:" |
|
783 |
||
784 |
|bgId| |
|
785 |
||
786 |
(aColor ~~ background) ifTrue:[ |
|
2835 | 787 |
aColor notNil ifTrue:[ |
788 |
background := aColor. |
|
789 |
gcId notNil ifTrue:[ |
|
790 |
background := background onDevice:device. |
|
791 |
bgId := background colorId. |
|
792 |
||
793 |
" |
|
794 |
mhmh the following is a kludge .... |
|
795 |
" |
|
796 |
bgId isNil ifTrue:[ |
|
797 |
(background grayIntensity >= 50) ifTrue:[ |
|
798 |
bgId := device whitepixel |
|
799 |
] ifFalse:[ |
|
800 |
bgId := device blackpixel |
|
801 |
] |
|
802 |
]. |
|
803 |
device setBackground:bgId in:gcId |
|
804 |
] |
|
805 |
] |
|
732 | 806 |
] |
807 |
||
745 | 808 |
"Modified: 28.5.1996 / 20:44:55 / cg" |
732 | 809 |
! |
810 |
||
811 |
foreground |
|
812 |
"return the current foreground drawing color. |
|
813 |
OBSOLETE: use #paint: / #paint:on:" |
|
814 |
||
815 |
^ foreground |
|
816 |
||
817 |
"Modified: 12.5.1996 / 22:28:03 / cg" |
|
818 |
! |
|
819 |
||
820 |
foreground:aColor |
|
821 |
"set the internal foreground color for drawing - aColor must be a real color. |
|
822 |
OBSOLETE: this method will vanish; use #paint: / #paint:on:" |
|
823 |
||
824 |
|fgId| |
|
825 |
||
826 |
(aColor ~~ foreground) ifTrue:[ |
|
2835 | 827 |
aColor notNil ifTrue:[ |
828 |
foreground := aColor. |
|
829 |
gcId notNil ifTrue:[ |
|
830 |
(foreground class == SmallInteger) ifTrue:[ |
|
831 |
fgId := foreground |
|
832 |
] ifFalse:[ |
|
833 |
foreground := foreground onDevice:device. |
|
834 |
fgId := foreground colorId. |
|
835 |
]. |
|
836 |
||
837 |
"mhmh the following is a kludge ...." |
|
838 |
fgId isNil ifTrue:[ |
|
839 |
(foreground grayIntensity >= 50) ifTrue:[ |
|
840 |
fgId := device whitepixel |
|
841 |
] ifFalse:[ |
|
842 |
fgId := device blackpixel |
|
843 |
] |
|
844 |
]. |
|
845 |
device setForeground:fgId in:gcId. |
|
846 |
paint := foreground |
|
847 |
] |
|
848 |
] |
|
732 | 849 |
] |
850 |
||
745 | 851 |
"Modified: 28.5.1996 / 20:45:02 / cg" |
732 | 852 |
! |
853 |
||
854 |
foreground:fgColor background:bgColor |
|
855 |
"set both internal foreground and internal background colors |
|
856 |
- these must be real colors. |
|
857 |
OBSOLETE: this method will vanish; use #paint: / #paint:on:" |
|
858 |
||
859 |
|fgPixel bgPixel| |
|
860 |
||
861 |
((fgColor ~~ foreground) or:[bgColor ~~ background]) ifTrue:[ |
|
2835 | 862 |
fgColor notNil ifTrue:[ |
863 |
foreground := fgColor |
|
864 |
]. |
|
865 |
bgColor notNil ifTrue:[ |
|
866 |
background := bgColor |
|
867 |
]. |
|
868 |
gcId notNil ifTrue:[ |
|
869 |
foreground := foreground onDevice:device. |
|
870 |
background := background onDevice:device. |
|
871 |
fgPixel := foreground colorId. |
|
872 |
bgPixel := background colorId. |
|
873 |
||
874 |
"mhmh the following is a kludge ...." |
|
875 |
fgPixel isNil ifTrue:[ |
|
876 |
(foreground grayIntensity >= 50) ifTrue:[ |
|
877 |
fgPixel := device whitepixel |
|
878 |
] ifFalse:[ |
|
879 |
fgPixel := device blackpixel |
|
880 |
] |
|
881 |
]. |
|
882 |
bgPixel isNil ifTrue:[ |
|
883 |
(background grayIntensity >= 50) ifTrue:[ |
|
884 |
bgPixel := device whitepixel |
|
885 |
] ifFalse:[ |
|
886 |
bgPixel := device blackpixel |
|
887 |
] |
|
888 |
]. |
|
889 |
device setForeground:fgPixel background:bgPixel in:gcId. |
|
890 |
paint := foreground |
|
891 |
] |
|
732 | 892 |
] |
893 |
||
745 | 894 |
"Modified: 28.5.1996 / 20:45:27 / cg" |
732 | 895 |
! |
896 |
||
897 |
foreground:fgColor background:bgColor function:fun |
|
898 |
"set foreground, background colors and function. |
|
899 |
OBSOLETE: this method will vanish; use #paint: / #paint:on:" |
|
900 |
||
901 |
self foreground:fgColor background:bgColor. |
|
902 |
self function:fun |
|
903 |
||
904 |
"Modified: 12.5.1996 / 22:28:34 / cg" |
|
905 |
! |
|
906 |
||
907 |
foreground:aColor function:fun |
|
908 |
"set the foreground color and function for drawing. |
|
909 |
OBSOLETE: this method will vanish; use #paint: / #paint:on:" |
|
910 |
||
911 |
|fgPixel| |
|
912 |
||
913 |
((aColor ~~ foreground) or:[fun ~~ function]) ifTrue:[ |
|
2835 | 914 |
foreground := aColor. |
915 |
function := fun. |
|
916 |
gcId notNil ifTrue:[ |
|
917 |
foreground := foreground onDevice:device. |
|
918 |
fgPixel := foreground colorId. |
|
919 |
||
920 |
"mhmh the following is a kludge ...." |
|
921 |
fgPixel isNil ifTrue:[ |
|
922 |
(foreground grayIntensity >= 50) ifTrue:[ |
|
923 |
fgPixel := device whitepixel |
|
924 |
] ifFalse:[ |
|
925 |
fgPixel := device blackpixel |
|
926 |
] |
|
927 |
]. |
|
928 |
device setForeground:fgPixel in:gcId. |
|
929 |
device setFunction:fun in:gcId. |
|
930 |
paint := foreground |
|
931 |
] |
|
732 | 932 |
] |
933 |
||
745 | 934 |
"Modified: 28.5.1996 / 20:45:09 / cg" |
732 | 935 |
! ! |
936 |
||
937 |
!DeviceGraphicsContext methodsFor:'bit blitting'! |
|
938 |
||
2016 | 939 |
copyBitsFrom:aByteArray bitsPerPixel:bpp depth:depth padding:pad width:srcW height:srcH x:srcX y:srcY toX:dstX y:dstY |
940 |
"copy bits from a smalltalk byteArray. |
|
941 |
The bits found there are supposed to be in the devices native format (i.e. |
|
942 |
translated to allocated color indices on pseudoColor devices and padded as required. |
|
943 |
The byteOrder is MSB and will be converted as appropriate by the underlying devices |
|
944 |
method to whatever the device needs." |
|
945 |
||
946 |
device |
|
947 |
drawBits:aByteArray |
|
948 |
bitsPerPixel:bpp |
|
949 |
depth:depth |
|
950 |
padding:pad |
|
951 |
width:srcW height:srcH |
|
952 |
x:srcX y:srcY |
|
953 |
into:drawableId |
|
954 |
x:dstX y:dstY |
|
955 |
width:(self width) height:(self height) |
|
956 |
with:gcId. |
|
957 |
! |
|
958 |
||
732 | 959 |
copyBitsFrom:aByteArray bitsPerPixel:bpp depth:depth width:srcW height:srcH x:srcX y:srcY toX:dstX y:dstY |
960 |
"copy bits from a smalltalk byteArray. |
|
961 |
The bits found there are supposed to be in the devices native format (i.e. |
|
962 |
translated to allocated color indices on pseudoColor devices and padded as required. |
|
963 |
The byteOrder is MSB and will be converted as appropriate by the underlying devices |
|
1996
d8b8149ab79d
added interface to specify padding in drawBits method
Claus Gittinger <cg@exept.de>
parents:
1842
diff
changeset
|
964 |
method to whatever the device needs. |
d8b8149ab79d
added interface to specify padding in drawBits method
Claus Gittinger <cg@exept.de>
parents:
1842
diff
changeset
|
965 |
Assumes the source bits are in ST/X's natural padding (i.e. 8-bit padded)" |
d8b8149ab79d
added interface to specify padding in drawBits method
Claus Gittinger <cg@exept.de>
parents:
1842
diff
changeset
|
966 |
|
d8b8149ab79d
added interface to specify padding in drawBits method
Claus Gittinger <cg@exept.de>
parents:
1842
diff
changeset
|
967 |
device |
d8b8149ab79d
added interface to specify padding in drawBits method
Claus Gittinger <cg@exept.de>
parents:
1842
diff
changeset
|
968 |
drawBits:aByteArray |
d8b8149ab79d
added interface to specify padding in drawBits method
Claus Gittinger <cg@exept.de>
parents:
1842
diff
changeset
|
969 |
bitsPerPixel:bpp |
d8b8149ab79d
added interface to specify padding in drawBits method
Claus Gittinger <cg@exept.de>
parents:
1842
diff
changeset
|
970 |
depth:depth |
d8b8149ab79d
added interface to specify padding in drawBits method
Claus Gittinger <cg@exept.de>
parents:
1842
diff
changeset
|
971 |
padding:8 |
d8b8149ab79d
added interface to specify padding in drawBits method
Claus Gittinger <cg@exept.de>
parents:
1842
diff
changeset
|
972 |
width:srcW height:srcH |
d8b8149ab79d
added interface to specify padding in drawBits method
Claus Gittinger <cg@exept.de>
parents:
1842
diff
changeset
|
973 |
x:srcX y:srcY |
d8b8149ab79d
added interface to specify padding in drawBits method
Claus Gittinger <cg@exept.de>
parents:
1842
diff
changeset
|
974 |
into:drawableId |
d8b8149ab79d
added interface to specify padding in drawBits method
Claus Gittinger <cg@exept.de>
parents:
1842
diff
changeset
|
975 |
x:dstX y:dstY |
d8b8149ab79d
added interface to specify padding in drawBits method
Claus Gittinger <cg@exept.de>
parents:
1842
diff
changeset
|
976 |
width:(self width) height:(self height) |
d8b8149ab79d
added interface to specify padding in drawBits method
Claus Gittinger <cg@exept.de>
parents:
1842
diff
changeset
|
977 |
with:gcId. |
d8b8149ab79d
added interface to specify padding in drawBits method
Claus Gittinger <cg@exept.de>
parents:
1842
diff
changeset
|
978 |
|
d8b8149ab79d
added interface to specify padding in drawBits method
Claus Gittinger <cg@exept.de>
parents:
1842
diff
changeset
|
979 |
"Created: 21.10.1995 / 00:04:22 / cg" |
d8b8149ab79d
added interface to specify padding in drawBits method
Claus Gittinger <cg@exept.de>
parents:
1842
diff
changeset
|
980 |
! |
d8b8149ab79d
added interface to specify padding in drawBits method
Claus Gittinger <cg@exept.de>
parents:
1842
diff
changeset
|
981 |
|
732 | 982 |
copyFrom:aDrawable x:srcX y:srcY toX:dstX y:dstY width:w height:h |
983 |
"copy from aDrawable into the receiver; |
|
984 |
the source may be the receiver as well - in this case its a scroll. |
|
985 |
All coordinates are in device coordinates." |
|
986 |
||
1291 | 987 |
^ self |
988 |
copyFrom:aDrawable |
|
989 |
x:srcX y:srcY |
|
990 |
toX:dstX y:dstY |
|
991 |
width:w height:h |
|
992 |
async:false |
|
993 |
||
994 |
"Modified: 29.1.1997 / 13:12:36 / cg" |
|
995 |
! |
|
996 |
||
997 |
copyFrom:aDrawable x:srcX y:srcY toX:dstX y:dstY width:w height:h async:async |
|
998 |
"copy from aDrawable into the receiver; |
|
999 |
the source may be the receiver as well - in this case its a scroll. |
|
1000 |
All coordinates are in device coordinates. |
|
1001 |
If the receiver is a view AND async is true, the call returns immediately |
|
1002 |
- otherwise, it returns when the scroll operation is finished. |
|
1003 |
(not all devices care for this). |
|
1004 |
If the receiver is a pixmap, the call always returns immediately." |
|
1005 |
||
1006 |
|deviceDrawable id srcGCId asy| |
|
976 | 1007 |
|
2210
18d4e83d08ad
care for images being passed to #copyFrom: as source.
Claus Gittinger <cg@exept.de>
parents:
2192
diff
changeset
|
1008 |
((aDrawable graphicsDevice ~~ device) |
18d4e83d08ad
care for images being passed to #copyFrom: as source.
Claus Gittinger <cg@exept.de>
parents:
2192
diff
changeset
|
1009 |
or:[aDrawable isImage]) ifTrue:[ |
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1010 |
deviceDrawable := aDrawable asFormOn:device. |
976 | 1011 |
] ifFalse:[ |
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1012 |
deviceDrawable := aDrawable |
976 | 1013 |
]. |
1014 |
||
1015 |
id := deviceDrawable id. |
|
732 | 1016 |
|
1017 |
"temporary ... |
|
1018 |
this fixes a problem after restart on another display, |
|
976 | 1019 |
when a file-bitmap was not found. |
1020 |
In this case, the id of the bitmap will be nil. |
|
1021 |
This will be fixed soon (no longer use device>>bitmapFromFile:). |
|
732 | 1022 |
" |
976 | 1023 |
id isNil ifTrue:[ |
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1024 |
'DeviceGraphicsContext [warning]: invalid bitmap copy - ignored' errorPrintCR. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1025 |
^ self |
732 | 1026 |
]. |
1027 |
||
1028 |
gcId isNil ifTrue:[ |
|
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1029 |
self initGC |
732 | 1030 |
]. |
1031 |
||
2065 | 1032 |
deviceDrawable gcId isNil ifTrue:[deviceDrawable initGC]. |
976 | 1033 |
srcGCId := deviceDrawable gcId. |
1034 |
||
1035 |
((deviceDrawable depth == 1) and:[device depth ~~ 1]) ifTrue:[ |
|
1249
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1036 |
deviceDrawable isForm ifTrue:[ |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1037 |
device |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1038 |
copyPlaneFromPixmapId:id |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1039 |
x:srcX |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1040 |
y:srcY |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1041 |
gc:srcGCId |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1042 |
to:drawableId |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1043 |
x:dstX |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1044 |
y:dstY |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1045 |
gc:gcId |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1046 |
width:w |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1047 |
height:h |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1048 |
] ifFalse:[ |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1049 |
device |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1050 |
copyPlaneFromId:id |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1051 |
x:srcX |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1052 |
y:srcY |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1053 |
gc:srcGCId |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1054 |
to:drawableId |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1055 |
x:dstX |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1056 |
y:dstY |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1057 |
gc:gcId |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1058 |
width:w |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1059 |
height:h |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1060 |
] |
732 | 1061 |
] ifFalse:[ |
1249
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1062 |
deviceDrawable isForm ifTrue:[ |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1063 |
device |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1064 |
copyFromPixmapId:id |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1065 |
x:srcX |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1066 |
y:srcY |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1067 |
gc:srcGCId |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1068 |
to:drawableId |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1069 |
x:dstX |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1070 |
y:dstY |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1071 |
gc:gcId |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1072 |
width:w |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1073 |
height:h |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1074 |
] ifFalse:[ |
1291 | 1075 |
asy := async or:[self isView not]. |
1076 |
asy ifFalse:[ |
|
1077 |
self catchExpose |
|
1078 |
]. |
|
1249
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1079 |
device |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1080 |
copyFromId:id |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1081 |
x:srcX |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1082 |
y:srcY |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1083 |
gc:srcGCId |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1084 |
to:drawableId |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1085 |
x:dstX |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1086 |
y:dstY |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1087 |
gc:gcId |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1088 |
width:w |
1291 | 1089 |
height:h. |
1090 |
asy ifFalse:[ |
|
1294 | 1091 |
device flush. |
1291 | 1092 |
self waitForExpose |
1093 |
] |
|
1249
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1094 |
] |
732 | 1095 |
] |
868 | 1096 |
|
2210
18d4e83d08ad
care for images being passed to #copyFrom: as source.
Claus Gittinger <cg@exept.de>
parents:
2192
diff
changeset
|
1097 |
"Created: / 29.1.1997 / 13:02:10 / cg" |
18d4e83d08ad
care for images being passed to #copyFrom: as source.
Claus Gittinger <cg@exept.de>
parents:
2192
diff
changeset
|
1098 |
"Modified: / 31.7.1998 / 17:23:43 / cg" |
732 | 1099 |
! |
1100 |
||
1101 |
copyPlaneFrom:aDrawable x:srcX y:srcY toX:dstX y:dstY width:w height:h |
|
1102 |
"copy one plane from aDrawable into the receiver. 0's are drawn in |
|
1103 |
background, while 1's are drawn with foreground color. |
|
1104 |
The depth of aDrawable must (should) be 1. |
|
1105 |
The drawable must have been allocated on the same device. |
|
1106 |
All coordinates are in device coordinates." |
|
1107 |
||
1064 | 1108 |
|deviceDrawable id| |
976 | 1109 |
|
2210
18d4e83d08ad
care for images being passed to #copyFrom: as source.
Claus Gittinger <cg@exept.de>
parents:
2192
diff
changeset
|
1110 |
((aDrawable graphicsDevice ~~ device) |
18d4e83d08ad
care for images being passed to #copyFrom: as source.
Claus Gittinger <cg@exept.de>
parents:
2192
diff
changeset
|
1111 |
or:[aDrawable isImage]) ifTrue:[ |
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1112 |
deviceDrawable := aDrawable asFormOn:device. |
976 | 1113 |
] ifFalse:[ |
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1114 |
deviceDrawable := aDrawable |
976 | 1115 |
]. |
1116 |
||
1117 |
id := deviceDrawable id. |
|
732 | 1118 |
|
1119 |
"temporary ... |
|
1120 |
this fixes a problem after restart on another display, |
|
976 | 1121 |
when a file-bitmap was not found. |
1122 |
In this case, the id of the bitmap will be nil. |
|
1123 |
This will be fixed soon (no longer use device>>bitmapFromFile:). |
|
732 | 1124 |
" |
976 | 1125 |
id isNil ifTrue:[ |
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1126 |
'DeviceGraphicsContext [warning]: invalid copyPlane - ignored' errorPrintCR. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1127 |
^ self |
732 | 1128 |
]. |
1129 |
||
1130 |
gcId isNil ifTrue:[ |
|
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1131 |
self initGC |
732 | 1132 |
]. |
1133 |
||
1249
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1134 |
deviceDrawable isForm ifTrue:[ |
2271
46b68ae54cbc
win32 needs source-gc to be initialized in a bitBlt.
Claus Gittinger <cg@exept.de>
parents:
2268
diff
changeset
|
1135 |
deviceDrawable gcId isNil ifTrue:[ |
46b68ae54cbc
win32 needs source-gc to be initialized in a bitBlt.
Claus Gittinger <cg@exept.de>
parents:
2268
diff
changeset
|
1136 |
deviceDrawable initGC |
46b68ae54cbc
win32 needs source-gc to be initialized in a bitBlt.
Claus Gittinger <cg@exept.de>
parents:
2268
diff
changeset
|
1137 |
]. |
1249
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1138 |
device |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1139 |
copyPlaneFromPixmapId:id |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1140 |
x:srcX |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1141 |
y:srcY |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1142 |
gc:(deviceDrawable gcId) |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1143 |
to:drawableId |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1144 |
x:dstX |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1145 |
y:dstY |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1146 |
gc:gcId |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1147 |
width:w |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1148 |
height:h |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1149 |
] ifFalse:[ |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1150 |
device |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1151 |
copyPlaneFromId:id |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1152 |
x:srcX |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1153 |
y:srcY |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1154 |
gc:(deviceDrawable gcId) |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1155 |
to:drawableId |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1156 |
x:dstX |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1157 |
y:dstY |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1158 |
gc:gcId |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1159 |
width:w |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1160 |
height:h |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1161 |
] |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
1162 |
|
2271
46b68ae54cbc
win32 needs source-gc to be initialized in a bitBlt.
Claus Gittinger <cg@exept.de>
parents:
2268
diff
changeset
|
1163 |
"Modified: / 22.8.1998 / 15:15:52 / cg" |
732 | 1164 |
! ! |
1165 |
||
1166 |
!DeviceGraphicsContext methodsFor:'copying'! |
|
1167 |
||
3611
8b4384c9e660
Use #finalize instead of #disposed
Stefan Vogel <sv@exept.de>
parents:
3569
diff
changeset
|
1168 |
executor |
8b4384c9e660
Use #finalize instead of #disposed
Stefan Vogel <sv@exept.de>
parents:
3569
diff
changeset
|
1169 |
"I am abstract" |
8b4384c9e660
Use #finalize instead of #disposed
Stefan Vogel <sv@exept.de>
parents:
3569
diff
changeset
|
1170 |
|
8b4384c9e660
Use #finalize instead of #disposed
Stefan Vogel <sv@exept.de>
parents:
3569
diff
changeset
|
1171 |
self subclassResponsibility. |
8b4384c9e660
Use #finalize instead of #disposed
Stefan Vogel <sv@exept.de>
parents:
3569
diff
changeset
|
1172 |
|
8b4384c9e660
Use #finalize instead of #disposed
Stefan Vogel <sv@exept.de>
parents:
3569
diff
changeset
|
1173 |
"Created: 2.4.1997 / 19:22:11 / cg" |
8b4384c9e660
Use #finalize instead of #disposed
Stefan Vogel <sv@exept.de>
parents:
3569
diff
changeset
|
1174 |
! |
8b4384c9e660
Use #finalize instead of #disposed
Stefan Vogel <sv@exept.de>
parents:
3569
diff
changeset
|
1175 |
|
732 | 1176 |
postCopy |
1177 |
"this may not be enough to allow copying of views ..." |
|
1178 |
||
1179 |
super postCopy. |
|
1180 |
device := drawableId := gcId := nil. |
|
1181 |
self recreate |
|
1182 |
! ! |
|
1183 |
||
1184 |
!DeviceGraphicsContext methodsFor:'drawing'! |
|
1185 |
||
1186 |
displayArcX:x y:y width:w height:h from:startAngle angle:angle |
|
1187 |
"draw an arc; apply transformation if nonNil" |
|
1188 |
||
2268
1a774fc02c83
fixed non-float (i.e. fraction) args to fillArc/ displayArc
Claus Gittinger <cg@exept.de>
parents:
2259
diff
changeset
|
1189 |
|pX pY nW nH sA a| |
732 | 1190 |
|
1191 |
gcId isNil ifTrue:[ |
|
1029
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
1192 |
self initGC |
732 | 1193 |
]. |
1194 |
transformation notNil ifTrue:[ |
|
1029
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
1195 |
pX := transformation applyToX:x. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
1196 |
pY := transformation applyToY:y. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
1197 |
nW := transformation applyScaleX:w. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
1198 |
nH := transformation applyScaleY:h. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
1199 |
nW < 0 ifTrue:[ |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
1200 |
nW := nW abs. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
1201 |
pX := pX - nW. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
1202 |
]. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
1203 |
nH < 0 ifTrue:[ |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
1204 |
nH := nH abs. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
1205 |
pY := pY - nH. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
1206 |
]. |
732 | 1207 |
] ifFalse:[ |
1029
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
1208 |
pX := x. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
1209 |
pY := y. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
1210 |
nW := w. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
1211 |
nH := h. |
732 | 1212 |
]. |
1213 |
||
1214 |
pX := pX rounded. |
|
1215 |
pY := pY rounded. |
|
1216 |
nW := nW rounded. |
|
1217 |
nH := nH rounded. |
|
1218 |
||
2268
1a774fc02c83
fixed non-float (i.e. fraction) args to fillArc/ displayArc
Claus Gittinger <cg@exept.de>
parents:
2259
diff
changeset
|
1219 |
sA := startAngle. |
1a774fc02c83
fixed non-float (i.e. fraction) args to fillArc/ displayArc
Claus Gittinger <cg@exept.de>
parents:
2259
diff
changeset
|
1220 |
sA isInteger ifFalse:[sA := sA asFloat]. |
1a774fc02c83
fixed non-float (i.e. fraction) args to fillArc/ displayArc
Claus Gittinger <cg@exept.de>
parents:
2259
diff
changeset
|
1221 |
a := angle. |
1a774fc02c83
fixed non-float (i.e. fraction) args to fillArc/ displayArc
Claus Gittinger <cg@exept.de>
parents:
2259
diff
changeset
|
1222 |
a isInteger ifFalse:[a := a asFloat]. |
1a774fc02c83
fixed non-float (i.e. fraction) args to fillArc/ displayArc
Claus Gittinger <cg@exept.de>
parents:
2259
diff
changeset
|
1223 |
|
732 | 1224 |
device |
1029
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
1225 |
displayArcX:pX |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
1226 |
y:pY |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
1227 |
width:nW |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
1228 |
height:nH |
2268
1a774fc02c83
fixed non-float (i.e. fraction) args to fillArc/ displayArc
Claus Gittinger <cg@exept.de>
parents:
2259
diff
changeset
|
1229 |
from:sA |
1a774fc02c83
fixed non-float (i.e. fraction) args to fillArc/ displayArc
Claus Gittinger <cg@exept.de>
parents:
2259
diff
changeset
|
1230 |
angle:a |
1029
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
1231 |
in:drawableId |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
1232 |
with:gcId |
732 | 1233 |
|
1234 |
"Created: 8.5.1996 / 08:31:30 / cg" |
|
784 | 1235 |
"Modified: 4.6.1996 / 17:59:28 / cg" |
732 | 1236 |
! |
1237 |
||
1238 |
displayForm:formToDraw x:x y:y |
|
1592
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1239 |
"draw a form or image non opaque; |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1240 |
if its a 1-plane bitmap, 1-bits are drawn in the |
732 | 1241 |
current paint-color, leaving pixels with 0-bits unchanged |
1242 |
(i.e. only 1-bits are drawn from the form). |
|
1243 |
If its a deep form (i.e. a pixmap) the current paint |
|
1244 |
settings are ignored and the form is drawn as-is. |
|
1245 |
Care must be taken, that the paint color is correctly allocated |
|
1246 |
(by sending #on: to the color) before doing so. |
|
1247 |
Using functions other than #copy only makes sense if you are |
|
1248 |
certain, that the colors are real colors (actually, only for |
|
1249 |
noColor or allColor)." |
|
1250 |
||
1251 |
|realForm pX pY w h nW nH| |
|
1252 |
||
1253 |
realForm := formToDraw. |
|
1254 |
||
1255 |
transformation notNil ifTrue:[ |
|
1592
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1256 |
pX := transformation applyToX:x. |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1257 |
pY := transformation applyToY:y. |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1258 |
|
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1259 |
transformation noScale ifFalse:[ |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1260 |
w := formToDraw width. |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1261 |
h := formToDraw height. |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1262 |
|
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1263 |
nW := (transformation applyScaleX:w) rounded. |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1264 |
nH := (transformation applyScaleY:h) rounded. |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1265 |
|
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1266 |
((nW ~= w) or:[nH ~= h]) ifTrue:[ |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1267 |
"/ |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1268 |
"/ hard case - someone is drawing forms with scaling in effect |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1269 |
"/ look if we have a scaled version in our pocket ... |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1270 |
"/ |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1271 |
realForm := nil. |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1272 |
CachedScaledForms notNil ifTrue:[ |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1273 |
(CachedScales at:formToDraw ifAbsent:nil) = transformation scale ifTrue:[ |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1274 |
realForm := CachedScaledForms at:formToDraw ifAbsent:nil. |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1275 |
] |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1276 |
]. |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1277 |
realForm isNil ifTrue:[ |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1278 |
"/ |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1279 |
"/ nope - must do the work ... |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1280 |
"/ |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1281 |
realForm := formToDraw magnifiedBy:(nW / w) @ (nH / h). |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1282 |
CachedScaledForms isNil ifTrue:[ |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1283 |
CachedScaledForms := WeakIdentityDictionary new. |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1284 |
CachedScales := WeakIdentityDictionary new. |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1285 |
]. |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1286 |
CachedScaledForms at:formToDraw put:realForm. |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1287 |
CachedScales at:formToDraw put:transformation scale. |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1288 |
] |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1289 |
] |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1290 |
] |
732 | 1291 |
] ifFalse:[ |
1592
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1292 |
pX := x. |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1293 |
pY := y. |
732 | 1294 |
]. |
1295 |
||
1296 |
self displayDeviceForm:realForm x:pX y:pY |
|
1297 |
||
1592
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1298 |
"Modified: 12.4.1997 / 12:47:29 / cg" |
732 | 1299 |
! |
1300 |
||
1301 |
displayLineFromX:x0 y:y0 toX:x1 y:y1 |
|
1302 |
"draw a line (with current paint-color); apply transformation if nonNil" |
|
1303 |
||
1304 |
|pX0 pY0 pX1 pY1 easy fgId bgId| |
|
1305 |
||
1306 |
gcId isNil ifTrue:[ |
|
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1307 |
self initGC |
732 | 1308 |
]. |
1309 |
||
1310 |
lineStyle == #doubleDashed ifTrue:[ |
|
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1311 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1312 |
if bgPaint or paint is not a real color, we have to do it the hard way ... |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1313 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1314 |
easy := true. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1315 |
paint isColor ifFalse:[ |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1316 |
easy := false |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1317 |
] ifTrue:[ |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1318 |
fgId := paint colorId. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1319 |
fgId isNil ifTrue:[ |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1320 |
easy := false |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1321 |
] |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1322 |
]. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1323 |
bgPaint isColor ifFalse:[ |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1324 |
easy := false |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1325 |
] ifTrue:[ |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1326 |
bgId := bgPaint colorId. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1327 |
bgId isNil ifTrue:[ |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1328 |
easy := false |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1329 |
] |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1330 |
]. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1331 |
|
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1332 |
easy ifTrue:[ |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1333 |
((foreground ~~ paint) or:[background ~~ bgPaint]) ifTrue:[ |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1334 |
device setForeground:fgId background:bgId in:gcId. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1335 |
foreground := paint. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1336 |
background := bgPaint. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1337 |
]. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1338 |
] ifFalse:[ |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1339 |
'DeviceGraphicsContext [warning]: cannot draw dashes with dithered colors' errorPrintCR |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1340 |
]. |
732 | 1341 |
]. |
1342 |
||
1343 |
transformation notNil ifTrue:[ |
|
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1344 |
pX0 := transformation applyToX:x0. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1345 |
pY0 := transformation applyToY:y0. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1346 |
pX1 := transformation applyToX:x1. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1347 |
pY1 := transformation applyToY:y1. |
732 | 1348 |
] ifFalse:[ |
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1349 |
pX0 := x0. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1350 |
pY0 := y0. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1351 |
pX1 := x1. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1352 |
pY1 := y1 |
732 | 1353 |
]. |
1354 |
||
1355 |
pX0 := pX0 rounded. |
|
1356 |
pY0 := pY0 rounded. |
|
1357 |
pX1 := pX1 rounded. |
|
1358 |
pY1 := pY1 rounded. |
|
1359 |
||
1360 |
device displayLineFromX:pX0 y:pY0 toX:pX1 y:pY1 in:drawableId with:gcId |
|
1361 |
||
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1362 |
"Modified: 10.1.1997 / 17:46:32 / cg" |
732 | 1363 |
! |
1364 |
||
1365 |
displayOpaqueForm:formToDraw x:x y:y |
|
1592
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1366 |
"draw a form or image opaque; |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1367 |
if its a 1-plane bitmap, 1-bits are drawn in the |
732 | 1368 |
current paint-color and 0-bits in the bgPaint color. |
1369 |
If its a deep form (i.e. a pixmap) the current paint/bgPaint |
|
1370 |
settings are ignored and the form drawn as-is. |
|
1371 |
In the 1-plane case, special care must be taken if paint and/or bgPaint |
|
1372 |
dithered colors or patterns, since are that the colors are correctly allocated |
|
1373 |
(by sending #on: to the colors) before doing so. |
|
1374 |
If there is a transformation, the image is scaled as appropiate." |
|
1375 |
||
1376 |
|w h realForm pX pY nW nH| |
|
1377 |
||
1378 |
bgPaint isNil ifTrue:[ |
|
1592
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1379 |
"/ |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1380 |
"/ actually not an opaque draw |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1381 |
"/ |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1382 |
self displayForm:formToDraw x:x y:y. |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1383 |
^ self |
732 | 1384 |
]. |
1385 |
||
1386 |
realForm := formToDraw. |
|
1387 |
||
1388 |
transformation notNil ifTrue:[ |
|
1592
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1389 |
pX := transformation applyToX:x. |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1390 |
pY := transformation applyToY:y. |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1391 |
|
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1392 |
transformation noScale ifFalse:[ |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1393 |
w := formToDraw width. |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1394 |
h := formToDraw height. |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1395 |
|
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1396 |
nW := (transformation applyScaleX:w) rounded. |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1397 |
nH := (transformation applyScaleY:h) rounded. |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1398 |
|
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1399 |
((nW ~= w) or:[nH ~= h]) ifTrue:[ |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1400 |
"/ |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1401 |
"/ hard case - someone is drawing forms with scaling in effect |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1402 |
"/ look if we have a scaled version in our pocket ... |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1403 |
"/ |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1404 |
realForm := nil. |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1405 |
CachedScaledForms notNil ifTrue:[ |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1406 |
(CachedScales at:formToDraw ifAbsent:nil) = transformation scale ifTrue:[ |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1407 |
realForm := CachedScaledForms at:formToDraw ifAbsent:nil. |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1408 |
] |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1409 |
]. |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1410 |
realForm isNil ifTrue:[ |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1411 |
"/ |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1412 |
"/ nope - must do the work ... |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1413 |
"/ |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1414 |
realForm := formToDraw magnifiedBy:(nW / w) @ (nH / h). |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1415 |
CachedScaledForms isNil ifTrue:[ |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1416 |
CachedScaledForms := WeakIdentityDictionary new. |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1417 |
CachedScales := WeakIdentityDictionary new. |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1418 |
]. |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1419 |
CachedScaledForms at:formToDraw put:realForm. |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1420 |
CachedScales at:formToDraw put:transformation scale. |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1421 |
] |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1422 |
] |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1423 |
] |
732 | 1424 |
] ifFalse:[ |
1592
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1425 |
pX := x. |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1426 |
pY := y. |
732 | 1427 |
]. |
1428 |
||
1429 |
self displayDeviceOpaqueForm:realForm x:pX y:pY |
|
1430 |
||
1592
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1431 |
"Modified: 12.4.1997 / 12:49:02 / cg" |
732 | 1432 |
! |
1433 |
||
1434 |
displayOpaqueString:aString from:index1 to:index2 x:x y:y |
|
1435 |
"draw a substring at the coordinate x/y - draw foreground pixels in |
|
1436 |
paint-color and background pixels in bgPaint-color. |
|
1437 |
If the transformation involves scaling, |
|
1438 |
the fonts point-size is scaled as appropriate. |
|
1439 |
Assuming that device can only draw in device colors, we have to handle |
|
1440 |
the case where paint and/or bgPaint are dithered colors" |
|
1441 |
||
1442 |
|easy w h savedPaint fgId bgId |
|
1443 |
id pX pY fontUsed sz s| |
|
1444 |
||
1445 |
" |
|
1446 |
if backgroundPaint color is nil, we assume |
|
1447 |
this is a non-opaque draw |
|
1448 |
" |
|
1449 |
bgPaint isNil ifTrue:[ |
|
1797 | 1450 |
self displayString:aString from:index1 to:index2 x:x y:y. |
1451 |
^ self |
|
732 | 1452 |
]. |
1453 |
||
1454 |
(aString isString not |
|
1455 |
or:[aString isText]) ifTrue:[ |
|
1797 | 1456 |
" |
1457 |
hook for non-strings (i.e. attributed text) |
|
1458 |
that 'thing' should know how to display itself ... |
|
1459 |
" |
|
1460 |
aString displayOpaqueOn:self x:x y:y from:index1 to:index2. |
|
1461 |
^ self |
|
732 | 1462 |
]. |
1463 |
||
1464 |
gcId isNil ifTrue:[ |
|
1797 | 1465 |
self initGC |
732 | 1466 |
]. |
1467 |
||
1468 |
fontUsed := font. |
|
1469 |
transformation notNil ifTrue:[ |
|
1797 | 1470 |
pX := transformation applyToX:x. |
1471 |
pY := transformation applyToY:y. |
|
1472 |
transformation noScale ifFalse:[ |
|
1473 |
sz := font size. |
|
1474 |
sz isNil ifTrue:[ |
|
1475 |
"/ oops - not a real font; use original font |
|
1476 |
fontUsed := font |
|
1477 |
] ifFalse:[ |
|
1478 |
fontUsed := font size:(transformation applyScaleY:sz) rounded. |
|
1479 |
] |
|
1480 |
] |
|
732 | 1481 |
] ifFalse:[ |
1797 | 1482 |
pX := x. |
1483 |
pY := y. |
|
732 | 1484 |
]. |
1485 |
pX := pX rounded. |
|
1486 |
pY := pY rounded. |
|
1487 |
||
2835 | 1488 |
fontUsed := fontUsed onDevice:device. |
732 | 1489 |
|
1490 |
id := fontUsed fontId. |
|
1491 |
id isNil ifTrue:[ |
|
1797 | 1492 |
" |
1493 |
hook for alien fonts |
|
1494 |
that 'font' should know how to display the string ... |
|
1495 |
" |
|
1496 |
fontUsed displayOpaqueString:aString from:index1 to:index2 x:x y:y in:self. |
|
1497 |
^ self |
|
732 | 1498 |
]. |
1499 |
||
1500 |
s := aString. |
|
1501 |
s encoding ~~ font encoding ifTrue:[ |
|
1797 | 1502 |
s := s encodeForDisplayInto:(font encoding). |
732 | 1503 |
]. |
1504 |
||
1505 |
" |
|
1506 |
if bgPaint or paint is not a real Color, we have to do it the hard way ... |
|
1507 |
" |
|
1508 |
easy := true. |
|
1509 |
paint isColor ifFalse:[ |
|
1797 | 1510 |
easy := false |
732 | 1511 |
] ifTrue:[ |
1797 | 1512 |
fgId := paint colorId. |
1513 |
fgId isNil ifTrue:[ |
|
1514 |
easy := false |
|
1515 |
] |
|
732 | 1516 |
]. |
1517 |
bgPaint isColor ifFalse:[ |
|
1797 | 1518 |
easy := false |
732 | 1519 |
] ifTrue:[ |
1797 | 1520 |
bgId := bgPaint colorId. |
1521 |
bgId isNil ifTrue:[ |
|
1522 |
easy := false |
|
1523 |
] |
|
732 | 1524 |
]. |
1525 |
||
1526 |
easy ifTrue:[ |
|
1797 | 1527 |
deviceFont ~~ fontUsed ifTrue:[ |
1528 |
device setFont:id in:gcId. |
|
1529 |
deviceFont := fontUsed |
|
1530 |
]. |
|
1531 |
||
1532 |
device setForeground:fgId background:bgId in:gcId. |
|
1533 |
foreground := paint. |
|
1534 |
background := bgPaint. |
|
1535 |
device displayOpaqueString:s |
|
1536 |
from:index1 to:index2 |
|
1537 |
x:pX y:pY |
|
1538 |
in:drawableId with:gcId. |
|
1539 |
^ self |
|
732 | 1540 |
]. |
1541 |
||
1542 |
w := fontUsed widthOf:s from:index1 to:index2. |
|
1543 |
h := fontUsed height. |
|
1544 |
||
1545 |
(fgId notNil and:[function == #copy]) ifTrue:[ |
|
1797 | 1546 |
deviceFont ~~ fontUsed ifTrue:[ |
1547 |
device setFont:id in:gcId. |
|
1548 |
deviceFont := fontUsed |
|
1549 |
]. |
|
1550 |
" |
|
1551 |
only bg is dithered; fill with bg first ... |
|
1552 |
" |
|
1553 |
savedPaint := paint. |
|
1554 |
self paint:bgPaint. |
|
1555 |
self fillDeviceRectangleX:pX y:(pY - fontUsed ascent) width:w height:h. |
|
1556 |
self paint:savedPaint. |
|
1557 |
||
1558 |
" |
|
1559 |
then draw using fgPaint (which is a real color) |
|
1560 |
" |
|
1561 |
device displayString:s |
|
1562 |
from:index1 to:index2 |
|
1563 |
x:pX y:pY |
|
1564 |
in:drawableId with:gcId. |
|
1565 |
^ self |
|
732 | 1566 |
]. |
1567 |
||
832
064890dcfabd
fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents:
786
diff
changeset
|
1568 |
"/ the very hard case (fg-dither) |
064890dcfabd
fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents:
786
diff
changeset
|
1569 |
|
732 | 1570 |
self displayDeviceOpaqueString:s from:index1 to:index2 in:fontUsed x:pX y:pY. |
1571 |
||
1797 | 1572 |
"Modified: 30.6.1997 / 15:06:15 / cg" |
732 | 1573 |
! |
1574 |
||
1575 |
displayOpaqueString:aString x:x y:y |
|
1576 |
"draw a string at the coordinate x/y - draw foreground pixels in paint-color, |
|
1577 |
background pixels in bgPaint color. If the transformation involves scaling, |
|
1578 |
the fonts point-size is scaled as appropriate. |
|
1579 |
Assuming that device can only draw in device colors, we have to handle |
|
1580 |
the case where paint and/or bgPaint are dithered colors or images." |
|
1581 |
||
1582 |
|id easy fgId bgId pX pY fontUsed sz s| |
|
1583 |
||
1584 |
" |
|
1585 |
if backgroundPaint color is nil, we assume |
|
1586 |
this is a non-opaque draw |
|
1587 |
" |
|
1588 |
bgPaint isNil ifTrue:[ |
|
1797 | 1589 |
self displayString:aString x:x y:y. |
1590 |
^ self |
|
732 | 1591 |
]. |
1592 |
||
1593 |
(aString isString not |
|
1594 |
or:[aString isText]) ifTrue:[ |
|
1797 | 1595 |
" |
1596 |
hook for non-strings (i.e. attributed text) |
|
1597 |
that 'thing' should know how to display itself ... |
|
1598 |
" |
|
1599 |
aString displayOpaqueOn:self x:x y:y. |
|
1600 |
^ self |
|
732 | 1601 |
]. |
1602 |
||
1603 |
" |
|
1604 |
if bgPaint or paint is not a real Color, we have to do it the hard way ... |
|
1605 |
" |
|
1606 |
easy := true. |
|
1607 |
paint isColor ifFalse:[ |
|
1797 | 1608 |
easy := false |
732 | 1609 |
] ifTrue:[ |
1797 | 1610 |
fgId := paint colorId. |
1611 |
fgId isNil ifTrue:[ |
|
1612 |
easy := false |
|
1613 |
] |
|
732 | 1614 |
]. |
1615 |
bgPaint isColor ifFalse:[ |
|
1797 | 1616 |
easy := false |
732 | 1617 |
] ifTrue:[ |
1797 | 1618 |
bgId := bgPaint colorId. |
1619 |
bgId isNil ifTrue:[ |
|
1620 |
easy := false |
|
1621 |
] |
|
732 | 1622 |
]. |
1623 |
easy ifFalse:[ |
|
1797 | 1624 |
" |
1625 |
for the hard case, use the general drawing method |
|
1626 |
(no need for optimizations - its slow anyway) |
|
1627 |
" |
|
1628 |
self displayOpaqueString:aString |
|
1629 |
from:1 to:(aString size) |
|
1630 |
x:x y:y. |
|
1631 |
^ self |
|
732 | 1632 |
]. |
1633 |
||
1634 |
gcId isNil ifTrue:[ |
|
1797 | 1635 |
self initGC |
732 | 1636 |
]. |
1637 |
||
1638 |
fontUsed := font. |
|
1639 |
transformation notNil ifTrue:[ |
|
1797 | 1640 |
pX := transformation applyToX:x. |
1641 |
pY := transformation applyToY:y. |
|
1642 |
transformation noScale ifFalse:[ |
|
1643 |
sz := font size. |
|
1644 |
sz isNil ifTrue:[ |
|
1645 |
"/ oops - not a real font; use original font |
|
1646 |
fontUsed := font |
|
1647 |
] ifFalse:[ |
|
1648 |
fontUsed := font size:(transformation applyScaleY:sz) rounded. |
|
1649 |
] |
|
1650 |
] |
|
732 | 1651 |
] ifFalse:[ |
1797 | 1652 |
pX := x. |
1653 |
pY := y. |
|
732 | 1654 |
]. |
1655 |
pX := pX rounded. |
|
1656 |
pY := pY rounded. |
|
1657 |
||
2835 | 1658 |
fontUsed := fontUsed onDevice:device. |
732 | 1659 |
|
1660 |
id := fontUsed fontId. |
|
1661 |
id isNil ifTrue:[ |
|
1797 | 1662 |
" |
1663 |
hook for alien fonts |
|
1664 |
that 'font' should know how to display the string ... |
|
1665 |
" |
|
1666 |
fontUsed displayOpaqueString:aString from:1 to:(aString size) x:x y:y in:self. |
|
1667 |
^ self |
|
732 | 1668 |
]. |
1669 |
||
1670 |
s := aString. |
|
1671 |
s encoding ~~ font encoding ifTrue:[ |
|
1797 | 1672 |
s := s encodeForDisplayInto:(font encoding). |
732 | 1673 |
]. |
1674 |
||
1675 |
deviceFont ~~ fontUsed ifTrue:[ |
|
1797 | 1676 |
device setFont:id in:gcId. |
1677 |
deviceFont := fontUsed |
|
732 | 1678 |
]. |
1679 |
||
1680 |
||
1681 |
device setForeground:fgId background:bgId in:gcId. |
|
1682 |
foreground := paint. |
|
1683 |
background := bgPaint. |
|
1684 |
device displayOpaqueString:s |
|
1797 | 1685 |
x:pX y:pY |
1686 |
in:drawableId with:gcId. |
|
1687 |
||
1688 |
"Modified: 30.6.1997 / 15:06:17 / cg" |
|
732 | 1689 |
! |
1690 |
||
1691 |
displayPointX:x y:y |
|
1692 |
"draw a point (with current paint-color); apply transformation if nonNil" |
|
1693 |
||
1694 |
|pX pY| |
|
1695 |
||
1696 |
gcId isNil ifTrue:[ |
|
1697 |
self initGC |
|
1698 |
]. |
|
1699 |
transformation notNil ifTrue:[ |
|
1700 |
pX := transformation applyToX:x. |
|
1701 |
pY := transformation applyToY:y. |
|
1702 |
] ifFalse:[ |
|
1703 |
pX := x. |
|
1704 |
pY := y |
|
1705 |
]. |
|
1706 |
pX := pX rounded. |
|
1707 |
pY := pY rounded. |
|
1708 |
||
1709 |
device displayPointX:pX y:pY in:drawableId with:gcId |
|
1710 |
! |
|
1711 |
||
1712 |
displayPolygon:aPolygon |
|
1713 |
"draw (the outline of) a polygon (with current paint-color). |
|
1714 |
Apply transformation if nonNil" |
|
1715 |
||
1716 |
|newPolygon| |
|
1717 |
||
1718 |
gcId isNil ifTrue:[ |
|
1719 |
self initGC |
|
1720 |
]. |
|
1721 |
transformation notNil ifTrue:[ |
|
1722 |
newPolygon := aPolygon collect:[:point | transformation applyTo:point]. |
|
1723 |
] ifFalse:[ |
|
1724 |
newPolygon := aPolygon |
|
1725 |
]. |
|
1726 |
(newPolygon findFirst:[:p | |
|
1727 |
(p isPoint not |
|
1728 |
or:[(p x class ~~ SmallInteger) |
|
1729 |
or:[(p y class ~~ SmallInteger)]]) |
|
1730 |
]) ~~ 0 ifTrue:[ |
|
1731 |
newPolygon := newPolygon collect:[:p | p asPoint rounded] |
|
1732 |
]. |
|
1733 |
||
1734 |
device displayPolygon:newPolygon in:drawableId with:gcId |
|
1735 |
! |
|
1736 |
||
1737 |
displayRectangleX:x y:y width:w height:h |
|
1738 |
"draw a rectangle (with current paint-color). |
|
1739 |
If transformation is nonNil, drawing is in logical coordinates." |
|
1740 |
||
1064 | 1741 |
|pX pY nW nH easy fgId bgId| |
732 | 1742 |
|
1743 |
gcId isNil ifTrue:[ |
|
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1744 |
self initGC |
732 | 1745 |
]. |
1746 |
||
1747 |
lineStyle == #doubleDashed ifTrue:[ |
|
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1748 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1749 |
if bgPaint or paint is not a real color, we have to do it the hard way ... |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1750 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1751 |
easy := true. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1752 |
paint isColor ifFalse:[ |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1753 |
easy := false |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1754 |
] ifTrue:[ |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1755 |
fgId := paint colorId. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1756 |
fgId isNil ifTrue:[ |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1757 |
easy := false |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1758 |
] |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1759 |
]. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1760 |
bgPaint isColor ifFalse:[ |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1761 |
easy := false |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1762 |
] ifTrue:[ |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1763 |
bgId := bgPaint colorId. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1764 |
bgId isNil ifTrue:[ |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1765 |
easy := false |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1766 |
] |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1767 |
]. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1768 |
|
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1769 |
easy ifTrue:[ |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1770 |
((foreground ~~ paint) or:[background ~~ bgPaint]) ifTrue:[ |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1771 |
device setForeground:fgId background:bgId in:gcId. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1772 |
foreground := paint. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1773 |
background := bgPaint. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1774 |
]. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1775 |
] ifFalse:[ |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1776 |
'DeviceGraphicsContext [warning]: cannot draw dashes with dithered colors' errorPrintCR |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1777 |
]. |
732 | 1778 |
]. |
1779 |
||
1780 |
transformation notNil ifTrue:[ |
|
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1781 |
pX := transformation applyToX:x. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1782 |
pY := transformation applyToY:y. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1783 |
nW := transformation applyScaleX:w. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1784 |
nH := transformation applyScaleY:h. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1785 |
nW < 0 ifTrue:[ |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1786 |
nW := nW abs. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1787 |
pX := pX - nW. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1788 |
]. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1789 |
nH < 0 ifTrue:[ |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1790 |
nH := nH abs. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1791 |
pY := pY - nH. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1792 |
]. |
732 | 1793 |
] ifFalse:[ |
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1794 |
pX := x. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1795 |
pY := y. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1796 |
nW := w. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1797 |
nH := h |
732 | 1798 |
]. |
1799 |
||
1800 |
pX := pX rounded. |
|
1801 |
pY := pY rounded. |
|
1802 |
nW := nW rounded. |
|
1803 |
nH := nH rounded. |
|
1804 |
||
1805 |
"I asked myself many times if we should draw w/h or (w-1)/(h-1) bits - |
|
1806 |
this one seems mathematically incorrect but allows to draw and fill |
|
1807 |
a rectangle using the same extents. |
|
1808 |
I'm not certain if is the right thing to do ... |
|
1809 |
" |
|
784 | 1810 |
device displayRectangleX:pX |
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1811 |
y:pY |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1812 |
width:(nW - 1) |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1813 |
height:(nH - 1) |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1814 |
in:drawableId with:gcId |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1815 |
|
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1816 |
"Modified: 10.1.1997 / 17:46:41 / cg" |
732 | 1817 |
! |
1818 |
||
1819 |
displayString:aString from:index1 to:index2 x:x y:y |
|
1820 |
"draw a substring at the coordinate x/y - |
|
1821 |
draw foreground-pixels only (in current paint-color), |
|
1822 |
leaving background as-is. If the transformation involves scaling, |
|
1823 |
the fonts point-size is scaled as appropriate." |
|
1824 |
||
1805
532a11ba8458
tuned-out another send if encoding is wrong in display-string
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
1825 |
|id pX pY fontUsed sz s fEnc| |
732 | 1826 |
|
1827 |
"hook for non-strings (i.e. attributed text)" |
|
3666
01d7bf1d2333
fixed Text drawing in displayString
Michael Beyl <mb@exept.de>
parents:
3630
diff
changeset
|
1828 |
(aString isString not |
01d7bf1d2333
fixed Text drawing in displayString
Michael Beyl <mb@exept.de>
parents:
3630
diff
changeset
|
1829 |
or:[aString isText]) ifTrue:[ |
1797 | 1830 |
^ aString displayOn:self x:x y:y from:index1 to:index2 |
732 | 1831 |
]. |
1832 |
||
1833 |
gcId isNil ifTrue:[ |
|
1797 | 1834 |
self initGC |
732 | 1835 |
]. |
1836 |
||
1837 |
fontUsed := font. |
|
1838 |
transformation notNil ifTrue:[ |
|
1797 | 1839 |
pX := transformation applyToX:x. |
1840 |
pY := transformation applyToY:y. |
|
1841 |
transformation noScale ifFalse:[ |
|
1842 |
sz := font size. |
|
1843 |
sz isNil ifTrue:[ |
|
1844 |
"/ oops - not a real font; use original font |
|
1845 |
fontUsed := font |
|
1846 |
] ifFalse:[ |
|
1847 |
fontUsed := font size:(transformation applyScaleY:sz) rounded. |
|
1848 |
] |
|
1849 |
] |
|
732 | 1850 |
] ifFalse:[ |
1797 | 1851 |
pX := x. |
1852 |
pY := y. |
|
732 | 1853 |
]. |
1854 |
pX := pX rounded. |
|
1855 |
pY := pY rounded. |
|
1856 |
||
2835 | 1857 |
fontUsed := fontUsed onDevice:device. |
732 | 1858 |
|
1859 |
id := fontUsed fontId. |
|
1860 |
id isNil ifTrue:[ |
|
1797 | 1861 |
"hook for alien fonts" |
1862 |
font displayString:aString from:index1 to:index2 x:x y:y in:self. |
|
1863 |
^ self |
|
732 | 1864 |
]. |
1865 |
||
1866 |
s := aString. |
|
1805
532a11ba8458
tuned-out another send if encoding is wrong in display-string
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
1867 |
s encoding ~~ (fEnc := font encoding) ifTrue:[ |
532a11ba8458
tuned-out another send if encoding is wrong in display-string
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
1868 |
s := s encodeForDisplayInto:fEnc. |
732 | 1869 |
]. |
1870 |
||
1871 |
deviceFont ~~ fontUsed ifTrue:[ |
|
1797 | 1872 |
device setFont:id in:gcId. |
1873 |
deviceFont := fontUsed |
|
732 | 1874 |
]. |
1875 |
device displayString:s from:index1 to:index2 |
|
1797 | 1876 |
x:pX y:pY in:drawableId with:gcId |
1877 |
||
1805
532a11ba8458
tuned-out another send if encoding is wrong in display-string
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
1878 |
"Modified: 1.7.1997 / 17:08:44 / cg" |
732 | 1879 |
! |
1880 |
||
1881 |
displayString:aString x:x y:y |
|
1882 |
"draw a string at the coordinate x/y - |
|
1883 |
draw foreground-pixels only (in current paint-color), |
|
1884 |
leaving background as-is. If the transformation involves scaling, |
|
1885 |
the fonts point-size is scaled as appropriate." |
|
1886 |
||
1805
532a11ba8458
tuned-out another send if encoding is wrong in display-string
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
1887 |
|id pX pY fontUsed sz s fEnc| |
732 | 1888 |
|
1889 |
"hook for non-strings (i.e. attributed text)" |
|
1890 |
(aString isString not |
|
1891 |
or:[aString isText]) ifTrue:[ |
|
1797 | 1892 |
^ aString displayOn:self x:x y:y |
732 | 1893 |
]. |
1894 |
||
1895 |
gcId isNil ifTrue:[ |
|
1797 | 1896 |
self initGC |
732 | 1897 |
]. |
1898 |
||
1899 |
fontUsed := font. |
|
1900 |
transformation notNil ifTrue:[ |
|
1797 | 1901 |
pX := transformation applyToX:x. |
1902 |
pY := transformation applyToY:y. |
|
1903 |
transformation noScale ifFalse:[ |
|
1904 |
sz := font size. |
|
1905 |
sz isNil ifTrue:[ |
|
1906 |
"/ oops - not a real font; use original font |
|
1907 |
fontUsed := font |
|
1908 |
] ifFalse:[ |
|
1909 |
fontUsed := font size:(transformation applyScaleY:sz) rounded. |
|
1910 |
] |
|
1911 |
] |
|
732 | 1912 |
] ifFalse:[ |
1797 | 1913 |
pX := x. |
1914 |
pY := y. |
|
732 | 1915 |
]. |
1916 |
pX := pX rounded. |
|
1917 |
pY := pY rounded. |
|
1918 |
||
2835 | 1919 |
fontUsed := fontUsed onDevice:device. |
732 | 1920 |
|
1921 |
id := fontUsed fontId. |
|
1922 |
id isNil ifTrue:[ |
|
1797 | 1923 |
"hook for alien fonts" |
1924 |
fontUsed displayString:aString x:x y:y in:self |
|
732 | 1925 |
] ifFalse:[ |
1797 | 1926 |
s := aString. |
1805
532a11ba8458
tuned-out another send if encoding is wrong in display-string
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
1927 |
s encoding ~~ (fEnc := fontUsed encoding) ifTrue:[ |
532a11ba8458
tuned-out another send if encoding is wrong in display-string
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
1928 |
s := s encodeForDisplayInto:fEnc. |
1797 | 1929 |
]. |
1930 |
||
1931 |
deviceFont ~~ fontUsed ifTrue:[ |
|
1932 |
device setFont:id in:gcId. |
|
1933 |
deviceFont := fontUsed |
|
1934 |
]. |
|
1935 |
device displayString:s x:pX y:pY in:drawableId with:gcId |
|
732 | 1936 |
] |
1937 |
||
1805
532a11ba8458
tuned-out another send if encoding is wrong in display-string
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
1938 |
"Modified: 1.7.1997 / 17:08:35 / cg" |
732 | 1939 |
! |
1940 |
||
1941 |
displayUnscaledForm:formToDraw x:x y:y |
|
1592
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1942 |
"draw a form or image non opaque and unscaled; |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1943 |
if its a 1-plane bitmap, 1-bits are drawn in the |
732 | 1944 |
current paint-color, leaving pixels with 0-bits unchanged |
1945 |
(i.e. only 1-bits are drawn from the form). |
|
1946 |
If its a deep form (i.e. a pixmap) the current paint |
|
1947 |
settings are ignored and the form is drawn as-is. |
|
1948 |
Care must be taken, that the paint color is correctly allocated |
|
1949 |
(by sending #on: to the color) before doing so. |
|
1950 |
Using functions other than #copy only makes sense if you are |
|
1951 |
certain, that the colors are real colors (actually, only for |
|
1952 |
noColor or allColor). |
|
1953 |
The origins coordinate is transformed, but the image itself is unscaled." |
|
1954 |
||
1955 |
|pX pY| |
|
1956 |
||
1957 |
transformation notNil ifTrue:[ |
|
1592
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1958 |
pX := transformation applyToX:x. |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1959 |
pY := transformation applyToY:y. |
732 | 1960 |
] ifFalse:[ |
1592
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1961 |
pX := x. |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1962 |
pY := y. |
732 | 1963 |
]. |
1964 |
||
1965 |
self displayDeviceForm:formToDraw x:pX y:pY |
|
1592
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1966 |
|
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1967 |
"Modified: 12.4.1997 / 12:48:04 / cg" |
732 | 1968 |
! |
1969 |
||
1970 |
displayUnscaledOpaqueForm:formToDraw x:x y:y |
|
1592
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1971 |
"draw a form or image opaque and unscaled; |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1972 |
if its a 1-plane bitmap, 1-bits are drawn in the |
732 | 1973 |
current paint-color, 0 bits in background color. |
1974 |
If its a deep form (i.e. a pixmap) the current paint |
|
1975 |
settings are ignored and the form is drawn as-is (opaque). |
|
1976 |
The origins coordinate is transformed, but the image itself is unscaled." |
|
1977 |
||
1978 |
|pX pY| |
|
1979 |
||
1980 |
transformation notNil ifTrue:[ |
|
1592
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1981 |
pX := transformation applyToX:x. |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1982 |
pY := transformation applyToY:y. |
732 | 1983 |
] ifFalse:[ |
1592
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1984 |
pX := x. |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1985 |
pY := y. |
732 | 1986 |
]. |
1987 |
||
1988 |
self displayDeviceOpaqueForm:formToDraw x:pX y:pY |
|
1592
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1989 |
|
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
1990 |
"Modified: 12.4.1997 / 12:49:21 / cg" |
732 | 1991 |
! |
1992 |
||
1993 |
displayUnscaledOpaqueString:aString from:index1 to:index2 x:x y:y |
|
1994 |
"draw a substring at the transformed coordinate x/y but do not scale the font. |
|
1995 |
Draw foreground pixels in paint-color, background pixels in bgPaint color." |
|
1996 |
||
1997 |
|pX pY| |
|
1998 |
||
1999 |
transformation notNil ifTrue:[ |
|
2000 |
pX := transformation applyToX:x. |
|
2001 |
pY := transformation applyToY:y. |
|
2002 |
] ifFalse:[ |
|
2003 |
pX := x. |
|
2004 |
pY := y. |
|
2005 |
]. |
|
2006 |
self displayDeviceOpaqueString:aString from:index1 to:index2 in:font x:pX y:pY |
|
2007 |
! |
|
2008 |
||
2009 |
displayUnscaledOpaqueString:aString x:x y:y |
|
2010 |
"draw a string at the transformed coordinate x/y but do not scale the font. |
|
2011 |
Draw foreground pixels in paint-color, background pixels in bgPaint color." |
|
2012 |
||
2013 |
|pX pY| |
|
2014 |
||
2015 |
transformation notNil ifTrue:[ |
|
2016 |
pX := transformation applyToX:x. |
|
2017 |
pY := transformation applyToY:y. |
|
2018 |
] ifFalse:[ |
|
2019 |
pX := x. |
|
2020 |
pY := y. |
|
2021 |
]. |
|
2022 |
self displayDeviceOpaqueString:aString from:1 to:(aString size) in:font x:pX y:pY |
|
2023 |
! |
|
2024 |
||
2025 |
displayUnscaledString:aString from:index1 to:index2 x:x y:y |
|
2026 |
"draw a substring at the transformed coordinate x/y but do not scale the font. |
|
2027 |
draw foreground-pixels only (in current paint-color), leaving background as-is." |
|
2028 |
||
2029 |
|pX pY| |
|
2030 |
||
2031 |
transformation notNil ifTrue:[ |
|
2032 |
pX := transformation applyToX:x. |
|
2033 |
pY := transformation applyToY:y. |
|
2034 |
] ifFalse:[ |
|
2035 |
pX := x. |
|
2036 |
pY := y. |
|
2037 |
]. |
|
2038 |
self displayDeviceString:aString from:index1 to:index2 in:font x:pX y:pY |
|
2039 |
! |
|
2040 |
||
2041 |
displayUnscaledString:aString x:x y:y |
|
2042 |
"draw a string at the transformed coordinate x/y but do not scale the font. |
|
2043 |
draw foreground-pixels only (in current paint-color), leaving background as-is." |
|
2044 |
||
2045 |
|pX pY| |
|
2046 |
||
2047 |
transformation notNil ifTrue:[ |
|
2048 |
pX := transformation applyToX:x. |
|
2049 |
pY := transformation applyToY:y. |
|
2050 |
] ifFalse:[ |
|
2051 |
pX := x. |
|
2052 |
pY := y. |
|
2053 |
]. |
|
2054 |
self displayDeviceString:aString from:1 to:(aString size) in:font x:pX y:pY |
|
2055 |
! ! |
|
2056 |
||
2057 |
!DeviceGraphicsContext methodsFor:'drawing in device coordinates'! |
|
2058 |
||
2059 |
displayDeviceForm:aForm x:x y:y |
|
1592
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2060 |
"draw a form or image non opaque (i.e. only foreground color is drawn); |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2061 |
If its a 1-plane bitmap, 1-bits are drawn in the |
732 | 2062 |
current paint-color, leaving pixels with 0-bits unchanged |
2063 |
(i.e. only 1-bits are drawn from the form). |
|
1592
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2064 |
If its a deep form (i.e. a pixmap) the current paint |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2065 |
settings are ignored and the form is drawn as-is; |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2066 |
however, the mask is applied if present. |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2067 |
|
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2068 |
The form should must have been allocated on the same device, |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2069 |
otherwise its converted here, which slows down the draw. |
732 | 2070 |
No transformation or scaling is done. |
2071 |
Care must be taken, that the paint color is correctly allocated |
|
2072 |
(by sending #on: to the color) before doing so. |
|
2073 |
Using functions other than #copy only makes sense if you are |
|
2074 |
certain, that the colors are real colors (actually, only for |
|
2075 |
noColor or allColor)." |
|
2076 |
||
1453
e93293618275
only fetch id's once in displayForm.
Claus Gittinger <cg@exept.de>
parents:
1294
diff
changeset
|
2077 |
|id w h easy paintDither tmpForm tmpId tmpGCId |
3530 | 2078 |
fgId noColor allColor allBits pX pY |
2865
a97dc9f1e21a
no need to create a GC for source bitmap under X
Claus Gittinger <cg@exept.de>
parents:
2835
diff
changeset
|
2079 |
mask maskId deviceForm deviceFormGCId deviceMask colorMap| |
732 | 2080 |
|
2081 |
w := aForm width. |
|
2082 |
h := aForm height. |
|
2083 |
||
2084 |
pX := x rounded. |
|
2085 |
pY := y rounded. |
|
2086 |
||
1034 | 2087 |
deviceForm := aForm asFormOn:device. |
2192
01f76f23f03f
handle case when no deviceForms can be created,
Claus Gittinger <cg@exept.de>
parents:
2065
diff
changeset
|
2088 |
deviceForm isNil ifTrue:[ |
01f76f23f03f
handle case when no deviceForms can be created,
Claus Gittinger <cg@exept.de>
parents:
2065
diff
changeset
|
2089 |
'DeviceGraphicsContext [warning]: cannot create device-form' errorPrintCR. |
01f76f23f03f
handle case when no deviceForms can be created,
Claus Gittinger <cg@exept.de>
parents:
2065
diff
changeset
|
2090 |
^self |
01f76f23f03f
handle case when no deviceForms can be created,
Claus Gittinger <cg@exept.de>
parents:
2065
diff
changeset
|
2091 |
]. |
976 | 2092 |
id := deviceForm id. |
2093 |
||
2094 |
id isNil ifTrue:[ |
|
1237 | 2095 |
'DeviceGraphicsContext [warning]: invalid form draw - ignored' errorPrintCR. |
2096 |
^ self |
|
732 | 2097 |
]. |
2098 |
gcId isNil ifTrue:[ |
|
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2099 |
self initGC |
732 | 2100 |
]. |
2865
a97dc9f1e21a
no need to create a GC for source bitmap under X
Claus Gittinger <cg@exept.de>
parents:
2835
diff
changeset
|
2101 |
(deviceFormGCId := deviceForm gcId) isNil ifTrue:[ |
a97dc9f1e21a
no need to create a GC for source bitmap under X
Claus Gittinger <cg@exept.de>
parents:
2835
diff
changeset
|
2102 |
"/ device needGCForBitmapSource - i.e. WIN32 |
a97dc9f1e21a
no need to create a GC for source bitmap under X
Claus Gittinger <cg@exept.de>
parents:
2835
diff
changeset
|
2103 |
device platformName ~= 'X11' ifTrue:[ |
a97dc9f1e21a
no need to create a GC for source bitmap under X
Claus Gittinger <cg@exept.de>
parents:
2835
diff
changeset
|
2104 |
deviceForm initGC. |
a97dc9f1e21a
no need to create a GC for source bitmap under X
Claus Gittinger <cg@exept.de>
parents:
2835
diff
changeset
|
2105 |
deviceFormGCId := deviceForm gcId. |
a97dc9f1e21a
no need to create a GC for source bitmap under X
Claus Gittinger <cg@exept.de>
parents:
2835
diff
changeset
|
2106 |
] |
a97dc9f1e21a
no need to create a GC for source bitmap under X
Claus Gittinger <cg@exept.de>
parents:
2835
diff
changeset
|
2107 |
]. |
732 | 2108 |
|
2109 |
" |
|
2110 |
a deep form ignores paint/bgPaint settings |
|
2111 |
" |
|
1085
3513a4cae87b
handle depth1-images with a mask
Claus Gittinger <cg@exept.de>
parents:
1064
diff
changeset
|
2112 |
mask := aForm mask. |
3513a4cae87b
handle depth1-images with a mask
Claus Gittinger <cg@exept.de>
parents:
1064
diff
changeset
|
2113 |
|
3513a4cae87b
handle depth1-images with a mask
Claus Gittinger <cg@exept.de>
parents:
1064
diff
changeset
|
2114 |
((aForm depth ~~ 1) |
3513a4cae87b
handle depth1-images with a mask
Claus Gittinger <cg@exept.de>
parents:
1064
diff
changeset
|
2115 |
or:[mask notNil]) ifTrue:[ |
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2116 |
mask notNil ifTrue:[ |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2117 |
mask depth == 1 ifFalse:[ |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2118 |
'DEVGC: alpha channel not yet supported' errorPrintCR. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2119 |
] ifTrue:[ |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2120 |
deviceMask := mask asFormOn:device. |
2192
01f76f23f03f
handle case when no deviceForms can be created,
Claus Gittinger <cg@exept.de>
parents:
2065
diff
changeset
|
2121 |
deviceMask isNil ifTrue:[ |
01f76f23f03f
handle case when no deviceForms can be created,
Claus Gittinger <cg@exept.de>
parents:
2065
diff
changeset
|
2122 |
'DeviceGraphicsContext [warning]: cannot create device-mask' errorPrintCR. |
01f76f23f03f
handle case when no deviceForms can be created,
Claus Gittinger <cg@exept.de>
parents:
2065
diff
changeset
|
2123 |
^self |
01f76f23f03f
handle case when no deviceForms can be created,
Claus Gittinger <cg@exept.de>
parents:
2065
diff
changeset
|
2124 |
]. |
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2125 |
maskId := deviceMask id. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2126 |
maskId notNil ifTrue:[ |
2192
01f76f23f03f
handle case when no deviceForms can be created,
Claus Gittinger <cg@exept.de>
parents:
2065
diff
changeset
|
2127 |
deviceMask gcId isNil ifTrue:[deviceMask initGC]. |
1592
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2128 |
allColor := Color allColor. |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2129 |
allBits := allColor colorId. |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2130 |
|
1599
55a782d2c2f5
oops - masked image draw with depth1 images was wrong
Claus Gittinger <cg@exept.de>
parents:
1592
diff
changeset
|
2131 |
(deviceForm depth == device depth |
55a782d2c2f5
oops - masked image draw with depth1 images was wrong
Claus Gittinger <cg@exept.de>
parents:
1592
diff
changeset
|
2132 |
and:[aForm maskedPixelsAre0]) ifTrue:[ |
1592
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2133 |
"/ can do it without a temporary pixmap: |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2134 |
"/ or-in the form into the inverse stamped-out area |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2135 |
"/ of the destination. |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2136 |
"/ Oring is of course only possible if we know that |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2137 |
"/ masked pixels are already zero in the form. |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2138 |
|
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2139 |
"/ stamp out using mask |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2140 |
device setForeground:0 background:allBits in:gcId. |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2141 |
device setFunction:#and in:gcId. |
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2142 |
device |
1592
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2143 |
copyPlaneFromPixmapId:maskId |
1249
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2144 |
x:0 |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2145 |
y:0 |
1592
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2146 |
gc:(deviceMask gcId) |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2147 |
to:drawableId |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2148 |
x:pX |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2149 |
y:pY |
1249
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2150 |
gc:gcId |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2151 |
width:w |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2152 |
height:h. |
1592
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2153 |
"/ or-in the form |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2154 |
device setFunction:#or in:gcId. |
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2155 |
device |
1249
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2156 |
copyFromPixmapId:id |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2157 |
x:0 |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2158 |
y:0 |
2865
a97dc9f1e21a
no need to create a GC for source bitmap under X
Claus Gittinger <cg@exept.de>
parents:
2835
diff
changeset
|
2159 |
gc:deviceFormGCId |
1592
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2160 |
to:drawableId |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2161 |
x:pX |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2162 |
y:pY |
1249
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2163 |
gc:gcId |
1592
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2164 |
width:w |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2165 |
height:h. |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2166 |
] ifFalse:[ |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2167 |
"/ must do it slow, using a temporary form .. |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2168 |
|
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2169 |
" |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2170 |
create temp-form; |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2171 |
" |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2172 |
tmpForm := Form width:w height:h depth:device depth on:device. |
2192
01f76f23f03f
handle case when no deviceForms can be created,
Claus Gittinger <cg@exept.de>
parents:
2065
diff
changeset
|
2173 |
tmpForm isNil ifTrue:[ |
01f76f23f03f
handle case when no deviceForms can be created,
Claus Gittinger <cg@exept.de>
parents:
2065
diff
changeset
|
2174 |
'DeviceGraphicsContext [warning]: cannot create temp form' errorPrintCR. |
01f76f23f03f
handle case when no deviceForms can be created,
Claus Gittinger <cg@exept.de>
parents:
2065
diff
changeset
|
2175 |
^self |
01f76f23f03f
handle case when no deviceForms can be created,
Claus Gittinger <cg@exept.de>
parents:
2065
diff
changeset
|
2176 |
]. |
1592
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2177 |
tmpForm initGC. |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2178 |
tmpId := tmpForm id. |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2179 |
tmpGCId := tmpForm gcId. |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2180 |
|
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2181 |
" |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2182 |
fill tempform with image |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2183 |
" |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2184 |
aForm depth == 1 ifTrue:[ |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2185 |
(colorMap := aForm colorMap) notNil ifTrue:[ |
3569
38818408ecae
care for monochrome image with a single color in its colorMap
Claus Gittinger <cg@exept.de>
parents:
3530
diff
changeset
|
2186 |
colorMap size < 2 ifTrue:[ |
38818408ecae
care for monochrome image with a single color in its colorMap
Claus Gittinger <cg@exept.de>
parents:
3530
diff
changeset
|
2187 |
device |
38818408ecae
care for monochrome image with a single color in its colorMap
Claus Gittinger <cg@exept.de>
parents:
3530
diff
changeset
|
2188 |
setForegroundColor:(colorMap at:1) |
38818408ecae
care for monochrome image with a single color in its colorMap
Claus Gittinger <cg@exept.de>
parents:
3530
diff
changeset
|
2189 |
in:tmpGCId. |
38818408ecae
care for monochrome image with a single color in its colorMap
Claus Gittinger <cg@exept.de>
parents:
3530
diff
changeset
|
2190 |
] ifFalse:[ |
38818408ecae
care for monochrome image with a single color in its colorMap
Claus Gittinger <cg@exept.de>
parents:
3530
diff
changeset
|
2191 |
device |
38818408ecae
care for monochrome image with a single color in its colorMap
Claus Gittinger <cg@exept.de>
parents:
3530
diff
changeset
|
2192 |
setForegroundColor:(colorMap at:2) |
38818408ecae
care for monochrome image with a single color in its colorMap
Claus Gittinger <cg@exept.de>
parents:
3530
diff
changeset
|
2193 |
backgroundColor:(colorMap at:1) |
38818408ecae
care for monochrome image with a single color in its colorMap
Claus Gittinger <cg@exept.de>
parents:
3530
diff
changeset
|
2194 |
in:tmpGCId. |
38818408ecae
care for monochrome image with a single color in its colorMap
Claus Gittinger <cg@exept.de>
parents:
3530
diff
changeset
|
2195 |
] |
1592
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2196 |
]. |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2197 |
device |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2198 |
copyPlaneFromPixmapId:id |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2199 |
x:0 |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2200 |
y:0 |
2865
a97dc9f1e21a
no need to create a GC for source bitmap under X
Claus Gittinger <cg@exept.de>
parents:
2835
diff
changeset
|
2201 |
gc:deviceFormGCId |
1592
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2202 |
to:tmpId |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2203 |
x:0 |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2204 |
y:0 |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2205 |
gc:tmpGCId |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2206 |
width:w |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2207 |
height:h. |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2208 |
] ifFalse:[ |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2209 |
device |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2210 |
copyFromPixmapId:id |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2211 |
x:0 |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2212 |
y:0 |
2865
a97dc9f1e21a
no need to create a GC for source bitmap under X
Claus Gittinger <cg@exept.de>
parents:
2835
diff
changeset
|
2213 |
gc:deviceFormGCId |
1592
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2214 |
to:tmpId |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2215 |
x:0 |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2216 |
y:0 |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2217 |
gc:tmpGCId |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2218 |
width:w |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2219 |
height:h. |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2220 |
]. |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2221 |
|
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2222 |
" |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2223 |
stamp out mask in temp form |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2224 |
" |
1637
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2225 |
device setForeground:allBits background:0 in:tmpGCId. |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2226 |
device setFunction:#and in:tmpGCId. |
1592
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2227 |
device |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2228 |
copyPlaneFromPixmapId:maskId |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2229 |
x:0 |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2230 |
y:0 |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2231 |
gc:(deviceMask gcId) |
1453
e93293618275
only fetch id's once in displayForm.
Claus Gittinger <cg@exept.de>
parents:
1294
diff
changeset
|
2232 |
to:tmpId |
1249
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2233 |
x:0 |
1453
e93293618275
only fetch id's once in displayForm.
Claus Gittinger <cg@exept.de>
parents:
1294
diff
changeset
|
2234 |
y:0 |
e93293618275
only fetch id's once in displayForm.
Claus Gittinger <cg@exept.de>
parents:
1294
diff
changeset
|
2235 |
gc:tmpGCId |
1249
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2236 |
width:w |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2237 |
height:h. |
1592
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2238 |
|
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2239 |
" |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2240 |
stamp out mask in destination |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2241 |
" |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2242 |
device setForeground:0 background:allBits in:gcId. |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2243 |
device setFunction:#and in:gcId. |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2244 |
device |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2245 |
copyPlaneFromPixmapId:maskId |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2246 |
x:0 |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2247 |
y:0 |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2248 |
gc:(deviceMask gcId) |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2249 |
to:drawableId |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2250 |
x:pX |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2251 |
y:pY |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2252 |
gc:gcId |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2253 |
width:w |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2254 |
height:h. |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2255 |
|
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2256 |
" |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2257 |
or-in tempform-bits ... |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2258 |
" |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2259 |
device setFunction:#or in:gcId. |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2260 |
device |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2261 |
copyFromPixmapId:tmpId |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2262 |
x:0 |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2263 |
y:0 |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2264 |
gc:tmpGCId |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2265 |
to:drawableId |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2266 |
x:pX |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2267 |
y:pY |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2268 |
gc:gcId |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2269 |
width:w |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2270 |
height:h. |
1637
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2271 |
|
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2272 |
" |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2273 |
release tempForm immediately |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2274 |
(although GC will eventually do it, |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2275 |
this creates less stress to the Xserver in the meanwhile ...) |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2276 |
" |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2277 |
tmpForm destroy. |
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2278 |
]. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2279 |
|
1592
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2280 |
"/ restore GC |
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2281 |
foreground notNil ifTrue:[ |
3530 | 2282 |
device setForegroundColor:foreground in:gcId. |
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2283 |
]. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2284 |
background notNil ifTrue:[ |
3530 | 2285 |
device setBackgroundColor:background in:gcId |
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2286 |
]. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2287 |
device setFunction:function in:gcId. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2288 |
^ self |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2289 |
] |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2290 |
] |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2291 |
]. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2292 |
|
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2293 |
device |
1249
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2294 |
copyFromPixmapId:id |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2295 |
x:0 |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2296 |
y:0 |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2297 |
gc:deviceForm gcId |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2298 |
to:drawableId |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2299 |
x:pX |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2300 |
y:pY |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2301 |
gc:gcId |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2302 |
width:w |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2303 |
height:h. |
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2304 |
^ self |
732 | 2305 |
]. |
2306 |
||
2307 |
" |
|
2308 |
the following code is somewhat complicated, since it has to deal |
|
2309 |
with dithered paint colors, which cannot be done directly on most |
|
2310 |
devices (actually, a test for the devices capabilities has to be added here) |
|
2311 |
(just assume drawing a bitmap with dithered paint color ... sigh) |
|
2312 |
" |
|
2313 |
||
1507 | 2314 |
easy := (function == #copy). |
2315 |
||
732 | 2316 |
" |
2317 |
if paint is not a real color, we have to do it the hard way ... |
|
2318 |
" |
|
2319 |
easy ifTrue:[ |
|
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2320 |
paint isColor ifFalse:[ |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2321 |
paintDither := paint. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2322 |
easy := false |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2323 |
] ifTrue:[ |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2324 |
paintDither := paint ditherForm. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2325 |
paintDither notNil ifTrue:[ |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2326 |
easy := false. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2327 |
] |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2328 |
]. |
732 | 2329 |
]. |
2330 |
||
2331 |
allColor := Color allColor. |
|
2332 |
allBits := allColor colorId. |
|
2333 |
||
2334 |
easy ifTrue:[ |
|
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2335 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2336 |
paint is a real color |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2337 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2338 |
|
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2339 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2340 |
if paint color is all-0 or all-1's, we can do it in one |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2341 |
operation ... |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2342 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2343 |
fgId := paint colorId. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2344 |
|
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2345 |
((fgId ~~ ((1 bitShift:device depth)-1)) |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2346 |
and:[fgId ~~ allBits]) ifTrue:[ |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2347 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2348 |
clear fg-bits ... |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2349 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2350 |
device setForeground:0 background:allBits in:gcId. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2351 |
device setFunction:#and in:gcId. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2352 |
device |
1249
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2353 |
copyPlaneFromPixmapId:id |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2354 |
x:0 |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2355 |
y:0 |
2865
a97dc9f1e21a
no need to create a GC for source bitmap under X
Claus Gittinger <cg@exept.de>
parents:
2835
diff
changeset
|
2356 |
gc:deviceFormGCId |
1249
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2357 |
to:drawableId |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2358 |
x:pX |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2359 |
y:pY |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2360 |
gc:gcId |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2361 |
width:w |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2362 |
height:h. |
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2363 |
]. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2364 |
|
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2365 |
fgId ~~ 0 ifTrue:[ |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2366 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2367 |
or-in fg-bits ... |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2368 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2369 |
device setForeground:fgId background:0 in:gcId. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2370 |
device setFunction:#or in:gcId. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2371 |
device |
1249
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2372 |
copyPlaneFromPixmapId:id |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2373 |
x:0 |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2374 |
y:0 |
2865
a97dc9f1e21a
no need to create a GC for source bitmap under X
Claus Gittinger <cg@exept.de>
parents:
2835
diff
changeset
|
2375 |
gc:deviceFormGCId |
1249
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2376 |
to:drawableId |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2377 |
x:pX |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2378 |
y:pY |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2379 |
gc:gcId |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2380 |
width:w |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2381 |
height:h |
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2382 |
]. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2383 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2384 |
flush foreground/background cache |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2385 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2386 |
foreground := nil. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2387 |
background := nil. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2388 |
device setFunction:function in:gcId. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2389 |
^ self |
732 | 2390 |
]. |
2391 |
||
1507 | 2392 |
function == #or ifTrue:[ |
2393 |
easy := paint notNil |
|
2394 |
and:[paint isColor |
|
2395 |
and:[paint ditherForm isNil]]. |
|
2396 |
easy ifTrue:[ |
|
2397 |
easy := bgPaint isNil |
|
2398 |
or:[bgPaint isColor |
|
2399 |
and:[bgPaint colorId == 0]] |
|
2400 |
]. |
|
2401 |
easy ifTrue:[ |
|
2402 |
fgId := paint colorId. |
|
2403 |
||
2404 |
fgId ~~ 0 ifTrue:[ |
|
2405 |
" |
|
2406 |
or-in fg-bits ... |
|
2407 |
" |
|
2408 |
device setForeground:fgId background:0 in:gcId. |
|
2409 |
device |
|
2410 |
copyPlaneFromPixmapId:id |
|
2411 |
x:0 |
|
2412 |
y:0 |
|
2865
a97dc9f1e21a
no need to create a GC for source bitmap under X
Claus Gittinger <cg@exept.de>
parents:
2835
diff
changeset
|
2413 |
gc:deviceFormGCId |
1507 | 2414 |
to:drawableId |
2415 |
x:pX |
|
2416 |
y:pY |
|
2417 |
gc:gcId |
|
2418 |
width:w |
|
2419 |
height:h |
|
2420 |
]. |
|
2421 |
" |
|
2422 |
flush foreground/background cache |
|
2423 |
" |
|
2424 |
foreground := nil. |
|
2425 |
background := nil. |
|
2426 |
^ self |
|
2427 |
]. |
|
2428 |
]. |
|
732 | 2429 |
|
2430 |
" |
|
2431 |
hard case; paint is a dithered color |
|
2432 |
" |
|
2433 |
||
2434 |
noColor := Color noColor. |
|
2435 |
||
2436 |
" |
|
2437 |
create temp-form; |
|
2438 |
" |
|
2439 |
tmpForm := Form width:w height:h depth:device depth on:device. |
|
2192
01f76f23f03f
handle case when no deviceForms can be created,
Claus Gittinger <cg@exept.de>
parents:
2065
diff
changeset
|
2440 |
tmpForm isNil ifTrue:[ |
01f76f23f03f
handle case when no deviceForms can be created,
Claus Gittinger <cg@exept.de>
parents:
2065
diff
changeset
|
2441 |
'DeviceGraphicsContext [warning]: cannot create temp form' errorPrintCR. |
01f76f23f03f
handle case when no deviceForms can be created,
Claus Gittinger <cg@exept.de>
parents:
2065
diff
changeset
|
2442 |
^self |
01f76f23f03f
handle case when no deviceForms can be created,
Claus Gittinger <cg@exept.de>
parents:
2065
diff
changeset
|
2443 |
]. |
732 | 2444 |
" |
2445 |
fill tempform |
|
2446 |
" |
|
2447 |
tmpForm paint:paint. |
|
2448 |
tmpForm fillRectangleX:0 y:0 width:w height:h. |
|
2449 |
" |
|
2450 |
stamp out background |
|
2451 |
" |
|
2452 |
tmpForm paint:allColor on:noColor. |
|
2453 |
tmpForm function:#and. |
|
976 | 2454 |
tmpForm displayOpaqueForm:deviceForm x:0 y:0. |
732 | 2455 |
" |
2456 |
stamp out foreground from destination |
|
2457 |
" |
|
2458 |
device setForeground:0 background:allBits in:gcId. |
|
2459 |
device setFunction:#and in:gcId. |
|
2460 |
device |
|
1249
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2461 |
copyPlaneFromPixmapId:id |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2462 |
x:0 |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2463 |
y:0 |
2865
a97dc9f1e21a
no need to create a GC for source bitmap under X
Claus Gittinger <cg@exept.de>
parents:
2835
diff
changeset
|
2464 |
gc:deviceFormGCId |
1249
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2465 |
to:drawableId |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2466 |
x:pX |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2467 |
y:pY |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2468 |
gc:gcId |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2469 |
width:w |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2470 |
height:h. |
732 | 2471 |
" |
2472 |
or-in temp into destination |
|
2473 |
" |
|
2474 |
device setForeground:allBits background:0 in:gcId. |
|
2475 |
device setFunction:#or in:gcId. |
|
2476 |
||
2477 |
device |
|
1249
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2478 |
copyFromPixmapId:tmpForm id |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2479 |
x:0 |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2480 |
y:0 |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2481 |
gc:tmpForm gcId |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2482 |
to:drawableId |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2483 |
x:pX |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2484 |
y:pY |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2485 |
gc:gcId |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2486 |
width:w |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2487 |
height:h. |
1637
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2488 |
|
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2489 |
" |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2490 |
release tempForm immediately |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2491 |
(although GC will eventually do it, |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2492 |
this creates less stress to the Xserver in the meanwhile ...) |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2493 |
" |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2494 |
|
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2495 |
tmpForm destroy. |
732 | 2496 |
" |
2497 |
flush foreground/background cache |
|
2498 |
" |
|
2499 |
foreground := nil. |
|
2500 |
background := nil. |
|
2501 |
device setFunction:function in:gcId. |
|
768 | 2502 |
|
2192
01f76f23f03f
handle case when no deviceForms can be created,
Claus Gittinger <cg@exept.de>
parents:
2065
diff
changeset
|
2503 |
"Modified: / 27.7.1998 / 20:07:22 / cg" |
732 | 2504 |
! |
2505 |
||
2506 |
displayDeviceLineFromX:x0 y:y0 toX:x1 y:y1 |
|
2507 |
"draw a line (with current paint-color) in device coordinate space. |
|
2508 |
This ignores any transformations. The coordinates must be integers." |
|
2509 |
||
2510 |
gcId isNil ifTrue:[ |
|
2511 |
self initGC |
|
2512 |
]. |
|
2513 |
device displayLineFromX:x0 y:y0 toX:x1 y:y1 in:drawableId with:gcId |
|
2514 |
! |
|
2515 |
||
2516 |
displayDeviceOpaqueForm:aForm x:x y:y |
|
1592
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2517 |
"draw a form or image opaque (i.e. both fg and bg is drawn); |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2518 |
If its a 1-plane bitmap, 1-bits are drawn in the |
732 | 2519 |
current paint-color and 0-bits in the bgPaint color. |
2520 |
If its a deep form (i.e. a pixmap) the current paint/bgPaint |
|
2521 |
settings are ignored and the form drawn as-is. |
|
1592
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2522 |
Any mask is ignored. |
732 | 2523 |
In the 1-plane case, special care must be taken if paint and/or bgPaint |
2524 |
dithered colors or patterns, since are that the colors are correctly allocated (by sending #on: |
|
2525 |
to the colors) before doing so. |
|
1592
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2526 |
The form should have been allocated on the same device; otherwise, |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2527 |
its converted here, which slows down the draw. |
732 | 2528 |
Drawing is in device coordinates; no scaling is done." |
2529 |
||
2530 |
|id w h easy savedPaint bgForm fgForm tmpForm |
|
2531 |
fgId bgId noColor allColor allBits dx dy |
|
976 | 2532 |
pX pY deviceDepth deviceForm| |
732 | 2533 |
|
1033 | 2534 |
deviceForm := aForm asFormOn:device. |
976 | 2535 |
id := deviceForm id. |
732 | 2536 |
|
2537 |
"temporary ..." |
|
2538 |
(id isNil |
|
2539 |
or:[aForm graphicsDevice ~~ device]) ifTrue:[ |
|
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2540 |
deviceForm := deviceForm asFormOn:device. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2541 |
id := deviceForm id. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2542 |
id isNil ifTrue:[ |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2543 |
'DeviceGraphicsContext [warning]: invalid form draw - ignored' errorPrintCR. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2544 |
^ self |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2545 |
]. |
732 | 2546 |
]. |
2547 |
||
2548 |
gcId isNil ifTrue:[ |
|
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2549 |
self initGC |
732 | 2550 |
]. |
2065 | 2551 |
deviceForm gcId isNil ifTrue:[deviceForm initGC]. |
732 | 2552 |
|
1592
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2553 |
w := aForm width. |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2554 |
h := aForm height. |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2555 |
|
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2556 |
pX := x rounded. |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2557 |
pY := y rounded. |
7ec770f2047a
faster image drawing if masked pixels are known
Claus Gittinger <cg@exept.de>
parents:
1517
diff
changeset
|
2558 |
|
902 | 2559 |
" |
2560 |
a deep form ignores paint/bgPaint settings |
|
2561 |
and is always drawn opaque. |
|
2562 |
" |
|
2563 |
(aForm depth ~~ 1) ifTrue:[ |
|
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2564 |
device |
1249
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2565 |
copyFromPixmapId:id |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2566 |
x:0 |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2567 |
y:0 |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2568 |
gc:deviceForm gcId |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2569 |
to:drawableId |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2570 |
x:pX |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2571 |
y:pY |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2572 |
gc:gcId |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2573 |
width:w |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2574 |
height:h. |
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2575 |
^ self |
902 | 2576 |
]. |
2577 |
||
2578 |
"/ if no bgPaint is set, this is a non-opaque draw |
|
2579 |
||
2580 |
bgPaint isNil ifTrue:[ |
|
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2581 |
self displayDeviceForm:aForm x:x y:y. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2582 |
^ self |
902 | 2583 |
]. |
2584 |
||
732 | 2585 |
"the following code is somewhat complicated, since it has to deal |
2586 |
with dithered fg/bg colors, which cannot be done directly on most |
|
2587 |
devices (actually, a test for the devices capabilities has to be added here) |
|
2588 |
(just assume drawing a bitmap with dithered fg/bg colors ... sigh) |
|
2589 |
" |
|
2590 |
||
2591 |
" |
|
2592 |
if bgPaint or paint is not a real color, we have to do it the hard way ... |
|
2593 |
" |
|
2594 |
easy := true. |
|
2595 |
paint isColor ifFalse:[ |
|
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2596 |
easy := false |
732 | 2597 |
] ifTrue:[ |
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2598 |
fgId := paint colorId. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2599 |
fgId isNil ifTrue:[ |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2600 |
easy := false |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2601 |
] |
732 | 2602 |
]. |
2603 |
bgPaint isColor ifFalse:[ |
|
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2604 |
easy := false |
732 | 2605 |
] ifTrue:[ |
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2606 |
bgId := bgPaint colorId. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2607 |
bgId isNil ifTrue:[ |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2608 |
easy := false |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2609 |
] |
732 | 2610 |
]. |
2611 |
||
2612 |
easy ifTrue:[ |
|
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2613 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2614 |
easy: both paint and bgPaint are real colors |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2615 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2616 |
((foreground ~~ paint) or:[background ~~ bgPaint]) ifTrue:[ |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2617 |
device setForeground:fgId background:bgId in:gcId. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2618 |
foreground := paint. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2619 |
background := bgPaint. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2620 |
]. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2621 |
device |
1249
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2622 |
copyPlaneFromPixmapId:id |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2623 |
x:0 |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2624 |
y:0 |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2625 |
gc:(deviceForm gcId) |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2626 |
to:drawableId |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2627 |
x:pX |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2628 |
y:pY |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2629 |
gc:gcId |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2630 |
width:w |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2631 |
height:h. |
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2632 |
^ self |
732 | 2633 |
]. |
2634 |
||
2635 |
" |
|
2636 |
hard case: paint and/or bgPaint are dithered or patterns |
|
2637 |
" |
|
2638 |
allColor := Color allColor. |
|
2639 |
allBits := allColor colorId. |
|
2640 |
deviceDepth := device depth. |
|
2641 |
||
2642 |
(fgId notNil and:[function == #copy]) ifTrue:[ |
|
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2643 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2644 |
only bg is dithered; fill with bg first ... |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2645 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2646 |
savedPaint := paint. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2647 |
self paint:bgPaint. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2648 |
self fillDeviceRectangleX:pX y:pY width:w height:h. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2649 |
self paint:savedPaint. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2650 |
|
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2651 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2652 |
if paint color is all-0 or all-1's, we can do it in one |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2653 |
operation ... |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2654 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2655 |
((fgId ~~ ((1 bitShift:deviceDepth)-1)) |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2656 |
and:[fgId ~~ allBits]) ifTrue:[ |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2657 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2658 |
clear fg-bits ... |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2659 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2660 |
device setForeground:0 background:allBits in:gcId. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2661 |
device setFunction:#and in:gcId. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2662 |
device |
1249
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2663 |
copyPlaneFromPixmapId:id |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2664 |
x:0 |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2665 |
y:0 |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2666 |
gc:(deviceForm gcId) |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2667 |
to:drawableId |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2668 |
x:pX |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2669 |
y:pY |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2670 |
gc:gcId |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2671 |
width:w |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2672 |
height:h |
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2673 |
]. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2674 |
|
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2675 |
fgId ~~ 0 ifTrue:[ |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2676 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2677 |
or-in fg-bits ... |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2678 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2679 |
device setForeground:fgId background:0 in:gcId. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2680 |
device setFunction:#or in:gcId. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2681 |
device |
1249
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2682 |
copyPlaneFromPixmapId:id |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2683 |
x:0 |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2684 |
y:0 |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2685 |
gc:(deviceForm gcId) |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2686 |
to:drawableId |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2687 |
x:pX |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2688 |
y:pY |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2689 |
gc:gcId |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2690 |
width:w |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2691 |
height:h |
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2692 |
]. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2693 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2694 |
flush foreground/background cache |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2695 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2696 |
foreground := nil. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2697 |
background := nil. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2698 |
device setFunction:function in:gcId. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2699 |
^ self |
732 | 2700 |
]. |
2701 |
||
2702 |
(bgId notNil and:[function == #copy]) ifTrue:[ |
|
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2703 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2704 |
only fg is dithered; fill with fg first ... |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2705 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2706 |
self fillDeviceRectangleX:pX y:pY width:w height:h. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2707 |
|
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2708 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2709 |
if paint color is all-0 or all-1's, we can do it in one |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2710 |
operation ... |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2711 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2712 |
((bgId ~~ ((1 bitShift:deviceDepth)-1)) |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2713 |
and:[bgId ~~ allBits]) ifTrue:[ |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2714 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2715 |
clear bg-bits ... |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2716 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2717 |
device setForeground:allBits background:0 in:gcId. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2718 |
device setFunction:#and in:gcId. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2719 |
device |
1249
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2720 |
copyPlaneFromPixmapId:id |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2721 |
x:0 |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2722 |
y:0 |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2723 |
gc:(deviceForm gcId) |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2724 |
to:drawableId |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2725 |
x:pX |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2726 |
y:pY |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2727 |
gc:gcId |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2728 |
width:w |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2729 |
height:h |
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2730 |
]. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2731 |
|
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2732 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2733 |
or-in bg-bits ... |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2734 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2735 |
bgId ~~ 0 ifTrue:[ |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2736 |
device setForeground:0 background:bgId in:gcId. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2737 |
device setFunction:#or in:gcId. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2738 |
device |
1249
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2739 |
copyPlaneFromPixmapId:id |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2740 |
x:0 |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2741 |
y:0 |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2742 |
gc:(deviceForm gcId) |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2743 |
to:drawableId |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2744 |
x:pX |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2745 |
y:pY |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2746 |
gc:gcId |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2747 |
width:w |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2748 |
height:h |
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2749 |
]. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2750 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2751 |
flush foreground/background cache |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2752 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2753 |
foreground := nil. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2754 |
background := nil. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2755 |
device setFunction:function in:gcId. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2756 |
^ self |
732 | 2757 |
]. |
2758 |
||
2759 |
" |
|
2760 |
very hard case; both fg and bg are dithered colors |
|
2761 |
" |
|
2762 |
noColor := Color noColor. |
|
2763 |
||
2764 |
" |
|
2765 |
create temp-forms; |
|
2766 |
" |
|
2767 |
bgForm := Form width:w height:h depth:deviceDepth on:device. |
|
2768 |
fgForm := Form width:w height:h depth:deviceDepth on:device. |
|
2769 |
tmpForm := Form width:w height:h depth:deviceDepth on:device. |
|
2770 |
||
2771 |
" |
|
2772 |
fill |
|
2773 |
" |
|
2774 |
dx := dy := 0. |
|
2775 |
maskOrigin notNil ifTrue:[ |
|
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2776 |
dx := maskOrigin x. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2777 |
dy := maskOrigin y |
732 | 2778 |
]. |
2779 |
||
2780 |
bgForm paint:bgPaint. |
|
2781 |
bgForm setMaskOriginX:(x negated + dx) y:(y negated + dy). |
|
2782 |
bgForm fillRectangleX:0 y:0 width:w height:h. |
|
2783 |
fgForm paint:paint. |
|
2784 |
fgForm setMaskOriginX:(x negated + dx) y:(y negated + dy). |
|
2785 |
fgForm fillRectangleX:0 y:0 width:w height:h. |
|
2786 |
||
2787 |
" |
|
2788 |
stamp-out background |
|
2789 |
" |
|
2790 |
bgForm paint:noColor on:allColor. |
|
2791 |
bgForm function:#and. |
|
976 | 2792 |
bgForm displayOpaqueForm:deviceForm x:0 y:0. |
732 | 2793 |
|
2794 |
" |
|
2795 |
stamp-out foreground |
|
2796 |
" |
|
2797 |
fgForm paint:allColor on:noColor. |
|
2798 |
fgForm function:#and. |
|
976 | 2799 |
fgForm displayOpaqueForm:deviceForm x:0 y:0. |
732 | 2800 |
|
2801 |
" |
|
2802 |
clear tempform |
|
2803 |
" |
|
2804 |
tmpForm paint:noColor. |
|
2805 |
tmpForm fillRectangleX:0 y:0 width:w height:h. |
|
2806 |
||
2807 |
" |
|
2808 |
merge fg-temp and bg-temp into tmp |
|
2809 |
" |
|
2810 |
tmpForm function:#or. |
|
2811 |
tmpForm paint:noColor on:allColor. |
|
2812 |
tmpForm copyFrom:fgForm x:0 y:0 toX:0 y:0 width:w height:h. |
|
2813 |
tmpForm copyFrom:bgForm x:0 y:0 toX:0 y:0 width:w height:h. |
|
2814 |
||
2815 |
" |
|
2816 |
finally, draw it |
|
2817 |
" |
|
2818 |
device setForeground:0 background:allBits in:gcId. |
|
2819 |
device |
|
1249
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2820 |
copyFromPixmapId:tmpForm id |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2821 |
x:0 |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2822 |
y:0 |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2823 |
gc:tmpForm gcId |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2824 |
to:drawableId |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2825 |
x:pX |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2826 |
y:pY |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2827 |
gc:gcId |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2828 |
width:w |
5224bb7a97bf
use new copy interface, to avoid useless noExpose events
Claus Gittinger <cg@exept.de>
parents:
1237
diff
changeset
|
2829 |
height:h. |
1637
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2830 |
|
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2831 |
" |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2832 |
release tempForms immediately |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2833 |
(although GC will eventually do it, |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2834 |
this creates less stress to the Xserver in the meanwhile ...) |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2835 |
" |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2836 |
fgForm destroy. |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2837 |
bgForm destroy. |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2838 |
tmpForm destroy. |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2839 |
|
732 | 2840 |
" |
2841 |
flush foreground/background cache |
|
2842 |
" |
|
2843 |
foreground := nil. |
|
2844 |
background := nil. |
|
868 | 2845 |
|
1637
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2846 |
"Modified: 22.4.1997 / 21:44:10 / cg" |
732 | 2847 |
! |
2848 |
||
2849 |
displayDeviceOpaqueString:aString from:index1 to:index2 in:font x:x y:y |
|
2850 |
"draw a substring at the coordinate x/y - draw foreground pixels in |
|
2851 |
paint-color and background pixels in bgPaint-color. |
|
2852 |
Assuming that device can only draw in device colors, we have to handle |
|
2853 |
the case where paint and/or bgPaint are dithered colors. |
|
2854 |
No translation or scaling is done." |
|
2855 |
||
2856 |
|easy w h savedPaint fgId bgId allColor allBits noColor |
|
2857 |
id bgForm fgForm tmpForm maskForm dx dy pX pY fontUsed s |
|
3666
01d7bf1d2333
fixed Text drawing in displayString
Michael Beyl <mb@exept.de>
parents:
3630
diff
changeset
|
2858 |
deviceDepth fEnc ascent| |
732 | 2859 |
|
2860 |
" |
|
2861 |
if backgroundPaint color is nil, we assume |
|
2862 |
this is a non-opaque draw |
|
2863 |
" |
|
2864 |
bgPaint isNil ifTrue:[ |
|
1637
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2865 |
self displayDeviceString:aString from:index1 to:index2 x:x y:y. |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2866 |
^ self |
732 | 2867 |
]. |
2868 |
||
2869 |
(aString isString not |
|
2870 |
or:[aString isText]) ifTrue:[ |
|
1637
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2871 |
" |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2872 |
hook for non-strings (i.e. attributed text) |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2873 |
that 'thing' should know how to display itself ... |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2874 |
" |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2875 |
aString displayOpaqueOn:self x:x y:y from:index1 to:index2. |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2876 |
^ self |
732 | 2877 |
]. |
2878 |
||
2879 |
gcId isNil ifTrue:[ |
|
1637
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2880 |
self initGC |
732 | 2881 |
]. |
2882 |
||
2883 |
pX := x rounded. |
|
2884 |
pY := y rounded. |
|
2885 |
||
2835 | 2886 |
fontUsed := font onDevice:device. |
732 | 2887 |
|
2888 |
id := fontUsed fontId. |
|
2889 |
id isNil ifTrue:[ |
|
1637
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2890 |
" |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2891 |
hook for alien fonts |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2892 |
that 'font' should know how to display the string ... |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2893 |
" |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2894 |
font displayOpaqueString:aString from:index1 to:index2 x:x y:y in:self. |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2895 |
^ self |
732 | 2896 |
]. |
2897 |
||
2898 |
s := aString. |
|
1805
532a11ba8458
tuned-out another send if encoding is wrong in display-string
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
2899 |
s encoding ~~ (fEnc := font encoding) ifTrue:[ |
532a11ba8458
tuned-out another send if encoding is wrong in display-string
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
2900 |
s := s encodeForDisplayInto:fEnc. |
732 | 2901 |
]. |
2902 |
||
2903 |
deviceFont ~~ fontUsed ifTrue:[ |
|
1637
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2904 |
device setFont:id in:gcId. |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2905 |
deviceFont := fontUsed |
732 | 2906 |
]. |
2907 |
||
2908 |
" |
|
2909 |
if bgPaint or paint is not a real Color, we have to do it the hard way ... |
|
2910 |
" |
|
2911 |
easy := true. |
|
2912 |
paint isColor ifFalse:[ |
|
1637
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2913 |
easy := false |
732 | 2914 |
] ifTrue:[ |
1637
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2915 |
fgId := paint colorId. |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2916 |
fgId isNil ifTrue:[ |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2917 |
easy := false |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2918 |
] |
732 | 2919 |
]. |
2920 |
bgPaint isColor ifFalse:[ |
|
1637
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2921 |
easy := false |
732 | 2922 |
] ifTrue:[ |
1637
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2923 |
bgId := bgPaint colorId. |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2924 |
bgId isNil ifTrue:[ |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2925 |
easy := false |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2926 |
] |
732 | 2927 |
]. |
2928 |
||
2929 |
easy ifTrue:[ |
|
1637
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2930 |
device setForeground:fgId background:bgId in:gcId. |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2931 |
foreground := paint. |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2932 |
background := bgPaint. |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2933 |
device displayOpaqueString:s |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2934 |
from:index1 to:index2 |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2935 |
x:pX y:pY |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2936 |
in:drawableId with:gcId. |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2937 |
^ self |
732 | 2938 |
]. |
2939 |
||
2940 |
w := fontUsed widthOf:s from:index1 to:index2. |
|
2941 |
h := fontUsed height. |
|
3666
01d7bf1d2333
fixed Text drawing in displayString
Michael Beyl <mb@exept.de>
parents:
3630
diff
changeset
|
2942 |
ascent := fontUsed ascent. |
732 | 2943 |
|
2944 |
(fgId notNil and:[function == #copy]) ifTrue:[ |
|
1637
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2945 |
" |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2946 |
only bg is dithered; fill with bg first ... |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2947 |
" |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2948 |
savedPaint := paint. |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2949 |
self paint:bgPaint. |
3666
01d7bf1d2333
fixed Text drawing in displayString
Michael Beyl <mb@exept.de>
parents:
3630
diff
changeset
|
2950 |
self fillRectangleX:pX y:(pY - ascent) width:w height:h. |
1637
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2951 |
self paint:savedPaint. |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2952 |
|
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2953 |
" |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2954 |
then draw using fgPaint (which is a real color) |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2955 |
" |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2956 |
device displayString:s |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2957 |
from:index1 to:index2 |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2958 |
x:pX y:pY |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2959 |
in:drawableId with:gcId. |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
2960 |
^ self |
732 | 2961 |
]. |
2962 |
||
2963 |
allColor := Color allColor. |
|
2964 |
allBits := allColor colorId. |
|
2965 |
||
2966 |
deviceDepth := device depth. |
|
2967 |
||
2968 |
" |
|
2969 |
the code below is correct, but some (all?) implementations of the |
|
2970 |
X Window system seem to not support ALU-functions when drawing opaque strings. |
|
2971 |
Therefore we use the slower code below. |
|
2972 |
" |
|
2973 |
||
2974 |
"/ (bgId notNil and:[function == #copy]) ifTrue:[ |
|
2975 |
"/ " |
|
2976 |
"/ only fg is dithered; fill with fg first ... |
|
2977 |
"/ " |
|
2978 |
"/ self fillRectangleX:pX y:(pY - fontUsed ascent) width:w height:h. |
|
2979 |
"/ |
|
2980 |
"/ " |
|
2981 |
"/ if bgPaint color is all-0 or all-1's, we can do it in one |
|
2982 |
"/ operation ... |
|
2983 |
"/ " |
|
2984 |
"/ ((bgId ~~ ((1 bitShift:deviceDepth)-1)) |
|
2985 |
"/ and:[bgId ~~ allBits]) ifTrue:[ |
|
2986 |
"/ " |
|
2987 |
"/ clear bg bits ... |
|
2988 |
"/ " |
|
2989 |
"/ device setForeground:allBits background:0 in:gcId. |
|
2990 |
"/ device setFunction:#and in:gcId. |
|
2991 |
"/ device displayOpaqueString:s |
|
2992 |
"/ from:index1 to:index2 |
|
2993 |
"/ x:pX y:pY |
|
2994 |
"/ in:drawableId with:gcId. |
|
2995 |
"/ ]. |
|
2996 |
"/ |
|
2997 |
"/ " |
|
2998 |
"/ or-in bg bits ... |
|
2999 |
"/ " |
|
3000 |
"/ bgId ~~ 0 ifTrue:[ |
|
3001 |
"/ device setForeground:0 background:bgId in:gcId. |
|
3002 |
"/ device setFunction:#or in:gcId. |
|
3003 |
"/ device displayOpaqueString:s |
|
3004 |
"/ from:index1 to:index2 |
|
3005 |
"/ x:pX y:pY |
|
3006 |
"/ in:drawableId with:gcId. |
|
3007 |
"/ ]. |
|
3008 |
"/ " |
|
3009 |
"/ flush foreground/background cache |
|
3010 |
"/ " |
|
3011 |
"/ foreground := nil. |
|
3012 |
"/ background := nil. |
|
3013 |
"/ device setFunction:function in:gcId. |
|
3014 |
"/ ^ self |
|
3015 |
"/ ]. |
|
3016 |
||
768 | 3017 |
(bgId notNil and:[function == #copy]) ifTrue:[ |
1637
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
3018 |
" |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
3019 |
only fg is dithered; fill with bg first ... |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
3020 |
" |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
3021 |
device setForeground:bgId in:gcId. |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
3022 |
device setFunction:#copy in:gcId. |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
3023 |
device setBitmapMask:nil in:gcId. |
3666
01d7bf1d2333
fixed Text drawing in displayString
Michael Beyl <mb@exept.de>
parents:
3630
diff
changeset
|
3024 |
self fillRectangleX:pX y:(pY - ascent) width:w height:h. |
1637
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
3025 |
|
2024 | 3026 |
mask notNil ifTrue:[ |
3027 |
"/ draw fg dithered |
|
3028 |
(mask depth == 1) ifTrue:[ |
|
3029 |
device setBitmapMask:mask id in:gcId. |
|
3530 | 3030 |
device setForegroundColor:foreground backgroundColor:background in:gcId. |
2024 | 3031 |
] ifFalse:[ |
3032 |
device setPixmapMask:mask id in:gcId |
|
3033 |
]. |
|
1637
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
3034 |
]. |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
3035 |
|
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
3036 |
device displayString:s |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
3037 |
from:index1 to:index2 |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
3038 |
x:pX y:pY |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
3039 |
in:drawableId with:gcId. |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
3040 |
^ self. |
768 | 3041 |
"/ |
3042 |
"/ " |
|
3043 |
"/ if bgPaint color is all-0 or all-1's, we can do it in one |
|
3044 |
"/ operation ... |
|
3045 |
"/ " |
|
3046 |
"/ ((bgId ~~ ((1 bitShift:deviceDepth)-1)) |
|
3047 |
"/ and:[bgId ~~ allBits]) ifTrue:[ |
|
3048 |
"/ " |
|
3049 |
"/ clear bg bits ... |
|
3050 |
"/ " |
|
3051 |
"/ device setForeground:allBits background:0 in:gcId. |
|
3052 |
"/ device setFunction:#and in:gcId. |
|
3053 |
"/ device displayOpaqueString:s |
|
3054 |
"/ from:index1 to:index2 |
|
3055 |
"/ x:pX y:pY |
|
3056 |
"/ in:drawableId with:gcId. |
|
3057 |
"/ ]. |
|
3058 |
"/ |
|
3059 |
"/ " |
|
3060 |
"/ or-in bg bits ... |
|
3061 |
"/ " |
|
3062 |
"/ bgId ~~ 0 ifTrue:[ |
|
3063 |
"/ device setForeground:0 background:bgId in:gcId. |
|
3064 |
"/ device setFunction:#or in:gcId. |
|
3065 |
"/ device displayOpaqueString:s |
|
3066 |
"/ from:index1 to:index2 |
|
3067 |
"/ x:pX y:pY |
|
3068 |
"/ in:drawableId with:gcId. |
|
3069 |
"/ ]. |
|
3070 |
"/ " |
|
3071 |
"/ flush foreground/background cache |
|
3072 |
"/ " |
|
3073 |
"/ foreground := nil. |
|
3074 |
"/ background := nil. |
|
3075 |
"/ device setFunction:function in:gcId. |
|
3076 |
"/ ^ self |
|
832
064890dcfabd
fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents:
786
diff
changeset
|
3077 |
]. |
064890dcfabd
fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents:
786
diff
changeset
|
3078 |
|
732 | 3079 |
" |
832
064890dcfabd
fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents:
786
diff
changeset
|
3080 |
very hard case, both fg and bg are dithered colors/images |
732 | 3081 |
" |
3082 |
noColor := Color noColor. |
|
832
064890dcfabd
fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents:
786
diff
changeset
|
3083 |
"/ 'hard: ' print. aString print. ' ' print. paint print. ' ' print. bgPaint printCR. |
732 | 3084 |
" |
3085 |
create temp-forms; |
|
3086 |
" |
|
3087 |
bgForm := Form width:w height:h depth:deviceDepth on:device. |
|
3088 |
fgForm := Form width:w height:h depth:deviceDepth on:device. |
|
3089 |
tmpForm := Form width:w height:h depth:deviceDepth on:device. |
|
3090 |
maskForm := Form width:w height:h depth:deviceDepth on:device. |
|
3091 |
||
3092 |
" |
|
3093 |
fill |
|
3094 |
" |
|
3095 |
dx := 0. |
|
3666
01d7bf1d2333
fixed Text drawing in displayString
Michael Beyl <mb@exept.de>
parents:
3630
diff
changeset
|
3096 |
dy := ascent. |
732 | 3097 |
maskOrigin notNil ifTrue:[ |
1637
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
3098 |
dx := maskOrigin x. |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
3099 |
dy := dy + maskOrigin y |
732 | 3100 |
]. |
3101 |
||
3102 |
bgForm paint:bgPaint. |
|
3103 |
bgForm setMaskOriginX:(pX negated + dx) y:(pY negated + dy). |
|
3104 |
bgForm fillRectangleX:0 y:0 width:w height:h. |
|
3105 |
||
3106 |
fgForm paint:paint. |
|
3107 |
fgForm setMaskOriginX:(pX negated + dx) y:(pY negated + dy). |
|
3108 |
fgForm fillRectangleX:0 y:0 width:w height:h. |
|
3109 |
||
3110 |
" |
|
3111 |
stamp-out background (have now bg-bits with fg=0 in bgForm) |
|
3112 |
" |
|
3113 |
bgForm font:fontUsed. |
|
3114 |
bgForm paint:noColor on:allColor. |
|
3115 |
bgForm function:#and. |
|
3116 |
bgForm displayString:s |
|
1637
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
3117 |
from:index1 to:index2 |
3666
01d7bf1d2333
fixed Text drawing in displayString
Michael Beyl <mb@exept.de>
parents:
3630
diff
changeset
|
3118 |
x:0 y:ascent. |
732 | 3119 |
|
3120 |
" |
|
3121 |
stamp-out foreground |
|
3122 |
" |
|
3123 |
maskForm font:fontUsed. |
|
3124 |
maskForm paint:allColor on:noColor. |
|
3125 |
maskForm displayOpaqueString:s |
|
1637
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
3126 |
from:index1 to:index2 |
3666
01d7bf1d2333
fixed Text drawing in displayString
Michael Beyl <mb@exept.de>
parents:
3630
diff
changeset
|
3127 |
x:0 y:ascent. |
732 | 3128 |
|
3129 |
fgForm function:#and. |
|
3130 |
fgForm copyFrom:maskForm x:0 y:0 toX:0 y:0 width:w height:h. |
|
3131 |
||
3132 |
" |
|
3133 |
clear tempform |
|
3134 |
" |
|
3135 |
tmpForm paint:noColor. |
|
3136 |
tmpForm fillRectangleX:0 y:0 width:w height:h. |
|
3137 |
||
3138 |
" |
|
3139 |
merge fg-temp and bg-temp into tmp |
|
3140 |
" |
|
3141 |
tmpForm function:#or. |
|
3142 |
tmpForm paint:noColor on:allColor. |
|
3143 |
tmpForm copyFrom:fgForm x:0 y:0 toX:0 y:0 width:w height:h. |
|
3144 |
tmpForm copyFrom:bgForm x:0 y:0 toX:0 y:0 width:w height:h. |
|
3145 |
" |
|
3146 |
finally, draw it |
|
3147 |
" |
|
3148 |
device setForeground:0 background:allBits in:gcId. |
|
3149 |
device |
|
1637
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
3150 |
copyFromId:tmpForm id |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
3151 |
x:0 y:0 gc:tmpForm gcId |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
3152 |
to:drawableId |
3666
01d7bf1d2333
fixed Text drawing in displayString
Michael Beyl <mb@exept.de>
parents:
3630
diff
changeset
|
3153 |
x:pX y:(pY-ascent) gc:gcId |
1637
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
3154 |
width:w height:h. |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
3155 |
|
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
3156 |
" |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
3157 |
release tempForms immediately |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
3158 |
(although GC will eventually do it, |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
3159 |
this creates less stress to the Xserver in the meanwhile ...) |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
3160 |
" |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
3161 |
tmpForm destroy. |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
3162 |
fgForm destroy. |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
3163 |
bgForm destroy. |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
3164 |
maskForm destroy. |
4e6372dce15d
release temporary forms early
Claus Gittinger <cg@exept.de>
parents:
1599
diff
changeset
|
3165 |
|
732 | 3166 |
" |
3167 |
flush foreground/background cache |
|
3168 |
" |
|
3169 |
foreground := nil. |
|
3170 |
background := nil. |
|
3171 |
||
1805
532a11ba8458
tuned-out another send if encoding is wrong in display-string
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
3172 |
"Modified: 1.7.1997 / 17:08:46 / cg" |
732 | 3173 |
! |
3174 |
||
3175 |
displayDeviceOpaqueString:aString from:index1 to:index2 x:x y:y |
|
3176 |
"draw a substring at the coordinate x/y - draw foreground pixels in |
|
3177 |
paint-color and background pixels in bgPaint-color. |
|
3178 |
Assuming that device can only draw in device colors, we have to handle |
|
3179 |
the case where paint and/or bgPaint are dithered colors. |
|
3180 |
No translation or scaling is done." |
|
3181 |
||
3182 |
self displayDeviceOpaqueString:aString from:index1 to:index2 in:font x:x y:y |
|
3183 |
! |
|
3184 |
||
3185 |
displayDeviceOpaqueString:aString x:x y:y |
|
3186 |
"draw a string at the coordinate x/y - draw foreground pixels in |
|
3187 |
paint-color and background pixels in bgPaint-color. |
|
3188 |
No translation or scaling is done" |
|
3189 |
||
3190 |
self displayDeviceOpaqueString:aString from:1 to:(aString size) in:font x:x y:y |
|
3191 |
! |
|
3192 |
||
3193 |
displayDeviceString:aString from:index1 to:index2 in:font x:x y:y |
|
3194 |
"draw a substring at the coordinate x/y - |
|
3195 |
draw foreground-pixels only (in current paint-color), leaving background as-is. |
|
3196 |
No translation or scaling is done" |
|
3197 |
||
1805
532a11ba8458
tuned-out another send if encoding is wrong in display-string
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
3198 |
|id pX pY fontUsed s fEnc| |
732 | 3199 |
|
3200 |
" |
|
3201 |
hook for non-strings (i.e. attributed text) |
|
3202 |
" |
|
3203 |
(aString isString not |
|
3204 |
or:[aString isText]) ifTrue:[ |
|
1797 | 3205 |
^ aString displayOn:self x:x y:y from:index1 to:index2 |
732 | 3206 |
]. |
3207 |
||
3208 |
gcId isNil ifTrue:[ |
|
1797 | 3209 |
self initGC |
732 | 3210 |
]. |
3211 |
||
3212 |
pX := x rounded. |
|
3213 |
pY := y rounded. |
|
3214 |
||
2835 | 3215 |
fontUsed := font onDevice:device. |
732 | 3216 |
|
3217 |
id := fontUsed fontId. |
|
3218 |
id isNil ifTrue:[ |
|
1797 | 3219 |
"hook for alien fonts" |
3220 |
font displayString:aString from:index1 to:index2 x:x y:y in:self |
|
732 | 3221 |
] ifFalse:[ |
1797 | 3222 |
s := aString. |
1805
532a11ba8458
tuned-out another send if encoding is wrong in display-string
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
3223 |
s encoding ~~ (fEnc := font encoding) ifTrue:[ |
532a11ba8458
tuned-out another send if encoding is wrong in display-string
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
3224 |
s := s encodeForDisplayInto:fEnc. |
1797 | 3225 |
]. |
3226 |
||
3227 |
deviceFont ~~ fontUsed ifTrue:[ |
|
3228 |
device setFont:id in:gcId. |
|
3229 |
deviceFont := fontUsed |
|
3230 |
]. |
|
3231 |
device displayString:s from:index1 to:index2 |
|
3232 |
x:pX y:pY in:drawableId with:gcId |
|
732 | 3233 |
] |
3234 |
||
1805
532a11ba8458
tuned-out another send if encoding is wrong in display-string
Claus Gittinger <cg@exept.de>
parents:
1797
diff
changeset
|
3235 |
"Modified: 1.7.1997 / 17:08:48 / cg" |
732 | 3236 |
! |
3237 |
||
3238 |
displayDeviceString:aString from:index1 to:index2 x:x y:y |
|
3239 |
"draw a substring at the coordinate x/y - |
|
3240 |
draw foreground-pixels only (in current paint-color), leaving background as-is. |
|
3241 |
No translation or scaling is done" |
|
3242 |
||
3243 |
self displayDeviceString:aString from:index1 to:index2 in:font x:x y:y |
|
3244 |
! |
|
3245 |
||
3246 |
displayDeviceString:aString x:x y:y |
|
3247 |
"draw a string at the coordinate x/y - |
|
3248 |
draw foreground-pixels only (in current paint-color), leaving background as-is. |
|
3249 |
No translation or scaling is done" |
|
3250 |
||
3251 |
self displayDeviceString:aString from:1 to:(aString size) in:font x:x y:y |
|
3252 |
! |
|
3253 |
||
3254 |
fillDeviceRectangleX:x y:y width:w height:h |
|
3255 |
"draw a filled rectangle in device coordinate space. |
|
3256 |
This ignores any transformations. The coordinates must be integers." |
|
3257 |
||
3258 |
gcId isNil ifTrue:[ |
|
3259 |
self initGC |
|
3260 |
]. |
|
3261 |
device |
|
3262 |
fillRectangleX:x |
|
3263 |
y:y |
|
3264 |
width:w |
|
3265 |
height:h |
|
3266 |
in:drawableId with:gcId |
|
3267 |
! ! |
|
3268 |
||
3269 |
!DeviceGraphicsContext methodsFor:'evaluating in another context'! |
|
3270 |
||
3271 |
reverseDo:aBlock |
|
3272 |
"evaluate aBlock with foreground and background interchanged. |
|
3273 |
This can be reimplemented here in a faster way." |
|
3274 |
||
3275 |
|oldFg oldBg| |
|
3276 |
||
2835 | 3277 |
oldFg := foreground. |
3278 |
oldBg := background. |
|
732 | 3279 |
self foreground:background background:foreground. |
3280 |
aBlock value. |
|
3281 |
self foreground:oldFg background:oldBg |
|
3282 |
! |
|
3283 |
||
3284 |
withBackground:fgColor do:aBlock |
|
3285 |
"evaluate aBlock with changed background." |
|
3286 |
||
3287 |
|oldBg| |
|
3288 |
||
3289 |
oldBg := background. |
|
3290 |
self background:fgColor. |
|
3291 |
aBlock value. |
|
3292 |
self background:oldBg |
|
3293 |
! |
|
3294 |
||
3295 |
withForeground:fgColor background:bgColor do:aBlock |
|
3296 |
"evaluate aBlock with changed foreground and background." |
|
3297 |
||
3298 |
|oldFg oldBg| |
|
3299 |
||
3300 |
oldFg := foreground. |
|
3301 |
oldBg := background. |
|
3302 |
self foreground:fgColor background:bgColor. |
|
3303 |
aBlock value. |
|
3304 |
self foreground:oldFg background:oldBg |
|
3305 |
! |
|
3306 |
||
3307 |
withForeground:fgColor background:bgColor function:aFunction do:aBlock |
|
3308 |
"evaluate aBlock with foreground, background and function" |
|
3309 |
||
3310 |
|oldFg oldBg oldFun| |
|
3311 |
||
3312 |
oldFg := foreground. |
|
3313 |
oldBg := background. |
|
3314 |
oldFun := function. |
|
3315 |
self foreground:fgColor background:bgColor function:aFunction. |
|
3316 |
aBlock value. |
|
3317 |
self foreground:oldFg background:oldBg function:oldFun |
|
3318 |
! |
|
3319 |
||
3320 |
withForeground:fgColor background:bgColor mask:aMask do:aBlock |
|
3321 |
"evaluate aBlock with foreground, background and mask" |
|
3322 |
||
3323 |
|oldFg oldBg oldMask| |
|
3324 |
||
3325 |
oldFg := foreground. |
|
3326 |
oldBg := background. |
|
3327 |
oldMask := mask. |
|
3328 |
self foreground:fgColor background:bgColor. |
|
3329 |
self mask:aMask. |
|
3330 |
aBlock value. |
|
3331 |
self foreground:oldFg background:oldBg. |
|
3332 |
self mask:oldMask |
|
3333 |
! |
|
3334 |
||
3335 |
withForeground:fgColor do:aBlock |
|
3336 |
"evaluate aBlock with changed foreground." |
|
3337 |
||
3338 |
|oldFg| |
|
3339 |
||
3340 |
oldFg := foreground. |
|
3341 |
self foreground:fgColor. |
|
3342 |
aBlock value. |
|
3343 |
self foreground:oldFg |
|
3344 |
! |
|
3345 |
||
3346 |
withForeground:fgColor function:aFunction do:aBlock |
|
3347 |
"evaluate aBlock with changed foreground and function." |
|
3348 |
||
3349 |
|oldFg oldFun| |
|
3350 |
||
3351 |
oldFg := foreground. |
|
3352 |
oldFun := function. |
|
3353 |
self foreground:fgColor background:background function:aFunction. |
|
3354 |
aBlock value. |
|
3355 |
self foreground:oldFg background:background function:oldFun |
|
3356 |
! |
|
3357 |
||
3358 |
xoring:aBlock |
|
3359 |
"evaluate aBlock with function xoring" |
|
3360 |
||
3361 |
|fgPixel bgPixel oldFunction| |
|
3362 |
||
2322 | 3363 |
fgPixel := device blackpixel. |
3364 |
bgPixel := device whitepixel. |
|
732 | 3365 |
|
3366 |
gcId isNil ifTrue:[ |
|
1199
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3367 |
self initGC |
732 | 3368 |
]. |
3369 |
oldFunction := function. |
|
3370 |
device setForeground:(fgPixel bitXor:bgPixel) |
|
1199
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3371 |
background:bgPixel |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3372 |
in:gcId. |
732 | 3373 |
device setFunction:#xor in:gcId. |
3374 |
aBlock value. |
|
2322 | 3375 |
|
2879 | 3376 |
paint := bgPaint := nil. "invalidate" |
1199
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3377 |
foreground := device blackColor. |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3378 |
background := device whiteColor. |
2322 | 3379 |
device setForeground:fgPixel background:bgPixel in:gcId. |
732 | 3380 |
device setFunction:oldFunction in:gcId. |
3381 |
function := oldFunction |
|
1199
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3382 |
|
2322 | 3383 |
"Modified: / 10.9.1998 / 12:17:39 / cg" |
732 | 3384 |
! ! |
3385 |
||
3386 |
!DeviceGraphicsContext methodsFor:'filling'! |
|
3387 |
||
3388 |
fillArcX:x y:y width:w height:h from:startAngle angle:angle |
|
3389 |
"draw a filled arc; apply transformation if nonNil" |
|
3390 |
||
2268
1a774fc02c83
fixed non-float (i.e. fraction) args to fillArc/ displayArc
Claus Gittinger <cg@exept.de>
parents:
2259
diff
changeset
|
3391 |
|pX pY nW nH sA a| |
732 | 3392 |
|
3393 |
gcId isNil ifTrue:[ |
|
1029
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3394 |
self initGC |
732 | 3395 |
]. |
3396 |
transformation notNil ifTrue:[ |
|
1029
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3397 |
pX := transformation applyToX:x. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3398 |
pY := transformation applyToY:y. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3399 |
nW := transformation applyScaleX:w. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3400 |
nH := transformation applyScaleY:h. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3401 |
nW < 0 ifTrue:[ |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3402 |
nW := nW abs. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3403 |
pX := pX - nW. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3404 |
]. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3405 |
nH < 0 ifTrue:[ |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3406 |
nH := nH abs. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3407 |
pY := pY - nH. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3408 |
]. |
732 | 3409 |
] ifFalse:[ |
1029
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3410 |
pX := x. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3411 |
pY := y. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3412 |
nW := w. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3413 |
nH := h. |
732 | 3414 |
]. |
3415 |
||
3416 |
pX := pX rounded. |
|
3417 |
pY := pY rounded. |
|
3418 |
nW := nW rounded. |
|
3419 |
nH := nH rounded. |
|
3420 |
||
2268
1a774fc02c83
fixed non-float (i.e. fraction) args to fillArc/ displayArc
Claus Gittinger <cg@exept.de>
parents:
2259
diff
changeset
|
3421 |
sA := startAngle. |
1a774fc02c83
fixed non-float (i.e. fraction) args to fillArc/ displayArc
Claus Gittinger <cg@exept.de>
parents:
2259
diff
changeset
|
3422 |
sA isInteger ifFalse:[sA := sA asFloat]. |
1a774fc02c83
fixed non-float (i.e. fraction) args to fillArc/ displayArc
Claus Gittinger <cg@exept.de>
parents:
2259
diff
changeset
|
3423 |
a := angle. |
1a774fc02c83
fixed non-float (i.e. fraction) args to fillArc/ displayArc
Claus Gittinger <cg@exept.de>
parents:
2259
diff
changeset
|
3424 |
a isInteger ifFalse:[a := a asFloat]. |
1a774fc02c83
fixed non-float (i.e. fraction) args to fillArc/ displayArc
Claus Gittinger <cg@exept.de>
parents:
2259
diff
changeset
|
3425 |
|
732 | 3426 |
device |
1029
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3427 |
fillArcX:pX |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3428 |
y:pY |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3429 |
width:nW |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3430 |
height:nH |
2268
1a774fc02c83
fixed non-float (i.e. fraction) args to fillArc/ displayArc
Claus Gittinger <cg@exept.de>
parents:
2259
diff
changeset
|
3431 |
from:sA |
1a774fc02c83
fixed non-float (i.e. fraction) args to fillArc/ displayArc
Claus Gittinger <cg@exept.de>
parents:
2259
diff
changeset
|
3432 |
angle:a |
1029
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3433 |
in:drawableId |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3434 |
with:gcId |
732 | 3435 |
|
3436 |
"Created: 8.5.1996 / 08:29:45 / cg" |
|
784 | 3437 |
"Modified: 4.6.1996 / 17:58:21 / cg" |
732 | 3438 |
! |
3439 |
||
3440 |
fillPolygon:aPolygon |
|
3441 |
"draw a filled polygon; apply transformation if nonNil" |
|
3442 |
||
3443 |
|newPolygon| |
|
3444 |
||
3445 |
gcId isNil ifTrue:[ |
|
3446 |
self initGC |
|
3447 |
]. |
|
3448 |
transformation notNil ifTrue:[ |
|
3449 |
newPolygon := aPolygon collect:[:point | transformation applyTo:point]. |
|
3450 |
] ifFalse:[ |
|
3451 |
newPolygon := aPolygon |
|
3452 |
]. |
|
3453 |
(newPolygon findFirst:[:p | |
|
3454 |
(p isPoint not |
|
3455 |
or:[(p x class ~~ SmallInteger) |
|
3456 |
or:[(p y class ~~ SmallInteger)]]) |
|
3457 |
]) ~~ 0 ifTrue:[ |
|
3458 |
newPolygon := newPolygon collect:[:p | p asPoint rounded] |
|
3459 |
]. |
|
3460 |
device |
|
3461 |
fillPolygon:newPolygon |
|
3462 |
in:drawableId |
|
3463 |
with:gcId |
|
3464 |
! |
|
3465 |
||
3466 |
fillRectangleX:x y:y width:w height:h |
|
3467 |
"draw a filled rectangle; apply transformation if nonNil" |
|
3468 |
||
1064 | 3469 |
|pX pY nW nH| |
732 | 3470 |
|
3471 |
gcId isNil ifTrue:[ |
|
1029
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3472 |
self initGC |
732 | 3473 |
]. |
3474 |
transformation notNil ifTrue:[ |
|
1029
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3475 |
pX := transformation applyToX:x. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3476 |
pY := transformation applyToY:y. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3477 |
nW := transformation applyScaleX:w. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3478 |
nH := transformation applyScaleY:h. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3479 |
nW < 0 ifTrue:[ |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3480 |
nW := nW abs. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3481 |
pX := pX - nW. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3482 |
]. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3483 |
nH < 0 ifTrue:[ |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3484 |
nH := nH abs. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3485 |
pY := pY - nH. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3486 |
]. |
732 | 3487 |
] ifFalse:[ |
1029
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3488 |
pX := x. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3489 |
pY := y. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3490 |
nW := w. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3491 |
nH := h. |
732 | 3492 |
]. |
3493 |
pX := pX rounded. |
|
3494 |
pY := pY rounded. |
|
3495 |
nW := nW rounded. |
|
3496 |
nH := nH rounded. |
|
3497 |
||
3498 |
device |
|
1029
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3499 |
fillRectangleX:pX |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3500 |
y:pY |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3501 |
width:nW |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3502 |
height:nH |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3503 |
in:drawableId with:gcId |
784 | 3504 |
|
3505 |
"Modified: 4.6.1996 / 17:58:49 / cg" |
|
732 | 3506 |
! ! |
3507 |
||
3612
6e0f462e0b7a
Allow #registerForFinalization for classes defining their own Lobby.
Stefan Vogel <sv@exept.de>
parents:
3611
diff
changeset
|
3508 |
!DeviceGraphicsContext methodsFor:'finalization'! |
6e0f462e0b7a
Allow #registerForFinalization for classes defining their own Lobby.
Stefan Vogel <sv@exept.de>
parents:
3611
diff
changeset
|
3509 |
|
6e0f462e0b7a
Allow #registerForFinalization for classes defining their own Lobby.
Stefan Vogel <sv@exept.de>
parents:
3611
diff
changeset
|
3510 |
finalize |
6e0f462e0b7a
Allow #registerForFinalization for classes defining their own Lobby.
Stefan Vogel <sv@exept.de>
parents:
3611
diff
changeset
|
3511 |
"some Drawable has been collected |
6e0f462e0b7a
Allow #registerForFinalization for classes defining their own Lobby.
Stefan Vogel <sv@exept.de>
parents:
3611
diff
changeset
|
3512 |
- must release operating system resources" |
6e0f462e0b7a
Allow #registerForFinalization for classes defining their own Lobby.
Stefan Vogel <sv@exept.de>
parents:
3611
diff
changeset
|
3513 |
|
6e0f462e0b7a
Allow #registerForFinalization for classes defining their own Lobby.
Stefan Vogel <sv@exept.de>
parents:
3611
diff
changeset
|
3514 |
^ self subclassResponsibility |
6e0f462e0b7a
Allow #registerForFinalization for classes defining their own Lobby.
Stefan Vogel <sv@exept.de>
parents:
3611
diff
changeset
|
3515 |
! ! |
6e0f462e0b7a
Allow #registerForFinalization for classes defining their own Lobby.
Stefan Vogel <sv@exept.de>
parents:
3611
diff
changeset
|
3516 |
|
2572 | 3517 |
!DeviceGraphicsContext methodsFor:'initialize / release'! |
732 | 3518 |
|
1517
ac751bb3dfdf
no need for registration here;
Claus Gittinger <cg@exept.de>
parents:
1514
diff
changeset
|
3519 |
close |
ac751bb3dfdf
no need for registration here;
Claus Gittinger <cg@exept.de>
parents:
1514
diff
changeset
|
3520 |
"same as destroy - for ST-80 compatibility" |
ac751bb3dfdf
no need for registration here;
Claus Gittinger <cg@exept.de>
parents:
1514
diff
changeset
|
3521 |
|
ac751bb3dfdf
no need for registration here;
Claus Gittinger <cg@exept.de>
parents:
1514
diff
changeset
|
3522 |
self destroy |
ac751bb3dfdf
no need for registration here;
Claus Gittinger <cg@exept.de>
parents:
1514
diff
changeset
|
3523 |
|
ac751bb3dfdf
no need for registration here;
Claus Gittinger <cg@exept.de>
parents:
1514
diff
changeset
|
3524 |
"Created: 2.4.1997 / 19:31:27 / cg" |
ac751bb3dfdf
no need for registration here;
Claus Gittinger <cg@exept.de>
parents:
1514
diff
changeset
|
3525 |
! |
ac751bb3dfdf
no need for registration here;
Claus Gittinger <cg@exept.de>
parents:
1514
diff
changeset
|
3526 |
|
732 | 3527 |
createGC |
1453
e93293618275
only fetch id's once in displayForm.
Claus Gittinger <cg@exept.de>
parents:
1294
diff
changeset
|
3528 |
"physically create a device GC. |
e93293618275
only fetch id's once in displayForm.
Claus Gittinger <cg@exept.de>
parents:
1294
diff
changeset
|
3529 |
Since we do not need a gc-object for the drawable until something is |
e93293618275
only fetch id's once in displayForm.
Claus Gittinger <cg@exept.de>
parents:
1294
diff
changeset
|
3530 |
really drawn, none is created up to the first draw. |
732 | 3531 |
This method is sent, when the first drawing happens" |
3532 |
||
1138
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1094
diff
changeset
|
3533 |
gcId := device gcFor:drawableId. |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1094
diff
changeset
|
3534 |
Lobby registerChange:self. |
1453
e93293618275
only fetch id's once in displayForm.
Claus Gittinger <cg@exept.de>
parents:
1294
diff
changeset
|
3535 |
|
e93293618275
only fetch id's once in displayForm.
Claus Gittinger <cg@exept.de>
parents:
1294
diff
changeset
|
3536 |
"Modified: 19.3.1997 / 11:07:52 / cg" |
1138
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1094
diff
changeset
|
3537 |
! |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1094
diff
changeset
|
3538 |
|
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1094
diff
changeset
|
3539 |
destroy |
1517
ac751bb3dfdf
no need for registration here;
Claus Gittinger <cg@exept.de>
parents:
1514
diff
changeset
|
3540 |
"I am abstract" |
ac751bb3dfdf
no need for registration here;
Claus Gittinger <cg@exept.de>
parents:
1514
diff
changeset
|
3541 |
|
2913 | 3542 |
self subclassResponsibility. |
1517
ac751bb3dfdf
no need for registration here;
Claus Gittinger <cg@exept.de>
parents:
1514
diff
changeset
|
3543 |
|
ac751bb3dfdf
no need for registration here;
Claus Gittinger <cg@exept.de>
parents:
1514
diff
changeset
|
3544 |
"/ "when the drawable is destroyed, the associated GC must be destroyed with it" |
ac751bb3dfdf
no need for registration here;
Claus Gittinger <cg@exept.de>
parents:
1514
diff
changeset
|
3545 |
"/ |
ac751bb3dfdf
no need for registration here;
Claus Gittinger <cg@exept.de>
parents:
1514
diff
changeset
|
3546 |
"/ gcId notNil ifTrue:[ |
ac751bb3dfdf
no need for registration here;
Claus Gittinger <cg@exept.de>
parents:
1514
diff
changeset
|
3547 |
"/ device destroyGC:gcId. |
ac751bb3dfdf
no need for registration here;
Claus Gittinger <cg@exept.de>
parents:
1514
diff
changeset
|
3548 |
"/ gcId := nil. |
ac751bb3dfdf
no need for registration here;
Claus Gittinger <cg@exept.de>
parents:
1514
diff
changeset
|
3549 |
"/ Lobby registerChange:self. |
ac751bb3dfdf
no need for registration here;
Claus Gittinger <cg@exept.de>
parents:
1514
diff
changeset
|
3550 |
"/ ] |
ac751bb3dfdf
no need for registration here;
Claus Gittinger <cg@exept.de>
parents:
1514
diff
changeset
|
3551 |
|
ac751bb3dfdf
no need for registration here;
Claus Gittinger <cg@exept.de>
parents:
1514
diff
changeset
|
3552 |
"Modified: 2.4.1997 / 19:37:53 / cg" |
1138
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1094
diff
changeset
|
3553 |
! |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1094
diff
changeset
|
3554 |
|
3612
6e0f462e0b7a
Allow #registerForFinalization for classes defining their own Lobby.
Stefan Vogel <sv@exept.de>
parents:
3611
diff
changeset
|
3555 |
finalizationLobby |
6e0f462e0b7a
Allow #registerForFinalization for classes defining their own Lobby.
Stefan Vogel <sv@exept.de>
parents:
3611
diff
changeset
|
3556 |
"answer the registry used for finalization. |
6e0f462e0b7a
Allow #registerForFinalization for classes defining their own Lobby.
Stefan Vogel <sv@exept.de>
parents:
3611
diff
changeset
|
3557 |
DeviceGraphicContexts have their own Registry" |
6e0f462e0b7a
Allow #registerForFinalization for classes defining their own Lobby.
Stefan Vogel <sv@exept.de>
parents:
3611
diff
changeset
|
3558 |
|
6e0f462e0b7a
Allow #registerForFinalization for classes defining their own Lobby.
Stefan Vogel <sv@exept.de>
parents:
3611
diff
changeset
|
3559 |
^ Lobby |
2572 | 3560 |
! |
3561 |
||
1138
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1094
diff
changeset
|
3562 |
initGC |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1094
diff
changeset
|
3563 |
"since we do not need a gc-object for the drawable until something is |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1094
diff
changeset
|
3564 |
really drawn, none is created. |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1094
diff
changeset
|
3565 |
This method is sent, when the first drawing happens" |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1094
diff
changeset
|
3566 |
|
732 | 3567 |
|fgId bgId p| |
3568 |
||
1453
e93293618275
only fetch id's once in displayForm.
Claus Gittinger <cg@exept.de>
parents:
1294
diff
changeset
|
3569 |
gcId notNil ifTrue:[^ self]. |
1514
7c2a921ae46b
better error report when drawing on closed view.
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
3570 |
drawableId isNil ifTrue:[ |
2031
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
3571 |
"/ |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
3572 |
"/ the drawable has been closed (or was never open) |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
3573 |
"/ no drawing is possible. |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
3574 |
"/ |
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
3575 |
^ DrawingOnClosedDrawableSignal raiseRequest |
1514
7c2a921ae46b
better error report when drawing on closed view.
Claus Gittinger <cg@exept.de>
parents:
1507
diff
changeset
|
3576 |
]. |
1138
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1094
diff
changeset
|
3577 |
self createGC. |
732 | 3578 |
|
1199
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3579 |
foreground isNil ifTrue:[foreground := device blackColor]. |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3580 |
background isNil ifTrue:[background := device whiteColor]. |
732 | 3581 |
|
3582 |
foreground isColor ifTrue:[ |
|
1199
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3583 |
"get device colors from the device indep. colors" |
2835 | 3584 |
foreground := foreground onDevice:device. |
1199
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3585 |
fgId := foreground colorId. |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3586 |
fgId isNil ifTrue:[ |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3587 |
(foreground grayIntensity >= 50) ifTrue:[ |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3588 |
fgId := device whitepixel |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3589 |
] ifFalse:[ |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3590 |
fgId := device blackpixel |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3591 |
] |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3592 |
]. |
732 | 3593 |
] ifFalse:[ |
1199
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3594 |
fgId := device blackpixel. |
732 | 3595 |
]. |
3596 |
||
3597 |
background isColor ifTrue:[ |
|
2835 | 3598 |
background := background onDevice:device. |
1199
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3599 |
bgId := background colorId. |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3600 |
bgId isNil ifTrue:[ |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3601 |
(background grayIntensity >= 50) ifTrue:[ |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3602 |
bgId := device whitepixel |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3603 |
] ifFalse:[ |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3604 |
bgId := device blackpixel |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3605 |
] |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3606 |
]. |
732 | 3607 |
] ifFalse:[ |
1199
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3608 |
bgId := device whitepixel |
732 | 3609 |
]. |
3610 |
||
3611 |
"now, this is something the device can work with ..." |
|
3612 |
device setForeground:fgId background:bgId in:gcId. |
|
3613 |
||
3614 |
"switch to paint" |
|
3615 |
p := paint. |
|
3616 |
paint := nil. |
|
3617 |
self paint:p. |
|
3618 |
||
3619 |
((lineWidth ~~ 0) |
|
3620 |
or:[(lineStyle ~~ #solid) |
|
3621 |
or:[(capStyle ~~ #butt) |
|
3622 |
or:[joinStyle ~~ #miter]]]) ifTrue:[ |
|
1199
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3623 |
device setLineWidth:lineWidth |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3624 |
style:lineStyle |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3625 |
cap:capStyle |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3626 |
join:joinStyle |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3627 |
in:gcId |
732 | 3628 |
]. |
3629 |
||
3630 |
mask notNil ifTrue:[ |
|
1199
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3631 |
(mask depth == 1) ifTrue:[ |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3632 |
device setBitmapMask:(mask id) in:gcId |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3633 |
] ifFalse:[ |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3634 |
device setPixmapMask:(mask id) in:gcId |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3635 |
]. |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3636 |
maskOrigin notNil ifTrue:[ |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3637 |
device setMaskOriginX:maskOrigin x y:maskOrigin y in:gcId |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3638 |
] |
732 | 3639 |
]. |
3640 |
(function ~~ #copy) ifTrue:[device setFunction:function in:gcId]. |
|
3641 |
||
3642 |
"defer the getting of a device font |
|
3643 |
- this is now done when the first drawstring occurs, |
|
3644 |
since many views (layout-views) will never draw strings and |
|
3645 |
therefore, the overhead of aquiring a font can be avoided. |
|
3646 |
" |
|
1138
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1094
diff
changeset
|
3647 |
"/ font := font on:device. |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1094
diff
changeset
|
3648 |
"/ id := font fontId. |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1094
diff
changeset
|
3649 |
"/ id notNil ifTrue:[ |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1094
diff
changeset
|
3650 |
"/ device setFont:id in:gcId |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1094
diff
changeset
|
3651 |
"/ ] |
1199
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3652 |
|
2031
d369d38213cf
dont use #error when drawing on a closed drawable;
Claus Gittinger <cg@exept.de>
parents:
2024
diff
changeset
|
3653 |
"Modified: / 29.1.1998 / 12:55:24 / cg" |
732 | 3654 |
! |
3655 |
||
3656 |
initialize |
|
3657 |
"setup everything for later use; actual work is done in |
|
3658 |
initColors and initFont, which are usually redefined." |
|
3659 |
||
3660 |
super initialize. |
|
3661 |
||
2259 | 3662 |
"/ just in case, someone redefined new without setting device |
3663 |
device isNil ifTrue:[device := Screen current]. |
|
3664 |
||
950 | 3665 |
foreground isNil ifTrue:[foreground := Black]. |
3666 |
background isNil ifTrue:[background := White]. |
|
3667 |
||
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
3668 |
"Modified: 10.1.1997 / 17:46:51 / cg" |
732 | 3669 |
! |
3670 |
||
3671 |
prepareForReinit |
|
3672 |
"kludge - clear drawableId and gcId |
|
3673 |
needed after snapin" |
|
3674 |
||
3675 |
gcId := nil. |
|
3676 |
drawableId := nil. |
|
3677 |
deviceFont := nil |
|
3678 |
! |
|
3679 |
||
3680 |
recreate |
|
3300 | 3681 |
"sent after a snapin or a migration, reinit draw stuff for new device" |
732 | 3682 |
|
3683 |
gcId := nil. |
|
3684 |
foreground notNil ifTrue:[ |
|
2835 | 3685 |
foreground := foreground onDevice:device |
732 | 3686 |
]. |
3687 |
background notNil ifTrue:[ |
|
2835 | 3688 |
background := background onDevice:device |
732 | 3689 |
]. |
3690 |
paint notNil ifTrue:[ |
|
2835 | 3691 |
paint := paint onDevice:device |
732 | 3692 |
]. |
3693 |
bgPaint notNil ifTrue:[ |
|
2835 | 3694 |
bgPaint := bgPaint onDevice:device |
1094
470f906e3687
recreate device font early - this avoids some deviceFont query errors
Claus Gittinger <cg@exept.de>
parents:
1092
diff
changeset
|
3695 |
]. |
470f906e3687
recreate device font early - this avoids some deviceFont query errors
Claus Gittinger <cg@exept.de>
parents:
1092
diff
changeset
|
3696 |
font notNil ifTrue:[ |
2835 | 3697 |
font := font onDevice:device |
732 | 3698 |
] |
1094
470f906e3687
recreate device font early - this avoids some deviceFont query errors
Claus Gittinger <cg@exept.de>
parents:
1092
diff
changeset
|
3699 |
|
470f906e3687
recreate device font early - this avoids some deviceFont query errors
Claus Gittinger <cg@exept.de>
parents:
1092
diff
changeset
|
3700 |
"Modified: 28.10.1996 / 13:25:02 / cg" |
732 | 3701 |
! |
3702 |
||
3703 |
reinitialize |
|
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
3704 |
'DeviceGraphicsContext [warning]: reinit of ' errorPrint. self classNameWithArticle errorPrint. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
3705 |
' failed' errorPrintCR |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
3706 |
|
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
3707 |
"Modified: 10.1.1997 / 17:47:06 / cg" |
832
064890dcfabd
fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents:
786
diff
changeset
|
3708 |
! |
064890dcfabd
fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents:
786
diff
changeset
|
3709 |
|
064890dcfabd
fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents:
786
diff
changeset
|
3710 |
releaseGC |
1517
ac751bb3dfdf
no need for registration here;
Claus Gittinger <cg@exept.de>
parents:
1514
diff
changeset
|
3711 |
"destroy the associated device GC resource - can be done to be nice to the |
832
064890dcfabd
fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents:
786
diff
changeset
|
3712 |
display if you know that you are done with a drawable." |
064890dcfabd
fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents:
786
diff
changeset
|
3713 |
|
844 | 3714 |
foreground := background := paint := bgPaint := nil. |
1517
ac751bb3dfdf
no need for registration here;
Claus Gittinger <cg@exept.de>
parents:
1514
diff
changeset
|
3715 |
|
832
064890dcfabd
fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents:
786
diff
changeset
|
3716 |
gcId notNil ifTrue:[ |
1517
ac751bb3dfdf
no need for registration here;
Claus Gittinger <cg@exept.de>
parents:
1514
diff
changeset
|
3717 |
device destroyGC:gcId. |
ac751bb3dfdf
no need for registration here;
Claus Gittinger <cg@exept.de>
parents:
1514
diff
changeset
|
3718 |
gcId := nil. |
ac751bb3dfdf
no need for registration here;
Claus Gittinger <cg@exept.de>
parents:
1514
diff
changeset
|
3719 |
Lobby registerChange:self. |
844 | 3720 |
]. |
832
064890dcfabd
fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents:
786
diff
changeset
|
3721 |
|
064890dcfabd
fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents:
786
diff
changeset
|
3722 |
"Created: 11.6.1996 / 22:07:30 / cg" |
1517
ac751bb3dfdf
no need for registration here;
Claus Gittinger <cg@exept.de>
parents:
1514
diff
changeset
|
3723 |
"Modified: 2.4.1997 / 19:36:30 / cg" |
732 | 3724 |
! ! |
3725 |
||
3726 |
!DeviceGraphicsContext methodsFor:'private'! |
|
3727 |
||
3728 |
setDevice:aDevice id:aDrawbleId gcId:aGCId |
|
3729 |
"private" |
|
3730 |
||
3731 |
device := aDevice. |
|
3732 |
gcId := aGCId. |
|
3733 |
drawableId := aDrawbleId |
|
3734 |
! |
|
3735 |
||
3736 |
setGCForPaint |
|
3737 |
"private; given a complex color (i.e. a pixmap or dithered color, |
|
3738 |
setup the GC to draw in this color. |
|
3739 |
A helper for paint and paint:on:" |
|
3740 |
||
832
064890dcfabd
fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents:
786
diff
changeset
|
3741 |
|dither map pixelId p fg bg vOrg ditherDepth deviceDepth| |
732 | 3742 |
|
3743 |
gcId notNil ifTrue:[ |
|
1742 | 3744 |
(p := paint) isColor ifTrue:[ |
2835 | 3745 |
paint := p := p onDevice:device. |
1742 | 3746 |
pixelId := p colorId. |
3747 |
pixelId notNil ifTrue:[ |
|
3748 |
" |
|
3749 |
a real (undithered) color |
|
3750 |
" |
|
3751 |
mask notNil ifTrue:[ |
|
3752 |
mask := nil. |
|
3753 |
device setBitmapMask:nil in:gcId |
|
3754 |
]. |
|
3755 |
(p ~~ foreground) ifTrue:[ |
|
3756 |
foreground := paint. |
|
3757 |
device setForeground:pixelId in:gcId |
|
3758 |
]. |
|
3759 |
^ self |
|
3760 |
]. |
|
3761 |
"a dithered color" |
|
3762 |
dither := paint ditherForm. |
|
3763 |
] ifFalse:[ |
|
3764 |
"mhmh - seems to be some kind of form ..." |
|
3765 |
paint := paint onDevice:device. |
|
3766 |
dither := paint |
|
3767 |
]. |
|
3768 |
" |
|
3769 |
a dithered color or image |
|
3770 |
" |
|
3771 |
(ditherDepth := dither depth) == 1 ifTrue:[ |
|
3772 |
"a simple 0/1 bitmap" |
|
3773 |
map := dither colorMap. |
|
3774 |
"temporary (kludgy) fix for destroyed paint" |
|
3775 |
p := paint. |
|
3776 |
map isNil ifTrue:[ |
|
3777 |
fg := Color black. |
|
3778 |
bg := Color white. |
|
3779 |
] ifFalse:[ |
|
3780 |
fg := map at:2. |
|
3781 |
bg := map at:1. |
|
3782 |
]. |
|
3783 |
self foreground:fg background:bg. |
|
3784 |
paint := p |
|
3785 |
] ifFalse:[ |
|
3786 |
deviceDepth := device depth. |
|
3787 |
(ditherDepth ~~ deviceDepth) ifTrue:[ |
|
3788 |
dither := dither asFormOn:device. |
|
3789 |
ditherDepth := dither depth. |
|
3790 |
(dither isNil or:[ditherDepth ~~ deviceDepth]) ifTrue:[ |
|
3791 |
self error:'bad dither'. |
|
3792 |
^ self |
|
3793 |
] |
|
3794 |
] |
|
3795 |
]. |
|
3796 |
self mask:dither. |
|
3797 |
vOrg := self viewOrigin. |
|
3798 |
self setMaskOriginX:vOrg x negated y:vOrg y negated. |
|
732 | 3799 |
] |
3800 |
||
3801 |
"Created: 16.5.1996 / 15:35:51 / cg" |
|
1742 | 3802 |
"Modified: 6.6.1997 / 12:55:38 / cg" |
2049 | 3803 |
! |
3804 |
||
3805 |
setId:aDrawbleId |
|
3806 |
"private" |
|
3807 |
||
3808 |
drawableId := aDrawbleId |
|
3809 |
||
3810 |
"Created: / 6.2.1998 / 12:44:45 / cg" |
|
732 | 3811 |
! ! |
3812 |
||
3813 |
!DeviceGraphicsContext methodsFor:'queries'! |
|
3814 |
||
3815 |
horizontalIntegerPixelPerMillimeter |
|
3816 |
"return the (rounded) number of pixels per millimeter" |
|
3817 |
||
3818 |
^ device horizontalPixelPerMillimeter rounded |
|
3819 |
! |
|
3820 |
||
3821 |
horizontalPixelPerInch |
|
3822 |
"return the number of horizontal pixels per inch of the display" |
|
3823 |
||
3824 |
^ device horizontalPixelPerMillimeter * 25.4 |
|
3825 |
! |
|
3826 |
||
3827 |
horizontalPixelPerMillimeter |
|
3828 |
"return the number of pixels per millimeter (not rounded)" |
|
3829 |
||
3830 |
^ device horizontalPixelPerMillimeter |
|
3831 |
! |
|
3832 |
||
3833 |
horizontalPixelPerMillimeter:millis |
|
3834 |
"return the number of pixels (not rounded) for millis millimeter" |
|
3835 |
||
3836 |
^ device horizontalPixelPerMillimeter * millis |
|
3837 |
! |
|
3838 |
||
784 | 3839 |
resolution |
3840 |
"return a point consisting of pixel-per-inch horizontally and vertically." |
|
3841 |
||
3842 |
^ device resolution |
|
3843 |
||
3844 |
"Created: 4.6.1996 / 15:23:55 / cg" |
|
3845 |
! |
|
3846 |
||
732 | 3847 |
verticalIntegerPixelPerMillimeter |
3848 |
"return the (rounded) number of pixels per millimeter" |
|
3849 |
||
3850 |
^ device verticalPixelPerMillimeter rounded |
|
3851 |
! |
|
3852 |
||
3853 |
verticalPixelPerInch |
|
3854 |
"return the number of vertical pixels per inch of the display" |
|
3855 |
||
3856 |
^ device verticalPixelPerMillimeter * 25.4 |
|
3857 |
! |
|
3858 |
||
3859 |
verticalPixelPerMillimeter |
|
3860 |
"return the number of pixels per millimeter (not rounded)" |
|
3861 |
||
3862 |
^ device verticalPixelPerMillimeter |
|
3863 |
! |
|
3864 |
||
3865 |
verticalPixelPerMillimeter:millis |
|
3866 |
"return the number of pixels (not rounded) for millis millimeter" |
|
3867 |
||
3868 |
^ device verticalPixelPerMillimeter * millis |
|
3869 |
! ! |
|
3870 |
||
1085
3513a4cae87b
handle depth1-images with a mask
Claus Gittinger <cg@exept.de>
parents:
1064
diff
changeset
|
3871 |
!DeviceGraphicsContext class methodsFor:'documentation'! |
732 | 3872 |
|
3873 |
version |
|
3880 | 3874 |
^ '$Header: /cvs/stx/stx/libview/DeviceGraphicsContext.st,v 1.88 2003-05-07 14:30:25 cg Exp $' |
732 | 3875 |
! ! |
3880 | 3876 |
|
732 | 3877 |
DeviceGraphicsContext initialize! |