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