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