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