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