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