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