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