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