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