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