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