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