author | penk |
Thu, 25 Nov 2004 10:58:41 +0100 | |
changeset 2026 | 7b5a4fe5fbca |
parent 1789 | f52f0a0d8448 |
child 2131 | 768a3cb71598 |
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:'' |
|
1789 | 19 |
category:'Compatibility-ST80-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 at:aPoint |
260 | 80 |
"for ST-80 compatibility; not used in ST/X" |
81 |
||
122 | 82 |
self displayOn:aDisplayMedium |
260 | 83 |
at:aPoint |
122 | 84 |
clippingBox:nil |
260 | 85 |
rule:#copy |
86 |
mask:nil |
|
87 |
||
88 |
"Modified: 12.5.1996 / 20:19:15 / cg" |
|
0 | 89 |
! |
90 |
||
122 | 91 |
displayOn:aDisplayMedium at:aPoint clippingBox:clipRectangle |
260 | 92 |
"for ST-80 compatibility; not used in ST/X" |
93 |
||
122 | 94 |
^ self displayOn:aDisplayMedium |
260 | 95 |
at:aPoint |
96 |
clippingBox:clipRectangle |
|
97 |
rule:#copy |
|
98 |
mask:nil |
|
99 |
||
100 |
"Modified: 12.5.1996 / 20:19:17 / cg" |
|
7 | 101 |
! |
102 |
||
122 | 103 |
displayOn:aDisplayMedium at:aPoint clippingBox:clip rule:rule mask: aForm |
260 | 104 |
"for ST-80 compatibility; not used in ST/X. |
105 |
in ST-80 programs, this is redefined" |
|
7 | 106 |
|
122 | 107 |
aDisplayMedium function:rule. |
260 | 108 |
^ self drawIn:aDisplayMedium at:(aPoint + self origin) |
109 |
||
110 |
"Modified: 12.5.1996 / 20:19:27 / cg" |
|
111 |
! |
|
112 |
||
113 |
displayOn:aDisplayMedium x:x y:y |
|
114 |
self displayOn:aDisplayMedium |
|
115 |
at:(x@y) |
|
116 |
clippingBox:nil |
|
117 |
rule:#copy |
|
118 |
mask:nil |
|
119 |
||
120 |
"Modified: 12.5.1996 / 20:19:15 / cg" |
|
121 |
"Created: 12.5.1996 / 20:20:09 / cg" |
|
34 | 122 |
! ! |
123 |
||
0 | 124 |
!DisplayObject methodsFor:'accessing'! |
125 |
||
1688 | 126 |
bottom |
127 |
^ self frame bottom |
|
128 |
! |
|
129 |
||
1496 | 130 |
bounds |
131 |
"ST80 component compatibility" |
|
132 |
||
133 |
^ self frame. |
|
134 |
! |
|
135 |
||
122 | 136 |
corner |
137 |
"return the frame corner" |
|
138 |
||
139 |
frame isNil ifTrue:[ |
|
1692 | 140 |
self computeBoundingBox |
122 | 141 |
]. |
142 |
^ frame corner |
|
143 |
! |
|
144 |
||
145 |
extent |
|
146 |
"return the extent of the frame" |
|
147 |
||
148 |
frame isNil ifTrue:[ |
|
1692 | 149 |
self computeBoundingBox |
122 | 150 |
]. |
151 |
^ frame extent |
|
152 |
! |
|
153 |
||
0 | 154 |
frame |
155 |
"object must return a frame boundary rectangle" |
|
156 |
||
157 |
frame isNil ifTrue:[ |
|
1692 | 158 |
self computeBoundingBox |
0 | 159 |
]. |
160 |
^ frame |
|
161 |
! |
|
162 |
||
163 |
height |
|
164 |
"return the height of the frame" |
|
165 |
||
166 |
frame isNil ifTrue:[ |
|
1692 | 167 |
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:[ |
|
1692 | 184 |
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 |
||
1688 | 201 |
right |
202 |
^ self frame right |
|
203 |
! |
|
204 |
||
122 | 205 |
width |
206 |
"return the width of the frame" |
|
207 |
||
208 |
frame isNil ifTrue:[ |
|
1692 | 209 |
self computeBoundingBox |
122 | 210 |
]. |
211 |
^ frame width |
|
260 | 212 |
! |
213 |
||
1579 | 214 |
widthFrom:startIndex to:endIndex on:aGC |
215 |
"return the width of part of myself if drawn on aCG" |
|
216 |
||
217 |
^ self subclassResponsibility |
|
218 |
! |
|
219 |
||
260 | 220 |
widthOn:aGC |
1579 | 221 |
"return the width of the frame if drawn on aCG" |
260 | 222 |
|
223 |
^ self width |
|
224 |
||
225 |
"Created: 12.5.1996 / 20:20:45 / cg" |
|
122 | 226 |
! ! |
227 |
||
1496 | 228 |
!DisplayObject methodsFor:'component protocol'! |
229 |
||
230 |
container:aComponent |
|
231 |
"ignored here - added to allow images to be used like |
|
232 |
VisualComponents (later, Image should inherit from it)" |
|
233 |
! |
|
234 |
||
235 |
containerChangedSize |
|
236 |
"ignored here - added to allow images to be used like |
|
237 |
VisualComponents (later, Image should inherit from it)" |
|
238 |
! |
|
239 |
||
240 |
realize |
|
241 |
"ignored here - added to allow images to be used like |
|
242 |
VisualComponents (later, Image should inherit from it)" |
|
243 |
! ! |
|
244 |
||
122 | 245 |
!DisplayObject methodsFor:'converting'! |
246 |
||
247 |
asDisplayObject |
|
248 |
^ self |
|
0 | 249 |
! ! |
250 |
||
122 | 251 |
!DisplayObject methodsFor:'drawing'! |
252 |
||
505
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
253 |
drawDashedOutlineIn:aGC offset:anOffset |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
254 |
"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
|
255 |
|
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
256 |
|prevStyle| |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
257 |
|
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
258 |
prevStyle := aGC lineStyle. |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
259 |
aGC lineStyle:#dashed. |
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 |
self drawOutlineIn:aGC offset:anOffset. |
1559
75127f6bf318
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
1496
diff
changeset
|
262 |
] ensure:[ |
505
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
263 |
aGC lineStyle:prevStyle. |
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 |
|
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
266 |
"Created: 28.3.1997 / 16:23:25 / cg" |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
267 |
"Modified: 28.3.1997 / 16:29:24 / cg" |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
268 |
! |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
269 |
|
122 | 270 |
drawDragIn:aView |
505
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
271 |
"draw the receiver for dragging at its origin" |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
272 |
|
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
273 |
self drawDragIn:aView offset:0@0 |
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:27:32 / cg" |
122 | 276 |
! |
277 |
||
278 |
drawDragIn:aView at:drawOrigin |
|
505
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
279 |
"draw the receiver for dragging at some point" |
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 |
|offs| |
122 | 282 |
|
505
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
283 |
offs := drawOrigin - (self origin). |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
284 |
self drawDragIn:aView offset:offs |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
285 |
|
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
286 |
"Modified: 28.3.1997 / 16:20:17 / cg" |
122 | 287 |
! |
0 | 288 |
|
122 | 289 |
drawDragIn:aView offset:drawOrigin |
505
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
290 |
"draw the receiver for dragging offset by some amount" |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
291 |
|
122 | 292 |
self class dragOutline ifTrue:[ |
505
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
293 |
self class dragDashedOutline ifTrue:[ |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
294 |
self drawDashedOutlineIn:aView offset:drawOrigin |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
295 |
] ifFalse:[ |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
296 |
self drawOutlineIn:aView offset:drawOrigin |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
297 |
] |
122 | 298 |
] ifFalse: [ |
505
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
299 |
self drawIn:aView offset:drawOrigin |
122 | 300 |
] |
505
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 |
"Modified: 28.3.1997 / 16:22:31 / cg" |
122 | 303 |
! |
304 |
||
305 |
drawIn:aView |
|
306 |
"draw the receiver at its origin" |
|
0 | 307 |
|
505
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
308 |
self drawIn:aView offset:0@0 |
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 |
"Modified: 28.3.1997 / 16:27:46 / cg" |
122 | 311 |
! |
312 |
||
313 |
drawIn:aView at:drawOrigin |
|
314 |
"draw the receiver at drawOrigin, aPoint" |
|
315 |
||
316 |
self drawIn:aView offset:(drawOrigin - (self origin)) |
|
317 |
! |
|
318 |
||
319 |
drawIn:aView offset:anOffset |
|
320 |
"draw the receiver at its origin offset by anOffset, aPoint" |
|
321 |
||
322 |
^ self subclassResponsibility |
|
0 | 323 |
! |
324 |
||
122 | 325 |
drawOutlineIn:aView |
326 |
"draw the receivers outline at its origin" |
|
327 |
||
505
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
328 |
self drawOutlineIn:aView offset:0@0 |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
329 |
|
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
330 |
"Modified: 28.3.1997 / 16:27:50 / cg" |
122 | 331 |
! |
332 |
||
333 |
drawOutlineIn:aView at:drawOrigin |
|
334 |
"draw the receivers outline at drawOrigin, aPoint" |
|
335 |
||
336 |
self drawOutlineIn:aView offset:(drawOrigin - self origin) |
|
337 |
! |
|
338 |
||
339 |
drawOutlineIn:aView offset:anOffset |
|
340 |
"draw the receivers outline at its origin offset by anOffset, aPoint" |
|
341 |
||
505
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
342 |
|org x y w h| |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
343 |
|
122 | 344 |
org := self origin + anOffset. |
505
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
345 |
x := org x. |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
346 |
y := org y. |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
347 |
w := frame width. |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
348 |
h := frame height. |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
349 |
|
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
350 |
aView displayRectangleX:x y:y width:w height:h |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
351 |
|
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
352 |
"Modified: 28.3.1997 / 16:32:34 / cg" |
122 | 353 |
! |
354 |
||
355 |
drawSelectedIn:aView |
|
356 |
"draw the receiver highlighted at its position" |
|
357 |
||
505
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
358 |
self drawSelectedIn:aView offset:0@0 |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
359 |
|
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
360 |
"Modified: 28.3.1997 / 16:27:56 / cg" |
122 | 361 |
! |
362 |
||
363 |
drawSelectedIn:aView offset:anOffset |
|
364 |
"draw the receiver highlighted - this is usually redefined" |
|
365 |
||
366 |
self drawIn:aView offset:anOffset. |
|
367 |
self drawOutlineIn:aView offset:anOffset |
|
368 |
! ! |
|
369 |
||
1688 | 370 |
!DisplayObject methodsFor:'dummy event handling'! |
371 |
||
372 |
buttonMotion:buttNr x:x y:y |
|
373 |
! |
|
374 |
||
375 |
buttonPress:buttNr x:x y:y |
|
376 |
! |
|
377 |
||
378 |
buttonRelease:buttNr x:x y:y |
|
379 |
! |
|
380 |
||
381 |
keyPress:key x:x y:y |
|
382 |
! |
|
383 |
||
384 |
keyRelease:key x:x y:y |
|
385 |
! ! |
|
386 |
||
122 | 387 |
!DisplayObject methodsFor:'initialization'! |
388 |
||
389 |
computeBoundingBox |
|
390 |
"compute my boundingBox into the local variable 'frame'. |
|
391 |
The box should be computed for Display." |
|
392 |
||
393 |
^ self subclassResponsibility |
|
394 |
! |
|
395 |
||
396 |
computeBoundingBoxFor:aDevice |
|
397 |
"compute my boundingBox into the local variable 'frame'. |
|
398 |
The box is to be computed for aDevice." |
|
399 |
||
400 |
"/ for backward compatibility, fall back to Display box computation |
|
401 |
||
1692 | 402 |
self computeBoundingBox |
122 | 403 |
! |
404 |
||
405 |
initialize |
|
0 | 406 |
^ self |
407 |
! ! |
|
408 |
||
409 |
!DisplayObject methodsFor:'queries'! |
|
410 |
||
122 | 411 |
canBeMoved |
1193 | 412 |
"return true, if the receiver can be moved around (in an ObjectView)" |
122 | 413 |
|
414 |
^ true |
|
1193 | 415 |
|
416 |
"Modified: / 4.7.1999 / 18:49:26 / cg" |
|
417 |
! |
|
418 |
||
419 |
canBeSelected |
|
420 |
"return true, if the receiver can be selected (in an ObjectView)" |
|
421 |
||
422 |
^ true |
|
423 |
||
424 |
"Created: / 4.7.1999 / 18:49:20 / cg" |
|
122 | 425 |
! |
426 |
||
427 |
containsPoint: aPoint |
|
428 |
^ frame containsPoint: aPoint |
|
429 |
! |
|
430 |
||
288 | 431 |
frameIsHitBy:aPoint withDelta:delta |
432 |
"return true, if my frame is hit by aPoint" |
|
433 |
||
434 |
|org left right top bott px py d2| |
|
435 |
||
436 |
frame isNil ifTrue:[ |
|
2026 | 437 |
self computeBoundingBox. |
438 |
frame isNil ifTrue:[^ false ]. |
|
288 | 439 |
]. |
440 |
(delta == 0) ifTrue:[ |
|
441 |
^ frame containsPoint:aPoint |
|
442 |
]. |
|
443 |
||
444 |
" |
|
445 |
its quicker to not create a new rectangle for the test |
|
446 |
(which is not obvious for simple lines, but complex polygons |
|
447 |
or grouped objects may call this for many of its components) |
|
448 |
" |
|
449 |
org := frame origin. |
|
450 |
left := org x - delta. |
|
451 |
||
452 |
px := aPoint x. |
|
453 |
(px < left) ifTrue:[^ false]. "aPoint is to the left of my left edge" |
|
454 |
||
455 |
d2 := delta * 2. |
|
456 |
right := left + frame width + d2. |
|
457 |
(px > right) ifTrue:[^ false]. "aPoint is to the right of my right edge" |
|
458 |
||
459 |
top := org y - delta. |
|
460 |
py := aPoint y. |
|
461 |
(py < top) ifTrue:[^ false]. "aPoint is above my top edge" |
|
462 |
||
463 |
bott := top + frame height + d2. |
|
464 |
(py > bott) ifTrue:[^ false]. "aPoint is below my bottom edge" |
|
465 |
||
466 |
^ true |
|
467 |
||
468 |
"Created: 5.6.1996 / 15:26:51 / cg" |
|
469 |
! |
|
470 |
||
122 | 471 |
handlesKeyboardInput |
472 |
"return true, if the receiver handles keyboard input" |
|
473 |
||
474 |
^ false |
|
475 |
! |
|
476 |
||
477 |
hasFixedSize |
|
478 |
"return true, if the receiver has fixed size i.e. cannot be |
|
479 |
resized |
|
480 |
- by default, we do not allow resizing" |
|
481 |
||
482 |
^ true |
|
483 |
! |
|
484 |
||
485 |
intersects:aRectangle |
|
486 |
"object must decide, if its intersecting a rectangle" |
|
487 |
||
488 |
^ frame intersects:aRectangle |
|
489 |
! |
|
490 |
||
491 |
isContainedIn:aRectangle |
|
492 |
"object must decide, if its within a rectangle" |
|
493 |
||
494 |
^ aRectangle contains:frame |
|
495 |
! |
|
496 |
||
497 |
isHitBy:aPoint |
|
498 |
"object must decide, if hit by a click at aPoint" |
|
499 |
||
500 |
^ self isHitBy:aPoint withDelta:0 |
|
501 |
! |
|
502 |
||
0 | 503 |
isHitBy:aPoint withDelta:delta |
504 |
"object must decide, if hit by a click at aPoint; |
|
505 |
usually this method is redefined in subclasses for a more complete |
|
506 |
check (i.e. if objects boundary is not rectangular)" |
|
507 |
||
288 | 508 |
^ self frameIsHitBy:aPoint withDelta:delta |
0 | 509 |
|
288 | 510 |
"Modified: 5.6.1996 / 15:27:06 / cg" |
0 | 511 |
! |
512 |
||
122 | 513 |
isOpaque |
514 |
"return true, if the object fully covers its frame (i.e. is rectangular |
|
515 |
and has no 'holes'. Since we dont know, return false here" |
|
0 | 516 |
|
122 | 517 |
^ false |
0 | 518 |
! ! |
519 |
||
1399 | 520 |
!DisplayObject methodsFor:'user actions'! |
0 | 521 |
|
122 | 522 |
keyInput:akey |
523 |
^ self |
|
1399 | 524 |
! ! |
525 |
||
1765 | 526 |
!DisplayObject methodsFor:'user actions-move'! |
0 | 527 |
|
122 | 528 |
moveTo:aPoint |
529 |
"object must move to new origin |
|
530 |
- default is to stay; ought to be redefined in subclass" |
|
0 | 531 |
|
122 | 532 |
^ self |
533 |
! ! |
|
0 | 534 |
|
134 | 535 |
!DisplayObject class methodsFor:'documentation'! |
536 |
||
537 |
version |
|
2026 | 538 |
^ '$Header: /cvs/stx/stx/libview2/DisplayObject.st,v 1.33 2004-11-25 09:58:41 penk Exp $' |
134 | 539 |
! ! |