156
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1995 by eXept Software AG
|
|
3 |
All Rights Reserved
|
|
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 |
|
|
13 |
|
|
14 |
|
60
|
15 |
ObjectView subclass:#UIObjectView
|
123
|
16 |
instanceVariableNames:'saveSelection inputView enableChannel undoHistory copiedExtent
|
175
|
17 |
copiedLayout resizeData clipChildren selectionHiddenLevel
|
|
18 |
setOfSuperViewsSizeChanged'
|
60
|
19 |
classVariableNames:''
|
|
20 |
poolDictionaries:''
|
|
21 |
category:'Interface-UIPainter'
|
|
22 |
!
|
|
23 |
|
|
24 |
Object subclass:#UndoHistory
|
134
|
25 |
instanceVariableNames:'startIdentifier identifier painter history transaction enabled'
|
60
|
26 |
classVariableNames:''
|
|
27 |
poolDictionaries:''
|
|
28 |
privateIn:UIObjectView
|
|
29 |
!
|
|
30 |
|
54
|
31 |
Object subclass:#Transaction
|
134
|
32 |
instanceVariableNames:'identifier type text actions'
|
54
|
33 |
classVariableNames:''
|
|
34 |
poolDictionaries:''
|
|
35 |
privateIn:UIObjectView::UndoHistory
|
|
36 |
!
|
|
37 |
|
128
|
38 |
!UIObjectView class methodsFor:'documentation'!
|
|
39 |
|
156
|
40 |
copyright
|
|
41 |
"
|
|
42 |
COPYRIGHT (c) 1995 by eXept Software AG
|
|
43 |
All Rights Reserved
|
|
44 |
|
|
45 |
This software is furnished under a license and may be used
|
|
46 |
only in accordance with the terms of that license and with the
|
|
47 |
inclusion of the above copyright notice. This software may not
|
|
48 |
be provided or otherwise made available to, or used by, any
|
|
49 |
other person. No title to or ownership of the software is
|
|
50 |
hereby transferred.
|
|
51 |
"
|
|
52 |
|
|
53 |
|
|
54 |
!
|
|
55 |
|
128
|
56 |
documentation
|
|
57 |
"
|
131
|
58 |
buildIn view used by the UIPainter; it provides all services for creating, deleting
|
|
59 |
moving and changing layouts of painted components on a canvas.
|
128
|
60 |
|
|
61 |
[see also:]
|
|
62 |
UIBuilder
|
|
63 |
UIPainterView
|
156
|
64 |
|
|
65 |
[author:]
|
|
66 |
Claus Atzkern
|
128
|
67 |
"
|
|
68 |
|
|
69 |
! !
|
60
|
70 |
|
63
|
71 |
!UIObjectView class methodsFor:'conversion'!
|
|
72 |
|
|
73 |
asLayoutFrameFromView:aView
|
|
74 |
"convert layout from aView to a frameLayout. On success the frameLayout is
|
|
75 |
returned otherwise nil
|
|
76 |
"
|
68
|
77 |
|lF lO rF rO tF tO bF bO type layout newLyt|
|
|
78 |
|
|
79 |
type := self layoutType:aView.
|
|
80 |
layout := aView geometryLayout.
|
|
81 |
|
91
|
82 |
layout isNil ifTrue:[
|
|
83 |
type == #Extent ifTrue:[
|
|
84 |
layout := aView bounds asLayout
|
|
85 |
]
|
|
86 |
].
|
|
87 |
|
68
|
88 |
(type isNil or:[layout isNil]) ifTrue:[
|
63
|
89 |
^ nil
|
|
90 |
].
|
|
91 |
|
68
|
92 |
type == #LayoutFrame ifTrue:[
|
|
93 |
^ layout copy
|
|
94 |
].
|
|
95 |
|
|
96 |
layout isLayout ifFalse:[
|
|
97 |
type == #Rectangle ifTrue:[
|
63
|
98 |
lO := layout left.
|
|
99 |
tO := layout top.
|
|
100 |
rO := layout right.
|
|
101 |
bO := layout bottom.
|
|
102 |
] ifFalse:[
|
|
103 |
lO := layout x.
|
|
104 |
tO := layout y.
|
|
105 |
rO := lO + aView extent x.
|
|
106 |
bO := tO + aView extent y.
|
|
107 |
].
|
68
|
108 |
|
|
109 |
^ LayoutFrame leftFraction:0 offset:lO rightFraction:0 offset:rO
|
|
110 |
topFraction:0 offset:tO bottomFraction:0 offset:bO
|
63
|
111 |
].
|
|
112 |
|
68
|
113 |
lF := layout leftFraction.
|
|
114 |
lO := layout leftOffset.
|
|
115 |
tF := layout topFraction.
|
|
116 |
tO := layout topOffset.
|
|
117 |
bF := tF.
|
|
118 |
bO := tO + aView extent y.
|
|
119 |
rF := lF.
|
|
120 |
rO := lO + aView extent x.
|
|
121 |
|
|
122 |
newLyt := LayoutFrame leftFraction:lF offset:lO rightFraction:rF offset:rO
|
|
123 |
topFraction:tF offset:tO bottomFraction:bF offset:bO.
|
|
124 |
|
|
125 |
( (type == #AlignmentOrigin)
|
|
126 |
and:[layout leftAlignmentFraction ~~ 0
|
|
127 |
or:[layout topAlignmentFraction ~~ 0]]
|
|
128 |
) ifTrue:[
|
|
129 |
|svRc prBd dlta|
|
|
130 |
|
|
131 |
svRc := aView superView viewRectangle.
|
|
132 |
prBd := aView preferredBounds.
|
|
133 |
dlta := ( ((layout rectangleRelativeTo:svRc preferred:prBd) corner)
|
|
134 |
- ((newLyt rectangleRelativeTo:svRc preferred:prBd) corner)
|
|
135 |
) rounded.
|
|
136 |
|
|
137 |
newLyt leftOffset:(lO + dlta x).
|
|
138 |
newLyt rightOffset:(rO + dlta x).
|
|
139 |
newLyt topOffset:(tO + dlta y).
|
|
140 |
newLyt bottomOffset:(bO + dlta y).
|
|
141 |
].
|
|
142 |
^ newLyt.
|
91
|
143 |
|
|
144 |
"Modified: 28.3.1997 / 19:52:48 / cg"
|
63
|
145 |
! !
|
|
146 |
|
60
|
147 |
!UIObjectView class methodsFor:'defaults'!
|
|
148 |
|
|
149 |
defaultGrid
|
|
150 |
^ 4 @ 4
|
|
151 |
|
|
152 |
!
|
|
153 |
|
|
154 |
gridShown
|
|
155 |
^ false
|
|
156 |
|
|
157 |
!
|
|
158 |
|
|
159 |
handleSize
|
|
160 |
"size of blob drawn for handles"
|
|
161 |
^ 4
|
|
162 |
|
|
163 |
!
|
|
164 |
|
|
165 |
hitDelta
|
|
166 |
^ 4
|
|
167 |
|
|
168 |
! !
|
|
169 |
|
175
|
170 |
!UIObjectView class methodsFor:'handles'!
|
|
171 |
|
|
172 |
handlesOf:aView do:aBlock
|
|
173 |
|type v h|
|
|
174 |
|
|
175 |
type := self layoutType:aView.
|
|
176 |
|
|
177 |
(type == #LayoutFrame or:[type == #Rectangle]) ifTrue:[
|
|
178 |
v := self isVerticalResizable:aView.
|
|
179 |
h := self isHorizontalResizable:aView.
|
|
180 |
|
|
181 |
h ifTrue:[ aBlock value:(aView leftCenter ) value:#left.
|
|
182 |
aBlock value:(aView rightCenter) value:#right.
|
|
183 |
].
|
|
184 |
v ifTrue:[ aBlock value:(aView topCenter ) value:#top.
|
|
185 |
aBlock value:(aView bottomCenter) value:#bottom.
|
|
186 |
].
|
|
187 |
|
|
188 |
(h and:[v]) ifTrue:[
|
|
189 |
aBlock value:(aView origin ) value:#origin.
|
|
190 |
aBlock value:(aView topRight ) value:#topRight.
|
|
191 |
aBlock value:(aView bottomLeft) value:#bottomLeft.
|
|
192 |
aBlock value:(aView corner ) value:#corner.
|
|
193 |
^ self
|
|
194 |
]
|
|
195 |
].
|
|
196 |
|
|
197 |
aBlock value:(aView origin ) value:#view.
|
|
198 |
aBlock value:(aView topRight ) value:#view.
|
|
199 |
aBlock value:(aView bottomLeft) value:#view.
|
|
200 |
|
|
201 |
type == #Extent ifTrue:[
|
|
202 |
v := self isVerticalResizable:aView.
|
|
203 |
h := self isHorizontalResizable:aView.
|
|
204 |
|
|
205 |
v ifTrue:[aBlock value:(aView bottomCenter) value:#bottom].
|
|
206 |
h ifTrue:[aBlock value:(aView rightCenter ) value:#right ].
|
|
207 |
|
|
208 |
(h and:[v]) ifTrue:[
|
|
209 |
aBlock value:(aView corner) value:#corner.
|
|
210 |
^ self
|
|
211 |
]
|
|
212 |
].
|
|
213 |
aBlock value:(aView corner) value:#view.
|
|
214 |
|
|
215 |
|
|
216 |
! !
|
|
217 |
|
61
|
218 |
!UIObjectView class methodsFor:'queries'!
|
|
219 |
|
175
|
220 |
isHorizontalResizable:aComponent
|
|
221 |
"returns true if instance is horizontal resizeable
|
|
222 |
"
|
|
223 |
(aComponent isKindOf:ScrollBar) ifTrue:[
|
|
224 |
^ aComponent orientation == #horizontal
|
|
225 |
].
|
|
226 |
(aComponent isKindOf:Scroller) ifTrue:[
|
|
227 |
^ aComponent orientation == #horizontal
|
|
228 |
].
|
|
229 |
(aComponent isKindOf:Slider) ifTrue:[
|
|
230 |
^ aComponent orientation == #horizontal
|
|
231 |
].
|
|
232 |
^ true
|
|
233 |
|
|
234 |
!
|
|
235 |
|
|
236 |
isVerticalResizable:aComponent
|
|
237 |
"returns true if instance is vertical resizeable
|
|
238 |
"
|
|
239 |
(aComponent isKindOf:EditField) ifTrue:[
|
|
240 |
^ false
|
|
241 |
].
|
|
242 |
(aComponent isKindOf:ComboBoxView) ifTrue:[
|
|
243 |
^ false
|
|
244 |
].
|
|
245 |
(aComponent isKindOf:CheckBox) ifTrue:[
|
|
246 |
^ false
|
|
247 |
].
|
|
248 |
(aComponent isKindOf:ScrollBar) ifTrue:[
|
|
249 |
^ aComponent orientation == #vertical
|
|
250 |
].
|
|
251 |
(aComponent isKindOf:Scroller) ifTrue:[
|
|
252 |
^ aComponent orientation == #vertical
|
|
253 |
].
|
|
254 |
(aComponent isKindOf:Slider) ifTrue:[
|
|
255 |
^ aComponent orientation == #vertical
|
|
256 |
].
|
|
257 |
^ true
|
|
258 |
|
|
259 |
!
|
|
260 |
|
61
|
261 |
layoutType:aView
|
|
262 |
"returns layout type of aView or nil
|
|
263 |
"
|
113
|
264 |
|layout spec superView|
|
|
265 |
|
|
266 |
aView notNil ifTrue:[
|
|
267 |
layout := aView geometryLayout.
|
|
268 |
layout notNil ifTrue:[
|
|
269 |
layout isLayout ifTrue:[
|
|
270 |
layout isLayoutFrame ifTrue:[ ^ #LayoutFrame ].
|
|
271 |
layout isAlignmentOrigin ifTrue:[ ^ #AlignmentOrigin ].
|
|
272 |
layout isLayoutOrigin ifTrue:[ ^ #LayoutOrigin ].
|
|
273 |
] ifFalse:[
|
|
274 |
layout isRectangle ifTrue:[ ^ #Rectangle ].
|
|
275 |
layout isPoint ifTrue:[ ^ #Point ].
|
|
276 |
]
|
61
|
277 |
] ifFalse:[
|
113
|
278 |
(superView := aView superView) notNil ifTrue:[
|
|
279 |
spec := superView specClass.
|
|
280 |
spec canResizeSubComponents ifTrue:[
|
|
281 |
^ #Extent
|
|
282 |
]
|
|
283 |
]
|
61
|
284 |
]
|
|
285 |
].
|
|
286 |
^ nil
|
|
287 |
|
67
|
288 |
"Modified: 28.2.1997 / 13:02:16 / cg"
|
61
|
289 |
! !
|
|
290 |
|
60
|
291 |
!UIObjectView methodsFor:'accessing'!
|
|
292 |
|
119
|
293 |
enableChannel
|
|
294 |
"returns the channel which keeps false if running test otherwise true
|
|
295 |
"
|
|
296 |
^ enableChannel
|
113
|
297 |
!
|
|
298 |
|
60
|
299 |
gridAlign
|
61
|
300 |
"returns state of aligning to grid
|
|
301 |
"
|
60
|
302 |
^ aligning
|
|
303 |
|
|
304 |
!
|
|
305 |
|
|
306 |
gridAlign:aBool
|
61
|
307 |
"change state of aligning to grid
|
|
308 |
"
|
60
|
309 |
aBool ifTrue:[self alignOn]
|
|
310 |
ifFalse:[self alignOff]
|
|
311 |
|
|
312 |
!
|
|
313 |
|
|
314 |
gridParameters
|
|
315 |
"used by defineGrid, and in a separate method for
|
|
316 |
easier redefinition in subclasses.
|
|
317 |
Returns the grid parameters in an array of 7 elements,
|
|
318 |
which control the appearance of the grid-pattern.
|
|
319 |
the elements are:
|
|
320 |
|
|
321 |
bigStepH number of pixels horizontally between 2 major steps
|
|
322 |
bigStepV number of pixels vertically between 2 major steps
|
|
323 |
littleStepH number of pixels horizontally between 2 minor steps
|
|
324 |
littleStepV number of pixels vertically between 2 minor steps
|
|
325 |
gridAlignH number of pixels for horizontal grid align (pointer snap)
|
|
326 |
gridAlignV number of pixels for vertical grid align (pointer snap)
|
|
327 |
docBounds true, if document boundary should be shown
|
|
328 |
|
|
329 |
if littleStepH/V are nil, only bigSteps are drawn.
|
|
330 |
"
|
|
331 |
|
|
332 |
^ #(10 10 nil nil 10 10 false)
|
|
333 |
|
|
334 |
|
|
335 |
!
|
|
336 |
|
|
337 |
gridShown:aBool
|
61
|
338 |
"change visibility of grid
|
|
339 |
"
|
60
|
340 |
aBool ifTrue:[self showGrid]
|
|
341 |
ifFalse:[self hideGrid]
|
|
342 |
!
|
|
343 |
|
|
344 |
hideGrid
|
61
|
345 |
"hide grid
|
|
346 |
"
|
60
|
347 |
gridShown ifTrue:[
|
61
|
348 |
self withSelectionHiddenDo:[super hideGrid]
|
60
|
349 |
]
|
|
350 |
|
|
351 |
|
|
352 |
!
|
|
353 |
|
|
354 |
showGrid
|
61
|
355 |
"show grid
|
|
356 |
"
|
|
357 |
self withSelectionHiddenDo:[super showGrid]
|
119
|
358 |
! !
|
|
359 |
|
|
360 |
!UIObjectView methodsFor:'accessing behavior'!
|
|
361 |
|
|
362 |
enabled
|
|
363 |
^ enableChannel value
|
|
364 |
!
|
|
365 |
|
|
366 |
enabled:aState
|
|
367 |
"set the modification / test mode
|
|
368 |
"
|
|
369 |
(aState == enableChannel value) ifFalse:[
|
123
|
370 |
aState ifFalse:[
|
131
|
371 |
saveSelection := self selection.
|
|
372 |
self select:nil.
|
128
|
373 |
enableChannel value:aState.
|
140
|
374 |
inputView unmap.
|
119
|
375 |
] ifTrue:[
|
|
376 |
inputView raise.
|
123
|
377 |
inputView realize.
|
128
|
378 |
enableChannel value:aState.
|
123
|
379 |
self select:saveSelection.
|
|
380 |
]
|
119
|
381 |
]
|
|
382 |
|
|
383 |
|
|
384 |
|
60
|
385 |
!
|
|
386 |
|
134
|
387 |
resetModification
|
|
388 |
"set modification state to false
|
|
389 |
"
|
|
390 |
undoHistory resetModification
|
|
391 |
!
|
|
392 |
|
60
|
393 |
testMode
|
61
|
394 |
"returns true if running test
|
60
|
395 |
"
|
119
|
396 |
^ enableChannel value not
|
60
|
397 |
|
|
398 |
|
|
399 |
!
|
|
400 |
|
|
401 |
testMode:aBoolean
|
61
|
402 |
"change test mode
|
60
|
403 |
"
|
119
|
404 |
self enabled:(aBoolean not)
|
60
|
405 |
! !
|
|
406 |
|
|
407 |
!UIObjectView methodsFor:'blocked'!
|
|
408 |
|
|
409 |
addObject:anObject
|
61
|
410 |
"add the argument, anObject to the contents - with redraw
|
|
411 |
"
|
60
|
412 |
self halt
|
|
413 |
|
|
414 |
!
|
|
415 |
|
|
416 |
addObjectWithoutRedraw:anObject
|
61
|
417 |
"add the argument, anObject to the contents - with redraw
|
|
418 |
"
|
60
|
419 |
self halt
|
|
420 |
|
175
|
421 |
!
|
|
422 |
|
|
423 |
startCreate:aPoint
|
|
424 |
self setDefaultActions.
|
|
425 |
self halt
|
60
|
426 |
! !
|
|
427 |
|
|
428 |
!UIObjectView methodsFor:'event handling'!
|
|
429 |
|
61
|
430 |
elementChangedSize:aView
|
|
431 |
"some element has changed its size; collect them during selectionHiddenLevel
|
|
432 |
is on
|
|
433 |
"
|
|
434 |
selectionHiddenLevel ~~ 0 ifTrue:[
|
|
435 |
setOfSuperViewsSizeChanged add:aView superView
|
|
436 |
] ifFalse:[
|
|
437 |
aView superView sizeChanged:nil
|
|
438 |
]
|
60
|
439 |
!
|
|
440 |
|
|
441 |
exposeX:x y:y width:w height:h
|
|
442 |
"handle an expose event from device; redraw selection
|
|
443 |
"
|
175
|
444 |
resizeData isNil ifTrue:[
|
|
445 |
super exposeX:x y:y width:w height:h.
|
|
446 |
|
|
447 |
"/ handle any expose events (for subcomponents) before
|
|
448 |
"/ redrawing the handles.
|
|
449 |
(self sensor hasExposeEventFor:nil) ifTrue:[^ self].
|
|
450 |
|
|
451 |
self selectionDo:[:aComponent |
|
|
452 |
aComponent withAllSubViewsDo:[:v |
|
|
453 |
self sensor flushExposeEventsFor:v.
|
|
454 |
v exposeX:0 y:0 width:9999 height:9999.
|
|
455 |
].
|
|
456 |
|
|
457 |
self showSelected:aComponent
|
|
458 |
]
|
132
|
459 |
]
|
60
|
460 |
|
|
461 |
!
|
|
462 |
|
|
463 |
keyPress:key x:x y:y
|
61
|
464 |
"any key pressed
|
|
465 |
"
|
78
|
466 |
<resource: #keyboard ( #Delete #BackSpace #Cut #Copy #Paste ) >
|
60
|
467 |
|
|
468 |
(key == #Cut or:[key == #Delete or:[key == #BackSpace]]) ifTrue: [
|
|
469 |
^ self deleteSelection
|
|
470 |
].
|
|
471 |
|
78
|
472 |
key == #Copy ifTrue:[ ^ self copySelection].
|
|
473 |
key == #Paste ifTrue:[ ^ self pasteBuffer].
|
60
|
474 |
!
|
|
475 |
|
|
476 |
processEvent:anEvent
|
|
477 |
"catch expose events for components, and redraw its handles after
|
|
478 |
the redraw when this happens
|
|
479 |
"
|
128
|
480 |
(anEvent type == #damage and:[self isSelected:(anEvent view)]) ifTrue:[
|
|
481 |
self showSelected:(anEvent view)
|
60
|
482 |
].
|
|
483 |
^ false.
|
|
484 |
|
|
485 |
|
|
486 |
!
|
|
487 |
|
|
488 |
sizeChanged:how
|
61
|
489 |
"size of a view(s) changed
|
|
490 |
"
|
60
|
491 |
self withSelectionHiddenDo:[
|
|
492 |
super sizeChanged:how
|
|
493 |
]
|
|
494 |
|
|
495 |
|
|
496 |
! !
|
|
497 |
|
|
498 |
!UIObjectView methodsFor:'initialization'!
|
|
499 |
|
|
500 |
initialize
|
61
|
501 |
"setup attributes
|
|
502 |
"
|
60
|
503 |
super initialize.
|
|
504 |
|
|
505 |
"funny: since I do not want the created widgets to get pointer
|
|
506 |
events, I put an InputView on top of them, which catches those events
|
|
507 |
and passes them back to me - have to take care, that this inputView
|
|
508 |
is always on top
|
|
509 |
"
|
|
510 |
inputView := InputView origin:0.0@0.0 extent:1.0@1.0 in:self.
|
61
|
511 |
setOfSuperViewsSizeChanged := IdentitySet new.
|
60
|
512 |
|
|
513 |
inputView eventReceiver:self.
|
|
514 |
inputView enableButtonEvents.
|
|
515 |
inputView enableButtonMotionEvents.
|
|
516 |
|
|
517 |
self setDefaultActions.
|
|
518 |
|
134
|
519 |
undoHistory := UndoHistory on:self.
|
119
|
520 |
enableChannel := true asValue.
|
|
521 |
clipChildren := true.
|
61
|
522 |
selectionHiddenLevel := 0.
|
60
|
523 |
|
|
524 |
(self class gridShown) ifTrue:[
|
|
525 |
super showGrid
|
|
526 |
].
|
|
527 |
|
|
528 |
!
|
|
529 |
|
|
530 |
realize
|
|
531 |
super realize.
|
|
532 |
self windowGroup postEventHook:self
|
|
533 |
|
|
534 |
! !
|
|
535 |
|
|
536 |
!UIObjectView methodsFor:'misc'!
|
|
537 |
|
|
538 |
cursor:aCursor
|
61
|
539 |
"set cursor
|
|
540 |
"
|
60
|
541 |
inputView realized ifTrue:[
|
|
542 |
inputView cursor:aCursor
|
|
543 |
].
|
|
544 |
super cursor:aCursor
|
|
545 |
|
|
546 |
|
|
547 |
!
|
|
548 |
|
175
|
549 |
invertOutlineOf:something
|
|
550 |
"invert outline of an object or collection of objects
|
61
|
551 |
"
|
175
|
552 |
|wasClipped p|
|
60
|
553 |
|
|
554 |
(wasClipped := clipChildren) ifTrue:[
|
|
555 |
self clippedByChildren:(clipChildren := false).
|
|
556 |
].
|
175
|
557 |
|
|
558 |
something isCollection ifTrue:[
|
|
559 |
something do:[:v|
|
|
560 |
p := v originRelativeTo:self.
|
|
561 |
self xoring:[self displayRectangle:(p extent:v extent)].
|
|
562 |
]
|
|
563 |
] ifFalse:[
|
|
564 |
p := something originRelativeTo:self.
|
|
565 |
self xoring:[self displayRectangle:(p extent:something extent)]
|
60
|
566 |
].
|
|
567 |
|
|
568 |
wasClipped ifTrue:[
|
|
569 |
self clippedByChildren:(clipChildren := true).
|
|
570 |
].
|
|
571 |
|
|
572 |
!
|
|
573 |
|
78
|
574 |
minSetOfSuperViews:setOfViews
|
|
575 |
|
|
576 |
setOfViews isCollection ifFalse:[
|
|
577 |
setOfViews notNil ifTrue:[^ Array with:setOfViews]
|
|
578 |
ifFalse:[^ nil]
|
72
|
579 |
].
|
78
|
580 |
^ setOfViews select:[:aView|
|
|
581 |
(setOfViews detect:[:v|aView isComponentOf:v] ifNone:nil) isNil
|
|
582 |
]
|
72
|
583 |
!
|
|
584 |
|
60
|
585 |
setDefaultActions
|
61
|
586 |
"set default actions
|
|
587 |
"
|
60
|
588 |
pressAction := [:pressPoint | self startSelectOrMove:pressPoint].
|
|
589 |
shiftPressAction := [:pressPoint | self startSelectMoreOrMove:pressPoint].
|
|
590 |
motionAction := [:movePoint | nil].
|
|
591 |
releaseAction := [nil].
|
|
592 |
keyPressAction := nil.
|
|
593 |
|
|
594 |
self cursor:Cursor normal.
|
|
595 |
|
|
596 |
! !
|
|
597 |
|
|
598 |
!UIObjectView methodsFor:'object moving'!
|
|
599 |
|
|
600 |
doObjectMove:aPoint
|
|
601 |
"move selection
|
|
602 |
"
|
|
603 |
movedObject notNil ifTrue:[
|
175
|
604 |
self invertOutlineOf:movedObject.
|
|
605 |
|
|
606 |
movedObject keysAndValuesDo:[:i :v|
|
|
607 |
self moveObject:v to:(aPoint - (moveDelta at:i)).
|
|
608 |
].
|
|
609 |
self invertOutlineOf:movedObject.
|
60
|
610 |
]
|
|
611 |
|
|
612 |
!
|
|
613 |
|
|
614 |
endObjectMove
|
61
|
615 |
"cleanup after object(s) move
|
|
616 |
"
|
60
|
617 |
movedObject notNil ifTrue:[
|
175
|
618 |
self invertOutlineOf:movedObject.
|
128
|
619 |
|
|
620 |
movedObject size == 1 ifTrue:[
|
|
621 |
movedObject := movedObject first
|
60
|
622 |
].
|
128
|
623 |
self setSelection:movedObject withRedraw:true.
|
60
|
624 |
movedObject := nil.
|
|
625 |
self setDefaultActions.
|
|
626 |
self changed:#layout.
|
|
627 |
].
|
|
628 |
!
|
|
629 |
|
|
630 |
moveObject:anObject to:aPoint
|
|
631 |
"move anObject to newOrigin, aPoint
|
|
632 |
"
|
|
633 |
|dX dY org delta|
|
|
634 |
|
|
635 |
anObject notNil ifTrue:[
|
|
636 |
org := anObject computeOrigin.
|
|
637 |
|
|
638 |
delta := aPoint - org.
|
|
639 |
delta := (self alignToGrid:aPoint) - org.
|
|
640 |
dX := delta x.
|
|
641 |
dY := delta y.
|
|
642 |
|
134
|
643 |
undoHistory withoutTransactionDo:[
|
60
|
644 |
self shiftLayout:anObject top:dY bottom:dY left:dX right:dX
|
|
645 |
]
|
|
646 |
]
|
|
647 |
|
|
648 |
!
|
|
649 |
|
|
650 |
startObjectMoveAt:aPoint
|
61
|
651 |
"start object(s) move at a point
|
|
652 |
"
|
128
|
653 |
self startObjectMove:(self selection) at:aPoint.
|
|
654 |
movedObject := self selection.
|
|
655 |
|
|
656 |
movedObject isCollection ifFalse:[
|
|
657 |
movedObject := Array with:movedObject
|
60
|
658 |
].
|
128
|
659 |
self setSelection:nil withRedraw:true.
|
60
|
660 |
|
|
661 |
moveDelta := movedObject collect:[:aView|
|
|
662 |
aPoint - aView computeOrigin
|
|
663 |
].
|
175
|
664 |
self transaction:#move objects:movedObject do:[:v|self createUndoLayout:v].
|
|
665 |
self invertOutlineOf:movedObject.
|
60
|
666 |
!
|
|
667 |
|
|
668 |
startSelectMoreOrMove:aPoint
|
|
669 |
"add/remove to/from selection"
|
|
670 |
|
|
671 |
|anObject|
|
|
672 |
|
119
|
673 |
self enabled ifFalse:[^ self].
|
60
|
674 |
|
|
675 |
anObject := self findObjectAt:aPoint.
|
|
676 |
anObject notNil ifTrue:[
|
|
677 |
(self isSelected:anObject) ifTrue:[
|
|
678 |
self removeFromSelection:anObject
|
|
679 |
] ifFalse:[
|
|
680 |
self addToSelection:anObject
|
|
681 |
]
|
|
682 |
]
|
|
683 |
!
|
|
684 |
|
|
685 |
startSelectOrMove:aPoint
|
61
|
686 |
"a button is pressed at a point; start moving or selection
|
60
|
687 |
"
|
61
|
688 |
|aView b|
|
60
|
689 |
|
119
|
690 |
self enabled ifFalse:[^ self].
|
60
|
691 |
|
61
|
692 |
aView := self singleSelection.
|
|
693 |
|
|
694 |
aView notNil ifTrue:[
|
|
695 |
(aView superView specClass canResizeSubComponents) ifTrue:[
|
|
696 |
b := self whichHandleOf:aView isHitBy:aPoint.
|
|
697 |
|
|
698 |
(b notNil and:[b ~~ #view]) ifTrue:[
|
|
699 |
^ self startResizeBorder:b of:aView.
|
|
700 |
]
|
100
|
701 |
].
|
|
702 |
|
|
703 |
(self sensor ctrlDown and:[self canMove:aView]) ifFalse:[
|
|
704 |
aView := nil
|
60
|
705 |
]
|
|
706 |
].
|
|
707 |
|
100
|
708 |
aView isNil ifTrue:[
|
|
709 |
(aView := self findObjectAt:aPoint) isNil ifTrue:[
|
131
|
710 |
^ self select:nil
|
100
|
711 |
].
|
|
712 |
|
|
713 |
(self canMove:aView) ifFalse:[
|
128
|
714 |
^ self select:aView
|
100
|
715 |
]
|
61
|
716 |
].
|
|
717 |
|
|
718 |
(self isSelected:aView) ifFalse:[
|
|
719 |
self select:aView.
|
60
|
720 |
].
|
|
721 |
|
|
722 |
(self numberOfSelections ~~ 1) ifTrue:[
|
|
723 |
releaseAction := [
|
|
724 |
self setDefaultActions.
|
61
|
725 |
self select:aView
|
60
|
726 |
]
|
|
727 |
] ifFalse:[
|
|
728 |
releaseAction := [self setDefaultActions]
|
|
729 |
].
|
|
730 |
|
|
731 |
"prepare move operation for an object
|
|
732 |
"
|
61
|
733 |
|
60
|
734 |
motionAction := [:movePoint|
|
72
|
735 |
(aPoint dist:movePoint) > 8.0 ifTrue:[
|
60
|
736 |
self startObjectMoveAt:aPoint
|
|
737 |
]
|
|
738 |
].
|
|
739 |
! !
|
|
740 |
|
|
741 |
!UIObjectView methodsFor:'object resize'!
|
|
742 |
|
|
743 |
actionResize:anObject selector:aSelector
|
|
744 |
"create and initialize action for resize
|
|
745 |
"
|
|
746 |
|selector delta|
|
|
747 |
|
|
748 |
delta := anObject container originRelativeTo:self.
|
|
749 |
selector := ('resize:', aSelector, ':') asSymbol.
|
|
750 |
|
175
|
751 |
resizeData := Structure with:(#object->anObject)
|
60
|
752 |
with:(#selector->selector)
|
|
753 |
with:(#delta->delta).
|
|
754 |
|
|
755 |
"can change cursor dependent on vertical/horizontal resizing
|
|
756 |
"
|
|
757 |
oldCursor := cursor.
|
|
758 |
self cursor:(Cursor leftHand).
|
|
759 |
|
|
760 |
|
|
761 |
|
|
762 |
!
|
|
763 |
|
|
764 |
doDragResize:aPoint
|
61
|
765 |
"do a widget resize drag
|
|
766 |
"
|
60
|
767 |
|p object|
|
|
768 |
|
175
|
769 |
object := resizeData object.
|
60
|
770 |
|
|
771 |
self invertOutlineOf:object.
|
175
|
772 |
p := (self alignToGrid:aPoint) - (resizeData delta).
|
|
773 |
|
|
774 |
self perform:(resizeData selector) with:object with:p.
|
79
|
775 |
"/ object geometryLayout:(object geometryLayout).
|
60
|
776 |
self invertOutlineOf:object
|
|
777 |
|
|
778 |
!
|
|
779 |
|
|
780 |
endResize
|
61
|
781 |
"cleanup after object resize
|
|
782 |
"
|
|
783 |
|object|
|
|
784 |
|
175
|
785 |
object := resizeData object.
|
|
786 |
resizeData := nil.
|
61
|
787 |
|
|
788 |
self invertOutlineOf:object.
|
60
|
789 |
self setDefaultActions.
|
61
|
790 |
self elementChangedSize:object.
|
138
|
791 |
|
|
792 |
"/ handle any expose events (for subcomponents) before
|
|
793 |
"/ redrawing the handles.
|
|
794 |
Delay waitForSeconds:0.05.
|
|
795 |
[self sensor hasExposeEventFor:nil] whileTrue:[
|
|
796 |
self windowGroup processExposeEvents
|
|
797 |
].
|
|
798 |
|
128
|
799 |
self setSelection:object withRedraw:true.
|
60
|
800 |
self changed:#layout.
|
|
801 |
!
|
|
802 |
|
|
803 |
startResizeBorder:b of:selection
|
|
804 |
"resize selected view
|
|
805 |
"
|
|
806 |
|object|
|
|
807 |
|
|
808 |
object := self singleSelection.
|
|
809 |
self actionResize:object selector:b.
|
|
810 |
|
72
|
811 |
self transaction:#resize selectionDo:[:aView|
|
134
|
812 |
self createUndoLayout:aView
|
60
|
813 |
].
|
128
|
814 |
self setSelection:nil withRedraw:true.
|
60
|
815 |
|
|
816 |
motionAction := [:movePoint | self doDragResize:movePoint].
|
|
817 |
releaseAction := [self endResize].
|
|
818 |
self invertOutlineOf:object
|
|
819 |
! !
|
|
820 |
|
|
821 |
!UIObjectView methodsFor:'private handles'!
|
|
822 |
|
175
|
823 |
handlesOf:aComponent do:aTwoArgAction
|
|
824 |
"perform action on each handle of a component
|
|
825 |
"
|
|
826 |
|dlt ext|
|
|
827 |
|
|
828 |
dlt := (aComponent originRelativeTo:self) - aComponent origin.
|
|
829 |
dlt := dlt - (3@3).
|
|
830 |
ext := 6@6.
|
|
831 |
|
|
832 |
self class handlesOf:aComponent do:[:pnt :wht |
|
|
833 |
aTwoArgAction value:(pnt + dlt extent:ext) value:wht
|
|
834 |
]
|
60
|
835 |
!
|
|
836 |
|
|
837 |
showSelected:aComponent
|
61
|
838 |
"show object selected
|
|
839 |
"
|
175
|
840 |
|wasClipped|
|
|
841 |
|
|
842 |
selectionHiddenLevel == 0 ifTrue:[
|
|
843 |
self paint:Color black.
|
|
844 |
|
|
845 |
(wasClipped := clipChildren) ifTrue:[
|
|
846 |
self clippedByChildren:(clipChildren := false).
|
|
847 |
].
|
|
848 |
|
|
849 |
self handlesOf:aComponent do:[:rectangle :what|
|
|
850 |
what == #view ifTrue:[self displayRectangle:rectangle]
|
|
851 |
ifFalse:[self fillRectangle:rectangle]
|
|
852 |
].
|
|
853 |
|
|
854 |
wasClipped ifTrue:[
|
|
855 |
self clippedByChildren:(clipChildren := true).
|
|
856 |
]
|
|
857 |
]
|
60
|
858 |
!
|
|
859 |
|
|
860 |
showUnselected:aComponent
|
61
|
861 |
"show object unselected
|
|
862 |
"
|
132
|
863 |
|wasClipped delta r|
|
60
|
864 |
|
138
|
865 |
selectionHiddenLevel ~~ 0 ifTrue:[^ self].
|
|
866 |
|
60
|
867 |
(wasClipped := clipChildren) ifTrue:[
|
|
868 |
self clippedByChildren:(clipChildren := false).
|
|
869 |
].
|
|
870 |
|
175
|
871 |
self handlesOf:aComponent do:[:rec :wht| self clearRectangle:rec ].
|
60
|
872 |
|
|
873 |
wasClipped ifTrue:[
|
|
874 |
self clippedByChildren:(clipChildren := true).
|
|
875 |
].
|
|
876 |
|
|
877 |
"/ must redraw all components which are affected b the handles
|
|
878 |
|
175
|
879 |
r := (aComponent originRelativeTo:self) - (3@3) extent:(aComponent extent + (6@6)).
|
60
|
880 |
|
|
881 |
subViews do:[:anotherComponent |
|
|
882 |
|absOrg absFrame|
|
|
883 |
|
|
884 |
anotherComponent ~~ inputView ifTrue:[
|
|
885 |
absOrg := anotherComponent originRelativeTo:self.
|
|
886 |
absFrame := absOrg extent:(anotherComponent extent).
|
|
887 |
(absFrame intersects:r) ifTrue:[
|
|
888 |
anotherComponent withAllSubViewsDo:[:v |
|
95
|
889 |
v shown ifTrue:[
|
132
|
890 |
v fill:v viewBackground.
|
95
|
891 |
v exposeX:0 y:0 width:9999 height:9999.
|
|
892 |
]
|
60
|
893 |
]
|
|
894 |
]
|
|
895 |
]
|
|
896 |
]
|
|
897 |
|
95
|
898 |
"Modified: 8.4.1997 / 00:32:26 / cg"
|
60
|
899 |
!
|
|
900 |
|
175
|
901 |
whichHandleOf:aComponent isHitBy:aPoint
|
61
|
902 |
"returns kind of handle or nil
|
|
903 |
"
|
175
|
904 |
self handlesOf:aComponent do:[:rectangle :what|
|
|
905 |
(rectangle containsPoint:aPoint) ifTrue:[^ what]
|
60
|
906 |
].
|
175
|
907 |
^ nil
|
60
|
908 |
! !
|
|
909 |
|
|
910 |
!UIObjectView methodsFor:'private resizing-subviews'!
|
|
911 |
|
|
912 |
resize:aView bottom:aPoint
|
61
|
913 |
"resize a views bottom
|
|
914 |
"
|
134
|
915 |
undoHistory withoutTransactionDo:[
|
60
|
916 |
self shiftLayout:aView top:0 bottom:((aPoint y) - (aView computeCorner y))
|
|
917 |
]
|
|
918 |
!
|
|
919 |
|
|
920 |
resize:aView bottomLeft:aPoint
|
61
|
921 |
"resize a views bottom and left
|
|
922 |
"
|
134
|
923 |
undoHistory withoutTransactionDo:[
|
60
|
924 |
self shiftLayout:aView top:0
|
|
925 |
bottom:((aPoint y) - (aView computeCorner y))
|
|
926 |
left:((aPoint x) - (aView computeOrigin x))
|
|
927 |
right:0
|
|
928 |
|
|
929 |
]
|
|
930 |
|
|
931 |
|
|
932 |
!
|
|
933 |
|
|
934 |
resize:aView corner:aPoint
|
61
|
935 |
"resize a views corner
|
|
936 |
"
|
60
|
937 |
|delta|
|
|
938 |
|
|
939 |
delta := aPoint - aView computeCorner.
|
|
940 |
|
134
|
941 |
undoHistory withoutTransactionDo:[
|
60
|
942 |
self shiftLayout:aView top:0 bottom:(delta y) left:0 right:(delta x)
|
|
943 |
]
|
|
944 |
!
|
|
945 |
|
|
946 |
resize:aView left:aPoint
|
61
|
947 |
"resize a views left
|
|
948 |
"
|
134
|
949 |
undoHistory withoutTransactionDo:[
|
60
|
950 |
self shiftLayout:aView left:((aPoint x) - (aView computeOrigin x)) right:0
|
|
951 |
]
|
|
952 |
|
|
953 |
!
|
|
954 |
|
|
955 |
resize:aView origin:aPoint
|
61
|
956 |
"resize a views origin
|
|
957 |
"
|
60
|
958 |
|delta|
|
|
959 |
|
|
960 |
delta := aPoint - aView computeOrigin.
|
|
961 |
|
134
|
962 |
undoHistory withoutTransactionDo:[
|
60
|
963 |
self shiftLayout:aView top:(delta y) bottom:0 left:(delta x) right:0
|
|
964 |
]
|
|
965 |
|
|
966 |
!
|
|
967 |
|
|
968 |
resize:aView right:aPoint
|
61
|
969 |
"resize a views right
|
|
970 |
"
|
134
|
971 |
undoHistory withoutTransactionDo:[
|
60
|
972 |
self shiftLayout:aView left:0 right:((aPoint x) - (aView computeCorner x))
|
|
973 |
]
|
|
974 |
!
|
|
975 |
|
|
976 |
resize:aView top:aPoint
|
61
|
977 |
"resize a views top
|
|
978 |
"
|
134
|
979 |
undoHistory withoutTransactionDo:[
|
60
|
980 |
self shiftLayout:aView top:((aPoint y) - (aView computeOrigin y)) bottom:0
|
|
981 |
]
|
|
982 |
!
|
|
983 |
|
|
984 |
resize:aView topRight:aPoint
|
61
|
985 |
"resize a views top and right
|
|
986 |
"
|
134
|
987 |
undoHistory withoutTransactionDo:[
|
60
|
988 |
self shiftLayout:aView top:((aPoint y) - (aView computeOrigin y))
|
|
989 |
bottom:0
|
|
990 |
left:0
|
|
991 |
right:((aPoint x) - (aView computeCorner x))
|
|
992 |
|
|
993 |
]
|
|
994 |
|
|
995 |
! !
|
|
996 |
|
|
997 |
!UIObjectView methodsFor:'private shift-layout'!
|
|
998 |
|
|
999 |
shiftLayout:aView left:l right:r
|
|
1000 |
"shift layout for a view; in case of an open transaction, the undo
|
|
1001 |
action is registered
|
|
1002 |
"
|
|
1003 |
self shiftLayout:aView top:0 bottom:0 left:l right:r
|
|
1004 |
|
|
1005 |
!
|
|
1006 |
|
|
1007 |
shiftLayout:aView top:t bottom:b
|
|
1008 |
"shift layout for a view; in case of an open transaction, the undo
|
|
1009 |
action is registered
|
|
1010 |
"
|
|
1011 |
self shiftLayout:aView top:t bottom:b left:0 right:0
|
|
1012 |
|
|
1013 |
|
|
1014 |
!
|
|
1015 |
|
|
1016 |
shiftLayout:aView top:t bottom:b left:l right:r
|
|
1017 |
"shift layout for a view; in case of an open transaction, the undo
|
|
1018 |
action is registered
|
|
1019 |
"
|
79
|
1020 |
|type layout oldExt|
|
61
|
1021 |
|
|
1022 |
type := self class layoutType:aView.
|
|
1023 |
|
|
1024 |
type notNil ifTrue:[
|
134
|
1025 |
self createUndoLayout:aView.
|
61
|
1026 |
|
|
1027 |
type == #Extent ifTrue:[
|
79
|
1028 |
oldExt := aView extent.
|
|
1029 |
aView extent:(oldExt + ((r-l) @ (b-t))).
|
|
1030 |
^ self
|
60
|
1031 |
].
|
61
|
1032 |
|
78
|
1033 |
layout := aView geometryLayout copy.
|
61
|
1034 |
|
|
1035 |
layout isLayout ifTrue:[
|
|
1036 |
layout leftOffset:(layout leftOffset + l)
|
|
1037 |
topOffset:(layout topOffset + t).
|
|
1038 |
|
|
1039 |
type == #LayoutFrame ifTrue:[
|
|
1040 |
layout bottomOffset:(layout bottomOffset + b).
|
|
1041 |
layout rightOffset:(layout rightOffset + r).
|
|
1042 |
]
|
|
1043 |
] ifFalse:[
|
|
1044 |
type == #Rectangle ifTrue:[
|
|
1045 |
layout left:(layout left + l)
|
|
1046 |
right:(layout right + r)
|
|
1047 |
top:(layout top + t)
|
|
1048 |
bottom:(layout bottom + b).
|
|
1049 |
] ifFalse:[ "POINT"
|
|
1050 |
layout x:(layout x + l) y:(layout y + t).
|
|
1051 |
]
|
|
1052 |
].
|
|
1053 |
aView geometryLayout:layout
|
60
|
1054 |
]
|
|
1055 |
! !
|
|
1056 |
|
|
1057 |
!UIObjectView methodsFor:'searching'!
|
|
1058 |
|
89
|
1059 |
findContainerViewAt:aPoint
|
|
1060 |
"find container view responds to aPoint.
|
|
1061 |
"
|
|
1062 |
^ self subclassResponsibility
|
|
1063 |
|
|
1064 |
|
|
1065 |
!
|
|
1066 |
|
60
|
1067 |
findObjectAt:aPoint
|
|
1068 |
"find the origin/corner of the currentWidget
|
|
1069 |
"
|
|
1070 |
|view viewId lastId point listOfViews|
|
|
1071 |
|
|
1072 |
viewId := rootView id.
|
|
1073 |
point := aPoint + (device translatePoint:0@0 from:(self id) to:viewId).
|
|
1074 |
|
|
1075 |
inputView lower.
|
|
1076 |
|
|
1077 |
[viewId notNil] whileTrue:[
|
|
1078 |
lastId := viewId.
|
|
1079 |
viewId := device viewIdFromPoint:point in:lastId
|
|
1080 |
].
|
|
1081 |
|
|
1082 |
inputView raise.
|
|
1083 |
|
|
1084 |
view := device viewFromId:lastId.
|
|
1085 |
|
|
1086 |
view ~~ inputView ifTrue:[^ view].
|
|
1087 |
|
|
1088 |
"/ look for 'hidden' views ...
|
|
1089 |
|
|
1090 |
listOfViews := OrderedCollection new.
|
|
1091 |
self allSubViewsDo:[:aView |
|
|
1092 |
|org|
|
|
1093 |
|
|
1094 |
aView ~~ inputView ifTrue:[
|
|
1095 |
org := device translatePoint:0@0 from:(aView id) to:self id.
|
|
1096 |
((org extent:aView extent) containsPoint:aPoint) ifTrue:[
|
|
1097 |
listOfViews add:aView.
|
|
1098 |
]
|
|
1099 |
]
|
|
1100 |
].
|
|
1101 |
|
|
1102 |
listOfViews size > 0 ifTrue:[
|
|
1103 |
^ listOfViews last
|
|
1104 |
].
|
|
1105 |
^ nil
|
|
1106 |
|
|
1107 |
|
|
1108 |
! !
|
|
1109 |
|
|
1110 |
!UIObjectView methodsFor:'selections'!
|
|
1111 |
|
128
|
1112 |
moveableSelection
|
131
|
1113 |
"checks whether the selection is not empty and all selected instances
|
|
1114 |
can be moved. If true the selection is returned otherwise nil
|
128
|
1115 |
"
|
|
1116 |
|coll|
|
|
1117 |
|
|
1118 |
self hasSelection ifTrue:[
|
|
1119 |
(self canMove:(coll := self selection)) ifTrue:[
|
|
1120 |
^ coll
|
|
1121 |
]
|
|
1122 |
].
|
|
1123 |
^ nil
|
|
1124 |
!
|
|
1125 |
|
60
|
1126 |
numberOfSelections
|
131
|
1127 |
"return the number of selected instances
|
61
|
1128 |
"
|
128
|
1129 |
|coll size|
|
|
1130 |
|
|
1131 |
coll := self selection.
|
|
1132 |
size := coll size.
|
|
1133 |
|
|
1134 |
(size ~~ 0 or:[coll isNil]) ifTrue:[^ size].
|
|
1135 |
^ 1
|
60
|
1136 |
!
|
|
1137 |
|
|
1138 |
select:something
|
61
|
1139 |
"change selection to something
|
|
1140 |
"
|
128
|
1141 |
(self enabled and:[something ~= self selection]) ifTrue:[
|
|
1142 |
self setSelection:something withRedraw:true.
|
113
|
1143 |
self selectionChanged
|
60
|
1144 |
]
|
|
1145 |
|
|
1146 |
!
|
|
1147 |
|
149
|
1148 |
selection:something
|
|
1149 |
"change selection to something
|
|
1150 |
"
|
|
1151 |
self select:something
|
|
1152 |
!
|
|
1153 |
|
113
|
1154 |
selectionChanged
|
|
1155 |
"called whenever the selection changed
|
|
1156 |
"
|
|
1157 |
self subclassResponsibility
|
|
1158 |
|
|
1159 |
!
|
|
1160 |
|
128
|
1161 |
selectionDo:aBlock
|
|
1162 |
"apply block to every selected object
|
|
1163 |
"
|
|
1164 |
self forEach:(self selection) do:aBlock
|
|
1165 |
|
|
1166 |
|
|
1167 |
!
|
|
1168 |
|
61
|
1169 |
showSelection
|
128
|
1170 |
"show the selection - draw handles
|
|
1171 |
"
|
61
|
1172 |
selectionHiddenLevel == 0 ifTrue:[
|
128
|
1173 |
self selectionDo:[:el| self showSelected:el ]
|
60
|
1174 |
].
|
|
1175 |
!
|
|
1176 |
|
|
1177 |
singleSelection
|
131
|
1178 |
"checks whether one element is selected; in this case the element is
|
|
1179 |
returned otherwise nil
|
60
|
1180 |
"
|
128
|
1181 |
|coll|
|
|
1182 |
|
|
1183 |
(coll := self selection) isCollection ifFalse:[
|
|
1184 |
^ coll
|
60
|
1185 |
].
|
128
|
1186 |
|
|
1187 |
coll size == 1 ifTrue:[ ^ coll first].
|
|
1188 |
^ nil
|
60
|
1189 |
!
|
|
1190 |
|
|
1191 |
singleSelectionDo:aBlock
|
131
|
1192 |
"checks whether one element is selected; in this case the block
|
|
1193 |
with argument the selected instance will be processed
|
61
|
1194 |
"
|
60
|
1195 |
|view|
|
|
1196 |
|
|
1197 |
(view := self singleSelection) notNil ifTrue:[
|
|
1198 |
aBlock value:view
|
|
1199 |
]
|
|
1200 |
!
|
|
1201 |
|
|
1202 |
unselect
|
61
|
1203 |
"clear selection
|
|
1204 |
"
|
128
|
1205 |
self select:nil
|
60
|
1206 |
!
|
|
1207 |
|
|
1208 |
withSelectionHiddenDo:aBlock
|
61
|
1209 |
"apply block with selection hidden (no handles)
|
|
1210 |
"
|
78
|
1211 |
|coll|
|
|
1212 |
|
138
|
1213 |
selectionHiddenLevel == 0 ifTrue:[
|
61
|
1214 |
self selectionDo:[:aView| self showUnselected:aView].
|
|
1215 |
device flush.
|
|
1216 |
].
|
138
|
1217 |
selectionHiddenLevel := selectionHiddenLevel + 1.
|
61
|
1218 |
|
|
1219 |
aBlock valueNowOrOnUnwindDo:[
|
|
1220 |
selectionHiddenLevel == 1 ifTrue:[
|
|
1221 |
setOfSuperViewsSizeChanged notEmpty ifTrue:[
|
78
|
1222 |
coll := self minSetOfSuperViews:setOfSuperViewsSizeChanged.
|
|
1223 |
coll do:[:aView| aView sizeChanged:nil].
|
61
|
1224 |
setOfSuperViewsSizeChanged := IdentitySet new
|
|
1225 |
].
|
138
|
1226 |
selectionHiddenLevel := 0.
|
61
|
1227 |
self selectionDo:[:aView| self showSelected:aView].
|
138
|
1228 |
] ifFalse:[
|
|
1229 |
selectionHiddenLevel := selectionHiddenLevel - 1.
|
|
1230 |
]
|
61
|
1231 |
]
|
|
1232 |
|
|
1233 |
!
|
|
1234 |
|
|
1235 |
withoutSelectionDo:aBlock
|
|
1236 |
"evaluate aBlock while selection is nilled
|
|
1237 |
"
|
60
|
1238 |
|sel|
|
|
1239 |
|
128
|
1240 |
self hasSelection ifFalse:[
|
60
|
1241 |
aBlock value
|
128
|
1242 |
] ifTrue:[
|
|
1243 |
sel := self selection.
|
|
1244 |
self setSelection:nil withRedraw:true.
|
60
|
1245 |
aBlock value.
|
128
|
1246 |
self setSelection:sel withRedraw:true.
|
60
|
1247 |
]
|
|
1248 |
|
|
1249 |
|
|
1250 |
! !
|
|
1251 |
|
131
|
1252 |
!UIObjectView methodsFor:'selections basic'!
|
|
1253 |
|
|
1254 |
addToSelection:anObject
|
|
1255 |
"add an object to the selection
|
|
1256 |
"
|
|
1257 |
(self enabled and:[(self isSelected:anObject) not]) ifTrue:[
|
|
1258 |
selection isCollection ifFalse:[
|
|
1259 |
selection isNil ifTrue:[
|
|
1260 |
selection := anObject
|
|
1261 |
] ifFalse:[
|
|
1262 |
selection := OrderedCollection with:selection with:anObject
|
|
1263 |
]
|
|
1264 |
] ifTrue:[
|
|
1265 |
selection add:anObject
|
|
1266 |
].
|
|
1267 |
self showSelected:anObject.
|
|
1268 |
self selectionChanged.
|
|
1269 |
]
|
|
1270 |
!
|
|
1271 |
|
|
1272 |
removeFromSelection:anObject
|
|
1273 |
"remove an object from the selection
|
|
1274 |
"
|
|
1275 |
(self isSelected:anObject) ifTrue:[
|
|
1276 |
self showUnselected:anObject.
|
|
1277 |
|
|
1278 |
selection size > 1 ifTrue:[
|
|
1279 |
selection remove:anObject ifAbsent:nil.
|
|
1280 |
self showSelection.
|
|
1281 |
] ifFalse:[
|
|
1282 |
selection := nil
|
|
1283 |
].
|
|
1284 |
self selectionChanged.
|
|
1285 |
]
|
|
1286 |
!
|
|
1287 |
|
|
1288 |
selection
|
|
1289 |
"returns the current selection
|
|
1290 |
"
|
|
1291 |
^ selection
|
|
1292 |
|
|
1293 |
|
|
1294 |
!
|
|
1295 |
|
|
1296 |
setSelection:aNewSelection withRedraw:doRedraw
|
|
1297 |
"set a new selection without change notifications
|
|
1298 |
"
|
|
1299 |
doRedraw ifTrue:[
|
|
1300 |
self hideSelection.
|
|
1301 |
selection := aNewSelection.
|
|
1302 |
self showSelection
|
|
1303 |
] ifFalse:[
|
|
1304 |
selection := aNewSelection
|
|
1305 |
]
|
|
1306 |
! !
|
|
1307 |
|
60
|
1308 |
!UIObjectView methodsFor:'testing'!
|
|
1309 |
|
|
1310 |
canMove:something
|
61
|
1311 |
"returns always true; all contained views can be moved
|
|
1312 |
"
|
|
1313 |
|sv|
|
|
1314 |
|
|
1315 |
something notNil ifTrue:[
|
|
1316 |
self forEach:something do:[:v|
|
|
1317 |
sv ~~ v superView ifTrue:[
|
|
1318 |
(sv notNil or:[v superView specClass isLayoutContainer]) ifTrue:[
|
|
1319 |
^ false
|
|
1320 |
].
|
|
1321 |
sv := v superView
|
|
1322 |
]
|
|
1323 |
].
|
|
1324 |
^ true
|
|
1325 |
].
|
|
1326 |
^ false
|
60
|
1327 |
|
|
1328 |
!
|
|
1329 |
|
|
1330 |
canPaste:something
|
|
1331 |
"returns true if something could be paste
|
|
1332 |
"
|
|
1333 |
something notNil ifTrue:[
|
|
1334 |
something isCollection ifTrue:[
|
|
1335 |
something notEmpty ifTrue:[
|
|
1336 |
^ (something at:1) isKindOf:UISpecification
|
|
1337 |
]
|
|
1338 |
] ifFalse:[
|
|
1339 |
^ something isKindOf:UISpecification
|
|
1340 |
]
|
|
1341 |
].
|
|
1342 |
^ false
|
|
1343 |
|
|
1344 |
!
|
|