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