author | Claus Gittinger <cg@exept.de> |
Thu, 16 Jan 1997 23:57:16 +0100 | |
changeset 1237 | 15848ece8b95 |
parent 1224 | 2a2270ec4236 |
child 1249 | 5224bb7a97bf |
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 |
1237 | 1845 |
mask maskId deviceForm deviceMask colorMap| |
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:[ |
|
1237 | 1857 |
'DeviceGraphicsContext [warning]: invalid form draw - ignored' errorPrintCR. |
1858 |
^ self |
|
732 | 1859 |
]. |
1860 |
gcId isNil ifTrue:[ |
|
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1861 |
self initGC |
732 | 1862 |
]. |
1863 |
||
1864 |
" |
|
1865 |
a deep form ignores paint/bgPaint settings |
|
1866 |
" |
|
1085
3513a4cae87b
handle depth1-images with a mask
Claus Gittinger <cg@exept.de>
parents:
1064
diff
changeset
|
1867 |
mask := aForm mask. |
3513a4cae87b
handle depth1-images with a mask
Claus Gittinger <cg@exept.de>
parents:
1064
diff
changeset
|
1868 |
|
3513a4cae87b
handle depth1-images with a mask
Claus Gittinger <cg@exept.de>
parents:
1064
diff
changeset
|
1869 |
((aForm depth ~~ 1) |
3513a4cae87b
handle depth1-images with a mask
Claus Gittinger <cg@exept.de>
parents:
1064
diff
changeset
|
1870 |
or:[mask notNil]) ifTrue:[ |
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1871 |
mask notNil ifTrue:[ |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1872 |
mask depth == 1 ifFalse:[ |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1873 |
'DEVGC: alpha channel not yet supported' errorPrintCR. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1874 |
] ifTrue:[ |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1875 |
deviceMask := mask asFormOn:device. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1876 |
maskId := deviceMask id. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1877 |
maskId notNil ifTrue:[ |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1878 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1879 |
create temp-form; |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1880 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1881 |
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
|
1882 |
tmpForm initGC. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1883 |
|
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 |
fill tempform with image |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1886 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1887 |
aForm depth == 1 ifTrue:[ |
1237 | 1888 |
(colorMap := aForm colorMap) notNil ifTrue:[ |
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1889 |
device |
1237 | 1890 |
setForeground:((colorMap at:2) on:device) colorId |
1891 |
background:((colorMap at:1) on:device) colorId |
|
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1892 |
in:tmpForm gcId. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1893 |
]. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1894 |
device |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1895 |
copyPlaneFromId:id |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1896 |
x:0 y:0 gc:gcId |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1897 |
to:tmpForm id |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1898 |
x:0 y:0 gc:tmpForm gcId |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1899 |
width:w height:h. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1900 |
] ifFalse:[ |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1901 |
device |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1902 |
copyFromId:id |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1903 |
x:0 y:0 gc:gcId |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1904 |
to:tmpForm id |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1905 |
x:0 y:0 gc:(tmpForm gcId) |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1906 |
width:w height:h. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1907 |
]. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1908 |
|
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1909 |
allColor := Color allColor. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1910 |
allBits := allColor colorId. |
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 |
stamp out mask in temp form |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1914 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1915 |
device setForeground:allBits background:0 in:tmpForm gcId. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1916 |
device setFunction:#and in:tmpForm gcId. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1917 |
device |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1918 |
copyPlaneFromId:maskId |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1919 |
x:0 y:0 gc:(deviceMask gcId) |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1920 |
to:tmpForm id |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1921 |
x:0 y:0 gc:tmpForm gcId |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1922 |
width:w height:h. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1923 |
|
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1924 |
|
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1925 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1926 |
stamp out mask in destination |
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 |
device setForeground:0 background:allBits in:gcId. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1929 |
device setFunction:#and in:gcId. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1930 |
device |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1931 |
copyPlaneFromId:maskId |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1932 |
x:0 y:0 gc:(deviceMask gcId) |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1933 |
to:drawableId |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1934 |
x:pX y:pY gc:gcId |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1935 |
width:w height:h. |
1237 | 1936 |
|
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1937 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1938 |
or-in tempform-bits ... |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1939 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1940 |
device setFunction:#or in:gcId. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1941 |
device |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1942 |
copyFromId:tmpForm id |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1943 |
x:0 y:0 gc:tmpForm gcId |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1944 |
to:drawableId |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1945 |
x:pX y:pY gc:gcId |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1946 |
width:w height:h. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1947 |
|
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1948 |
foreground notNil ifTrue:[ |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1949 |
device setForeground:foreground colorId in:gcId. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1950 |
]. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1951 |
background notNil ifTrue:[ |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1952 |
device setBackground:background colorId in:gcId. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1953 |
]. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1954 |
device setFunction:function in:gcId. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1955 |
^ self |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1956 |
] |
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 |
]. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1959 |
|
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1960 |
device |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1961 |
copyFromId:id |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1962 |
x:0 y:0 gc:deviceForm gcId |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1963 |
to:drawableId |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1964 |
x:pX y:pY gc:gcId |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1965 |
width:w height:h. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1966 |
^ self |
732 | 1967 |
]. |
1968 |
||
1969 |
" |
|
1970 |
the following code is somewhat complicated, since it has to deal |
|
1971 |
with dithered paint colors, which cannot be done directly on most |
|
1972 |
devices (actually, a test for the devices capabilities has to be added here) |
|
1973 |
(just assume drawing a bitmap with dithered paint color ... sigh) |
|
1974 |
" |
|
1975 |
||
1976 |
" |
|
1977 |
if paint is not a real color, we have to do it the hard way ... |
|
1978 |
" |
|
1979 |
easy := (function == #copy). |
|
1980 |
easy ifTrue:[ |
|
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1981 |
paint isColor ifFalse:[ |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1982 |
paintDither := paint. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1983 |
easy := false |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1984 |
] ifTrue:[ |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1985 |
paintDither := paint ditherForm. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1986 |
paintDither notNil ifTrue:[ |
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 |
] |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1989 |
]. |
732 | 1990 |
]. |
1991 |
||
1992 |
allColor := Color allColor. |
|
1993 |
allBits := allColor colorId. |
|
1994 |
||
1995 |
easy ifTrue:[ |
|
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1996 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1997 |
paint is a real color |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1998 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
1999 |
|
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 |
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
|
2002 |
operation ... |
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 |
fgId := paint colorId. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2005 |
|
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2006 |
((fgId ~~ ((1 bitShift:device depth)-1)) |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2007 |
and:[fgId ~~ allBits]) ifTrue:[ |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2008 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2009 |
clear fg-bits ... |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2010 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2011 |
device setForeground:0 background:allBits in:gcId. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2012 |
device setFunction:#and in:gcId. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2013 |
device |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2014 |
copyPlaneFromId:id |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2015 |
x:0 y:0 gc:(deviceForm gcId) |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2016 |
to:drawableId |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2017 |
x:pX y:pY gc:gcId |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2018 |
width:w height:h. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2019 |
]. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2020 |
|
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2021 |
fgId ~~ 0 ifTrue:[ |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2022 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2023 |
or-in fg-bits ... |
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 |
device setForeground:fgId background:0 in:gcId. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2026 |
device setFunction:#or in:gcId. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2027 |
device |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2028 |
copyPlaneFromId:id |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2029 |
x:0 y:0 gc:(deviceForm gcId) |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2030 |
to:drawableId |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2031 |
x:pX y:pY gc:gcId |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2032 |
width:w height:h |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2033 |
]. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2034 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2035 |
flush foreground/background cache |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2036 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2037 |
foreground := nil. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2038 |
background := nil. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2039 |
device setFunction:function in:gcId. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2040 |
^ self |
732 | 2041 |
]. |
2042 |
||
2043 |
||
2044 |
" |
|
2045 |
hard case; paint is a dithered color |
|
2046 |
" |
|
2047 |
||
2048 |
noColor := Color noColor. |
|
2049 |
||
2050 |
" |
|
2051 |
create temp-form; |
|
2052 |
" |
|
2053 |
tmpForm := Form width:w height:h depth:device depth on:device. |
|
2054 |
" |
|
2055 |
fill tempform |
|
2056 |
" |
|
2057 |
tmpForm paint:paint. |
|
2058 |
tmpForm fillRectangleX:0 y:0 width:w height:h. |
|
2059 |
" |
|
2060 |
stamp out background |
|
2061 |
" |
|
2062 |
tmpForm paint:allColor on:noColor. |
|
2063 |
tmpForm function:#and. |
|
976 | 2064 |
tmpForm displayOpaqueForm:deviceForm x:0 y:0. |
732 | 2065 |
" |
2066 |
stamp out foreground from destination |
|
2067 |
" |
|
2068 |
device setForeground:0 background:allBits in:gcId. |
|
2069 |
device setFunction:#and in:gcId. |
|
2070 |
device |
|
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2071 |
copyPlaneFromId:id |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2072 |
x:0 y:0 gc:(deviceForm gcId) |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2073 |
to:drawableId |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2074 |
x:pX y:pY gc:gcId |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2075 |
width:w height:h. |
732 | 2076 |
" |
2077 |
or-in temp into destination |
|
2078 |
" |
|
2079 |
device setForeground:allBits background:0 in:gcId. |
|
2080 |
device setFunction:#or in:gcId. |
|
2081 |
||
2082 |
device |
|
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2083 |
copyFromId:tmpForm id |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2084 |
x:0 y:0 gc:tmpForm gcId |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2085 |
to:drawableId |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2086 |
x:pX y:pY gc:gcId |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2087 |
width:w height:h. |
732 | 2088 |
" |
2089 |
flush foreground/background cache |
|
2090 |
" |
|
2091 |
foreground := nil. |
|
2092 |
background := nil. |
|
2093 |
device setFunction:function in:gcId. |
|
768 | 2094 |
|
1237 | 2095 |
"Modified: 16.1.1997 / 23:55:43 / cg" |
732 | 2096 |
! |
2097 |
||
2098 |
displayDeviceLineFromX:x0 y:y0 toX:x1 y:y1 |
|
2099 |
"draw a line (with current paint-color) in device coordinate space. |
|
2100 |
This ignores any transformations. The coordinates must be integers." |
|
2101 |
||
2102 |
gcId isNil ifTrue:[ |
|
2103 |
self initGC |
|
2104 |
]. |
|
2105 |
device displayLineFromX:x0 y:y0 toX:x1 y:y1 in:drawableId with:gcId |
|
2106 |
! |
|
2107 |
||
2108 |
displayDeviceOpaqueForm:aForm x:x y:y |
|
2109 |
"draw a form; if its a 1-plane bitmap, 1-bits are drawn in the |
|
2110 |
current paint-color and 0-bits in the bgPaint color. |
|
2111 |
If its a deep form (i.e. a pixmap) the current paint/bgPaint |
|
2112 |
settings are ignored and the form drawn as-is. |
|
2113 |
In the 1-plane case, special care must be taken if paint and/or bgPaint |
|
2114 |
dithered colors or patterns, since are that the colors are correctly allocated (by sending #on: |
|
2115 |
to the colors) before doing so. |
|
2116 |
The form must have been allocated on the same device. |
|
2117 |
Drawing is in device coordinates; no scaling is done." |
|
2118 |
||
2119 |
|id w h easy savedPaint bgForm fgForm tmpForm |
|
2120 |
fgId bgId noColor allColor allBits dx dy |
|
976 | 2121 |
pX pY deviceDepth deviceForm| |
732 | 2122 |
|
2123 |
w := aForm width. |
|
2124 |
h := aForm height. |
|
2125 |
||
2126 |
pX := x rounded. |
|
2127 |
pY := y rounded. |
|
2128 |
||
1033 | 2129 |
deviceForm := aForm asFormOn:device. |
976 | 2130 |
id := deviceForm id. |
732 | 2131 |
|
2132 |
"temporary ..." |
|
2133 |
(id isNil |
|
2134 |
or:[aForm graphicsDevice ~~ device]) ifTrue:[ |
|
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2135 |
deviceForm := deviceForm asFormOn:device. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2136 |
id := deviceForm id. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2137 |
id isNil ifTrue:[ |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2138 |
'DeviceGraphicsContext [warning]: invalid form draw - ignored' errorPrintCR. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2139 |
^ self |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2140 |
]. |
732 | 2141 |
]. |
2142 |
||
2143 |
gcId isNil ifTrue:[ |
|
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2144 |
self initGC |
732 | 2145 |
]. |
2146 |
||
902 | 2147 |
" |
2148 |
a deep form ignores paint/bgPaint settings |
|
2149 |
and is always drawn opaque. |
|
2150 |
" |
|
2151 |
(aForm depth ~~ 1) ifTrue:[ |
|
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2152 |
device |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2153 |
copyFromId:id |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2154 |
x:0 y:0 gc:deviceForm gcId |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2155 |
to:drawableId |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2156 |
x:pX y:pY gc:gcId |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2157 |
width:w height:h. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2158 |
^ self |
902 | 2159 |
]. |
2160 |
||
2161 |
"/ if no bgPaint is set, this is a non-opaque draw |
|
2162 |
||
2163 |
bgPaint isNil ifTrue:[ |
|
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2164 |
self displayDeviceForm:aForm x:x y:y. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2165 |
^ self |
902 | 2166 |
]. |
2167 |
||
732 | 2168 |
"the following code is somewhat complicated, since it has to deal |
2169 |
with dithered fg/bg colors, which cannot be done directly on most |
|
2170 |
devices (actually, a test for the devices capabilities has to be added here) |
|
2171 |
(just assume drawing a bitmap with dithered fg/bg colors ... sigh) |
|
2172 |
" |
|
2173 |
||
2174 |
" |
|
2175 |
if bgPaint or paint is not a real color, we have to do it the hard way ... |
|
2176 |
" |
|
2177 |
easy := true. |
|
2178 |
paint isColor ifFalse:[ |
|
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2179 |
easy := false |
732 | 2180 |
] ifTrue:[ |
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2181 |
fgId := paint colorId. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2182 |
fgId isNil ifTrue:[ |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2183 |
easy := false |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2184 |
] |
732 | 2185 |
]. |
2186 |
bgPaint isColor ifFalse:[ |
|
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2187 |
easy := false |
732 | 2188 |
] ifTrue:[ |
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2189 |
bgId := bgPaint colorId. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2190 |
bgId isNil ifTrue:[ |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2191 |
easy := false |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2192 |
] |
732 | 2193 |
]. |
2194 |
||
2195 |
easy ifTrue:[ |
|
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2196 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2197 |
easy: both paint and bgPaint are real colors |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2198 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2199 |
((foreground ~~ paint) or:[background ~~ bgPaint]) ifTrue:[ |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2200 |
device setForeground:fgId background:bgId in:gcId. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2201 |
foreground := paint. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2202 |
background := bgPaint. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2203 |
]. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2204 |
device |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2205 |
copyPlaneFromId:id |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2206 |
x:0 y:0 gc:(deviceForm gcId) |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2207 |
to:drawableId |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2208 |
x:pX y:pY gc:gcId |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2209 |
width:w height:h. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2210 |
^ self |
732 | 2211 |
]. |
2212 |
||
2213 |
" |
|
2214 |
hard case: paint and/or bgPaint are dithered or patterns |
|
2215 |
" |
|
2216 |
allColor := Color allColor. |
|
2217 |
allBits := allColor colorId. |
|
2218 |
deviceDepth := device depth. |
|
2219 |
||
2220 |
(fgId notNil and:[function == #copy]) ifTrue:[ |
|
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2221 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2222 |
only bg is dithered; fill with bg first ... |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2223 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2224 |
savedPaint := paint. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2225 |
self paint:bgPaint. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2226 |
self fillDeviceRectangleX:pX y:pY width:w height:h. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2227 |
self paint:savedPaint. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2228 |
|
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2229 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2230 |
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
|
2231 |
operation ... |
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 |
((fgId ~~ ((1 bitShift:deviceDepth)-1)) |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2234 |
and:[fgId ~~ allBits]) ifTrue:[ |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2235 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2236 |
clear fg-bits ... |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2237 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2238 |
device setForeground:0 background:allBits in:gcId. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2239 |
device setFunction:#and in:gcId. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2240 |
device |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2241 |
copyPlaneFromId:id |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2242 |
x:0 y:0 gc:(deviceForm gcId) |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2243 |
to:drawableId |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2244 |
x:pX y:pY gc:gcId |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2245 |
width:w height:h |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2246 |
]. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2247 |
|
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2248 |
fgId ~~ 0 ifTrue:[ |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2249 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2250 |
or-in fg-bits ... |
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 |
device setForeground:fgId background:0 in:gcId. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2253 |
device setFunction:#or in:gcId. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2254 |
device |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2255 |
copyPlaneFromId:id |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2256 |
x:0 y:0 gc:(deviceForm gcId) |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2257 |
to:drawableId |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2258 |
x:pX y:pY gc:gcId |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2259 |
width:w height:h |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2260 |
]. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2261 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2262 |
flush foreground/background cache |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2263 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2264 |
foreground := nil. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2265 |
background := nil. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2266 |
device setFunction:function in:gcId. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2267 |
^ self |
732 | 2268 |
]. |
2269 |
||
2270 |
(bgId notNil and:[function == #copy]) ifTrue:[ |
|
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2271 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2272 |
only fg is dithered; fill with fg first ... |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2273 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2274 |
self fillDeviceRectangleX:pX y:pY width:w height:h. |
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 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2277 |
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
|
2278 |
operation ... |
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 |
((bgId ~~ ((1 bitShift:deviceDepth)-1)) |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2281 |
and:[bgId ~~ allBits]) ifTrue:[ |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2282 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2283 |
clear bg-bits ... |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2284 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2285 |
device setForeground:allBits background:0 in:gcId. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2286 |
device setFunction:#and in:gcId. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2287 |
device |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2288 |
copyPlaneFromId:id |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2289 |
x:0 y:0 gc:(deviceForm gcId) |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2290 |
to:drawableId |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2291 |
x:pX y:pY gc:gcId |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2292 |
width:w height:h |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2293 |
]. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2294 |
|
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2295 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2296 |
or-in bg-bits ... |
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 |
bgId ~~ 0 ifTrue:[ |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2299 |
device setForeground:0 background:bgId in:gcId. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2300 |
device setFunction:#or in:gcId. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2301 |
device |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2302 |
copyPlaneFromId:id |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2303 |
x:0 y:0 gc:(deviceForm gcId) |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2304 |
to:drawableId |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2305 |
x:pX y:pY gc:gcId |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2306 |
width:w height:h |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2307 |
]. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2308 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2309 |
flush foreground/background cache |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2310 |
" |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2311 |
foreground := nil. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2312 |
background := nil. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2313 |
device setFunction:function in:gcId. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2314 |
^ self |
732 | 2315 |
]. |
2316 |
||
2317 |
" |
|
2318 |
very hard case; both fg and bg are dithered colors |
|
2319 |
" |
|
2320 |
noColor := Color noColor. |
|
2321 |
||
2322 |
" |
|
2323 |
create temp-forms; |
|
2324 |
" |
|
2325 |
bgForm := Form width:w height:h depth:deviceDepth on:device. |
|
2326 |
fgForm := Form width:w height:h depth:deviceDepth on:device. |
|
2327 |
tmpForm := Form width:w height:h depth:deviceDepth on:device. |
|
2328 |
||
2329 |
" |
|
2330 |
fill |
|
2331 |
" |
|
2332 |
dx := dy := 0. |
|
2333 |
maskOrigin notNil ifTrue:[ |
|
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2334 |
dx := maskOrigin x. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2335 |
dy := maskOrigin y |
732 | 2336 |
]. |
2337 |
||
2338 |
bgForm paint:bgPaint. |
|
2339 |
bgForm setMaskOriginX:(x negated + dx) y:(y negated + dy). |
|
2340 |
bgForm fillRectangleX:0 y:0 width:w height:h. |
|
2341 |
fgForm paint:paint. |
|
2342 |
fgForm setMaskOriginX:(x negated + dx) y:(y negated + dy). |
|
2343 |
fgForm fillRectangleX:0 y:0 width:w height:h. |
|
2344 |
||
2345 |
" |
|
2346 |
stamp-out background |
|
2347 |
" |
|
2348 |
bgForm paint:noColor on:allColor. |
|
2349 |
bgForm function:#and. |
|
976 | 2350 |
bgForm displayOpaqueForm:deviceForm x:0 y:0. |
732 | 2351 |
|
2352 |
" |
|
2353 |
stamp-out foreground |
|
2354 |
" |
|
2355 |
fgForm paint:allColor on:noColor. |
|
2356 |
fgForm function:#and. |
|
976 | 2357 |
fgForm displayOpaqueForm:deviceForm x:0 y:0. |
732 | 2358 |
|
2359 |
" |
|
2360 |
clear tempform |
|
2361 |
" |
|
2362 |
tmpForm paint:noColor. |
|
2363 |
tmpForm fillRectangleX:0 y:0 width:w height:h. |
|
2364 |
||
2365 |
" |
|
2366 |
merge fg-temp and bg-temp into tmp |
|
2367 |
" |
|
2368 |
tmpForm function:#or. |
|
2369 |
tmpForm paint:noColor on:allColor. |
|
2370 |
tmpForm copyFrom:fgForm x:0 y:0 toX:0 y:0 width:w height:h. |
|
2371 |
tmpForm copyFrom:bgForm x:0 y:0 toX:0 y:0 width:w height:h. |
|
2372 |
||
2373 |
" |
|
2374 |
finally, draw it |
|
2375 |
" |
|
2376 |
device setForeground:0 background:allBits in:gcId. |
|
2377 |
device |
|
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2378 |
copyFromId:tmpForm id |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2379 |
x:0 y:0 gc:tmpForm gcId |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2380 |
to:drawableId |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2381 |
x:pX y:pY gc:gcId |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2382 |
width:w height:h. |
732 | 2383 |
" |
2384 |
flush foreground/background cache |
|
2385 |
" |
|
2386 |
foreground := nil. |
|
2387 |
background := nil. |
|
868 | 2388 |
|
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
2389 |
"Modified: 10.1.1997 / 17:46:23 / cg" |
732 | 2390 |
! |
2391 |
||
2392 |
displayDeviceOpaqueString:aString from:index1 to:index2 in:font x:x y:y |
|
2393 |
"draw a substring at the coordinate x/y - draw foreground pixels in |
|
2394 |
paint-color and background pixels in bgPaint-color. |
|
2395 |
Assuming that device can only draw in device colors, we have to handle |
|
2396 |
the case where paint and/or bgPaint are dithered colors. |
|
2397 |
No translation or scaling is done." |
|
2398 |
||
2399 |
|easy w h savedPaint fgId bgId allColor allBits noColor |
|
2400 |
id bgForm fgForm tmpForm maskForm dx dy pX pY fontUsed s |
|
2401 |
deviceDepth| |
|
2402 |
||
2403 |
" |
|
2404 |
if backgroundPaint color is nil, we assume |
|
2405 |
this is a non-opaque draw |
|
2406 |
" |
|
2407 |
bgPaint isNil ifTrue:[ |
|
1029
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2408 |
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
|
2409 |
^ self |
732 | 2410 |
]. |
2411 |
||
2412 |
(aString isString not |
|
2413 |
or:[aString isText]) ifTrue:[ |
|
1029
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2414 |
" |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2415 |
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
|
2416 |
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
|
2417 |
" |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2418 |
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
|
2419 |
^ self |
732 | 2420 |
]. |
2421 |
||
2422 |
gcId isNil ifTrue:[ |
|
1029
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2423 |
self initGC |
732 | 2424 |
]. |
2425 |
||
2426 |
pX := x rounded. |
|
2427 |
pY := y rounded. |
|
2428 |
||
2429 |
fontUsed := font on:device. |
|
2430 |
||
2431 |
id := fontUsed fontId. |
|
2432 |
id isNil ifTrue:[ |
|
1029
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2433 |
" |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2434 |
hook for alien fonts |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2435 |
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
|
2436 |
" |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2437 |
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
|
2438 |
^ self |
732 | 2439 |
]. |
2440 |
||
2441 |
s := aString. |
|
2442 |
s encoding ~~ font encoding ifTrue:[ |
|
1029
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2443 |
s := s encodeInto:(font encoding). |
732 | 2444 |
]. |
2445 |
||
2446 |
deviceFont ~~ fontUsed ifTrue:[ |
|
1029
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2447 |
device setFont:id in:gcId. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2448 |
deviceFont := fontUsed |
732 | 2449 |
]. |
2450 |
||
2451 |
" |
|
2452 |
if bgPaint or paint is not a real Color, we have to do it the hard way ... |
|
2453 |
" |
|
2454 |
easy := true. |
|
2455 |
paint isColor ifFalse:[ |
|
1029
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2456 |
easy := false |
732 | 2457 |
] ifTrue:[ |
1029
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2458 |
fgId := paint colorId. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2459 |
fgId isNil ifTrue:[ |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2460 |
easy := false |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2461 |
] |
732 | 2462 |
]. |
2463 |
bgPaint isColor ifFalse:[ |
|
1029
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2464 |
easy := false |
732 | 2465 |
] ifTrue:[ |
1029
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2466 |
bgId := bgPaint colorId. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2467 |
bgId isNil ifTrue:[ |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2468 |
easy := false |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2469 |
] |
732 | 2470 |
]. |
2471 |
||
2472 |
easy ifTrue:[ |
|
1029
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2473 |
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
|
2474 |
foreground := paint. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2475 |
background := bgPaint. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2476 |
device displayOpaqueString:s |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2477 |
from:index1 to:index2 |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2478 |
x:pX y:pY |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2479 |
in:drawableId with:gcId. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2480 |
^ self |
732 | 2481 |
]. |
2482 |
||
2483 |
w := fontUsed widthOf:s from:index1 to:index2. |
|
2484 |
h := fontUsed height. |
|
2485 |
||
2486 |
(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
|
2487 |
" |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2488 |
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
|
2489 |
" |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2490 |
savedPaint := paint. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2491 |
self paint:bgPaint. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2492 |
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
|
2493 |
self paint:savedPaint. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2494 |
|
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2495 |
" |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2496 |
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
|
2497 |
" |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2498 |
device displayString:s |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2499 |
from:index1 to:index2 |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2500 |
x:pX y:pY |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2501 |
in:drawableId with:gcId. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2502 |
^ self |
732 | 2503 |
]. |
2504 |
||
2505 |
allColor := Color allColor. |
|
2506 |
allBits := allColor colorId. |
|
2507 |
||
2508 |
deviceDepth := device depth. |
|
2509 |
||
2510 |
" |
|
2511 |
the code below is correct, but some (all?) implementations of the |
|
2512 |
X Window system seem to not support ALU-functions when drawing opaque strings. |
|
2513 |
Therefore we use the slower code below. |
|
2514 |
" |
|
2515 |
||
2516 |
"/ (bgId notNil and:[function == #copy]) ifTrue:[ |
|
2517 |
"/ " |
|
2518 |
"/ only fg is dithered; fill with fg first ... |
|
2519 |
"/ " |
|
2520 |
"/ self fillRectangleX:pX y:(pY - fontUsed ascent) width:w height:h. |
|
2521 |
"/ |
|
2522 |
"/ " |
|
2523 |
"/ if bgPaint color is all-0 or all-1's, we can do it in one |
|
2524 |
"/ operation ... |
|
2525 |
"/ " |
|
2526 |
"/ ((bgId ~~ ((1 bitShift:deviceDepth)-1)) |
|
2527 |
"/ and:[bgId ~~ allBits]) ifTrue:[ |
|
2528 |
"/ " |
|
2529 |
"/ clear bg bits ... |
|
2530 |
"/ " |
|
2531 |
"/ device setForeground:allBits background:0 in:gcId. |
|
2532 |
"/ device setFunction:#and in:gcId. |
|
2533 |
"/ device displayOpaqueString:s |
|
2534 |
"/ from:index1 to:index2 |
|
2535 |
"/ x:pX y:pY |
|
2536 |
"/ in:drawableId with:gcId. |
|
2537 |
"/ ]. |
|
2538 |
"/ |
|
2539 |
"/ " |
|
2540 |
"/ or-in bg bits ... |
|
2541 |
"/ " |
|
2542 |
"/ bgId ~~ 0 ifTrue:[ |
|
2543 |
"/ device setForeground:0 background:bgId in:gcId. |
|
2544 |
"/ device setFunction:#or in:gcId. |
|
2545 |
"/ device displayOpaqueString:s |
|
2546 |
"/ from:index1 to:index2 |
|
2547 |
"/ x:pX y:pY |
|
2548 |
"/ in:drawableId with:gcId. |
|
2549 |
"/ ]. |
|
2550 |
"/ " |
|
2551 |
"/ flush foreground/background cache |
|
2552 |
"/ " |
|
2553 |
"/ foreground := nil. |
|
2554 |
"/ background := nil. |
|
2555 |
"/ device setFunction:function in:gcId. |
|
2556 |
"/ ^ self |
|
2557 |
"/ ]. |
|
2558 |
||
768 | 2559 |
(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
|
2560 |
" |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2561 |
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
|
2562 |
" |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2563 |
device setForeground:bgId in:gcId. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2564 |
device setFunction:#copy in:gcId. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2565 |
device setBitmapMask:nil in:gcId. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2566 |
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
|
2567 |
|
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2568 |
"/ draw fg dithered |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2569 |
(mask depth == 1) ifTrue:[ |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2570 |
device setBitmapMask:mask id in:gcId. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2571 |
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
|
2572 |
] ifFalse:[ |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2573 |
device setPixmapMask:mask id in:gcId |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2574 |
]. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2575 |
|
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2576 |
device displayString:s |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2577 |
from:index1 to:index2 |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2578 |
x:pX y:pY |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2579 |
in:drawableId with:gcId. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2580 |
^ self. |
768 | 2581 |
"/ |
2582 |
"/ " |
|
2583 |
"/ if bgPaint color is all-0 or all-1's, we can do it in one |
|
2584 |
"/ operation ... |
|
2585 |
"/ " |
|
2586 |
"/ ((bgId ~~ ((1 bitShift:deviceDepth)-1)) |
|
2587 |
"/ and:[bgId ~~ allBits]) ifTrue:[ |
|
2588 |
"/ " |
|
2589 |
"/ clear bg bits ... |
|
2590 |
"/ " |
|
2591 |
"/ device setForeground:allBits background:0 in:gcId. |
|
2592 |
"/ device setFunction:#and in:gcId. |
|
2593 |
"/ device displayOpaqueString:s |
|
2594 |
"/ from:index1 to:index2 |
|
2595 |
"/ x:pX y:pY |
|
2596 |
"/ in:drawableId with:gcId. |
|
2597 |
"/ ]. |
|
2598 |
"/ |
|
2599 |
"/ " |
|
2600 |
"/ or-in bg bits ... |
|
2601 |
"/ " |
|
2602 |
"/ bgId ~~ 0 ifTrue:[ |
|
2603 |
"/ device setForeground:0 background:bgId in:gcId. |
|
2604 |
"/ device setFunction:#or in:gcId. |
|
2605 |
"/ device displayOpaqueString:s |
|
2606 |
"/ from:index1 to:index2 |
|
2607 |
"/ x:pX y:pY |
|
2608 |
"/ in:drawableId with:gcId. |
|
2609 |
"/ ]. |
|
2610 |
"/ " |
|
2611 |
"/ flush foreground/background cache |
|
2612 |
"/ " |
|
2613 |
"/ foreground := nil. |
|
2614 |
"/ background := nil. |
|
2615 |
"/ device setFunction:function in:gcId. |
|
2616 |
"/ ^ self |
|
832
064890dcfabd
fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents:
786
diff
changeset
|
2617 |
]. |
064890dcfabd
fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents:
786
diff
changeset
|
2618 |
|
732 | 2619 |
" |
832
064890dcfabd
fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents:
786
diff
changeset
|
2620 |
very hard case, both fg and bg are dithered colors/images |
732 | 2621 |
" |
2622 |
noColor := Color noColor. |
|
832
064890dcfabd
fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents:
786
diff
changeset
|
2623 |
"/ 'hard: ' print. aString print. ' ' print. paint print. ' ' print. bgPaint printCR. |
732 | 2624 |
" |
2625 |
create temp-forms; |
|
2626 |
" |
|
2627 |
bgForm := Form width:w height:h depth:deviceDepth on:device. |
|
2628 |
fgForm := Form width:w height:h depth:deviceDepth on:device. |
|
2629 |
tmpForm := Form width:w height:h depth:deviceDepth on:device. |
|
2630 |
maskForm := Form width:w height:h depth:deviceDepth on:device. |
|
2631 |
||
2632 |
" |
|
2633 |
fill |
|
2634 |
" |
|
2635 |
dx := 0. |
|
2636 |
dy := fontUsed ascent. |
|
2637 |
maskOrigin notNil ifTrue:[ |
|
1029
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2638 |
dx := maskOrigin x. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2639 |
dy := dy + maskOrigin y |
732 | 2640 |
]. |
2641 |
||
2642 |
bgForm paint:bgPaint. |
|
2643 |
bgForm setMaskOriginX:(pX negated + dx) y:(pY negated + dy). |
|
2644 |
bgForm fillRectangleX:0 y:0 width:w height:h. |
|
2645 |
||
2646 |
fgForm paint:paint. |
|
2647 |
fgForm setMaskOriginX:(pX negated + dx) y:(pY negated + dy). |
|
2648 |
fgForm fillRectangleX:0 y:0 width:w height:h. |
|
2649 |
||
2650 |
" |
|
2651 |
stamp-out background (have now bg-bits with fg=0 in bgForm) |
|
2652 |
" |
|
2653 |
bgForm font:fontUsed. |
|
2654 |
bgForm paint:noColor on:allColor. |
|
2655 |
bgForm function:#and. |
|
2656 |
bgForm displayString:s |
|
1029
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2657 |
from:index1 to:index2 |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2658 |
x:0 y:fontUsed ascent. |
732 | 2659 |
|
2660 |
" |
|
2661 |
stamp-out foreground |
|
2662 |
" |
|
2663 |
maskForm font:fontUsed. |
|
2664 |
maskForm paint:allColor on:noColor. |
|
2665 |
maskForm displayOpaqueString:s |
|
1029
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2666 |
from:index1 to:index2 |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2667 |
x:0 y:fontUsed ascent. |
732 | 2668 |
|
2669 |
fgForm function:#and. |
|
2670 |
fgForm copyFrom:maskForm x:0 y:0 toX:0 y:0 width:w height:h. |
|
2671 |
||
2672 |
" |
|
2673 |
clear tempform |
|
2674 |
" |
|
2675 |
tmpForm paint:noColor. |
|
2676 |
tmpForm fillRectangleX:0 y:0 width:w height:h. |
|
2677 |
||
2678 |
" |
|
2679 |
merge fg-temp and bg-temp into tmp |
|
2680 |
" |
|
2681 |
tmpForm function:#or. |
|
2682 |
tmpForm paint:noColor on:allColor. |
|
2683 |
tmpForm copyFrom:fgForm x:0 y:0 toX:0 y:0 width:w height:h. |
|
2684 |
tmpForm copyFrom:bgForm x:0 y:0 toX:0 y:0 width:w height:h. |
|
2685 |
" |
|
2686 |
finally, draw it |
|
2687 |
" |
|
2688 |
device setForeground:0 background:allBits in:gcId. |
|
2689 |
device |
|
1029
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2690 |
copyFromId:tmpForm id |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2691 |
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
|
2692 |
to:drawableId |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2693 |
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
|
2694 |
width:w height:h. |
732 | 2695 |
" |
2696 |
flush foreground/background cache |
|
2697 |
" |
|
2698 |
foreground := nil. |
|
2699 |
background := nil. |
|
2700 |
||
832
064890dcfabd
fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents:
786
diff
changeset
|
2701 |
"Modified: 12.6.1996 / 12:50:12 / cg" |
732 | 2702 |
! |
2703 |
||
2704 |
displayDeviceOpaqueString:aString from:index1 to:index2 x:x y:y |
|
2705 |
"draw a substring at the coordinate x/y - draw foreground pixels in |
|
2706 |
paint-color and background pixels in bgPaint-color. |
|
2707 |
Assuming that device can only draw in device colors, we have to handle |
|
2708 |
the case where paint and/or bgPaint are dithered colors. |
|
2709 |
No translation or scaling is done." |
|
2710 |
||
2711 |
self displayDeviceOpaqueString:aString from:index1 to:index2 in:font x:x y:y |
|
2712 |
! |
|
2713 |
||
2714 |
displayDeviceOpaqueString:aString x:x y:y |
|
2715 |
"draw a string at the coordinate x/y - draw foreground pixels in |
|
2716 |
paint-color and background pixels in bgPaint-color. |
|
2717 |
No translation or scaling is done" |
|
2718 |
||
2719 |
self displayDeviceOpaqueString:aString from:1 to:(aString size) in:font x:x y:y |
|
2720 |
! |
|
2721 |
||
2722 |
displayDeviceString:aString from:index1 to:index2 in:font x:x y:y |
|
2723 |
"draw a substring at the coordinate x/y - |
|
2724 |
draw foreground-pixels only (in current paint-color), leaving background as-is. |
|
2725 |
No translation or scaling is done" |
|
2726 |
||
2727 |
|id pX pY fontUsed s| |
|
2728 |
||
2729 |
" |
|
2730 |
hook for non-strings (i.e. attributed text) |
|
2731 |
" |
|
2732 |
(aString isString not |
|
2733 |
or:[aString isText]) ifTrue:[ |
|
1029
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2734 |
^ aString displayOn:self x:x y:y from:index1 to:index2 |
732 | 2735 |
]. |
2736 |
||
2737 |
gcId isNil ifTrue:[ |
|
1029
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2738 |
self initGC |
732 | 2739 |
]. |
2740 |
||
2741 |
pX := x rounded. |
|
2742 |
pY := y rounded. |
|
2743 |
||
2744 |
fontUsed := font on:device. |
|
2745 |
||
2746 |
id := fontUsed fontId. |
|
2747 |
id isNil ifTrue:[ |
|
1029
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2748 |
"hook for alien fonts" |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2749 |
font displayString:aString from:index1 to:index2 x:x y:y in:self |
732 | 2750 |
] ifFalse:[ |
1029
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2751 |
s := aString. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2752 |
s encoding ~~ font encoding ifTrue:[ |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2753 |
s := s encodeInto:(font encoding). |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2754 |
]. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2755 |
|
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2756 |
deviceFont ~~ fontUsed ifTrue:[ |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2757 |
device setFont:id in:gcId. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2758 |
deviceFont := fontUsed |
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 |
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
|
2761 |
x:pX y:pY in:drawableId with:gcId |
732 | 2762 |
] |
2763 |
||
2764 |
"Modified: 12.5.1996 / 17:49:22 / cg" |
|
2765 |
! |
|
2766 |
||
2767 |
displayDeviceString:aString from:index1 to:index2 x:x y:y |
|
2768 |
"draw a substring at the coordinate x/y - |
|
2769 |
draw foreground-pixels only (in current paint-color), leaving background as-is. |
|
2770 |
No translation or scaling is done" |
|
2771 |
||
2772 |
self displayDeviceString:aString from:index1 to:index2 in:font x:x y:y |
|
2773 |
! |
|
2774 |
||
2775 |
displayDeviceString:aString x:x y:y |
|
2776 |
"draw a string at the coordinate x/y - |
|
2777 |
draw foreground-pixels only (in current paint-color), leaving background as-is. |
|
2778 |
No translation or scaling is done" |
|
2779 |
||
2780 |
self displayDeviceString:aString from:1 to:(aString size) in:font x:x y:y |
|
2781 |
! |
|
2782 |
||
2783 |
fillDeviceRectangleX:x y:y width:w height:h |
|
2784 |
"draw a filled rectangle in device coordinate space. |
|
2785 |
This ignores any transformations. The coordinates must be integers." |
|
2786 |
||
2787 |
gcId isNil ifTrue:[ |
|
2788 |
self initGC |
|
2789 |
]. |
|
2790 |
device |
|
2791 |
fillRectangleX:x |
|
2792 |
y:y |
|
2793 |
width:w |
|
2794 |
height:h |
|
2795 |
in:drawableId with:gcId |
|
2796 |
! ! |
|
2797 |
||
2798 |
!DeviceGraphicsContext methodsFor:'evaluating in another context'! |
|
2799 |
||
2800 |
reverseDo:aBlock |
|
2801 |
"evaluate aBlock with foreground and background interchanged. |
|
2802 |
This can be reimplemented here in a faster way." |
|
2803 |
||
2804 |
|oldFg oldBg| |
|
2805 |
||
2806 |
oldFg := foreground on:device. |
|
2807 |
oldBg := background on:device. |
|
2808 |
self foreground:background background:foreground. |
|
2809 |
aBlock value. |
|
2810 |
self foreground:oldFg background:oldBg |
|
2811 |
! |
|
2812 |
||
2813 |
withBackground:fgColor do:aBlock |
|
2814 |
"evaluate aBlock with changed background." |
|
2815 |
||
2816 |
|oldBg| |
|
2817 |
||
2818 |
oldBg := background. |
|
2819 |
self background:fgColor. |
|
2820 |
aBlock value. |
|
2821 |
self background:oldBg |
|
2822 |
! |
|
2823 |
||
2824 |
withForeground:fgColor background:bgColor do:aBlock |
|
2825 |
"evaluate aBlock with changed foreground and background." |
|
2826 |
||
2827 |
|oldFg oldBg| |
|
2828 |
||
2829 |
oldFg := foreground. |
|
2830 |
oldBg := background. |
|
2831 |
self foreground:fgColor background:bgColor. |
|
2832 |
aBlock value. |
|
2833 |
self foreground:oldFg background:oldBg |
|
2834 |
! |
|
2835 |
||
2836 |
withForeground:fgColor background:bgColor function:aFunction do:aBlock |
|
2837 |
"evaluate aBlock with foreground, background and function" |
|
2838 |
||
2839 |
|oldFg oldBg oldFun| |
|
2840 |
||
2841 |
oldFg := foreground. |
|
2842 |
oldBg := background. |
|
2843 |
oldFun := function. |
|
2844 |
self foreground:fgColor background:bgColor function:aFunction. |
|
2845 |
aBlock value. |
|
2846 |
self foreground:oldFg background:oldBg function:oldFun |
|
2847 |
! |
|
2848 |
||
2849 |
withForeground:fgColor background:bgColor mask:aMask do:aBlock |
|
2850 |
"evaluate aBlock with foreground, background and mask" |
|
2851 |
||
2852 |
|oldFg oldBg oldMask| |
|
2853 |
||
2854 |
oldFg := foreground. |
|
2855 |
oldBg := background. |
|
2856 |
oldMask := mask. |
|
2857 |
self foreground:fgColor background:bgColor. |
|
2858 |
self mask:aMask. |
|
2859 |
aBlock value. |
|
2860 |
self foreground:oldFg background:oldBg. |
|
2861 |
self mask:oldMask |
|
2862 |
! |
|
2863 |
||
2864 |
withForeground:fgColor do:aBlock |
|
2865 |
"evaluate aBlock with changed foreground." |
|
2866 |
||
2867 |
|oldFg| |
|
2868 |
||
2869 |
oldFg := foreground. |
|
2870 |
self foreground:fgColor. |
|
2871 |
aBlock value. |
|
2872 |
self foreground:oldFg |
|
2873 |
! |
|
2874 |
||
2875 |
withForeground:fgColor function:aFunction do:aBlock |
|
2876 |
"evaluate aBlock with changed foreground and function." |
|
2877 |
||
2878 |
|oldFg oldFun| |
|
2879 |
||
2880 |
oldFg := foreground. |
|
2881 |
oldFun := function. |
|
2882 |
self foreground:fgColor background:background function:aFunction. |
|
2883 |
aBlock value. |
|
2884 |
self foreground:oldFg background:background function:oldFun |
|
2885 |
! |
|
2886 |
||
2887 |
xoring:aBlock |
|
2888 |
"evaluate aBlock with function xoring" |
|
2889 |
||
2890 |
|fgPixel bgPixel oldFunction| |
|
2891 |
||
1199
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
2892 |
fgPixel := device blackColor colorId. |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
2893 |
bgPixel := device whiteColor colorId. |
732 | 2894 |
|
2895 |
gcId isNil ifTrue:[ |
|
1199
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
2896 |
self initGC |
732 | 2897 |
]. |
2898 |
oldFunction := function. |
|
2899 |
device setForeground:(fgPixel bitXor:bgPixel) |
|
1199
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
2900 |
background:bgPixel |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
2901 |
in:gcId. |
732 | 2902 |
device setFunction:#xor in:gcId. |
2903 |
aBlock value. |
|
2904 |
paint := nil. "invalidate" |
|
1199
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
2905 |
foreground := device blackColor. |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
2906 |
background := device whiteColor. |
732 | 2907 |
device setForeground:fgPixel |
1199
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
2908 |
background:bgPixel |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
2909 |
in:gcId. |
732 | 2910 |
device setFunction:oldFunction in:gcId. |
2911 |
function := oldFunction |
|
1199
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
2912 |
|
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
2913 |
"Modified: 13.1.1997 / 23:03:20 / cg" |
732 | 2914 |
! ! |
2915 |
||
2916 |
!DeviceGraphicsContext methodsFor:'filling'! |
|
2917 |
||
2918 |
fillArcX:x y:y width:w height:h from:startAngle angle:angle |
|
2919 |
"draw a filled arc; apply transformation if nonNil" |
|
2920 |
||
1064 | 2921 |
|pX pY nW nH| |
732 | 2922 |
|
2923 |
gcId isNil ifTrue:[ |
|
1029
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2924 |
self initGC |
732 | 2925 |
]. |
2926 |
transformation notNil ifTrue:[ |
|
1029
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2927 |
pX := transformation applyToX:x. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2928 |
pY := transformation applyToY:y. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2929 |
nW := transformation applyScaleX:w. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2930 |
nH := transformation applyScaleY:h. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2931 |
nW < 0 ifTrue:[ |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2932 |
nW := nW abs. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2933 |
pX := pX - nW. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2934 |
]. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2935 |
nH < 0 ifTrue:[ |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2936 |
nH := nH abs. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2937 |
pY := pY - nH. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2938 |
]. |
732 | 2939 |
] ifFalse:[ |
1029
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2940 |
pX := x. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2941 |
pY := y. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2942 |
nW := w. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2943 |
nH := h. |
732 | 2944 |
]. |
2945 |
||
2946 |
pX := pX rounded. |
|
2947 |
pY := pY rounded. |
|
2948 |
nW := nW rounded. |
|
2949 |
nH := nH rounded. |
|
2950 |
||
2951 |
device |
|
1029
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2952 |
fillArcX:pX |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2953 |
y:pY |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2954 |
width:nW |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2955 |
height:nH |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2956 |
from:startAngle |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2957 |
angle:angle |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2958 |
in:drawableId |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2959 |
with:gcId |
732 | 2960 |
|
2961 |
"Created: 8.5.1996 / 08:29:45 / cg" |
|
784 | 2962 |
"Modified: 4.6.1996 / 17:58:21 / cg" |
732 | 2963 |
! |
2964 |
||
2965 |
fillPolygon:aPolygon |
|
2966 |
"draw a filled polygon; apply transformation if nonNil" |
|
2967 |
||
2968 |
|newPolygon| |
|
2969 |
||
2970 |
gcId isNil ifTrue:[ |
|
2971 |
self initGC |
|
2972 |
]. |
|
2973 |
transformation notNil ifTrue:[ |
|
2974 |
newPolygon := aPolygon collect:[:point | transformation applyTo:point]. |
|
2975 |
] ifFalse:[ |
|
2976 |
newPolygon := aPolygon |
|
2977 |
]. |
|
2978 |
(newPolygon findFirst:[:p | |
|
2979 |
(p isPoint not |
|
2980 |
or:[(p x class ~~ SmallInteger) |
|
2981 |
or:[(p y class ~~ SmallInteger)]]) |
|
2982 |
]) ~~ 0 ifTrue:[ |
|
2983 |
newPolygon := newPolygon collect:[:p | p asPoint rounded] |
|
2984 |
]. |
|
2985 |
device |
|
2986 |
fillPolygon:newPolygon |
|
2987 |
in:drawableId |
|
2988 |
with:gcId |
|
2989 |
! |
|
2990 |
||
2991 |
fillRectangleX:x y:y width:w height:h |
|
2992 |
"draw a filled rectangle; apply transformation if nonNil" |
|
2993 |
||
1064 | 2994 |
|pX pY nW nH| |
732 | 2995 |
|
2996 |
gcId isNil ifTrue:[ |
|
1029
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
2997 |
self initGC |
732 | 2998 |
]. |
2999 |
transformation notNil ifTrue:[ |
|
1029
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3000 |
pX := transformation applyToX:x. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3001 |
pY := transformation applyToY:y. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3002 |
nW := transformation applyScaleX:w. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3003 |
nH := transformation applyScaleY:h. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3004 |
nW < 0 ifTrue:[ |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3005 |
nW := nW abs. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3006 |
pX := pX - nW. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3007 |
]. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3008 |
nH < 0 ifTrue:[ |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3009 |
nH := nH abs. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3010 |
pY := pY - nH. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3011 |
]. |
732 | 3012 |
] ifFalse:[ |
1029
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3013 |
pX := x. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3014 |
pY := y. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3015 |
nW := w. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3016 |
nH := h. |
732 | 3017 |
]. |
3018 |
pX := pX rounded. |
|
3019 |
pY := pY rounded. |
|
3020 |
nW := nW rounded. |
|
3021 |
nH := nH rounded. |
|
3022 |
||
3023 |
device |
|
1029
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3024 |
fillRectangleX:pX |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3025 |
y:pY |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3026 |
width:nW |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3027 |
height:nH |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3028 |
in:drawableId with:gcId |
784 | 3029 |
|
3030 |
"Modified: 4.6.1996 / 17:58:49 / cg" |
|
732 | 3031 |
! ! |
3032 |
||
3033 |
!DeviceGraphicsContext methodsFor:'initialization'! |
|
3034 |
||
3035 |
createGC |
|
3036 |
"since we do not need a gc-object for the drawable until something is |
|
3037 |
really drawn, none is created. |
|
3038 |
This method is sent, when the first drawing happens" |
|
3039 |
||
1138
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1094
diff
changeset
|
3040 |
gcId := device gcFor:drawableId. |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1094
diff
changeset
|
3041 |
Lobby registerChange:self. |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1094
diff
changeset
|
3042 |
! |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1094
diff
changeset
|
3043 |
|
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1094
diff
changeset
|
3044 |
destroy |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1094
diff
changeset
|
3045 |
"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
|
3046 |
|
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1094
diff
changeset
|
3047 |
gcId notNil ifTrue:[ |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1094
diff
changeset
|
3048 |
device destroyGC:gcId. |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1094
diff
changeset
|
3049 |
gcId := nil. |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1094
diff
changeset
|
3050 |
Lobby registerChange:self. |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1094
diff
changeset
|
3051 |
] |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1094
diff
changeset
|
3052 |
! |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1094
diff
changeset
|
3053 |
|
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1094
diff
changeset
|
3054 |
initGC |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1094
diff
changeset
|
3055 |
"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
|
3056 |
really drawn, none is created. |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1094
diff
changeset
|
3057 |
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
|
3058 |
|
732 | 3059 |
|fgId bgId p| |
3060 |
||
1138
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1094
diff
changeset
|
3061 |
self createGC. |
732 | 3062 |
|
1199
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3063 |
foreground isNil ifTrue:[foreground := device blackColor]. |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3064 |
background isNil ifTrue:[background := device whiteColor]. |
732 | 3065 |
|
3066 |
foreground isColor ifTrue:[ |
|
1199
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3067 |
"get device colors from the device indep. colors" |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3068 |
foreground := foreground on:device. |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3069 |
fgId := foreground colorId. |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3070 |
fgId isNil ifTrue:[ |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3071 |
(foreground grayIntensity >= 50) ifTrue:[ |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3072 |
fgId := device whitepixel |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3073 |
] ifFalse:[ |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3074 |
fgId := device blackpixel |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3075 |
] |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3076 |
]. |
732 | 3077 |
] ifFalse:[ |
1199
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3078 |
fgId := device blackpixel. |
732 | 3079 |
]. |
3080 |
||
3081 |
background isColor ifTrue:[ |
|
1199
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3082 |
background := background on:device. |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3083 |
bgId := background colorId. |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3084 |
bgId isNil ifTrue:[ |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3085 |
(background grayIntensity >= 50) ifTrue:[ |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3086 |
bgId := device whitepixel |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3087 |
] ifFalse:[ |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3088 |
bgId := device blackpixel |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3089 |
] |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3090 |
]. |
732 | 3091 |
] ifFalse:[ |
1199
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3092 |
bgId := device whitepixel |
732 | 3093 |
]. |
3094 |
||
3095 |
"now, this is something the device can work with ..." |
|
3096 |
device setForeground:fgId background:bgId in:gcId. |
|
3097 |
||
3098 |
"switch to paint" |
|
3099 |
p := paint. |
|
3100 |
paint := nil. |
|
3101 |
self paint:p. |
|
3102 |
||
3103 |
((lineWidth ~~ 0) |
|
3104 |
or:[(lineStyle ~~ #solid) |
|
3105 |
or:[(capStyle ~~ #butt) |
|
3106 |
or:[joinStyle ~~ #miter]]]) ifTrue:[ |
|
1199
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3107 |
device setLineWidth:lineWidth |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3108 |
style:lineStyle |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3109 |
cap:capStyle |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3110 |
join:joinStyle |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3111 |
in:gcId |
732 | 3112 |
]. |
3113 |
||
3114 |
mask notNil ifTrue:[ |
|
1199
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3115 |
(mask depth == 1) ifTrue:[ |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3116 |
device setBitmapMask:(mask id) in:gcId |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3117 |
] ifFalse:[ |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3118 |
device setPixmapMask:(mask id) in:gcId |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3119 |
]. |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3120 |
maskOrigin notNil ifTrue:[ |
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3121 |
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
|
3122 |
] |
732 | 3123 |
]. |
3124 |
(function ~~ #copy) ifTrue:[device setFunction:function in:gcId]. |
|
3125 |
||
3126 |
"defer the getting of a device font |
|
3127 |
- this is now done when the first drawstring occurs, |
|
3128 |
since many views (layout-views) will never draw strings and |
|
3129 |
therefore, the overhead of aquiring a font can be avoided. |
|
3130 |
" |
|
1138
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1094
diff
changeset
|
3131 |
"/ font := font on:device. |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1094
diff
changeset
|
3132 |
"/ id := font fontId. |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1094
diff
changeset
|
3133 |
"/ id notNil ifTrue:[ |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1094
diff
changeset
|
3134 |
"/ device setFont:id in:gcId |
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1094
diff
changeset
|
3135 |
"/ ] |
1199
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3136 |
|
f113f6a4c04a
use new device black/whiteColor interface
Claus Gittinger <cg@exept.de>
parents:
1177
diff
changeset
|
3137 |
"Modified: 13.1.1997 / 23:02:13 / cg" |
732 | 3138 |
! |
3139 |
||
3140 |
initialize |
|
3141 |
"setup everything for later use; actual work is done in |
|
3142 |
initColors and initFont, which are usually redefined." |
|
3143 |
||
3144 |
"make certain Workstation is initialized - just a check - will vanish soon" |
|
3145 |
Display isNil ifTrue:[ |
|
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
3146 |
'DeviceGraphicsContext [warning]: Display not initialized when first DeviceGraphicsContext created' errorPrintCR. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
3147 |
Workstation initialize |
732 | 3148 |
]. |
3149 |
||
3150 |
super initialize. |
|
3151 |
||
950 | 3152 |
foreground isNil ifTrue:[foreground := Black]. |
3153 |
background isNil ifTrue:[background := White]. |
|
3154 |
||
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
3155 |
"Modified: 10.1.1997 / 17:46:51 / cg" |
732 | 3156 |
! |
3157 |
||
3158 |
prepareForReinit |
|
3159 |
"kludge - clear drawableId and gcId |
|
3160 |
needed after snapin" |
|
3161 |
||
3162 |
gcId := nil. |
|
3163 |
drawableId := nil. |
|
3164 |
deviceFont := nil |
|
3165 |
! |
|
3166 |
||
3167 |
recreate |
|
3168 |
"sent after a snapin, reinit draw stuff for new device" |
|
3169 |
||
3170 |
gcId := nil. |
|
3171 |
foreground notNil ifTrue:[ |
|
1138
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1094
diff
changeset
|
3172 |
foreground := foreground on:device |
732 | 3173 |
]. |
3174 |
background notNil ifTrue:[ |
|
1138
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1094
diff
changeset
|
3175 |
background := background on:device |
732 | 3176 |
]. |
3177 |
paint notNil ifTrue:[ |
|
1138
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1094
diff
changeset
|
3178 |
paint := paint on:device |
732 | 3179 |
]. |
3180 |
bgPaint notNil ifTrue:[ |
|
1138
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1094
diff
changeset
|
3181 |
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
|
3182 |
]. |
470f906e3687
recreate device font early - this avoids some deviceFont query errors
Claus Gittinger <cg@exept.de>
parents:
1092
diff
changeset
|
3183 |
font notNil ifTrue:[ |
1138
4a2b3b407cae
need separate createGC method for bitmaps (for WIN)
Claus Gittinger <cg@exept.de>
parents:
1094
diff
changeset
|
3184 |
font := font on:device |
732 | 3185 |
] |
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 |
"Modified: 28.10.1996 / 13:25:02 / cg" |
732 | 3188 |
! |
3189 |
||
3190 |
reinitialize |
|
1177
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
3191 |
'DeviceGraphicsContext [warning]: reinit of ' errorPrint. self classNameWithArticle errorPrint. |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
3192 |
' failed' errorPrintCR |
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
3193 |
|
e89408c15bb5
newStyle info & error messages
Claus Gittinger <cg@exept.de>
parents:
1138
diff
changeset
|
3194 |
"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
|
3195 |
! |
064890dcfabd
fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents:
786
diff
changeset
|
3196 |
|
064890dcfabd
fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents:
786
diff
changeset
|
3197 |
releaseGC |
064890dcfabd
fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents:
786
diff
changeset
|
3198 |
"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
|
3199 |
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
|
3200 |
|
844 | 3201 |
foreground := background := paint := bgPaint := nil. |
832
064890dcfabd
fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents:
786
diff
changeset
|
3202 |
gcId notNil ifTrue:[ |
1029
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3203 |
device destroyGC:gcId. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3204 |
gcId := nil. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3205 |
Lobby registerChange:self. |
844 | 3206 |
]. |
832
064890dcfabd
fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents:
786
diff
changeset
|
3207 |
|
064890dcfabd
fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents:
786
diff
changeset
|
3208 |
"Created: 11.6.1996 / 22:07:30 / cg" |
844 | 3209 |
"Modified: 12.6.1996 / 20:52:34 / cg" |
732 | 3210 |
! ! |
3211 |
||
3212 |
!DeviceGraphicsContext methodsFor:'instance release'! |
|
3213 |
||
3214 |
disposed |
|
3215 |
"some Drawable has been collected |
|
3216 |
- must release operating system resources" |
|
3217 |
||
3218 |
^ self subclassResponsibility |
|
3219 |
! ! |
|
3220 |
||
3221 |
!DeviceGraphicsContext methodsFor:'private'! |
|
3222 |
||
3223 |
setDevice:aDevice id:aDrawbleId gcId:aGCId |
|
3224 |
"private" |
|
3225 |
||
3226 |
device := aDevice. |
|
3227 |
gcId := aGCId. |
|
3228 |
drawableId := aDrawbleId |
|
3229 |
! |
|
3230 |
||
3231 |
setGCForPaint |
|
3232 |
"private; given a complex color (i.e. a pixmap or dithered color, |
|
3233 |
setup the GC to draw in this color. |
|
3234 |
A helper for paint and paint:on:" |
|
3235 |
||
832
064890dcfabd
fixed opaque string draw with deep-dither
Claus Gittinger <cg@exept.de>
parents:
786
diff
changeset
|
3236 |
|dither map pixelId p fg bg vOrg ditherDepth deviceDepth| |
732 | 3237 |
|
3238 |
gcId notNil ifTrue:[ |
|
1029
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3239 |
(p := paint) isColor ifTrue:[ |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3240 |
paint := p := p on:device. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3241 |
pixelId := p colorId. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3242 |
pixelId notNil ifTrue:[ |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3243 |
" |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3244 |
a real (undithered) color |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3245 |
" |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3246 |
mask notNil ifTrue:[ |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3247 |
mask := nil. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3248 |
device setBitmapMask:nil in:gcId |
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 |
(p ~~ foreground) ifTrue:[ |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3251 |
foreground := paint. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3252 |
device setForeground:pixelId 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 |
^ self |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3255 |
]. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3256 |
"a dithered color" |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3257 |
dither := paint ditherForm. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3258 |
] ifFalse:[ |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3259 |
"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
|
3260 |
paint := paint on:device. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3261 |
dither := paint |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3262 |
]. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3263 |
" |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3264 |
a dithered color or image |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3265 |
" |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3266 |
(ditherDepth := dither depth) == 1 ifTrue:[ |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3267 |
"a simple 0/1 bitmap" |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3268 |
map := dither colorMap. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3269 |
"temporary (kludgy) fix for destroyed paint" |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3270 |
p := paint. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3271 |
map isNil ifTrue:[ |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3272 |
fg := Color black. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3273 |
bg := Color white. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3274 |
] ifFalse:[ |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3275 |
fg := map at:2. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3276 |
bg := map at:1. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3277 |
]. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3278 |
self foreground:fg background:bg. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3279 |
paint := p |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3280 |
] ifFalse:[ |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3281 |
deviceDepth := device depth. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3282 |
(ditherDepth ~~ deviceDepth) ifTrue:[ |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3283 |
dither := dither asFormOn:device. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3284 |
ditherDepth := dither depth. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3285 |
(dither isNil or:[ditherDepth ~~ deviceDepth]) ifTrue:[ |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3286 |
self error:'bad dither'. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3287 |
^ self |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3288 |
] |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3289 |
] |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3290 |
]. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3291 |
self mask:dither. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3292 |
vOrg := self viewOrigin. |
0b03a4f98dcd
pass srcGC to bitBlitter (req'd for WINDOWS)
Claus Gittinger <cg@exept.de>
parents:
976
diff
changeset
|
3293 |
self setMaskOriginX:vOrg x negated y:vOrg y negated. |
732 | 3294 |
] |
3295 |
||
3296 |
"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
|
3297 |
"Modified: 12.6.1996 / 12:49:07 / cg" |
732 | 3298 |
! ! |
3299 |
||
3300 |
!DeviceGraphicsContext methodsFor:'queries'! |
|
3301 |
||
3302 |
horizontalIntegerPixelPerMillimeter |
|
3303 |
"return the (rounded) number of pixels per millimeter" |
|
3304 |
||
3305 |
^ device horizontalPixelPerMillimeter rounded |
|
3306 |
! |
|
3307 |
||
3308 |
horizontalPixelPerInch |
|
3309 |
"return the number of horizontal pixels per inch of the display" |
|
3310 |
||
3311 |
^ device horizontalPixelPerMillimeter * 25.4 |
|
3312 |
! |
|
3313 |
||
3314 |
horizontalPixelPerMillimeter |
|
3315 |
"return the number of pixels per millimeter (not rounded)" |
|
3316 |
||
3317 |
^ device horizontalPixelPerMillimeter |
|
3318 |
! |
|
3319 |
||
3320 |
horizontalPixelPerMillimeter:millis |
|
3321 |
"return the number of pixels (not rounded) for millis millimeter" |
|
3322 |
||
3323 |
^ device horizontalPixelPerMillimeter * millis |
|
3324 |
! |
|
3325 |
||
784 | 3326 |
resolution |
3327 |
"return a point consisting of pixel-per-inch horizontally and vertically." |
|
3328 |
||
3329 |
^ device resolution |
|
3330 |
||
3331 |
"Created: 4.6.1996 / 15:23:55 / cg" |
|
3332 |
! |
|
3333 |
||
732 | 3334 |
verticalIntegerPixelPerMillimeter |
3335 |
"return the (rounded) number of pixels per millimeter" |
|
3336 |
||
3337 |
^ device verticalPixelPerMillimeter rounded |
|
3338 |
! |
|
3339 |
||
3340 |
verticalPixelPerInch |
|
3341 |
"return the number of vertical pixels per inch of the display" |
|
3342 |
||
3343 |
^ device verticalPixelPerMillimeter * 25.4 |
|
3344 |
! |
|
3345 |
||
3346 |
verticalPixelPerMillimeter |
|
3347 |
"return the number of pixels per millimeter (not rounded)" |
|
3348 |
||
3349 |
^ device verticalPixelPerMillimeter |
|
3350 |
! |
|
3351 |
||
3352 |
verticalPixelPerMillimeter:millis |
|
3353 |
"return the number of pixels (not rounded) for millis millimeter" |
|
3354 |
||
3355 |
^ device verticalPixelPerMillimeter * millis |
|
3356 |
! ! |
|
3357 |
||
1085
3513a4cae87b
handle depth1-images with a mask
Claus Gittinger <cg@exept.de>
parents:
1064
diff
changeset
|
3358 |
!DeviceGraphicsContext class methodsFor:'documentation'! |
732 | 3359 |
|
3360 |
version |
|
1237 | 3361 |
^ '$Header: /cvs/stx/stx/libview/DeviceGraphicsContext.st,v 1.27 1997-01-16 22:55:57 cg Exp $' |
732 | 3362 |
! ! |
3363 |
DeviceGraphicsContext initialize! |