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