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