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