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