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