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