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