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