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