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