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