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