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