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