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