0
|
1 |
"
|
6
|
2 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
71
|
3 |
All Rights Reserved
|
0
|
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 |
"
|
|
12 |
|
|
13 |
GraphicsContext subclass:#DisplayMedium
|
|
14 |
instanceVariableNames:'width height
|
71
|
15 |
clipRect window'
|
0
|
16 |
classVariableNames:''
|
|
17 |
poolDictionaries:''
|
46
|
18 |
category:'Graphics-Support'
|
0
|
19 |
!
|
|
20 |
|
|
21 |
DisplayMedium comment:'
|
46
|
22 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
71
|
23 |
All Rights Reserved
|
54
|
24 |
|
89
|
25 |
$Header: /cvs/stx/stx/libview/Attic/DMedium.st,v 1.9 1995-02-06 00:35:42 claus Exp $
|
46
|
26 |
'!
|
0
|
27 |
|
46
|
28 |
!DisplayMedium class methodsFor:'documentation'!
|
|
29 |
|
|
30 |
copyright
|
|
31 |
"
|
|
32 |
COPYRIGHT (c) 1989 by Claus Gittinger
|
71
|
33 |
All Rights Reserved
|
0
|
34 |
|
46
|
35 |
This software is furnished under a license and may be used
|
|
36 |
only in accordance with the terms of that license and with the
|
|
37 |
inclusion of the above copyright notice. This software may not
|
|
38 |
be provided or otherwise made available to, or used by, any
|
|
39 |
other person. No title to or ownership of the software is
|
|
40 |
hereby transferred.
|
|
41 |
"
|
|
42 |
!
|
0
|
43 |
|
46
|
44 |
version
|
|
45 |
"
|
89
|
46 |
$Header: /cvs/stx/stx/libview/Attic/DMedium.st,v 1.9 1995-02-06 00:35:42 claus Exp $
|
46
|
47 |
"
|
|
48 |
!
|
0
|
49 |
|
46
|
50 |
documentation
|
|
51 |
"
|
|
52 |
this is an abstract superclass for all kinds of drawables which
|
|
53 |
have a physical representation (i.e. have an extent). Dont use messages
|
|
54 |
from here - it will vanish soon.
|
0
|
55 |
|
46
|
56 |
Instance variables:
|
|
57 |
|
|
58 |
width <SmallInteger> the width (device dependent, usually pixels or inches)
|
|
59 |
height <SmallInteger> the height (device dependent, usually pixels or inches)
|
|
60 |
clipRect <Rectangle> a clip rectangle (device dep. usually pixels or inches)
|
|
61 |
"
|
|
62 |
! !
|
0
|
63 |
|
|
64 |
!DisplayMedium methodsFor:'initialization'!
|
|
65 |
|
|
66 |
initialize
|
|
67 |
"set up some useful default values"
|
|
68 |
|
|
69 |
super initialize.
|
|
70 |
|
|
71 |
width := 0.
|
|
72 |
height := 0
|
|
73 |
! !
|
|
74 |
|
|
75 |
!DisplayMedium methodsFor:'accessing'!
|
|
76 |
|
89
|
77 |
isView
|
|
78 |
"return true, if the receiver is a view"
|
|
79 |
|
|
80 |
^ false
|
|
81 |
!
|
|
82 |
|
0
|
83 |
origin
|
|
84 |
"return the origin i.e. coordinate of top-left of the receiver"
|
|
85 |
|
|
86 |
^ 0 @ 0
|
|
87 |
!
|
|
88 |
|
|
89 |
left
|
|
90 |
"return the left i.e. x-coordinate of top-left of the receiver"
|
|
91 |
|
|
92 |
^ 0
|
|
93 |
!
|
|
94 |
|
|
95 |
top
|
|
96 |
"return the top i.e. y-coordinate of top-left of the receiver"
|
|
97 |
|
|
98 |
^ 0
|
|
99 |
!
|
|
100 |
|
|
101 |
insideLeftOffset
|
|
102 |
"return the left offset for drawing in the receiver;
|
|
103 |
this is 0 here, but Views/Pages may add margins"
|
|
104 |
|
|
105 |
^ 0
|
|
106 |
!
|
|
107 |
|
|
108 |
insideTopOffset
|
|
109 |
"return the top offset for drawing in the receiver;
|
|
110 |
this is 0 here, but Views/Pages may add margins"
|
|
111 |
|
|
112 |
^ 0
|
|
113 |
!
|
|
114 |
|
|
115 |
width
|
|
116 |
"return the width of the receiver"
|
|
117 |
|
|
118 |
^ width
|
|
119 |
!
|
|
120 |
|
|
121 |
width:anInteger
|
|
122 |
"set the width of the receiver"
|
|
123 |
|
|
124 |
width := anInteger
|
|
125 |
!
|
|
126 |
|
|
127 |
height
|
|
128 |
"return the height of the receiver"
|
|
129 |
|
|
130 |
^ height
|
|
131 |
!
|
|
132 |
|
|
133 |
height:anInteger
|
|
134 |
"set the height of the receiver"
|
|
135 |
|
|
136 |
height := anInteger
|
|
137 |
!
|
|
138 |
|
|
139 |
width:w height:h
|
|
140 |
"set both width and height of the receiver"
|
|
141 |
|
|
142 |
width := w.
|
|
143 |
height := h
|
|
144 |
!
|
|
145 |
|
89
|
146 |
setWidth:w height:h
|
|
147 |
"set both width and height - not to be redefined"
|
|
148 |
|
|
149 |
width := w.
|
|
150 |
height := h
|
|
151 |
!
|
|
152 |
|
0
|
153 |
insideWidth
|
|
154 |
"return the usable width for drawing in the receiver;
|
|
155 |
this is width here, but Views/Pages may subtract margins"
|
|
156 |
|
|
157 |
^ width
|
|
158 |
!
|
|
159 |
|
|
160 |
insideHeight
|
|
161 |
"return the usable height for drawing in the receiver;
|
|
162 |
this is height here, but Views/Pages may subtract margins"
|
|
163 |
|
|
164 |
^ height
|
|
165 |
!
|
|
166 |
|
|
167 |
extent
|
|
168 |
"return the extent i.e. a point with width as x, height as y
|
|
169 |
coordinate"
|
|
170 |
|
|
171 |
^ width @ height
|
|
172 |
!
|
|
173 |
|
|
174 |
extent:extent
|
|
175 |
"set the extent"
|
|
176 |
|
|
177 |
width := extent x.
|
|
178 |
height := extent y
|
|
179 |
!
|
|
180 |
|
|
181 |
center
|
|
182 |
"return the point at the center of the receiver"
|
|
183 |
|
|
184 |
^ (self left + (width // 2)) @ (self top + (height // 2))
|
|
185 |
!
|
|
186 |
|
|
187 |
corner
|
|
188 |
"return the corner point i.e. the bottom-right point"
|
|
189 |
|
|
190 |
^ (self left + width - 1) @ (self top + height - 1)
|
|
191 |
!
|
|
192 |
|
|
193 |
corner:aPoint
|
|
194 |
"set the corner point i.e. change extent so that corner will be
|
|
195 |
aPoint while leaving the origin unchanging "
|
|
196 |
|
|
197 |
self extent:(aPoint x - self left + 1)
|
71
|
198 |
@
|
|
199 |
(aPoint y - self top + 1)
|
0
|
200 |
! !
|
|
201 |
|
|
202 |
!DisplayMedium methodsFor:'GC access'!
|
|
203 |
|
|
204 |
clipRect:aRectangle
|
|
205 |
"set the drawing clip-rectangle"
|
|
206 |
|
|
207 |
^ self subclassResponsibility
|
|
208 |
!
|
|
209 |
|
|
210 |
at:aPoint
|
|
211 |
"return pixel value at coordinate"
|
|
212 |
|
|
213 |
^ self subclassResponsibility
|
|
214 |
!
|
|
215 |
|
|
216 |
drawPattern:aPattern
|
|
217 |
"set the pattern to be drawn with - the pattern may be a color,
|
|
218 |
a bitmap or pixmap"
|
|
219 |
|
46
|
220 |
aPattern isColor ifTrue:[
|
71
|
221 |
self paint:aPattern
|
0
|
222 |
] ifFalse:[
|
71
|
223 |
self mask:aPattern
|
0
|
224 |
]
|
|
225 |
! !
|
|
226 |
|
|
227 |
!DisplayMedium methodsFor:'filling'!
|
|
228 |
|
|
229 |
black
|
|
230 |
"fill the receiver with black"
|
|
231 |
|
|
232 |
self fill:Black
|
|
233 |
!
|
|
234 |
|
|
235 |
white
|
|
236 |
"fill the receiver with white"
|
|
237 |
|
|
238 |
self fill:White
|
|
239 |
!
|
|
240 |
|
|
241 |
clearInside
|
|
242 |
"clear the receiver with background - ST-80 compatibility"
|
|
243 |
|
|
244 |
^ self clear
|
|
245 |
!
|
|
246 |
|
71
|
247 |
clear
|
|
248 |
"clear the receiver with background"
|
|
249 |
|
80
|
250 |
"currently need this kludge for form ..."
|
|
251 |
transformation isNil ifTrue:[
|
|
252 |
self clearRectangleX:0 y:0 width:width height:height
|
|
253 |
] ifFalse:[
|
|
254 |
self clearDeviceRectangleX:0 y:0 width:width height:height
|
|
255 |
]
|
71
|
256 |
!
|
|
257 |
|
0
|
258 |
clearRectangle:aRectangle
|
|
259 |
"clear the rectangular area in the receiver to background"
|
|
260 |
|
71
|
261 |
self clearRectangleX:(aRectangle left)
|
|
262 |
y:(aRectangle top)
|
|
263 |
width:(aRectangle width)
|
|
264 |
height:(aRectangle height)
|
0
|
265 |
!
|
|
266 |
|
|
267 |
clearRectangleX:left y:top width:w height:h
|
|
268 |
"clear the rectangular area in the receiver to background"
|
|
269 |
|
|
270 |
self fillRectangleX:left
|
71
|
271 |
y:top
|
|
272 |
width:w
|
|
273 |
height:h
|
75
|
274 |
with:bgPaint
|
0
|
275 |
!
|
|
276 |
|
|
277 |
fill:something
|
|
278 |
"fill the receiver with something;
|
|
279 |
something may be a Form, Color or colorIndex"
|
|
280 |
|
|
281 |
self fillRectangleX:0 y:0 width:width height:height with:something
|
|
282 |
!
|
|
283 |
|
|
284 |
fillRectangle:aRectangle with:something
|
|
285 |
"fill the rectangular area in the receiver with something;
|
|
286 |
something may be a Form, Color or colorIndex"
|
|
287 |
|
|
288 |
self fillRectangleX:(aRectangle left)
|
71
|
289 |
y:(aRectangle top)
|
|
290 |
width:(aRectangle width)
|
|
291 |
height:(aRectangle height)
|
|
292 |
with:something
|
0
|
293 |
!
|
|
294 |
|
|
295 |
fillRectangleX:x y:y width:w height:h with:aPattern
|
|
296 |
"fill the rectangular area in the receiver with aPattern,
|
|
297 |
which may be a Form or Color"
|
|
298 |
|
|
299 |
self withPattern:aPattern do:[
|
71
|
300 |
self fillRectangleX:x y:y width:w height:h
|
0
|
301 |
]
|
71
|
302 |
|
|
303 |
"
|
|
304 |
RootView fillRectangleX:0
|
|
305 |
y:0
|
|
306 |
width:50
|
|
307 |
height:50
|
|
308 |
with:(Color grey:50)
|
|
309 |
"
|
0
|
310 |
!
|
|
311 |
|
|
312 |
fillPolygon:aPolygon with:aPattern
|
|
313 |
"fill a polygon in the receiver with aPattern,
|
|
314 |
which may be a Form or Color"
|
|
315 |
|
|
316 |
self withPattern:aPattern do:[
|
71
|
317 |
self fillPolygon:aPolygon
|
0
|
318 |
]
|
|
319 |
!
|
|
320 |
|
|
321 |
invertRectangle:aRectangle
|
|
322 |
"invert a rectangle in the receiver"
|
|
323 |
|
|
324 |
self xoring:[
|
71
|
325 |
self fillRectangle:aRectangle
|
0
|
326 |
]
|
|
327 |
!
|
|
328 |
|
|
329 |
fillCircle:aPoint radius:aNumber with:aPattern
|
|
330 |
"fill a circle in the receiver with aPattern,
|
|
331 |
which may be a Color or Form"
|
|
332 |
|
|
333 |
self fillCircleX:(aPoint x) y:(aPoint y) radius:aNumber with:aPattern
|
|
334 |
!
|
|
335 |
|
|
336 |
fillCircleX:x y:y radius:r with:aPattern
|
|
337 |
"fill a circle with aPattern,
|
|
338 |
which may be a Color or Form"
|
|
339 |
|
|
340 |
|d|
|
|
341 |
d := 2 * r.
|
|
342 |
self fillArcX:(x - r) y:(y - r) w:d h:d from:0 angle:360 with:aPattern
|
|
343 |
!
|
|
344 |
|
|
345 |
fillArcX:x y:y w:w h:h from:startAngle angle:angle with:aPattern
|
|
346 |
"fill an arc in the receiver with aPattern,
|
|
347 |
which may be a Color or Form"
|
|
348 |
|
|
349 |
self withPattern:aPattern do:[
|
71
|
350 |
self fillArcX:x y:y w:w h:h from:startAngle angle:angle
|
0
|
351 |
]
|
|
352 |
! !
|
|
353 |
|
|
354 |
!DisplayMedium methodsFor:'evaluating in another context'!
|
|
355 |
|
|
356 |
withPattern:aPattern do:aBlock
|
|
357 |
|old|
|
|
358 |
|
46
|
359 |
aPattern isColor ifTrue:[
|
71
|
360 |
old := paint.
|
|
361 |
self paint:aPattern.
|
|
362 |
aBlock value.
|
|
363 |
self paint:old
|
0
|
364 |
] ifFalse:[
|
71
|
365 |
old := mask.
|
|
366 |
self mask:aPattern.
|
|
367 |
aBlock value.
|
|
368 |
self mask:old
|
0
|
369 |
]
|
|
370 |
!
|
|
371 |
|
|
372 |
withMask:aMask do:aBlock
|
|
373 |
"evaluate aBlock with mask set to aMask"
|
|
374 |
|
|
375 |
|oldMask|
|
|
376 |
|
|
377 |
oldMask := mask.
|
|
378 |
self mask:aMask.
|
|
379 |
aBlock value.
|
|
380 |
self mask:oldMask
|
|
381 |
!
|
|
382 |
|
|
383 |
withFunction:aFunction do:aBlock
|
|
384 |
"evaluate aBlock with function set to aFunction"
|
|
385 |
|
|
386 |
|oldFun|
|
|
387 |
|
|
388 |
oldFun := function.
|
|
389 |
self function:aFunction.
|
|
390 |
aBlock value.
|
|
391 |
self function:oldFun
|
|
392 |
!
|
|
393 |
|
|
394 |
clippedTo:aRectangle do:aBlock
|
|
395 |
"evaluate aBlock with clipping rectangle set to aRectangle"
|
|
396 |
|
|
397 |
|oldClip|
|
|
398 |
|
|
399 |
oldClip := clipRect.
|
|
400 |
self clipRect:aRectangle.
|
|
401 |
aBlock value.
|
|
402 |
self clipRect:oldClip
|
|
403 |
! !
|