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