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