author | Claus Gittinger <cg@exept.de> |
Thu, 10 Jul 2014 14:23:22 +0200 | |
changeset 3357 | 57e21ce0e033 |
parent 2840 | a04dce4a0221 |
child 3465 | 8d6d8462943c |
permissions | -rw-r--r-- |
0 | 1 |
" |
6 | 2 |
COPYRIGHT (c) 1989 by Claus Gittinger |
31 | 3 |
All Rights Reserved |
0 | 4 |
|
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
1399 | 12 |
"{ Package: 'stx:libview2' }" |
13 |
||
0 | 14 |
Object subclass:#DisplayObject |
219 | 15 |
instanceVariableNames:'frame' |
16 |
classVariableNames:'' |
|
17 |
poolDictionaries:'' |
|
1789 | 18 |
category:'Compatibility-ST80-Graphics-Display Objects' |
0 | 19 |
! |
20 |
||
21 | 21 |
!DisplayObject class methodsFor:'documentation'! |
22 |
||
23 |
copyright |
|
24 |
" |
|
25 |
COPYRIGHT (c) 1989 by Claus Gittinger |
|
31 | 26 |
All Rights Reserved |
0 | 27 |
|
21 | 28 |
This software is furnished under a license and may be used |
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
34 |
" |
|
35 |
! |
|
0 | 36 |
|
21 | 37 |
documentation |
38 |
" |
|
39 |
generic superclass for Display Objects held in ObjectViews |
|
255 | 40 |
see DrawObject/LogicObject/DeskTopObject and subclasses for example uses. |
41 |
||
219 | 42 |
[author:] |
43 |
Claus Gittinger |
|
21 | 44 |
" |
45 |
! ! |
|
0 | 46 |
|
47 |
!DisplayObject class methodsFor:'instance creation'! |
|
48 |
||
49 |
new |
|
50 |
^ self basicNew initialize |
|
51 |
! ! |
|
52 |
||
53 |
!DisplayObject class methodsFor:'behavior'! |
|
54 |
||
505
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
55 |
dragDashedOutline |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
56 |
"if true, outline dragging is done by drawing the line dashed. |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
57 |
if false, the outline is drawn solid. |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
58 |
Can be redefined in subclasses (for solid outline)." |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
59 |
|
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
60 |
^ true |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
61 |
|
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
62 |
"Created: 28.3.1997 / 16:21:56 / cg" |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
63 |
"Modified: 28.3.1997 / 16:40:54 / cg" |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
64 |
! |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
65 |
|
0 | 66 |
dragOutline |
67 |
"if true, dragging is done by drawing outline only; |
|
505
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
68 |
if false, dragging is done by full draw (fast servers only). |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
69 |
Can be redefined in subclasses (for full dragging)" |
0 | 70 |
|
71 |
^ true |
|
505
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
72 |
|
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
73 |
"Modified: 28.3.1997 / 16:40:44 / cg" |
0 | 74 |
! ! |
75 |
||
122 | 76 |
!DisplayObject methodsFor:'ST-80 drawing'! |
115 | 77 |
|
122 | 78 |
displayOn:aDisplayMedium at:aPoint |
260 | 79 |
"for ST-80 compatibility; not used in ST/X" |
80 |
||
122 | 81 |
self displayOn:aDisplayMedium |
260 | 82 |
at:aPoint |
122 | 83 |
clippingBox:nil |
260 | 84 |
rule:#copy |
85 |
mask:nil |
|
86 |
||
87 |
"Modified: 12.5.1996 / 20:19:15 / cg" |
|
0 | 88 |
! |
89 |
||
122 | 90 |
displayOn:aDisplayMedium at:aPoint clippingBox:clipRectangle |
260 | 91 |
"for ST-80 compatibility; not used in ST/X" |
92 |
||
122 | 93 |
^ self displayOn:aDisplayMedium |
260 | 94 |
at:aPoint |
95 |
clippingBox:clipRectangle |
|
96 |
rule:#copy |
|
97 |
mask:nil |
|
98 |
||
99 |
"Modified: 12.5.1996 / 20:19:17 / cg" |
|
7 | 100 |
! |
101 |
||
122 | 102 |
displayOn:aDisplayMedium at:aPoint clippingBox:clip rule:rule mask: aForm |
260 | 103 |
"for ST-80 compatibility; not used in ST/X. |
104 |
in ST-80 programs, this is redefined" |
|
7 | 105 |
|
122 | 106 |
aDisplayMedium function:rule. |
260 | 107 |
^ self drawIn:aDisplayMedium at:(aPoint + self origin) |
108 |
||
109 |
"Modified: 12.5.1996 / 20:19:27 / cg" |
|
110 |
! |
|
111 |
||
112 |
displayOn:aDisplayMedium x:x y:y |
|
3357 | 113 |
self |
114 |
displayOn:aDisplayMedium |
|
115 |
at:(x @ y) |
|
116 |
clippingBox:nil |
|
117 |
rule:#copy |
|
118 |
mask:nil |
|
260 | 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 |
||
2658 | 130 |
bottomCenter |
131 |
^ self frame bottomCenter |
|
132 |
! |
|
133 |
||
134 |
bottomLeft |
|
135 |
^ self frame bottomLeft |
|
136 |
! |
|
137 |
||
138 |
bottomRight |
|
139 |
^ self frame bottomRight |
|
140 |
! |
|
141 |
||
1496 | 142 |
bounds |
143 |
"ST80 component compatibility" |
|
144 |
||
145 |
^ self frame. |
|
146 |
! |
|
147 |
||
122 | 148 |
corner |
149 |
"return the frame corner" |
|
150 |
||
151 |
frame isNil ifTrue:[ |
|
1692 | 152 |
self computeBoundingBox |
122 | 153 |
]. |
154 |
^ frame corner |
|
155 |
! |
|
156 |
||
157 |
extent |
|
158 |
"return the extent of the frame" |
|
159 |
||
160 |
frame isNil ifTrue:[ |
|
1692 | 161 |
self computeBoundingBox |
122 | 162 |
]. |
163 |
^ frame extent |
|
164 |
! |
|
165 |
||
0 | 166 |
frame |
167 |
"object must return a frame boundary rectangle" |
|
168 |
||
169 |
frame isNil ifTrue:[ |
|
1692 | 170 |
self computeBoundingBox |
0 | 171 |
]. |
172 |
^ frame |
|
173 |
! |
|
174 |
||
175 |
height |
|
176 |
"return the height of the frame" |
|
177 |
||
178 |
frame isNil ifTrue:[ |
|
1692 | 179 |
self computeBoundingBox |
0 | 180 |
]. |
181 |
^ frame height |
|
182 |
! |
|
183 |
||
260 | 184 |
heightOn:aGC |
185 |
"return the height of the frame if drawon on aCG" |
|
186 |
||
187 |
^ self height |
|
188 |
||
189 |
"Created: 12.5.1996 / 20:20:54 / cg" |
|
190 |
! |
|
191 |
||
2267 | 192 |
left |
193 |
^ self frame left |
|
194 |
||
195 |
"Created: / 26-10-2006 / 18:08:42 / cg" |
|
196 |
! |
|
197 |
||
2658 | 198 |
leftCenter |
199 |
^ self frame leftCenter |
|
200 |
! |
|
201 |
||
0 | 202 |
origin |
203 |
"return the frame origin" |
|
204 |
||
205 |
frame isNil ifTrue:[ |
|
1692 | 206 |
self computeBoundingBox |
0 | 207 |
]. |
208 |
^ frame origin |
|
209 |
! |
|
210 |
||
211 |
origin:origin |
|
212 |
"object must calculate its dimension from outline" |
|
213 |
||
214 |
^ self subclassResponsibility |
|
215 |
! |
|
216 |
||
217 |
origin:origin corner:corner |
|
218 |
"object must calculate its dimension from outline" |
|
219 |
||
220 |
^ self subclassResponsibility |
|
122 | 221 |
! |
222 |
||
1688 | 223 |
right |
224 |
^ self frame right |
|
225 |
! |
|
226 |
||
2658 | 227 |
rightCenter |
228 |
^ self frame rightCenter |
|
229 |
! |
|
230 |
||
2131 | 231 |
top |
232 |
^ self frame top |
|
233 |
! |
|
234 |
||
2658 | 235 |
topCenter |
236 |
^ self frame topCenter |
|
237 |
! |
|
238 |
||
2131 | 239 |
topLeft |
240 |
^ self frame topLeft |
|
241 |
! |
|
242 |
||
243 |
topRight |
|
244 |
^ self frame topRight |
|
245 |
! |
|
246 |
||
122 | 247 |
width |
248 |
"return the width of the frame" |
|
249 |
||
250 |
frame isNil ifTrue:[ |
|
1692 | 251 |
self computeBoundingBox |
122 | 252 |
]. |
253 |
^ frame width |
|
260 | 254 |
! |
255 |
||
1579 | 256 |
widthFrom:startIndex to:endIndex on:aGC |
257 |
"return the width of part of myself if drawn on aCG" |
|
258 |
||
259 |
^ self subclassResponsibility |
|
260 |
! |
|
261 |
||
260 | 262 |
widthOn:aGC |
1579 | 263 |
"return the width of the frame if drawn on aCG" |
260 | 264 |
|
265 |
^ self width |
|
266 |
||
267 |
"Created: 12.5.1996 / 20:20:45 / cg" |
|
122 | 268 |
! ! |
269 |
||
1496 | 270 |
!DisplayObject methodsFor:'component protocol'! |
271 |
||
272 |
container:aComponent |
|
273 |
"ignored here - added to allow images to be used like |
|
274 |
VisualComponents (later, Image should inherit from it)" |
|
275 |
! |
|
276 |
||
277 |
containerChangedSize |
|
278 |
"ignored here - added to allow images to be used like |
|
279 |
VisualComponents (later, Image should inherit from it)" |
|
280 |
! |
|
281 |
||
2815 | 282 |
destroy |
283 |
"SimpleView>>destroySubviews wants to destroy us (if we are a view's component). |
|
284 |
Do nothing here" |
|
285 |
||
286 |
^ self |
|
287 |
! |
|
288 |
||
1496 | 289 |
realize |
290 |
"ignored here - added to allow images to be used like |
|
291 |
VisualComponents (later, Image should inherit from it)" |
|
292 |
! ! |
|
293 |
||
122 | 294 |
!DisplayObject methodsFor:'converting'! |
295 |
||
296 |
asDisplayObject |
|
297 |
^ self |
|
0 | 298 |
! ! |
299 |
||
122 | 300 |
!DisplayObject methodsFor:'drawing'! |
301 |
||
505
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
302 |
drawDashedOutlineIn:aGC offset:anOffset |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
303 |
"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
|
304 |
|
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
305 |
|prevStyle| |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
306 |
|
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
307 |
prevStyle := aGC lineStyle. |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
308 |
aGC lineStyle:#dashed. |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
309 |
[ |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
310 |
self drawOutlineIn:aGC offset:anOffset. |
1559
75127f6bf318
#valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents:
1496
diff
changeset
|
311 |
] ensure:[ |
505
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
312 |
aGC lineStyle:prevStyle. |
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 |
|
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
315 |
"Created: 28.3.1997 / 16:23:25 / cg" |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
316 |
"Modified: 28.3.1997 / 16:29:24 / cg" |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
317 |
! |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
318 |
|
122 | 319 |
drawDragIn:aView |
505
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
320 |
"draw the receiver for dragging at its origin" |
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 |
self drawDragIn:aView offset:0@0 |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
323 |
|
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
324 |
"Modified: 28.3.1997 / 16:27:32 / cg" |
122 | 325 |
! |
326 |
||
327 |
drawDragIn:aView at:drawOrigin |
|
505
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
328 |
"draw the receiver for dragging at some point" |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
329 |
|
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
330 |
|offs| |
122 | 331 |
|
505
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
332 |
offs := drawOrigin - (self origin). |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
333 |
self drawDragIn:aView offset:offs |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
334 |
|
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
335 |
"Modified: 28.3.1997 / 16:20:17 / cg" |
122 | 336 |
! |
0 | 337 |
|
122 | 338 |
drawDragIn:aView offset:drawOrigin |
505
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
339 |
"draw the receiver for dragging offset by some amount" |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
340 |
|
122 | 341 |
self class dragOutline ifTrue:[ |
505
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
342 |
self class dragDashedOutline ifTrue:[ |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
343 |
self drawDashedOutlineIn:aView offset:drawOrigin |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
344 |
] ifFalse:[ |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
345 |
self drawOutlineIn:aView offset:drawOrigin |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
346 |
] |
122 | 347 |
] ifFalse: [ |
505
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
348 |
self drawIn:aView offset:drawOrigin |
122 | 349 |
] |
505
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
350 |
|
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
351 |
"Modified: 28.3.1997 / 16:22:31 / cg" |
122 | 352 |
! |
353 |
||
354 |
drawIn:aView |
|
355 |
"draw the receiver at its origin" |
|
0 | 356 |
|
505
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
357 |
self drawIn:aView offset:0@0 |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
358 |
|
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
359 |
"Modified: 28.3.1997 / 16:27:46 / cg" |
122 | 360 |
! |
361 |
||
362 |
drawIn:aView at:drawOrigin |
|
363 |
"draw the receiver at drawOrigin, aPoint" |
|
364 |
||
365 |
self drawIn:aView offset:(drawOrigin - (self origin)) |
|
366 |
! |
|
367 |
||
368 |
drawIn:aView offset:anOffset |
|
369 |
"draw the receiver at its origin offset by anOffset, aPoint" |
|
370 |
||
371 |
^ self subclassResponsibility |
|
0 | 372 |
! |
373 |
||
122 | 374 |
drawOutlineIn:aView |
375 |
"draw the receivers outline at its origin" |
|
376 |
||
505
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
377 |
self drawOutlineIn: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:50 / cg" |
122 | 380 |
! |
381 |
||
382 |
drawOutlineIn:aView at:drawOrigin |
|
383 |
"draw the receivers outline at drawOrigin, aPoint" |
|
384 |
||
385 |
self drawOutlineIn:aView offset:(drawOrigin - self origin) |
|
386 |
! |
|
387 |
||
388 |
drawOutlineIn:aView offset:anOffset |
|
389 |
"draw the receivers outline at its origin offset by anOffset, aPoint" |
|
390 |
||
505
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
391 |
|org x y w h| |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
392 |
|
122 | 393 |
org := self origin + anOffset. |
505
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
394 |
x := org x. |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
395 |
y := org y. |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
396 |
w := frame width. |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
397 |
h := frame height. |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
398 |
|
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
399 |
aView displayRectangleX:x y:y width:w height:h |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
400 |
|
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
401 |
"Modified: 28.3.1997 / 16:32:34 / cg" |
122 | 402 |
! |
403 |
||
404 |
drawSelectedIn:aView |
|
405 |
"draw the receiver highlighted at its position" |
|
406 |
||
505
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
407 |
self drawSelectedIn:aView offset:0@0 |
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
408 |
|
ed95005f043b
support dashed outline drawing.
Claus Gittinger <cg@exept.de>
parents:
288
diff
changeset
|
409 |
"Modified: 28.3.1997 / 16:27:56 / cg" |
122 | 410 |
! |
411 |
||
412 |
drawSelectedIn:aView offset:anOffset |
|
413 |
"draw the receiver highlighted - this is usually redefined" |
|
414 |
||
415 |
self drawIn:aView offset:anOffset. |
|
416 |
self drawOutlineIn:aView offset:anOffset |
|
417 |
! ! |
|
418 |
||
1688 | 419 |
!DisplayObject methodsFor:'dummy event handling'! |
420 |
||
421 |
buttonMotion:buttNr x:x y:y |
|
422 |
! |
|
423 |
||
424 |
buttonPress:buttNr x:x y:y |
|
425 |
! |
|
426 |
||
427 |
buttonRelease:buttNr x:x y:y |
|
428 |
! |
|
429 |
||
430 |
keyPress:key x:x y:y |
|
431 |
! |
|
432 |
||
433 |
keyRelease:key x:x y:y |
|
434 |
! ! |
|
435 |
||
122 | 436 |
!DisplayObject methodsFor:'initialization'! |
437 |
||
438 |
computeBoundingBox |
|
439 |
"compute my boundingBox into the local variable 'frame'. |
|
440 |
The box should be computed for Display." |
|
441 |
||
442 |
^ self subclassResponsibility |
|
443 |
! |
|
444 |
||
445 |
computeBoundingBoxFor:aDevice |
|
446 |
"compute my boundingBox into the local variable 'frame'. |
|
447 |
The box is to be computed for aDevice." |
|
448 |
||
449 |
"/ for backward compatibility, fall back to Display box computation |
|
450 |
||
1692 | 451 |
self computeBoundingBox |
122 | 452 |
! |
453 |
||
454 |
initialize |
|
0 | 455 |
^ self |
456 |
! ! |
|
457 |
||
458 |
!DisplayObject methodsFor:'queries'! |
|
459 |
||
122 | 460 |
canBeMoved |
1193 | 461 |
"return true, if the receiver can be moved around (in an ObjectView)" |
122 | 462 |
|
463 |
^ true |
|
1193 | 464 |
|
465 |
"Modified: / 4.7.1999 / 18:49:26 / cg" |
|
466 |
! |
|
467 |
||
468 |
canBeSelected |
|
469 |
"return true, if the receiver can be selected (in an ObjectView)" |
|
470 |
||
471 |
^ true |
|
472 |
||
473 |
"Created: / 4.7.1999 / 18:49:20 / cg" |
|
122 | 474 |
! |
475 |
||
476 |
containsPoint: aPoint |
|
477 |
^ frame containsPoint: aPoint |
|
478 |
! |
|
479 |
||
288 | 480 |
frameIsHitBy:aPoint withDelta:delta |
481 |
"return true, if my frame is hit by aPoint" |
|
482 |
||
483 |
|org left right top bott px py d2| |
|
484 |
||
485 |
frame isNil ifTrue:[ |
|
2026 | 486 |
self computeBoundingBox. |
487 |
frame isNil ifTrue:[^ false ]. |
|
288 | 488 |
]. |
489 |
(delta == 0) ifTrue:[ |
|
490 |
^ frame containsPoint:aPoint |
|
491 |
]. |
|
492 |
||
493 |
" |
|
494 |
its quicker to not create a new rectangle for the test |
|
495 |
(which is not obvious for simple lines, but complex polygons |
|
496 |
or grouped objects may call this for many of its components) |
|
497 |
" |
|
498 |
org := frame origin. |
|
499 |
left := org x - delta. |
|
500 |
||
501 |
px := aPoint x. |
|
502 |
(px < left) ifTrue:[^ false]. "aPoint is to the left of my left edge" |
|
503 |
||
504 |
d2 := delta * 2. |
|
505 |
right := left + frame width + d2. |
|
506 |
(px > right) ifTrue:[^ false]. "aPoint is to the right of my right edge" |
|
507 |
||
508 |
top := org y - delta. |
|
509 |
py := aPoint y. |
|
510 |
(py < top) ifTrue:[^ false]. "aPoint is above my top edge" |
|
511 |
||
512 |
bott := top + frame height + d2. |
|
513 |
(py > bott) ifTrue:[^ false]. "aPoint is below my bottom edge" |
|
514 |
||
515 |
^ true |
|
516 |
||
517 |
"Created: 5.6.1996 / 15:26:51 / cg" |
|
518 |
! |
|
519 |
||
122 | 520 |
handlesKeyboardInput |
521 |
"return true, if the receiver handles keyboard input" |
|
522 |
||
523 |
^ false |
|
524 |
! |
|
525 |
||
526 |
hasFixedSize |
|
527 |
"return true, if the receiver has fixed size i.e. cannot be |
|
528 |
resized |
|
529 |
- by default, we do not allow resizing" |
|
530 |
||
531 |
^ true |
|
532 |
! |
|
533 |
||
534 |
intersects:aRectangle |
|
535 |
"object must decide, if its intersecting a rectangle" |
|
536 |
||
537 |
^ frame intersects:aRectangle |
|
538 |
! |
|
539 |
||
540 |
isContainedIn:aRectangle |
|
541 |
"object must decide, if its within a rectangle" |
|
542 |
||
543 |
^ aRectangle contains:frame |
|
544 |
! |
|
545 |
||
546 |
isHitBy:aPoint |
|
547 |
"object must decide, if hit by a click at aPoint" |
|
548 |
||
549 |
^ self isHitBy:aPoint withDelta:0 |
|
550 |
! |
|
551 |
||
0 | 552 |
isHitBy:aPoint withDelta:delta |
553 |
"object must decide, if hit by a click at aPoint; |
|
554 |
usually this method is redefined in subclasses for a more complete |
|
555 |
check (i.e. if objects boundary is not rectangular)" |
|
556 |
||
288 | 557 |
^ self frameIsHitBy:aPoint withDelta:delta |
0 | 558 |
|
288 | 559 |
"Modified: 5.6.1996 / 15:27:06 / cg" |
0 | 560 |
! |
561 |
||
122 | 562 |
isOpaque |
563 |
"return true, if the object fully covers its frame (i.e. is rectangular |
|
564 |
and has no 'holes'. Since we dont know, return false here" |
|
0 | 565 |
|
122 | 566 |
^ false |
0 | 567 |
! ! |
568 |
||
1399 | 569 |
!DisplayObject methodsFor:'user actions'! |
0 | 570 |
|
122 | 571 |
keyInput:akey |
572 |
^ self |
|
1399 | 573 |
! ! |
574 |
||
1765 | 575 |
!DisplayObject methodsFor:'user actions-move'! |
0 | 576 |
|
2840 | 577 |
moveBy:delta |
578 |
"move the receiver - extent is unchanged" |
|
579 |
||
580 |
self moveTo:(self origin + delta) |
|
581 |
! |
|
582 |
||
122 | 583 |
moveTo:aPoint |
584 |
"object must move to new origin |
|
585 |
- default is to stay; ought to be redefined in subclass" |
|
0 | 586 |
|
122 | 587 |
^ self |
588 |
! ! |
|
0 | 589 |
|
134 | 590 |
!DisplayObject class methodsFor:'documentation'! |
591 |
||
592 |
version |
|
3357 | 593 |
^ '$Header: /cvs/stx/stx/libview2/DisplayObject.st,v 1.39 2014-07-10 12:23:22 cg Exp $' |
2815 | 594 |
! |
595 |
||
596 |
version_CVS |
|
3357 | 597 |
^ '$Header: /cvs/stx/stx/libview2/DisplayObject.st,v 1.39 2014-07-10 12:23:22 cg Exp $' |
134 | 598 |
! ! |
3357 | 599 |