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