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