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