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
|
360
|
18 |
gridParameters 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 |
"
|
360
|
331 |
gridParameters isNil ifTrue:[
|
|
332 |
gridParameters := #(10 10 nil nil 10 10 false)
|
|
333 |
].
|
|
334 |
^ gridParameters
|
|
335 |
|
|
336 |
|
|
337 |
!
|
|
338 |
|
|
339 |
gridParameters:newGridParameters
|
|
340 |
"used by defineGrid, and in a separate method for
|
|
341 |
easier redefinition in subclasses.
|
|
342 |
Returns the grid parameters in an array of 7 elements,
|
|
343 |
which control the appearance of the grid-pattern.
|
|
344 |
the elements are:
|
|
345 |
|
|
346 |
bigStepH number of pixels horizontally between 2 major steps
|
|
347 |
bigStepV number of pixels vertically between 2 major steps
|
|
348 |
littleStepH number of pixels horizontally between 2 minor steps
|
|
349 |
littleStepV number of pixels vertically between 2 minor steps
|
|
350 |
gridAlignH number of pixels for horizontal grid align (pointer snap)
|
|
351 |
gridAlignV number of pixels for vertical grid align (pointer snap)
|
|
352 |
docBounds true, if document boundary should be shown
|
|
353 |
|
|
354 |
if littleStepH/V are nil, only bigSteps are drawn.
|
|
355 |
"
|
|
356 |
newGridParameters size == 7 ifTrue:[
|
|
357 |
gridParameters := newGridParameters
|
|
358 |
].
|
60
|
359 |
|
|
360 |
|
|
361 |
!
|
|
362 |
|
|
363 |
gridShown:aBool
|
61
|
364 |
"change visibility of grid
|
|
365 |
"
|
60
|
366 |
aBool ifTrue:[self showGrid]
|
|
367 |
ifFalse:[self hideGrid]
|
|
368 |
!
|
|
369 |
|
|
370 |
hideGrid
|
61
|
371 |
"hide grid
|
|
372 |
"
|
60
|
373 |
gridShown ifTrue:[
|
61
|
374 |
self withSelectionHiddenDo:[super hideGrid]
|
60
|
375 |
]
|
|
376 |
|
|
377 |
|
|
378 |
!
|
|
379 |
|
|
380 |
showGrid
|
61
|
381 |
"show grid
|
|
382 |
"
|
|
383 |
self withSelectionHiddenDo:[super showGrid]
|
119
|
384 |
! !
|
|
385 |
|
|
386 |
!UIObjectView methodsFor:'accessing behavior'!
|
|
387 |
|
|
388 |
enabled
|
|
389 |
^ enableChannel value
|
|
390 |
!
|
|
391 |
|
|
392 |
enabled:aState
|
|
393 |
"set the modification / test mode
|
|
394 |
"
|
|
395 |
(aState == enableChannel value) ifFalse:[
|
123
|
396 |
aState ifFalse:[
|
131
|
397 |
saveSelection := self selection.
|
|
398 |
self select:nil.
|
128
|
399 |
enableChannel value:aState.
|
140
|
400 |
inputView unmap.
|
119
|
401 |
] ifTrue:[
|
|
402 |
inputView raise.
|
123
|
403 |
inputView realize.
|
128
|
404 |
enableChannel value:aState.
|
123
|
405 |
self select:saveSelection.
|
|
406 |
]
|
119
|
407 |
]
|
|
408 |
|
|
409 |
|
|
410 |
|
60
|
411 |
!
|
|
412 |
|
134
|
413 |
resetModification
|
|
414 |
"set modification state to false
|
|
415 |
"
|
|
416 |
undoHistory resetModification
|
|
417 |
!
|
|
418 |
|
60
|
419 |
testMode
|
61
|
420 |
"returns true if running test
|
60
|
421 |
"
|
119
|
422 |
^ enableChannel value not
|
60
|
423 |
|
|
424 |
|
|
425 |
!
|
|
426 |
|
|
427 |
testMode:aBoolean
|
61
|
428 |
"change test mode
|
60
|
429 |
"
|
119
|
430 |
self enabled:(aBoolean not)
|
60
|
431 |
! !
|
|
432 |
|
|
433 |
!UIObjectView methodsFor:'blocked'!
|
|
434 |
|
|
435 |
addObject:anObject
|
61
|
436 |
"add the argument, anObject to the contents - with redraw
|
|
437 |
"
|
60
|
438 |
self halt
|
|
439 |
|
|
440 |
!
|
|
441 |
|
|
442 |
addObjectWithoutRedraw:anObject
|
61
|
443 |
"add the argument, anObject to the contents - with redraw
|
|
444 |
"
|
60
|
445 |
self halt
|
|
446 |
|
175
|
447 |
!
|
|
448 |
|
|
449 |
startCreate:aPoint
|
|
450 |
self setDefaultActions.
|
|
451 |
self halt
|
60
|
452 |
! !
|
|
453 |
|
|
454 |
!UIObjectView methodsFor:'event handling'!
|
|
455 |
|
61
|
456 |
elementChangedSize:aView
|
|
457 |
"some element has changed its size; collect them during selectionHiddenLevel
|
|
458 |
is on
|
|
459 |
"
|
284
|
460 |
|spv|
|
|
461 |
|
|
462 |
spv := self findContainerOfView:aView.
|
|
463 |
|
|
464 |
selectionHiddenLevel ~~ 0 ifTrue:[setOfSuperViewsSizeChanged add:spv]
|
|
465 |
ifFalse:[spv sizeChanged:nil]
|
60
|
466 |
!
|
|
467 |
|
|
468 |
exposeX:x y:y width:w height:h
|
|
469 |
"handle an expose event from device; redraw selection
|
|
470 |
"
|
175
|
471 |
resizeData isNil ifTrue:[
|
|
472 |
super exposeX:x y:y width:w height:h.
|
|
473 |
|
|
474 |
"/ handle any expose events (for subcomponents) before
|
|
475 |
"/ redrawing the handles.
|
|
476 |
(self sensor hasExposeEventFor:nil) ifTrue:[^ self].
|
|
477 |
|
|
478 |
self selectionDo:[:aComponent |
|
|
479 |
aComponent withAllSubViewsDo:[:v |
|
|
480 |
self sensor flushExposeEventsFor:v.
|
|
481 |
v exposeX:0 y:0 width:9999 height:9999.
|
|
482 |
].
|
|
483 |
self showSelected:aComponent
|
|
484 |
]
|
132
|
485 |
]
|
60
|
486 |
|
|
487 |
!
|
|
488 |
|
|
489 |
keyPress:key x:x y:y
|
61
|
490 |
"any key pressed
|
|
491 |
"
|
360
|
492 |
<resource: #keyboard ( #Delete #BackSpace #Cut #Copy #Paste #Cmdu ) >
|
60
|
493 |
|
|
494 |
(key == #Cut or:[key == #Delete or:[key == #BackSpace]]) ifTrue: [
|
|
495 |
^ self deleteSelection
|
|
496 |
].
|
78
|
497 |
key == #Copy ifTrue:[ ^ self copySelection].
|
|
498 |
key == #Paste ifTrue:[ ^ self pasteBuffer].
|
360
|
499 |
key == #Cmdu ifTrue:[ ^ self undoLast ]. "/ #Undo
|
|
500 |
|
374
|
501 |
super keyPress:key x:x y:y
|
|
502 |
|
|
503 |
"Modified: / 31.10.1997 / 20:28:00 / cg"
|
60
|
504 |
!
|
|
505 |
|
|
506 |
processEvent:anEvent
|
|
507 |
"catch expose events for components, and redraw its handles after
|
|
508 |
the redraw when this happens
|
|
509 |
"
|
128
|
510 |
(anEvent type == #damage and:[self isSelected:(anEvent view)]) ifTrue:[
|
|
511 |
self showSelected:(anEvent view)
|
60
|
512 |
].
|
|
513 |
^ false.
|
|
514 |
|
|
515 |
|
|
516 |
!
|
|
517 |
|
|
518 |
sizeChanged:how
|
61
|
519 |
"size of a view(s) changed
|
|
520 |
"
|
60
|
521 |
self withSelectionHiddenDo:[
|
|
522 |
super sizeChanged:how
|
|
523 |
]
|
|
524 |
|
|
525 |
|
|
526 |
! !
|
|
527 |
|
|
528 |
!UIObjectView methodsFor:'initialization'!
|
|
529 |
|
|
530 |
initialize
|
61
|
531 |
"setup attributes
|
|
532 |
"
|
60
|
533 |
super initialize.
|
|
534 |
|
|
535 |
"funny: since I do not want the created widgets to get pointer
|
|
536 |
events, I put an InputView on top of them, which catches those events
|
|
537 |
and passes them back to me - have to take care, that this inputView
|
|
538 |
is always on top
|
|
539 |
"
|
|
540 |
inputView := InputView origin:0.0@0.0 extent:1.0@1.0 in:self.
|
61
|
541 |
setOfSuperViewsSizeChanged := IdentitySet new.
|
60
|
542 |
|
|
543 |
inputView eventReceiver:self.
|
|
544 |
inputView enableButtonEvents.
|
|
545 |
inputView enableButtonMotionEvents.
|
|
546 |
|
|
547 |
self setDefaultActions.
|
|
548 |
|
134
|
549 |
undoHistory := UndoHistory on:self.
|
119
|
550 |
enableChannel := true asValue.
|
|
551 |
clipChildren := true.
|
61
|
552 |
selectionHiddenLevel := 0.
|
60
|
553 |
|
|
554 |
(self class gridShown) ifTrue:[
|
|
555 |
super showGrid
|
|
556 |
].
|
|
557 |
|
|
558 |
!
|
|
559 |
|
284
|
560 |
map
|
|
561 |
"make the view visible on the screen and in case of a none empty
|
|
562 |
selection the selection will be shown.
|
|
563 |
"
|
|
564 |
super map.
|
|
565 |
self showSelection.
|
|
566 |
!
|
|
567 |
|
60
|
568 |
realize
|
|
569 |
super realize.
|
|
570 |
self windowGroup postEventHook:self
|
|
571 |
|
|
572 |
! !
|
|
573 |
|
|
574 |
!UIObjectView methodsFor:'misc'!
|
|
575 |
|
|
576 |
cursor:aCursor
|
61
|
577 |
"set cursor
|
|
578 |
"
|
60
|
579 |
inputView realized ifTrue:[
|
|
580 |
inputView cursor:aCursor
|
|
581 |
].
|
|
582 |
super cursor:aCursor
|
|
583 |
|
|
584 |
|
|
585 |
!
|
|
586 |
|
175
|
587 |
invertOutlineOf:something
|
|
588 |
"invert outline of an object or collection of objects
|
61
|
589 |
"
|
175
|
590 |
|wasClipped p|
|
60
|
591 |
|
|
592 |
(wasClipped := clipChildren) ifTrue:[
|
|
593 |
self clippedByChildren:(clipChildren := false).
|
|
594 |
].
|
175
|
595 |
|
|
596 |
something isCollection ifTrue:[
|
|
597 |
something do:[:v|
|
|
598 |
p := v originRelativeTo:self.
|
|
599 |
self xoring:[self displayRectangle:(p extent:v extent)].
|
|
600 |
]
|
|
601 |
] ifFalse:[
|
|
602 |
p := something originRelativeTo:self.
|
|
603 |
self xoring:[self displayRectangle:(p extent:something extent)]
|
60
|
604 |
].
|
|
605 |
|
|
606 |
wasClipped ifTrue:[
|
|
607 |
self clippedByChildren:(clipChildren := true).
|
|
608 |
].
|
|
609 |
|
|
610 |
!
|
|
611 |
|
78
|
612 |
minSetOfSuperViews:setOfViews
|
|
613 |
|
|
614 |
setOfViews isCollection ifFalse:[
|
|
615 |
setOfViews notNil ifTrue:[^ Array with:setOfViews]
|
|
616 |
ifFalse:[^ nil]
|
72
|
617 |
].
|
78
|
618 |
^ setOfViews select:[:aView|
|
|
619 |
(setOfViews detect:[:v|aView isComponentOf:v] ifNone:nil) isNil
|
|
620 |
]
|
72
|
621 |
!
|
|
622 |
|
60
|
623 |
setDefaultActions
|
61
|
624 |
"set default actions
|
|
625 |
"
|
60
|
626 |
pressAction := [:pressPoint | self startSelectOrMove:pressPoint].
|
|
627 |
shiftPressAction := [:pressPoint | self startSelectMoreOrMove:pressPoint].
|
|
628 |
motionAction := [:movePoint | nil].
|
|
629 |
releaseAction := [nil].
|
|
630 |
keyPressAction := nil.
|
|
631 |
|
|
632 |
self cursor:Cursor normal.
|
|
633 |
|
|
634 |
! !
|
|
635 |
|
|
636 |
!UIObjectView methodsFor:'object moving'!
|
|
637 |
|
|
638 |
doObjectMove:aPoint
|
|
639 |
"move selection
|
|
640 |
"
|
|
641 |
movedObject notNil ifTrue:[
|
175
|
642 |
self invertOutlineOf:movedObject.
|
|
643 |
|
|
644 |
movedObject keysAndValuesDo:[:i :v|
|
|
645 |
self moveObject:v to:(aPoint - (moveDelta at:i)).
|
|
646 |
].
|
|
647 |
self invertOutlineOf:movedObject.
|
60
|
648 |
]
|
|
649 |
|
|
650 |
!
|
|
651 |
|
|
652 |
endObjectMove
|
61
|
653 |
"cleanup after object(s) move
|
|
654 |
"
|
60
|
655 |
movedObject notNil ifTrue:[
|
175
|
656 |
self invertOutlineOf:movedObject.
|
128
|
657 |
|
|
658 |
movedObject size == 1 ifTrue:[
|
|
659 |
movedObject := movedObject first
|
60
|
660 |
].
|
128
|
661 |
self setSelection:movedObject withRedraw:true.
|
60
|
662 |
movedObject := nil.
|
|
663 |
self setDefaultActions.
|
225
|
664 |
self layoutChanged.
|
60
|
665 |
].
|
|
666 |
!
|
|
667 |
|
|
668 |
moveObject:anObject to:aPoint
|
|
669 |
"move anObject to newOrigin, aPoint
|
|
670 |
"
|
|
671 |
|dX dY org delta|
|
|
672 |
|
|
673 |
anObject notNil ifTrue:[
|
|
674 |
org := anObject computeOrigin.
|
|
675 |
|
|
676 |
delta := aPoint - org.
|
|
677 |
delta := (self alignToGrid:aPoint) - org.
|
|
678 |
dX := delta x.
|
|
679 |
dY := delta y.
|
|
680 |
|
134
|
681 |
undoHistory withoutTransactionDo:[
|
60
|
682 |
self shiftLayout:anObject top:dY bottom:dY left:dX right:dX
|
|
683 |
]
|
|
684 |
]
|
|
685 |
|
|
686 |
!
|
|
687 |
|
|
688 |
startObjectMoveAt:aPoint
|
61
|
689 |
"start object(s) move at a point
|
|
690 |
"
|
128
|
691 |
self startObjectMove:(self selection) at:aPoint.
|
|
692 |
movedObject := self selection.
|
|
693 |
|
|
694 |
movedObject isCollection ifFalse:[
|
|
695 |
movedObject := Array with:movedObject
|
60
|
696 |
].
|
128
|
697 |
self setSelection:nil withRedraw:true.
|
60
|
698 |
|
|
699 |
moveDelta := movedObject collect:[:aView|
|
|
700 |
aPoint - aView computeOrigin
|
|
701 |
].
|
175
|
702 |
self transaction:#move objects:movedObject do:[:v|self createUndoLayout:v].
|
|
703 |
self invertOutlineOf:movedObject.
|
60
|
704 |
!
|
|
705 |
|
|
706 |
startSelectMoreOrMove:aPoint
|
|
707 |
"add/remove to/from selection"
|
|
708 |
|
|
709 |
|anObject|
|
|
710 |
|
119
|
711 |
self enabled ifFalse:[^ self].
|
60
|
712 |
|
|
713 |
anObject := self findObjectAt:aPoint.
|
|
714 |
anObject notNil ifTrue:[
|
|
715 |
(self isSelected:anObject) ifTrue:[
|
|
716 |
self removeFromSelection:anObject
|
|
717 |
] ifFalse:[
|
|
718 |
self addToSelection:anObject
|
|
719 |
]
|
|
720 |
]
|
|
721 |
!
|
|
722 |
|
|
723 |
startSelectOrMove:aPoint
|
61
|
724 |
"a button is pressed at a point; start moving or selection
|
60
|
725 |
"
|
284
|
726 |
|aView b v|
|
60
|
727 |
|
119
|
728 |
self enabled ifFalse:[^ self].
|
60
|
729 |
|
61
|
730 |
aView := self singleSelection.
|
|
731 |
|
|
732 |
aView notNil ifTrue:[
|
284
|
733 |
v := self findContainerOfView:aView.
|
|
734 |
|
|
735 |
v specClass canResizeSubComponents ifTrue:[
|
61
|
736 |
b := self whichHandleOf:aView isHitBy:aPoint.
|
|
737 |
|
|
738 |
(b notNil and:[b ~~ #view]) ifTrue:[
|
|
739 |
^ self startResizeBorder:b of:aView.
|
|
740 |
]
|
100
|
741 |
].
|
|
742 |
|
284
|
743 |
(self sensor ctrlDown and:[self canChangeLayoutOfView:aView]) ifFalse:[
|
100
|
744 |
aView := nil
|
60
|
745 |
]
|
|
746 |
].
|
|
747 |
|
100
|
748 |
aView isNil ifTrue:[
|
|
749 |
(aView := self findObjectAt:aPoint) isNil ifTrue:[
|
131
|
750 |
^ self select:nil
|
100
|
751 |
].
|
|
752 |
|
284
|
753 |
(self canChangeLayoutOfView:aView) ifFalse:[
|
128
|
754 |
^ self select:aView
|
100
|
755 |
]
|
61
|
756 |
].
|
|
757 |
|
|
758 |
(self isSelected:aView) ifFalse:[
|
|
759 |
self select:aView.
|
60
|
760 |
].
|
|
761 |
|
|
762 |
(self numberOfSelections ~~ 1) ifTrue:[
|
|
763 |
releaseAction := [
|
|
764 |
self setDefaultActions.
|
61
|
765 |
self select:aView
|
60
|
766 |
]
|
|
767 |
] ifFalse:[
|
|
768 |
releaseAction := [self setDefaultActions]
|
|
769 |
].
|
|
770 |
|
|
771 |
"prepare move operation for an object
|
|
772 |
"
|
61
|
773 |
|
60
|
774 |
motionAction := [:movePoint|
|
72
|
775 |
(aPoint dist:movePoint) > 8.0 ifTrue:[
|
60
|
776 |
self startObjectMoveAt:aPoint
|
|
777 |
]
|
|
778 |
].
|
|
779 |
! !
|
|
780 |
|
|
781 |
!UIObjectView methodsFor:'object resize'!
|
|
782 |
|
|
783 |
actionResize:anObject selector:aSelector
|
|
784 |
"create and initialize action for resize
|
|
785 |
"
|
|
786 |
|selector delta|
|
|
787 |
|
|
788 |
delta := anObject container originRelativeTo:self.
|
|
789 |
selector := ('resize:', aSelector, ':') asSymbol.
|
|
790 |
|
175
|
791 |
resizeData := Structure with:(#object->anObject)
|
60
|
792 |
with:(#selector->selector)
|
|
793 |
with:(#delta->delta).
|
|
794 |
|
|
795 |
"can change cursor dependent on vertical/horizontal resizing
|
|
796 |
"
|
|
797 |
oldCursor := cursor.
|
|
798 |
self cursor:(Cursor leftHand).
|
|
799 |
|
|
800 |
|
|
801 |
|
|
802 |
!
|
|
803 |
|
|
804 |
doDragResize:aPoint
|
61
|
805 |
"do a widget resize drag
|
|
806 |
"
|
60
|
807 |
|p object|
|
|
808 |
|
175
|
809 |
object := resizeData object.
|
60
|
810 |
|
|
811 |
self invertOutlineOf:object.
|
175
|
812 |
p := (self alignToGrid:aPoint) - (resizeData delta).
|
|
813 |
|
|
814 |
self perform:(resizeData selector) with:object with:p.
|
79
|
815 |
"/ object geometryLayout:(object geometryLayout).
|
60
|
816 |
self invertOutlineOf:object
|
|
817 |
|
|
818 |
!
|
|
819 |
|
|
820 |
endResize
|
61
|
821 |
"cleanup after object resize
|
|
822 |
"
|
|
823 |
|object|
|
|
824 |
|
175
|
825 |
object := resizeData object.
|
|
826 |
resizeData := nil.
|
61
|
827 |
|
|
828 |
self invertOutlineOf:object.
|
60
|
829 |
self setDefaultActions.
|
61
|
830 |
self elementChangedSize:object.
|
138
|
831 |
|
|
832 |
"/ handle any expose events (for subcomponents) before
|
|
833 |
"/ redrawing the handles.
|
|
834 |
Delay waitForSeconds:0.05.
|
|
835 |
[self sensor hasExposeEventFor:nil] whileTrue:[
|
|
836 |
self windowGroup processExposeEvents
|
|
837 |
].
|
|
838 |
|
128
|
839 |
self setSelection:object withRedraw:true.
|
225
|
840 |
self layoutChanged.
|
60
|
841 |
!
|
|
842 |
|
|
843 |
startResizeBorder:b of:selection
|
|
844 |
"resize selected view
|
|
845 |
"
|
|
846 |
|object|
|
|
847 |
|
|
848 |
object := self singleSelection.
|
|
849 |
self actionResize:object selector:b.
|
|
850 |
|
72
|
851 |
self transaction:#resize selectionDo:[:aView|
|
134
|
852 |
self createUndoLayout:aView
|
60
|
853 |
].
|
128
|
854 |
self setSelection:nil withRedraw:true.
|
60
|
855 |
|
|
856 |
motionAction := [:movePoint | self doDragResize:movePoint].
|
|
857 |
releaseAction := [self endResize].
|
|
858 |
self invertOutlineOf:object
|
|
859 |
! !
|
|
860 |
|
|
861 |
!UIObjectView methodsFor:'private handles'!
|
|
862 |
|
175
|
863 |
handlesOf:aComponent do:aTwoArgAction
|
|
864 |
"perform action on each handle of a component
|
|
865 |
"
|
|
866 |
|dlt ext|
|
|
867 |
|
|
868 |
dlt := (aComponent originRelativeTo:self) - aComponent origin.
|
|
869 |
dlt := dlt - (3@3).
|
|
870 |
ext := 6@6.
|
|
871 |
|
|
872 |
self class handlesOf:aComponent do:[:pnt :wht |
|
|
873 |
aTwoArgAction value:(pnt + dlt extent:ext) value:wht
|
|
874 |
]
|
60
|
875 |
!
|
|
876 |
|
|
877 |
showSelected:aComponent
|
61
|
878 |
"show object selected
|
|
879 |
"
|
175
|
880 |
|wasClipped|
|
|
881 |
|
|
882 |
selectionHiddenLevel == 0 ifTrue:[
|
|
883 |
self paint:Color black.
|
|
884 |
|
|
885 |
(wasClipped := clipChildren) ifTrue:[
|
|
886 |
self clippedByChildren:(clipChildren := false).
|
|
887 |
].
|
|
888 |
|
|
889 |
self handlesOf:aComponent do:[:rectangle :what|
|
|
890 |
what == #view ifTrue:[self displayRectangle:rectangle]
|
|
891 |
ifFalse:[self fillRectangle:rectangle]
|
|
892 |
].
|
|
893 |
|
|
894 |
wasClipped ifTrue:[
|
|
895 |
self clippedByChildren:(clipChildren := true).
|
|
896 |
]
|
|
897 |
]
|
60
|
898 |
!
|
|
899 |
|
|
900 |
showUnselected:aComponent
|
61
|
901 |
"show object unselected
|
|
902 |
"
|
251
|
903 |
|wasClipped r|
|
60
|
904 |
|
138
|
905 |
selectionHiddenLevel ~~ 0 ifTrue:[^ self].
|
|
906 |
|
60
|
907 |
(wasClipped := clipChildren) ifTrue:[
|
|
908 |
self clippedByChildren:(clipChildren := false).
|
|
909 |
].
|
|
910 |
|
175
|
911 |
self handlesOf:aComponent do:[:rec :wht| self clearRectangle:rec ].
|
60
|
912 |
|
|
913 |
wasClipped ifTrue:[
|
|
914 |
self clippedByChildren:(clipChildren := true).
|
|
915 |
].
|
|
916 |
|
|
917 |
"/ must redraw all components which are affected b the handles
|
|
918 |
|
175
|
919 |
r := (aComponent originRelativeTo:self) - (3@3) extent:(aComponent extent + (6@6)).
|
60
|
920 |
|
|
921 |
subViews do:[:anotherComponent |
|
|
922 |
|absOrg absFrame|
|
|
923 |
|
|
924 |
anotherComponent ~~ inputView ifTrue:[
|
|
925 |
absOrg := anotherComponent originRelativeTo:self.
|
|
926 |
absFrame := absOrg extent:(anotherComponent extent).
|
|
927 |
(absFrame intersects:r) ifTrue:[
|
|
928 |
anotherComponent withAllSubViewsDo:[:v |
|
95
|
929 |
v shown ifTrue:[
|
132
|
930 |
v fill:v viewBackground.
|
95
|
931 |
v exposeX:0 y:0 width:9999 height:9999.
|
|
932 |
]
|
60
|
933 |
]
|
|
934 |
]
|
|
935 |
]
|
|
936 |
]
|
|
937 |
|
95
|
938 |
"Modified: 8.4.1997 / 00:32:26 / cg"
|
60
|
939 |
!
|
|
940 |
|
175
|
941 |
whichHandleOf:aComponent isHitBy:aPoint
|
61
|
942 |
"returns kind of handle or nil
|
|
943 |
"
|
175
|
944 |
self handlesOf:aComponent do:[:rectangle :what|
|
|
945 |
(rectangle containsPoint:aPoint) ifTrue:[^ what]
|
60
|
946 |
].
|
175
|
947 |
^ nil
|
60
|
948 |
! !
|
|
949 |
|
|
950 |
!UIObjectView methodsFor:'private resizing-subviews'!
|
|
951 |
|
|
952 |
resize:aView bottom:aPoint
|
61
|
953 |
"resize a views bottom
|
|
954 |
"
|
134
|
955 |
undoHistory withoutTransactionDo:[
|
60
|
956 |
self shiftLayout:aView top:0 bottom:((aPoint y) - (aView computeCorner y))
|
|
957 |
]
|
|
958 |
!
|
|
959 |
|
|
960 |
resize:aView bottomLeft:aPoint
|
61
|
961 |
"resize a views bottom and left
|
|
962 |
"
|
134
|
963 |
undoHistory withoutTransactionDo:[
|
60
|
964 |
self shiftLayout:aView top:0
|
|
965 |
bottom:((aPoint y) - (aView computeCorner y))
|
|
966 |
left:((aPoint x) - (aView computeOrigin x))
|
|
967 |
right:0
|
|
968 |
|
|
969 |
]
|
|
970 |
|
|
971 |
|
|
972 |
!
|
|
973 |
|
|
974 |
resize:aView corner:aPoint
|
61
|
975 |
"resize a views corner
|
|
976 |
"
|
60
|
977 |
|delta|
|
|
978 |
|
|
979 |
delta := aPoint - aView computeCorner.
|
|
980 |
|
134
|
981 |
undoHistory withoutTransactionDo:[
|
60
|
982 |
self shiftLayout:aView top:0 bottom:(delta y) left:0 right:(delta x)
|
|
983 |
]
|
|
984 |
!
|
|
985 |
|
|
986 |
resize:aView left:aPoint
|
61
|
987 |
"resize a views left
|
|
988 |
"
|
134
|
989 |
undoHistory withoutTransactionDo:[
|
60
|
990 |
self shiftLayout:aView left:((aPoint x) - (aView computeOrigin x)) right:0
|
|
991 |
]
|
|
992 |
|
|
993 |
!
|
|
994 |
|
|
995 |
resize:aView origin:aPoint
|
61
|
996 |
"resize a views origin
|
|
997 |
"
|
60
|
998 |
|delta|
|
|
999 |
|
|
1000 |
delta := aPoint - aView computeOrigin.
|
|
1001 |
|
134
|
1002 |
undoHistory withoutTransactionDo:[
|
60
|
1003 |
self shiftLayout:aView top:(delta y) bottom:0 left:(delta x) right:0
|
|
1004 |
]
|
|
1005 |
|
|
1006 |
!
|
|
1007 |
|
|
1008 |
resize:aView right:aPoint
|
61
|
1009 |
"resize a views right
|
|
1010 |
"
|
134
|
1011 |
undoHistory withoutTransactionDo:[
|
60
|
1012 |
self shiftLayout:aView left:0 right:((aPoint x) - (aView computeCorner x))
|
|
1013 |
]
|
|
1014 |
!
|
|
1015 |
|
|
1016 |
resize:aView top:aPoint
|
61
|
1017 |
"resize a views top
|
|
1018 |
"
|
134
|
1019 |
undoHistory withoutTransactionDo:[
|
60
|
1020 |
self shiftLayout:aView top:((aPoint y) - (aView computeOrigin y)) bottom:0
|
|
1021 |
]
|
|
1022 |
!
|
|
1023 |
|
|
1024 |
resize:aView topRight:aPoint
|
61
|
1025 |
"resize a views top and right
|
|
1026 |
"
|
134
|
1027 |
undoHistory withoutTransactionDo:[
|
60
|
1028 |
self shiftLayout:aView top:((aPoint y) - (aView computeOrigin y))
|
|
1029 |
bottom:0
|
|
1030 |
left:0
|
|
1031 |
right:((aPoint x) - (aView computeCorner x))
|
|
1032 |
|
|
1033 |
]
|
|
1034 |
|
|
1035 |
! !
|
|
1036 |
|
|
1037 |
!UIObjectView methodsFor:'private shift-layout'!
|
|
1038 |
|
|
1039 |
shiftLayout:aView left:l right:r
|
|
1040 |
"shift layout for a view; in case of an open transaction, the undo
|
|
1041 |
action is registered
|
|
1042 |
"
|
|
1043 |
self shiftLayout:aView top:0 bottom:0 left:l right:r
|
|
1044 |
|
|
1045 |
!
|
|
1046 |
|
|
1047 |
shiftLayout:aView top:t bottom:b
|
|
1048 |
"shift layout for a view; in case of an open transaction, the undo
|
|
1049 |
action is registered
|
|
1050 |
"
|
|
1051 |
self shiftLayout:aView top:t bottom:b left:0 right:0
|
|
1052 |
|
|
1053 |
|
|
1054 |
!
|
|
1055 |
|
|
1056 |
shiftLayout:aView top:t bottom:b left:l right:r
|
|
1057 |
"shift layout for a view; in case of an open transaction, the undo
|
|
1058 |
action is registered
|
|
1059 |
"
|
79
|
1060 |
|type layout oldExt|
|
61
|
1061 |
|
|
1062 |
type := self class layoutType:aView.
|
|
1063 |
|
|
1064 |
type notNil ifTrue:[
|
134
|
1065 |
self createUndoLayout:aView.
|
61
|
1066 |
|
|
1067 |
type == #Extent ifTrue:[
|
79
|
1068 |
oldExt := aView extent.
|
|
1069 |
aView extent:(oldExt + ((r-l) @ (b-t))).
|
|
1070 |
^ self
|
60
|
1071 |
].
|
61
|
1072 |
|
78
|
1073 |
layout := aView geometryLayout copy.
|
61
|
1074 |
|
|
1075 |
layout isLayout ifTrue:[
|
|
1076 |
layout leftOffset:(layout leftOffset + l)
|
|
1077 |
topOffset:(layout topOffset + t).
|
|
1078 |
|
|
1079 |
type == #LayoutFrame ifTrue:[
|
|
1080 |
layout bottomOffset:(layout bottomOffset + b).
|
|
1081 |
layout rightOffset:(layout rightOffset + r).
|
|
1082 |
]
|
|
1083 |
] ifFalse:[
|
|
1084 |
type == #Rectangle ifTrue:[
|
|
1085 |
layout left:(layout left + l)
|
|
1086 |
right:(layout right + r)
|
|
1087 |
top:(layout top + t)
|
|
1088 |
bottom:(layout bottom + b).
|
|
1089 |
] ifFalse:[ "POINT"
|
|
1090 |
layout x:(layout x + l) y:(layout y + t).
|
|
1091 |
]
|
|
1092 |
].
|
|
1093 |
aView geometryLayout:layout
|
60
|
1094 |
]
|
|
1095 |
! !
|
|
1096 |
|
|
1097 |
!UIObjectView methodsFor:'searching'!
|
|
1098 |
|
|
1099 |
findObjectAt:aPoint
|
|
1100 |
"find the origin/corner of the currentWidget
|
|
1101 |
"
|
|
1102 |
|view viewId lastId point listOfViews|
|
|
1103 |
|
|
1104 |
viewId := rootView id.
|
|
1105 |
point := aPoint + (device translatePoint:0@0 from:(self id) to:viewId).
|
|
1106 |
|
|
1107 |
inputView lower.
|
|
1108 |
|
|
1109 |
[viewId notNil] whileTrue:[
|
|
1110 |
lastId := viewId.
|
|
1111 |
viewId := device viewIdFromPoint:point in:lastId
|
|
1112 |
].
|
|
1113 |
|
|
1114 |
inputView raise.
|
|
1115 |
|
|
1116 |
view := device viewFromId:lastId.
|
|
1117 |
|
|
1118 |
view ~~ inputView ifTrue:[^ view].
|
|
1119 |
|
|
1120 |
"/ look for 'hidden' views ...
|
|
1121 |
|
|
1122 |
listOfViews := OrderedCollection new.
|
|
1123 |
self allSubViewsDo:[:aView |
|
|
1124 |
|org|
|
|
1125 |
|
|
1126 |
aView ~~ inputView ifTrue:[
|
|
1127 |
org := device translatePoint:0@0 from:(aView id) to:self id.
|
|
1128 |
((org extent:aView extent) containsPoint:aPoint) ifTrue:[
|
|
1129 |
listOfViews add:aView.
|
|
1130 |
]
|
|
1131 |
]
|
|
1132 |
].
|
|
1133 |
|
|
1134 |
listOfViews size > 0 ifTrue:[
|
|
1135 |
^ listOfViews last
|
|
1136 |
].
|
|
1137 |
^ nil
|
|
1138 |
|
|
1139 |
|
|
1140 |
! !
|
|
1141 |
|
|
1142 |
!UIObjectView methodsFor:'selections'!
|
|
1143 |
|
128
|
1144 |
moveableSelection
|
131
|
1145 |
"checks whether the selection is not empty and all selected instances
|
|
1146 |
can be moved. If true the selection is returned otherwise nil
|
128
|
1147 |
"
|
|
1148 |
|coll|
|
|
1149 |
|
|
1150 |
self hasSelection ifTrue:[
|
|
1151 |
(self canMove:(coll := self selection)) ifTrue:[
|
|
1152 |
^ coll
|
|
1153 |
]
|
|
1154 |
].
|
|
1155 |
^ nil
|
|
1156 |
!
|
|
1157 |
|
60
|
1158 |
numberOfSelections
|
131
|
1159 |
"return the number of selected instances
|
61
|
1160 |
"
|
128
|
1161 |
|coll size|
|
|
1162 |
|
|
1163 |
coll := self selection.
|
|
1164 |
size := coll size.
|
|
1165 |
|
|
1166 |
(size ~~ 0 or:[coll isNil]) ifTrue:[^ size].
|
|
1167 |
^ 1
|
60
|
1168 |
!
|
|
1169 |
|
149
|
1170 |
selection:something
|
|
1171 |
"change selection to something
|
|
1172 |
"
|
|
1173 |
self select:something
|
|
1174 |
!
|
|
1175 |
|
128
|
1176 |
selectionDo:aBlock
|
|
1177 |
"apply block to every selected object
|
|
1178 |
"
|
|
1179 |
self forEach:(self selection) do:aBlock
|
|
1180 |
|
|
1181 |
|
|
1182 |
!
|
|
1183 |
|
61
|
1184 |
showSelection
|
128
|
1185 |
"show the selection - draw handles
|
|
1186 |
"
|
61
|
1187 |
selectionHiddenLevel == 0 ifTrue:[
|
128
|
1188 |
self selectionDo:[:el| self showSelected:el ]
|
60
|
1189 |
].
|
|
1190 |
!
|
|
1191 |
|
|
1192 |
singleSelection
|
131
|
1193 |
"checks whether one element is selected; in this case the element is
|
|
1194 |
returned otherwise nil
|
60
|
1195 |
"
|
128
|
1196 |
|coll|
|
|
1197 |
|
|
1198 |
(coll := self selection) isCollection ifFalse:[
|
|
1199 |
^ coll
|
60
|
1200 |
].
|
128
|
1201 |
|
|
1202 |
coll size == 1 ifTrue:[ ^ coll first].
|
|
1203 |
^ nil
|
60
|
1204 |
!
|
|
1205 |
|
|
1206 |
singleSelectionDo:aBlock
|
131
|
1207 |
"checks whether one element is selected; in this case the block
|
|
1208 |
with argument the selected instance will be processed
|
61
|
1209 |
"
|
60
|
1210 |
|view|
|
|
1211 |
|
|
1212 |
(view := self singleSelection) notNil ifTrue:[
|
|
1213 |
aBlock value:view
|
|
1214 |
]
|
|
1215 |
!
|
|
1216 |
|
|
1217 |
unselect
|
61
|
1218 |
"clear selection
|
|
1219 |
"
|
128
|
1220 |
self select:nil
|
60
|
1221 |
!
|
|
1222 |
|
|
1223 |
withSelectionHiddenDo:aBlock
|
61
|
1224 |
"apply block with selection hidden (no handles)
|
|
1225 |
"
|
78
|
1226 |
|coll|
|
|
1227 |
|
138
|
1228 |
selectionHiddenLevel == 0 ifTrue:[
|
61
|
1229 |
self selectionDo:[:aView| self showUnselected:aView].
|
|
1230 |
device flush.
|
|
1231 |
].
|
138
|
1232 |
selectionHiddenLevel := selectionHiddenLevel + 1.
|
61
|
1233 |
|
|
1234 |
aBlock valueNowOrOnUnwindDo:[
|
|
1235 |
selectionHiddenLevel == 1 ifTrue:[
|
|
1236 |
setOfSuperViewsSizeChanged notEmpty ifTrue:[
|
78
|
1237 |
coll := self minSetOfSuperViews:setOfSuperViewsSizeChanged.
|
|
1238 |
coll do:[:aView| aView sizeChanged:nil].
|
61
|
1239 |
setOfSuperViewsSizeChanged := IdentitySet new
|
|
1240 |
].
|
138
|
1241 |
selectionHiddenLevel := 0.
|
61
|
1242 |
self selectionDo:[:aView| self showSelected:aView].
|
138
|
1243 |
] ifFalse:[
|
|
1244 |
selectionHiddenLevel := selectionHiddenLevel - 1.
|
|
1245 |
]
|
61
|
1246 |
]
|
|
1247 |
|
|
1248 |
!
|
|
1249 |
|
|
1250 |
withoutSelectionDo:aBlock
|
|
1251 |
"evaluate aBlock while selection is nilled
|
|
1252 |
"
|
60
|
1253 |
|sel|
|
|
1254 |
|
128
|
1255 |
self hasSelection ifFalse:[
|
60
|
1256 |
aBlock value
|
128
|
1257 |
] ifTrue:[
|
|
1258 |
sel := self selection.
|
|
1259 |
self setSelection:nil withRedraw:true.
|
60
|
1260 |
aBlock value.
|
128
|
1261 |
self setSelection:sel withRedraw:true.
|
60
|
1262 |
]
|
|
1263 |
|
|
1264 |
|
|
1265 |
! !
|
|
1266 |
|
131
|
1267 |
!UIObjectView methodsFor:'selections basic'!
|
|
1268 |
|
|
1269 |
selection
|
|
1270 |
"returns the current selection
|
|
1271 |
"
|
|
1272 |
^ selection
|
|
1273 |
|
|
1274 |
|
|
1275 |
!
|
|
1276 |
|
|
1277 |
setSelection:aNewSelection withRedraw:doRedraw
|
|
1278 |
"set a new selection without change notifications
|
|
1279 |
"
|
225
|
1280 |
|sel|
|
|
1281 |
|
|
1282 |
(sel := aNewSelection) == self ifTrue:[
|
|
1283 |
sel := nil
|
|
1284 |
].
|
|
1285 |
|
131
|
1286 |
doRedraw ifTrue:[
|
|
1287 |
self hideSelection.
|
225
|
1288 |
selection := sel.
|
131
|
1289 |
self showSelection
|
|
1290 |
] ifFalse:[
|
225
|
1291 |
selection := sel
|
131
|
1292 |
]
|
|
1293 |
! !
|
|
1294 |
|
60
|
1295 |
!UIObjectView methodsFor:'testing'!
|
|
1296 |
|
284
|
1297 |
hasSelection
|
|
1298 |
"returns true if any widget is selected
|
61
|
1299 |
"
|
284
|
1300 |
^ self numberOfSelections ~~ 0
|
60
|
1301 |
|
|
1302 |
!
|
|
1303 |
|
284
|
1304 |
hasSingleSelection
|
|
1305 |
"returns true if one widget is selected
|
61
|
1306 |
"
|
284
|
1307 |
^ self numberOfSelections == 1
|
|
1308 |
|
|
1309 |
!
|
|
1310 |
|
|
1311 |
hasUndoHistory
|
|
1312 |
"returns true if undos exists
|
|
1313 |
"
|
|
1314 |
^ undoHistory isEmpty not
|
60
|
1315 |
!
|
|
1316 |
|
134
|
1317 |
isModified
|
|
1318 |
"returns true if painter is modified
|
|
1319 |
"
|
|
1320 |
^ undoHistory isModified
|
|
1321 |
!
|
|
1322 |
|
128
|
1323 |
isSelected:anObject
|
|
1324 |
"return true, if the argument, anObject is selected
|
|
1325 |
"
|
|
1326 |
anObject notNil ifTrue:[
|
|
1327 |
self selectionDo:[:el| el == anObject ifTrue:[^ true]]
|
|
1328 |
].
|
|
1329 |
^ false
|
|
1330 |
|
60
|
1331 |
! !
|
|
1332 |
|
|
1333 |
!UIObjectView methodsFor:'transaction'!
|
|
1334 |
|
134
|
1335 |
createUndoLayout:aView
|
|
1336 |
"prepare undo action for a view changing its layout
|
|
1337 |
"
|
|
1338 |
self subclassResponsibility
|
|
1339 |
|
|
1340 |
!
|
|
1341 |
|
60
|
1342 |