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