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