author | Claus Gittinger <cg@exept.de> |
Tue, 05 May 2015 13:14:19 +0200 | |
changeset 3465 | 8d6d8462943c |
parent 3357 | 57e21ce0e033 |
child 3615 | dfa1e224ea8f |
permissions | -rw-r--r-- |
3465 | 1 |
"{ Encoding: utf8 }" |
2 |
||
0 | 3 |
" |
6 | 4 |
COPYRIGHT (c) 1989 by Claus Gittinger |
31 | 5 |
All Rights Reserved |
0 | 6 |
|
7 |
This software is furnished under a license and may be used |
|
8 |
only in accordance with the terms of that license and with the |
|
9 |
inclusion of the above copyright notice. This software may not |
|
10 |
be provided or otherwise made available to, or used by, any |
|
11 |
other person. No title to or ownership of the software is |
|
12 |
hereby transferred. |
|
13 |
" |
|
1399 | 14 |
"{ Package: 'stx:libview2' }" |
15 |
||
3465 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
0 | 18 |
Object subclass:#DisplayObject |
219 | 19 |
instanceVariableNames:'frame' |
20 |
classVariableNames:'' |
|
21 |
poolDictionaries:'' |
|
1789 | 22 |
category:'Compatibility-ST80-Graphics-Display Objects' |
0 | 23 |
! |
24 |
||
21 | 25 |
!DisplayObject class methodsFor:'documentation'! |
26 |
||
27 |
copyright |
|
28 |
" |
|
29 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
31 | 30 |
All Rights Reserved |
0 | 31 |
|
21 | 32 |
This software is furnished under a license and may be used |
33 |
only in accordance with the terms of that license and with the |
|
34 |
inclusion of the above copyright notice. This software may not |
|
35 |
be provided or otherwise made available to, or used by, any |
|
36 |
other person. No title to or ownership of the software is |
|
37 |
hereby transferred. |
|
38 |
" |
|
39 |
! |
|
0 | 40 |
|
21 | 41 |
documentation |
42 |
" |
|
43 |
generic superclass for Display Objects held in ObjectViews |
|
255 | 44 |
see DrawObject/LogicObject/DeskTopObject and subclasses for example uses. |
45 |
||
219 | 46 |
[author:] |
47 |
Claus Gittinger |
|
21 | 48 |
" |
49 |
! ! |
|
0 | 50 |
|
51 |
!DisplayObject class methodsFor:'instance creation'! |
|
52 |
||
53 |
new |
|
54 |
^ self basicNew initialize |
|
55 |
! ! |
|
56 |
||
57 |
!DisplayObject class methodsFor:'behavior'! |
|
58 |
||
505
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
59 |
dragDashedOutline |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
60 |
"if true, outline dragging is done by drawing the line dashed. |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
61 |
if false, the outline is drawn solid. |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
62 |
Can be redefined in subclasses (for solid outline)." |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
63 |
|
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
64 |
^ true |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
65 |
|
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
66 |
"Created: 28.3.1997 / 16:21:56 / cg" |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
67 |
"Modified: 28.3.1997 / 16:40:54 / cg" |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
68 |
! |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
69 |
|
0 | 70 |
dragOutline |
71 |
"if true, dragging is done by drawing outline only; |
|
505
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
72 |
if false, dragging is done by full draw (fast servers only). |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
73 |
Can be redefined in subclasses (for full dragging)" |
0 | 74 |
|
75 |
^ true |
|
505
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
76 |
|
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
77 |
"Modified: 28.3.1997 / 16:40:44 / cg" |
0 | 78 |
! ! |
79 |
||
122 | 80 |
!DisplayObject methodsFor:'ST-80 drawing'! |
115 | 81 |
|
122 | 82 |
displayOn:aDisplayMedium at:aPoint |
260 | 83 |
"for ST-80 compatibility; not used in ST/X" |
84 |
||
122 | 85 |
self displayOn:aDisplayMedium |
260 | 86 |
at:aPoint |
122 | 87 |
clippingBox:nil |
260 | 88 |
rule:#copy |
89 |
mask:nil |
|
90 |
||
91 |
"Modified: 12.5.1996 / 20:19:15 / cg" |
|
0 | 92 |
! |
93 |
||
122 | 94 |
displayOn:aDisplayMedium at:aPoint clippingBox:clipRectangle |
260 | 95 |
"for ST-80 compatibility; not used in ST/X" |
96 |
||
122 | 97 |
^ self displayOn:aDisplayMedium |
260 | 98 |
at:aPoint |
99 |
clippingBox:clipRectangle |
|
100 |
rule:#copy |
|
101 |
mask:nil |
|
102 |
||
103 |
"Modified: 12.5.1996 / 20:19:17 / cg" |
|
7 | 104 |
! |
105 |
||
122 | 106 |
displayOn:aDisplayMedium at:aPoint clippingBox:clip rule:rule mask: aForm |
260 | 107 |
"for ST-80 compatibility; not used in ST/X. |
108 |
in ST-80 programs, this is redefined" |
|
7 | 109 |
|
122 | 110 |
aDisplayMedium function:rule. |
260 | 111 |
^ self drawIn:aDisplayMedium at:(aPoint + self origin) |
112 |
||
113 |
"Modified: 12.5.1996 / 20:19:27 / cg" |
|
114 |
! |
|
115 |
||
116 |
displayOn:aDisplayMedium x:x y:y |
|
3357 | 117 |
self |
118 |
displayOn:aDisplayMedium |
|
119 |
at:(x @ y) |
|
120 |
clippingBox:nil |
|
121 |
rule:#copy |
|
122 |
mask:nil |
|
260 | 123 |
|
124 |
"Modified: 12.5.1996 / 20:19:15 / cg" |
|
125 |
"Created: 12.5.1996 / 20:20:09 / cg" |
|
34 | 126 |
! ! |
127 |
||
0 | 128 |
!DisplayObject methodsFor:'accessing'! |
129 |
||
1688 | 130 |
bottom |
131 |
^ self frame bottom |
|
132 |
! |
|
133 |
||
2658 | 134 |
bottomCenter |
135 |
^ self frame bottomCenter |
|
136 |
! |
|
137 |
||
138 |
bottomLeft |
|
139 |
^ self frame bottomLeft |
|
140 |
! |
|
141 |
||
142 |
bottomRight |
|
143 |
^ self frame bottomRight |
|
144 |
! |
|
145 |
||
1496 | 146 |
bounds |
147 |
"ST80 component compatibility" |
|
148 |
||
149 |
^ self frame. |
|
150 |
! |
|
151 |
||
122 | 152 |
corner |
153 |
"return the frame corner" |
|
154 |
||
155 |
frame isNil ifTrue:[ |
|
1692 | 156 |
self computeBoundingBox |
122 | 157 |
]. |
158 |
^ frame corner |
|
159 |
! |
|
160 |
||
161 |
extent |
|
162 |
"return the extent of the frame" |
|
163 |
||
164 |
frame isNil ifTrue:[ |
|
1692 | 165 |
self computeBoundingBox |
122 | 166 |
]. |
167 |
^ frame extent |
|
168 |
! |
|
169 |
||
0 | 170 |
frame |
171 |
"object must return a frame boundary rectangle" |
|
172 |
||
173 |
frame isNil ifTrue:[ |
|
1692 | 174 |
self computeBoundingBox |
0 | 175 |
]. |
176 |
^ frame |
|
177 |
! |
|
178 |
||
179 |
height |
|
180 |
"return the height of the frame" |
|
181 |
||
182 |
frame isNil ifTrue:[ |
|
1692 | 183 |
self computeBoundingBox |
0 | 184 |
]. |
185 |
^ frame height |
|
186 |
! |
|
187 |
||
260 | 188 |
heightOn:aGC |
189 |
"return the height of the frame if drawon on aCG" |
|
190 |
||
191 |
^ self height |
|
192 |
||
193 |
"Created: 12.5.1996 / 20:20:54 / cg" |
|
194 |
! |
|
195 |
||
2267 | 196 |
left |
197 |
^ self frame left |
|
198 |
||
199 |
"Created: / 26-10-2006 / 18:08:42 / cg" |
|
200 |
! |
|
201 |
||
2658 | 202 |
leftCenter |
203 |
^ self frame leftCenter |
|
204 |
! |
|
205 |
||
0 | 206 |
origin |
207 |
"return the frame origin" |
|
208 |
||
209 |
frame isNil ifTrue:[ |
|
1692 | 210 |
self computeBoundingBox |
0 | 211 |
]. |
212 |
^ frame origin |
|
213 |
! |
|
214 |
||
215 |
origin:origin |
|
216 |
"object must calculate its dimension from outline" |
|
217 |
||
218 |
^ self subclassResponsibility |
|
219 |
! |
|
220 |
||
221 |
origin:origin corner:corner |
|
222 |
"object must calculate its dimension from outline" |
|
223 |
||
224 |
^ self subclassResponsibility |
|
122 | 225 |
! |
226 |
||
1688 | 227 |
right |
228 |
^ self frame right |
|
229 |
! |
|
230 |
||
2658 | 231 |
rightCenter |
232 |
^ self frame rightCenter |
|
233 |
! |
|
234 |
||
2131 | 235 |
top |
236 |
^ self frame top |
|
237 |
! |
|
238 |
||
2658 | 239 |
topCenter |
240 |
^ self frame topCenter |
|
241 |
! |
|
242 |
||
2131 | 243 |
topLeft |
244 |
^ self frame topLeft |
|
245 |
! |
|
246 |
||
247 |
topRight |
|
248 |
^ self frame topRight |
|
249 |
! |
|
250 |
||
122 | 251 |
width |
252 |
"return the width of the frame" |
|
253 |
||
254 |
frame isNil ifTrue:[ |
|
1692 | 255 |
self computeBoundingBox |
122 | 256 |
]. |
257 |
^ frame width |
|
260 | 258 |
! |
259 |
||
1579 | 260 |
widthFrom:startIndex to:endIndex on:aGC |
261 |
"return the width of part of myself if drawn on aCG" |
|
262 |
||
263 |
^ self subclassResponsibility |
|
264 |
! |
|
265 |
||
260 | 266 |
widthOn:aGC |
1579 | 267 |
"return the width of the frame if drawn on aCG" |
260 | 268 |
|
269 |
^ self width |
|
270 |
||
271 |
"Created: 12.5.1996 / 20:20:45 / cg" |
|
122 | 272 |
! ! |
273 |
||
1496 | 274 |
!DisplayObject methodsFor:'component protocol'! |
275 |
||
276 |
container:aComponent |
|
277 |
"ignored here - added to allow images to be used like |
|
278 |
VisualComponents (later, Image should inherit from it)" |
|
279 |
! |
|
280 |
||
281 |
containerChangedSize |
|
282 |
"ignored here - added to allow images to be used like |
|
283 |
VisualComponents (later, Image should inherit from it)" |
|
284 |
! |
|
285 |
||
2815 | 286 |
destroy |
287 |
"SimpleView>>destroySubviews wants to destroy us (if we are a view's component). |
|
288 |
Do nothing here" |
|
289 |
||
290 |
^ self |
|
291 |
! |
|
292 |
||
1496 | 293 |
realize |
294 |
"ignored here - added to allow images to be used like |
|
295 |
VisualComponents (later, Image should inherit from it)" |
|
296 |
! ! |
|
297 |
||
122 | 298 |
!DisplayObject methodsFor:'converting'! |
299 |
||
300 |
asDisplayObject |
|
301 |
^ self |
|
0 | 302 |
! ! |
303 |
||
122 | 304 |
!DisplayObject methodsFor:'drawing'! |
305 |
||
505
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
306 |
drawDashedOutlineIn:aGC offset:anOffset |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
307 |
"draw the receivers outline at its origin offset by anOffset, aPoint" |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
308 |
|
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
309 |
|prevStyle| |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
310 |
|
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
311 |
prevStyle := aGC lineStyle. |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
312 |
aGC lineStyle:#dashed. |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
313 |
[ |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
314 |
self drawOutlineIn:aGC offset:anOffset. |
1559
75127f6bf318
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
1496
diff
changeset
|
315 |
] ensure:[ |
505
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
316 |
aGC lineStyle:prevStyle. |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
317 |
] |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
318 |
|
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
319 |
"Created: 28.3.1997 / 16:23:25 / cg" |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
320 |
"Modified: 28.3.1997 / 16:29:24 / cg" |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
321 |
! |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
322 |
|
122 | 323 |
drawDragIn:aView |
505
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
324 |
"draw the receiver for dragging at its origin" |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
325 |
|
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
326 |
self drawDragIn:aView offset:0@0 |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
327 |
|
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
328 |
"Modified: 28.3.1997 / 16:27:32 / cg" |
122 | 329 |
! |
330 |
||
331 |
drawDragIn:aView at:drawOrigin |
|
505
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
332 |
"draw the receiver for dragging at some point" |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
333 |
|
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
334 |
|offs| |
122 | 335 |
|
505
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
336 |
offs := drawOrigin - (self origin). |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
337 |
self drawDragIn:aView offset:offs |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
338 |
|
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
339 |
"Modified: 28.3.1997 / 16:20:17 / cg" |
122 | 340 |
! |
0 | 341 |
|
122 | 342 |
drawDragIn:aView offset:drawOrigin |
505
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
343 |
"draw the receiver for dragging offset by some amount" |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
344 |
|
122 | 345 |
self class dragOutline ifTrue:[ |
505
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
346 |
self class dragDashedOutline ifTrue:[ |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
347 |
self drawDashedOutlineIn:aView offset:drawOrigin |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
348 |
] ifFalse:[ |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
349 |
self drawOutlineIn:aView offset:drawOrigin |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
350 |
] |
122 | 351 |
] ifFalse: [ |
505
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
352 |
self drawIn:aView offset:drawOrigin |
122 | 353 |
] |
505
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
354 |
|
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
355 |
"Modified: 28.3.1997 / 16:22:31 / cg" |
122 | 356 |
! |
357 |
||
358 |
drawIn:aView |
|
359 |
"draw the receiver at its origin" |
|
0 | 360 |
|
505
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
361 |
self drawIn:aView offset:0@0 |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
362 |
|
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
363 |
"Modified: 28.3.1997 / 16:27:46 / cg" |
122 | 364 |
! |
365 |
||
366 |
drawIn:aView at:drawOrigin |
|
367 |
"draw the receiver at drawOrigin, aPoint" |
|
368 |
||
369 |
self drawIn:aView offset:(drawOrigin - (self origin)) |
|
370 |
! |
|
371 |
||
372 |
drawIn:aView offset:anOffset |
|
373 |
"draw the receiver at its origin offset by anOffset, aPoint" |
|
374 |
||
375 |
^ self subclassResponsibility |
|
0 | 376 |
! |
377 |
||
122 | 378 |
drawOutlineIn:aView |
379 |
"draw the receivers outline at its origin" |
|
380 |
||
505
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
381 |
self drawOutlineIn:aView offset:0@0 |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
382 |
|
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
383 |
"Modified: 28.3.1997 / 16:27:50 / cg" |
122 | 384 |
! |
385 |
||
386 |
drawOutlineIn:aView at:drawOrigin |
|
387 |
"draw the receivers outline at drawOrigin, aPoint" |
|
388 |
||
389 |
self drawOutlineIn:aView offset:(drawOrigin - self origin) |
|
390 |
! |
|
391 |
||
392 |
drawOutlineIn:aView offset:anOffset |
|
393 |
"draw the receivers outline at its origin offset by anOffset, aPoint" |
|
394 |
||
505
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
395 |
|org x y w h| |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
396 |
|
122 | 397 |
org := self origin + anOffset. |
505
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
398 |
x := org x. |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
399 |
y := org y. |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
400 |
w := frame width. |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
401 |
h := frame height. |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
402 |
|
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
403 |
aView displayRectangleX:x y:y width:w height:h |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
404 |
|
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
405 |
"Modified: 28.3.1997 / 16:32:34 / cg" |
122 | 406 |
! |
407 |
||
408 |
drawSelectedIn:aView |
|
409 |
"draw the receiver highlighted at its position" |
|
410 |
||
505
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
411 |
self drawSelectedIn:aView offset:0@0 |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
412 |
|
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
413 |
"Modified: 28.3.1997 / 16:27:56 / cg" |
122 | 414 |
! |
415 |
||
416 |
drawSelectedIn:aView offset:anOffset |
|
417 |
"draw the receiver highlighted - this is usually redefined" |
|
418 |
||
419 |
self drawIn:aView offset:anOffset. |
|
420 |
self drawOutlineIn:aView offset:anOffset |
|
421 |
! ! |
|
422 |
||
1688 | 423 |
!DisplayObject methodsFor:'dummy event handling'! |
424 |
||
425 |
buttonMotion:buttNr x:x y:y |
|
426 |
! |
|
427 |
||
428 |
buttonPress:buttNr x:x y:y |
|
429 |
! |
|
430 |
||
431 |
buttonRelease:buttNr x:x y:y |
|
432 |
! |
|
433 |
||
434 |
keyPress:key x:x y:y |
|
435 |
! |
|
436 |
||
437 |
keyRelease:key x:x y:y |
|
438 |
! ! |
|
439 |
||
122 | 440 |
!DisplayObject methodsFor:'initialization'! |
441 |
||
442 |
computeBoundingBox |
|
443 |
"compute my boundingBox into the local variable 'frame'. |
|
444 |
The box should be computed for Display." |
|
445 |
||
446 |
^ self subclassResponsibility |
|
447 |
! |
|
448 |
||
449 |
computeBoundingBoxFor:aDevice |
|
450 |
"compute my boundingBox into the local variable 'frame'. |
|
451 |
The box is to be computed for aDevice." |
|
452 |
||
453 |
"/ for backward compatibility, fall back to Display box computation |
|
454 |
||
1692 | 455 |
self computeBoundingBox |
122 | 456 |
! |
457 |
||
458 |
initialize |
|
0 | 459 |
^ self |
460 |
! ! |
|
461 |
||
462 |
!DisplayObject methodsFor:'queries'! |
|
463 |
||
122 | 464 |
canBeMoved |
1193 | 465 |
"return true, if the receiver can be moved around (in an ObjectView)" |
122 | 466 |
|
467 |
^ true |
|
1193 | 468 |
|
469 |
"Modified: / 4.7.1999 / 18:49:26 / cg" |
|
470 |
! |
|
471 |
||
472 |
canBeSelected |
|
473 |
"return true, if the receiver can be selected (in an ObjectView)" |
|
474 |
||
475 |
^ true |
|
476 |
||
477 |
"Created: / 4.7.1999 / 18:49:20 / cg" |
|
122 | 478 |
! |
479 |
||
480 |
containsPoint: aPoint |
|
481 |
^ frame containsPoint: aPoint |
|
482 |
! |
|
483 |
||
288 | 484 |
frameIsHitBy:aPoint withDelta:delta |
485 |
"return true, if my frame is hit by aPoint" |
|
486 |
||
487 |
|org left right top bott px py d2| |
|
488 |
||
489 |
frame isNil ifTrue:[ |
|
2026 | 490 |
self computeBoundingBox. |
491 |
frame isNil ifTrue:[^ false ]. |
|
288 | 492 |
]. |
493 |
(delta == 0) ifTrue:[ |
|
494 |
^ frame containsPoint:aPoint |
|
495 |
]. |
|
496 |
||
497 |
" |
|
498 |
its quicker to not create a new rectangle for the test |
|
499 |
(which is not obvious for simple lines, but complex polygons |
|
500 |
or grouped objects may call this for many of its components) |
|
501 |
" |
|
502 |
org := frame origin. |
|
503 |
left := org x - delta. |
|
504 |
||
505 |
px := aPoint x. |
|
506 |
(px < left) ifTrue:[^ false]. "aPoint is to the left of my left edge" |
|
507 |
||
508 |
d2 := delta * 2. |
|
509 |
right := left + frame width + d2. |
|
510 |
(px > right) ifTrue:[^ false]. "aPoint is to the right of my right edge" |
|
511 |
||
512 |
top := org y - delta. |
|
513 |
py := aPoint y. |
|
514 |
(py < top) ifTrue:[^ false]. "aPoint is above my top edge" |
|
515 |
||
516 |
bott := top + frame height + d2. |
|
517 |
(py > bott) ifTrue:[^ false]. "aPoint is below my bottom edge" |
|
518 |
||
519 |
^ true |
|
520 |
||
521 |
"Created: 5.6.1996 / 15:26:51 / cg" |
|
522 |
! |
|
523 |
||
122 | 524 |
handlesKeyboardInput |
525 |
"return true, if the receiver handles keyboard input" |
|
526 |
||
527 |
^ false |
|
528 |
! |
|
529 |
||
530 |
hasFixedSize |
|
531 |
"return true, if the receiver has fixed size i.e. cannot be |
|
532 |
resized |
|
533 |
- by default, we do not allow resizing" |
|
534 |
||
535 |
^ true |
|
536 |
! |
|
537 |
||
538 |
intersects:aRectangle |
|
539 |
"object must decide, if its intersecting a rectangle" |
|
540 |
||
541 |
^ frame intersects:aRectangle |
|
542 |
! |
|
543 |
||
544 |
isContainedIn:aRectangle |
|
545 |
"object must decide, if its within a rectangle" |
|
546 |
||
547 |
^ aRectangle contains:frame |
|
548 |
! |
|
549 |
||
550 |
isHitBy:aPoint |
|
551 |
"object must decide, if hit by a click at aPoint" |
|
552 |
||
553 |
^ self isHitBy:aPoint withDelta:0 |
|
554 |
! |
|
555 |
||
0 | 556 |
isHitBy:aPoint withDelta:delta |
557 |
"object must decide, if hit by a click at aPoint; |
|
558 |
usually this method is redefined in subclasses for a more complete |
|
559 |
check (i.e. if objects boundary is not rectangular)" |
|
560 |
||
288 | 561 |
^ self frameIsHitBy:aPoint withDelta:delta |
0 | 562 |
|
288 | 563 |
"Modified: 5.6.1996 / 15:27:06 / cg" |
0 | 564 |
! |
565 |
||
122 | 566 |
isOpaque |
567 |
"return true, if the object fully covers its frame (i.e. is rectangular |
|
3465 | 568 |
and has no 'holes'. Since we don't know, return false here" |
0 | 569 |
|
122 | 570 |
^ false |
0 | 571 |
! ! |
572 |
||
1399 | 573 |
!DisplayObject methodsFor:'user actions'! |
0 | 574 |
|
122 | 575 |
keyInput:akey |
576 |
^ self |
|
1399 | 577 |
! ! |
578 |
||
1765 | 579 |
!DisplayObject methodsFor:'user actions-move'! |
0 | 580 |
|
2840 | 581 |
moveBy:delta |
582 |
"move the receiver - extent is unchanged" |
|
583 |
||
584 |
self moveTo:(self origin + delta) |
|
585 |
! |
|
586 |
||
122 | 587 |
moveTo:aPoint |
588 |
"object must move to new origin |
|
589 |
- default is to stay; ought to be redefined in subclass" |
|
0 | 590 |
|
122 | 591 |
^ self |
592 |
! ! |
|
0 | 593 |
|
134 | 594 |
!DisplayObject class methodsFor:'documentation'! |
595 |
||
596 |
version |
|
3465 | 597 |
^ '$Header: /cvs/stx/stx/libview2/DisplayObject.st,v 1.40 2015-05-05 11:14:19 cg Exp $' |
2815 | 598 |
! |
599 |
||
600 |
version_CVS |
|
3465 | 601 |
^ '$Header: /cvs/stx/stx/libview2/DisplayObject.st,v 1.40 2015-05-05 11:14:19 cg Exp $' |
134 | 602 |
! ! |
3357 | 603 |