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 |
self showSelected:aComponent
|
|
457 |
]
|
132
|
458 |
]
|
60
|
459 |
|
|
460 |
!
|
|
461 |
|
|
462 |
keyPress:key x:x y:y
|
61
|
463 |
"any key pressed
|
|
464 |
"
|
78
|
465 |
<resource: #keyboard ( #Delete #BackSpace #Cut #Copy #Paste ) >
|
60
|
466 |
|
|
467 |
(key == #Cut or:[key == #Delete or:[key == #BackSpace]]) ifTrue: [
|
|
468 |
^ self deleteSelection
|
|
469 |
].
|
|
470 |
|
78
|
471 |
key == #Copy ifTrue:[ ^ self copySelection].
|
|
472 |
key == #Paste ifTrue:[ ^ self pasteBuffer].
|
60
|
473 |
!
|
|
474 |
|
|
475 |
processEvent:anEvent
|
|
476 |
"catch expose events for components, and redraw its handles after
|
|
477 |
the redraw when this happens
|
|
478 |
"
|
128
|
479 |
(anEvent type == #damage and:[self isSelected:(anEvent view)]) ifTrue:[
|
|
480 |
self showSelected:(anEvent view)
|
60
|
481 |
].
|
|
482 |
^ false.
|
|
483 |
|
|
484 |
|
|
485 |
!
|
|
486 |
|
|
487 |
sizeChanged:how
|
61
|
488 |
"size of a view(s) changed
|
|
489 |
"
|
60
|
490 |
self withSelectionHiddenDo:[
|
|
491 |
super sizeChanged:how
|
|
492 |
]
|
|
493 |
|
|
494 |
|
|
495 |
! !
|
|
496 |
|
|
497 |
!UIObjectView methodsFor:'initialization'!
|
|
498 |
|
|
499 |
initialize
|
61
|
500 |
"setup attributes
|
|
501 |
"
|
60
|
502 |
super initialize.
|
|
503 |
|
|
504 |
"funny: since I do not want the created widgets to get pointer
|
|
505 |
events, I put an InputView on top of them, which catches those events
|
|
506 |
and passes them back to me - have to take care, that this inputView
|
|
507 |
is always on top
|
|
508 |
"
|
|
509 |
inputView := InputView origin:0.0@0.0 extent:1.0@1.0 in:self.
|
61
|
510 |
setOfSuperViewsSizeChanged := IdentitySet new.
|
60
|
511 |
|
|
512 |
inputView eventReceiver:self.
|
|
513 |
inputView enableButtonEvents.
|
|
514 |
inputView enableButtonMotionEvents.
|
|
515 |
|
|
516 |
self setDefaultActions.
|
|
517 |
|
134
|
518 |
undoHistory := UndoHistory on:self.
|
119
|
519 |
enableChannel := true asValue.
|
|
520 |
clipChildren := true.
|
61
|
521 |
selectionHiddenLevel := 0.
|
60
|
522 |
|
|
523 |
(self class gridShown) ifTrue:[
|
|
524 |
super showGrid
|
|
525 |
].
|
|
526 |
|
|
527 |
!
|
|
528 |
|
|
529 |
realize
|
|
530 |
super realize.
|
|
531 |
self windowGroup postEventHook:self
|
|
532 |
|
|
533 |
! !
|
|
534 |
|
|
535 |
!UIObjectView methodsFor:'misc'!
|
|
536 |
|
|
537 |
cursor:aCursor
|
61
|
538 |
"set cursor
|
|
539 |
"
|
60
|
540 |
inputView realized ifTrue:[
|
|
541 |
inputView cursor:aCursor
|
|
542 |
].
|
|
543 |
super cursor:aCursor
|
|
544 |
|
|
545 |
|
|
546 |
!
|
|
547 |
|
175
|
548 |
invertOutlineOf:something
|
|
549 |
"invert outline of an object or collection of objects
|
61
|
550 |
"
|
175
|
551 |
|wasClipped p|
|
60
|
552 |
|
|
553 |
(wasClipped := clipChildren) ifTrue:[
|
|
554 |
self clippedByChildren:(clipChildren := false).
|
|
555 |
].
|
175
|
556 |
|
|
557 |
something isCollection ifTrue:[
|
|
558 |
something do:[:v|
|
|
559 |
p := v originRelativeTo:self.
|
|
560 |
self xoring:[self displayRectangle:(p extent:v extent)].
|
|
561 |
]
|
|
562 |
] ifFalse:[
|
|
563 |
p := something originRelativeTo:self.
|
|
564 |
self xoring:[self displayRectangle:(p extent:something extent)]
|
60
|
565 |
].
|
|
566 |
|
|
567 |
wasClipped ifTrue:[
|
|
568 |
self clippedByChildren:(clipChildren := true).
|
|
569 |
].
|
|
570 |
|
|
571 |
!
|
|
572 |
|
78
|
573 |
minSetOfSuperViews:setOfViews
|
|
574 |
|
|
575 |
setOfViews isCollection ifFalse:[
|
|
576 |
setOfViews notNil ifTrue:[^ Array with:setOfViews]
|
|
577 |
ifFalse:[^ nil]
|
72
|
578 |
].
|
78
|
579 |
^ setOfViews select:[:aView|
|
|
580 |
(setOfViews detect:[:v|aView isComponentOf:v] ifNone:nil) isNil
|
|
581 |
]
|
72
|
582 |
!
|
|
583 |
|
60
|
584 |
setDefaultActions
|
61
|
585 |
"set default actions
|
|
586 |
"
|
60
|
587 |
pressAction := [:pressPoint | self startSelectOrMove:pressPoint].
|
|
588 |
shiftPressAction := [:pressPoint | self startSelectMoreOrMove:pressPoint].
|
|
589 |
motionAction := [:movePoint | nil].
|
|
590 |
releaseAction := [nil].
|
|
591 |
keyPressAction := nil.
|
|
592 |
|
|
593 |
self cursor:Cursor normal.
|
|
594 |
|
|
595 |
! !
|
|
596 |
|
|
597 |
!UIObjectView methodsFor:'object moving'!
|
|
598 |
|
|
599 |
doObjectMove:aPoint
|
|
600 |
"move selection
|
|
601 |
"
|
|
602 |
movedObject notNil ifTrue:[
|
175
|
603 |
self invertOutlineOf:movedObject.
|
|
604 |
|
|
605 |
movedObject keysAndValuesDo:[:i :v|
|
|
606 |
self moveObject:v to:(aPoint - (moveDelta at:i)).
|
|
607 |
].
|
|
608 |
self invertOutlineOf:movedObject.
|
60
|
609 |
]
|
|
610 |
|
|
611 |
!
|
|
612 |
|
|
613 |
endObjectMove
|
61
|
614 |
"cleanup after object(s) move
|
|
615 |
"
|
60
|
616 |
movedObject notNil ifTrue:[
|
175
|
617 |
self invertOutlineOf:movedObject.
|
128
|
618 |
|
|
619 |
movedObject size == 1 ifTrue:[
|
|
620 |
movedObject := movedObject first
|
60
|
621 |
].
|
128
|
622 |
self setSelection:movedObject withRedraw:true.
|
60
|
623 |
movedObject := nil.
|
|
624 |
self setDefaultActions.
|
225
|
625 |
self layoutChanged.
|
60
|
626 |
].
|
|
627 |
!
|
|
628 |
|
|
629 |
moveObject:anObject to:aPoint
|
|
630 |
"move anObject to newOrigin, aPoint
|
|
631 |
"
|
|
632 |
|dX dY org delta|
|
|
633 |
|
|
634 |
anObject notNil ifTrue:[
|
|
635 |
org := anObject computeOrigin.
|
|
636 |
|
|
637 |
delta := aPoint - org.
|
|
638 |
delta := (self alignToGrid:aPoint) - org.
|
|
639 |
dX := delta x.
|
|
640 |
dY := delta y.
|
|
641 |
|
134
|
642 |
undoHistory withoutTransactionDo:[
|
60
|
643 |
self shiftLayout:anObject top:dY bottom:dY left:dX right:dX
|
|
644 |
]
|
|
645 |
]
|
|
646 |
|
|
647 |
!
|
|
648 |
|
|
649 |
startObjectMoveAt:aPoint
|
61
|
650 |
"start object(s) move at a point
|
|
651 |
"
|
128
|
652 |
self startObjectMove:(self selection) at:aPoint.
|
|
653 |
movedObject := self selection.
|
|
654 |
|
|
655 |
movedObject isCollection ifFalse:[
|
|
656 |
movedObject := Array with:movedObject
|
60
|
657 |
].
|
128
|
658 |
self setSelection:nil withRedraw:true.
|
60
|
659 |
|
|
660 |
moveDelta := movedObject collect:[:aView|
|
|
661 |
aPoint - aView computeOrigin
|
|
662 |
].
|
175
|
663 |
self transaction:#move objects:movedObject do:[:v|self createUndoLayout:v].
|
|
664 |
self invertOutlineOf:movedObject.
|
60
|
665 |
!
|
|
666 |
|
|
667 |
startSelectMoreOrMove:aPoint
|
|
668 |
"add/remove to/from selection"
|
|
669 |
|
|
670 |
|anObject|
|
|
671 |
|
119
|
672 |
self enabled ifFalse:[^ self].
|
60
|
673 |
|
|
674 |
anObject := self findObjectAt:aPoint.
|
|
675 |
anObject notNil ifTrue:[
|
|
676 |
(self isSelected:anObject) ifTrue:[
|
|
677 |
self removeFromSelection:anObject
|
|
678 |
] ifFalse:[
|
|
679 |
self addToSelection:anObject
|
|
680 |
]
|
|
681 |
]
|
|
682 |
!
|
|
683 |
|
|
684 |
startSelectOrMove:aPoint
|
61
|
685 |
"a button is pressed at a point; start moving or selection
|
60
|
686 |
"
|
61
|
687 |
|aView b|
|
60
|
688 |
|
119
|
689 |
self enabled ifFalse:[^ self].
|
60
|
690 |
|
61
|
691 |
aView := self singleSelection.
|
|
692 |
|
|
693 |
aView notNil ifTrue:[
|
|
694 |
(aView superView specClass canResizeSubComponents) ifTrue:[
|
|
695 |
b := self whichHandleOf:aView isHitBy:aPoint.
|
|
696 |
|
|
697 |
(b notNil and:[b ~~ #view]) ifTrue:[
|
|
698 |
^ self startResizeBorder:b of:aView.
|
|
699 |
]
|
100
|
700 |
].
|
|
701 |
|
|
702 |
(self sensor ctrlDown and:[self canMove:aView]) ifFalse:[
|
|
703 |
aView := nil
|
60
|
704 |
]
|
|
705 |
].
|
|
706 |
|
100
|
707 |
aView isNil ifTrue:[
|
|
708 |
(aView := self findObjectAt:aPoint) isNil ifTrue:[
|
131
|
709 |
^ self select:nil
|
100
|
710 |
].
|
|
711 |
|
|
712 |
(self canMove:aView) ifFalse:[
|
128
|
713 |
^ self select:aView
|
100
|
714 |
]
|
61
|
715 |
].
|
|
716 |
|
|
717 |
(self isSelected:aView) ifFalse:[
|
|
718 |
self select:aView.
|
60
|
719 |
].
|
|
720 |
|
|
721 |
(self numberOfSelections ~~ 1) ifTrue:[
|
|
722 |
releaseAction := [
|
|
723 |
self setDefaultActions.
|
61
|
724 |
self select:aView
|
60
|
725 |
]
|
|
726 |
] ifFalse:[
|
|
727 |
releaseAction := [self setDefaultActions]
|
|
728 |
].
|
|
729 |
|
|
730 |
"prepare move operation for an object
|
|
731 |
"
|
61
|
732 |
|
60
|
733 |
motionAction := [:movePoint|
|
72
|
734 |
(aPoint dist:movePoint) > 8.0 ifTrue:[
|
60
|
735 |
self startObjectMoveAt:aPoint
|
|
736 |
]
|
|
737 |
].
|
|
738 |
! !
|
|
739 |
|
|
740 |
!UIObjectView methodsFor:'object resize'!
|
|
741 |
|
|
742 |
actionResize:anObject selector:aSelector
|
|
743 |
"create and initialize action for resize
|
|
744 |
"
|
|
745 |
|selector delta|
|
|
746 |
|
|
747 |
delta := anObject container originRelativeTo:self.
|
|
748 |
selector := ('resize:', aSelector, ':') asSymbol.
|
|
749 |
|
175
|
750 |
resizeData := Structure with:(#object->anObject)
|
60
|
751 |
with:(#selector->selector)
|
|
752 |
with:(#delta->delta).
|
|
753 |
|
|
754 |
"can change cursor dependent on vertical/horizontal resizing
|
|
755 |
"
|
|
756 |
oldCursor := cursor.
|
|
757 |
self cursor:(Cursor leftHand).
|
|
758 |
|
|
759 |
|
|
760 |
|
|
761 |
!
|
|
762 |
|
|
763 |
doDragResize:aPoint
|
61
|
764 |
"do a widget resize drag
|
|
765 |
"
|
60
|
766 |
|p object|
|
|
767 |
|
175
|
768 |
object := resizeData object.
|
60
|
769 |
|
|
770 |
self invertOutlineOf:object.
|
175
|
771 |
p := (self alignToGrid:aPoint) - (resizeData delta).
|
|
772 |
|
|
773 |
self perform:(resizeData selector) with:object with:p.
|
79
|
774 |
"/ object geometryLayout:(object geometryLayout).
|
60
|
775 |
self invertOutlineOf:object
|
|
776 |
|
|
777 |
!
|
|
778 |
|
|
779 |
endResize
|
61
|
780 |
"cleanup after object resize
|
|
781 |
"
|
|
782 |
|object|
|
|
783 |
|
175
|
784 |
object := resizeData object.
|
|
785 |
resizeData := nil.
|
61
|
786 |
|
|
787 |
self invertOutlineOf:object.
|
60
|
788 |
self setDefaultActions.
|
61
|
789 |
self elementChangedSize:object.
|
138
|
790 |
|
|
791 |
"/ handle any expose events (for subcomponents) before
|
|
792 |
"/ redrawing the handles.
|
|
793 |
Delay waitForSeconds:0.05.
|
|
794 |
[self sensor hasExposeEventFor:nil] whileTrue:[
|
|
795 |
self windowGroup processExposeEvents
|
|
796 |
].
|
|
797 |
|
128
|
798 |
self setSelection:object withRedraw:true.
|
225
|
799 |
self layoutChanged.
|
60
|
800 |
!
|
|
801 |
|
|
802 |
startResizeBorder:b of:selection
|
|
803 |
"resize selected view
|
|
804 |
"
|
|
805 |
|object|
|
|
806 |
|
|
807 |
object := self singleSelection.
|
|
808 |
self actionResize:object selector:b.
|
|
809 |
|
72
|
810 |
self transaction:#resize selectionDo:[:aView|
|
134
|
811 |
self createUndoLayout:aView
|
60
|
812 |
].
|
128
|
813 |
self setSelection:nil withRedraw:true.
|
60
|
814 |
|
|
815 |
motionAction := [:movePoint | self doDragResize:movePoint].
|
|
816 |
releaseAction := [self endResize].
|
|
817 |
self invertOutlineOf:object
|
|
818 |
! !
|
|
819 |
|
|
820 |
!UIObjectView methodsFor:'private handles'!
|
|
821 |
|
175
|
822 |
handlesOf:aComponent do:aTwoArgAction
|
|
823 |
"perform action on each handle of a component
|
|
824 |
"
|
|
825 |
|dlt ext|
|
|
826 |
|
|
827 |
dlt := (aComponent originRelativeTo:self) - aComponent origin.
|
|
828 |
dlt := dlt - (3@3).
|
|
829 |
ext := 6@6.
|
|
830 |
|
|
831 |
self class handlesOf:aComponent do:[:pnt :wht |
|
|
832 |
aTwoArgAction value:(pnt + dlt extent:ext) value:wht
|
|
833 |
]
|
60
|
834 |
!
|
|
835 |
|
|
836 |
showSelected:aComponent
|
61
|
837 |
"show object selected
|
|
838 |
"
|
175
|
839 |
|wasClipped|
|
|
840 |
|
|
841 |
selectionHiddenLevel == 0 ifTrue:[
|
|
842 |
self paint:Color black.
|
|
843 |
|
|
844 |
(wasClipped := clipChildren) ifTrue:[
|
|
845 |
self clippedByChildren:(clipChildren := false).
|
|
846 |
].
|
|
847 |
|
|
848 |
self handlesOf:aComponent do:[:rectangle :what|
|
|
849 |
what == #view ifTrue:[self displayRectangle:rectangle]
|
|
850 |
ifFalse:[self fillRectangle:rectangle]
|
|
851 |
].
|
|
852 |
|
|
853 |
wasClipped ifTrue:[
|
|
854 |
self clippedByChildren:(clipChildren := true).
|
|
855 |
]
|
|
856 |
]
|
60
|
857 |
!
|
|
858 |
|
|
859 |
showUnselected:aComponent
|
61
|
860 |
"show object unselected
|
|
861 |
"
|
132
|
862 |
|wasClipped delta r|
|
60
|
863 |
|
138
|
864 |
selectionHiddenLevel ~~ 0 ifTrue:[^ self].
|
|
865 |
|
60
|
866 |
(wasClipped := clipChildren) ifTrue:[
|
|
867 |
self clippedByChildren:(clipChildren := false).
|
|
868 |
].
|
|
869 |
|
175
|
870 |
self handlesOf:aComponent do:[:rec :wht| self clearRectangle:rec ].
|
60
|
871 |
|
|
872 |
wasClipped ifTrue:[
|
|
873 |
self clippedByChildren:(clipChildren := true).
|
|
874 |
].
|
|
875 |
|
|
876 |
"/ must redraw all components which are affected b the handles
|
|
877 |
|
175
|
878 |
r := (aComponent originRelativeTo:self) - (3@3) extent:(aComponent extent + (6@6)).
|
60
|
879 |
|
|
880 |
subViews do:[:anotherComponent |
|
|
881 |
|absOrg absFrame|
|
|
882 |
|
|
883 |
anotherComponent ~~ inputView ifTrue:[
|
|
884 |
absOrg := anotherComponent originRelativeTo:self.
|
|
885 |
absFrame := absOrg extent:(anotherComponent extent).
|
|
886 |
(absFrame intersects:r) ifTrue:[
|
|
887 |
anotherComponent withAllSubViewsDo:[:v |
|
95
|
888 |
v shown ifTrue:[
|
132
|
889 |
v fill:v viewBackground.
|
95
|
890 |
v exposeX:0 y:0 width:9999 height:9999.
|
|
891 |
]
|
60
|
892 |
]
|
|
893 |
]
|
|
894 |
]
|
|
895 |
]
|
|
896 |
|
95
|
897 |
"Modified: 8.4.1997 / 00:32:26 / cg"
|
60
|
898 |
!
|
|
899 |
|
175
|
900 |
whichHandleOf:aComponent isHitBy:aPoint
|
61
|
901 |
"returns kind of handle or nil
|
|
902 |
"
|
175
|
903 |
self handlesOf:aComponent do:[:rectangle :what|
|
|
904 |
(rectangle containsPoint:aPoint) ifTrue:[^ what]
|
60
|
905 |
].
|
175
|
906 |
^ nil
|
60
|
907 |
! !
|
|
908 |
|
|
909 |
!UIObjectView methodsFor:'private resizing-subviews'!
|
|
910 |
|
|
911 |
resize:aView bottom:aPoint
|
61
|
912 |
"resize a views bottom
|
|
913 |
"
|
134
|
914 |
undoHistory withoutTransactionDo:[
|
60
|
915 |
self shiftLayout:aView top:0 bottom:((aPoint y) - (aView computeCorner y))
|
|
916 |
]
|
|
917 |
!
|
|
918 |
|
|
919 |
resize:aView bottomLeft:aPoint
|
61
|
920 |
"resize a views bottom and left
|
|
921 |
"
|
134
|
922 |
undoHistory withoutTransactionDo:[
|
60
|
923 |
self shiftLayout:aView top:0
|
|
924 |
bottom:((aPoint y) - (aView computeCorner y))
|
|
925 |
left:((aPoint x) - (aView computeOrigin x))
|
|
926 |
right:0
|
|
927 |
|
|
928 |
]
|
|
929 |
|
|
930 |
|
|
931 |
!
|
|
932 |
|
|
933 |
resize:aView corner:aPoint
|
61
|
934 |
"resize a views corner
|
|
935 |
"
|
60
|
936 |
|delta|
|
|
937 |
|
|
938 |
delta := aPoint - aView computeCorner.
|
|
939 |
|
134
|
940 |
undoHistory withoutTransactionDo:[
|
60
|
941 |
self shiftLayout:aView top:0 bottom:(delta y) left:0 right:(delta x)
|
|
942 |
]
|
|
943 |
!
|
|
944 |
|
|
945 |
resize:aView left:aPoint
|
61
|
946 |
"resize a views left
|
|
947 |
"
|
134
|
948 |
undoHistory withoutTransactionDo:[
|
60
|
949 |
self shiftLayout:aView left:((aPoint x) - (aView computeOrigin x)) right:0
|
|
950 |
]
|
|
951 |
|
|
952 |
!
|
|
953 |
|
|
954 |
resize:aView origin:aPoint
|
61
|
955 |
"resize a views origin
|
|
956 |
"
|
60
|
957 |
|delta|
|
|
958 |
|
|
959 |
delta := aPoint - aView computeOrigin.
|
|
960 |
|
134
|
961 |
undoHistory withoutTransactionDo:[
|
60
|
962 |
self shiftLayout:aView top:(delta y) bottom:0 left:(delta x) right:0
|
|
963 |
]
|
|
964 |
|
|
965 |
!
|
|
966 |
|
|
967 |
resize:aView right:aPoint
|
61
|
968 |
"resize a views right
|
|
969 |
"
|
134
|
970 |
undoHistory withoutTransactionDo:[
|
60
|
971 |
self shiftLayout:aView left:0 right:((aPoint x) - (aView computeCorner x))
|
|
972 |
]
|
|
973 |
!
|
|
974 |
|
|
975 |
resize:aView top:aPoint
|
61
|
976 |
"resize a views top
|
|
977 |
"
|
134
|
978 |
undoHistory withoutTransactionDo:[
|
60
|
979 |
self shiftLayout:aView top:((aPoint y) - (aView computeOrigin y)) bottom:0
|
|
980 |
]
|
|
981 |
!
|
|
982 |
|
|
983 |
resize:aView topRight:aPoint
|
61
|
984 |
"resize a views top and right
|
|
985 |
"
|
134
|
986 |
undoHistory withoutTransactionDo:[
|
60
|
987 |
self shiftLayout:aView top:((aPoint y) - (aView computeOrigin y))
|
|
988 |
bottom:0
|
|
989 |
left:0
|
|
990 |
right:((aPoint x) - (aView computeCorner x))
|
|
991 |
|
|
992 |
]
|
|
993 |
|
|
994 |
! !
|
|
995 |
|
|
996 |
!UIObjectView methodsFor:'private shift-layout'!
|
|
997 |
|
|
998 |
shiftLayout:aView left:l right:r
|
|
999 |
"shift layout for a view; in case of an open transaction, the undo
|
|
1000 |
action is registered
|
|
1001 |
"
|
|
1002 |
self shiftLayout:aView top:0 bottom:0 left:l right:r
|
|
1003 |
|
|
1004 |
!
|
|
1005 |
|
|
1006 |
shiftLayout:aView top:t bottom:b
|
|
1007 |
"shift layout for a view; in case of an open transaction, the undo
|
|
1008 |
action is registered
|
|
1009 |
"
|
|
1010 |
self shiftLayout:aView top:t bottom:b left:0 right:0
|
|
1011 |
|
|
1012 |
|
|
1013 |
!
|
|
1014 |
|
|
1015 |
shiftLayout:aView top:t bottom:b left:l right:r
|
|
1016 |
"shift layout for a view; in case of an open transaction, the undo
|
|
1017 |
action is registered
|
|
1018 |
"
|
79
|
1019 |
|type layout oldExt|
|
61
|
1020 |
|
|
1021 |
type := self class layoutType:aView.
|
|
1022 |
|
|
1023 |
type notNil ifTrue:[
|
134
|
1024 |
self createUndoLayout:aView.
|
61
|
1025 |
|
|
1026 |
type == #Extent ifTrue:[
|
79
|
1027 |
oldExt := aView extent.
|
|
1028 |
aView extent:(oldExt + ((r-l) @ (b-t))).
|
|
1029 |
^ self
|
60
|
1030 |
].
|
61
|
1031 |
|
78
|
1032 |
layout := aView geometryLayout copy.
|
61
|
1033 |
|
|
1034 |
layout isLayout ifTrue:[
|
|
1035 |
layout leftOffset:(layout leftOffset + l)
|
|
1036 |
topOffset:(layout topOffset + t).
|
|
1037 |
|
|
1038 |
type == #LayoutFrame ifTrue:[
|
|
1039 |
layout bottomOffset:(layout bottomOffset + b).
|
|
1040 |
layout rightOffset:(layout rightOffset + r).
|
|
1041 |
]
|
|
1042 |
] ifFalse:[
|
|
1043 |
type == #Rectangle ifTrue:[
|
|
1044 |
layout left:(layout left + l)
|
|
1045 |
right:(layout right + r)
|
|
1046 |
top:(layout top + t)
|
|
1047 |
bottom:(layout bottom + b).
|
|
1048 |
] ifFalse:[ "POINT"
|
|
1049 |
layout x:(layout x + l) y:(layout y + t).
|
|
1050 |
]
|
|
1051 |
].
|
|
1052 |
aView geometryLayout:layout
|
60
|
1053 |
]
|
|
1054 |
! !
|
|
1055 |
|
|
1056 |
!UIObjectView methodsFor:'searching'!
|
|
1057 |
|
89
|
1058 |
findContainerViewAt:aPoint
|
|
1059 |
"find container view responds to aPoint.
|
|
1060 |
"
|
|
1061 |
^ self subclassResponsibility
|
|
1062 |
|
|
1063 |
|
|
1064 |
!
|
|
1065 |
|
60
|
1066 |
findObjectAt:aPoint
|
|
1067 |
"find the origin/corner of the currentWidget
|
|
1068 |
"
|
|
1069 |
|view viewId lastId point listOfViews|
|
|
1070 |
|
|
1071 |
viewId := rootView id.
|
|
1072 |
point := aPoint + (device translatePoint:0@0 from:(self id) to:viewId).
|
|
1073 |
|
|
1074 |
inputView lower.
|
|
1075 |
|
|
1076 |
[viewId notNil] whileTrue:[
|
|
1077 |
lastId := viewId.
|
|
1078 |
viewId := device viewIdFromPoint:point in:lastId
|
|
1079 |
].
|
|
1080 |
|
|
1081 |
inputView raise.
|
|
1082 |
|
|
1083 |
view := device viewFromId:lastId.
|
|
1084 |
|
|
1085 |
view ~~ inputView ifTrue:[^ view].
|
|
1086 |
|
|
1087 |
"/ look for 'hidden' views ...
|
|
1088 |
|
|
1089 |
listOfViews := OrderedCollection new.
|
|
1090 |
self allSubViewsDo:[:aView |
|
|
1091 |
|org|
|
|
1092 |
|
|
1093 |
aView ~~ inputView ifTrue:[
|
|
1094 |
org := device translatePoint:0@0 from:(aView id) to:self id.
|
|
1095 |
((org extent:aView extent) containsPoint:aPoint) ifTrue:[
|
|
1096 |
listOfViews add:aView.
|
|
1097 |
]
|
|
1098 |
]
|
|
1099 |
].
|
|
1100 |
|
|
1101 |
listOfViews size > 0 ifTrue:[
|
|
1102 |
^ listOfViews last
|
|
1103 |
].
|
|
1104 |
^ nil
|
|
1105 |
|
|
1106 |
|
|
1107 |
! !
|
|
1108 |
|
|
1109 |
!UIObjectView methodsFor:'selections'!
|
|
1110 |
|
128
|
1111 |
moveableSelection
|
131
|
1112 |
"checks whether the selection is not empty and all selected instances
|
|
1113 |
can be moved. If true the selection is returned otherwise nil
|
128
|
1114 |
"
|
|
1115 |
|coll|
|
|
1116 |
|
|
1117 |
self hasSelection ifTrue:[
|
|
1118 |
(self canMove:(coll := self selection)) ifTrue:[
|
|
1119 |
^ coll
|
|
1120 |
]
|
|
1121 |
].
|
|
1122 |
^ nil
|
|
1123 |
!
|
|
1124 |
|
60
|
1125 |
numberOfSelections
|
131
|
1126 |
"return the number of selected instances
|
61
|
1127 |
"
|
128
|
1128 |
|coll size|
|
|
1129 |
|
|
1130 |
coll := self selection.
|
|
1131 |
size := coll size.
|
|
1132 |
|
|
1133 |
(size ~~ 0 or:[coll isNil]) ifTrue:[^ size].
|
|
1134 |
^ 1
|
60
|
1135 |
!
|
|
1136 |
|
149
|
1137 |
selection:something
|
|
1138 |
"change selection to something
|
|
1139 |
"
|
|
1140 |
self select:something
|
|
1141 |
!
|
|
1142 |
|
128
|
1143 |
selectionDo:aBlock
|
|
1144 |
"apply block to every selected object
|
|
1145 |
"
|
|
1146 |
self forEach:(self selection) do:aBlock
|
|
1147 |
|
|
1148 |
|
|
1149 |
!
|
|
1150 |
|
61
|
1151 |
showSelection
|
128
|
1152 |
"show the selection - draw handles
|
|
1153 |
"
|
61
|
1154 |
selectionHiddenLevel == 0 ifTrue:[
|
128
|
1155 |
self selectionDo:[:el| self showSelected:el ]
|
60
|
1156 |
].
|
|
1157 |
!
|
|
1158 |
|
|
1159 |
singleSelection
|
131
|
1160 |
"checks whether one element is selected; in this case the element is
|
|
1161 |
returned otherwise nil
|
60
|
1162 |
"
|
128
|
1163 |
|coll|
|
|
1164 |
|
|
1165 |
(coll := self selection) isCollection ifFalse:[
|
|
1166 |
^ coll
|
60
|
1167 |
].
|
128
|
1168 |
|
|
1169 |
coll size == 1 ifTrue:[ ^ coll first].
|
|
1170 |
^ nil
|
60
|
1171 |
!
|
|
1172 |
|
|
1173 |
singleSelectionDo:aBlock
|
131
|
1174 |
"checks whether one element is selected; in this case the block
|
|
1175 |
with argument the selected instance will be processed
|
61
|
1176 |
"
|
60
|
1177 |
|view|
|
|
1178 |
|
|
1179 |
(view := self singleSelection) notNil ifTrue:[
|
|
1180 |
aBlock value:view
|
|
1181 |
]
|
|
1182 |
!
|
|
1183 |
|
|
1184 |
unselect
|
61
|
1185 |
"clear selection
|
|
1186 |
"
|
128
|
1187 |
self select:nil
|
60
|
1188 |
!
|
|
1189 |
|
|
1190 |
withSelectionHiddenDo:aBlock
|
61
|
1191 |
"apply block with selection hidden (no handles)
|
|
1192 |
"
|
78
|
1193 |
|coll|
|
|
1194 |
|
138
|
1195 |
selectionHiddenLevel == 0 ifTrue:[
|
61
|
1196 |
self selectionDo:[:aView| self showUnselected:aView].
|
|
1197 |
device flush.
|
|
1198 |
].
|
138
|
1199 |
selectionHiddenLevel := selectionHiddenLevel + 1.
|
61
|
1200 |
|
|
1201 |
aBlock valueNowOrOnUnwindDo:[
|
|
1202 |
selectionHiddenLevel == 1 ifTrue:[
|
|
1203 |
setOfSuperViewsSizeChanged notEmpty ifTrue:[
|
78
|
1204 |
coll := self minSetOfSuperViews:setOfSuperViewsSizeChanged.
|
|
1205 |
coll do:[:aView| aView sizeChanged:nil].
|
61
|
1206 |
setOfSuperViewsSizeChanged := IdentitySet new
|
|
1207 |
].
|
138
|
1208 |
selectionHiddenLevel := 0.
|
61
|
1209 |
self selectionDo:[:aView| self showSelected:aView].
|
138
|
1210 |
] ifFalse:[
|
|
1211 |
selectionHiddenLevel := selectionHiddenLevel - 1.
|
|
1212 |
]
|
61
|
1213 |
]
|
|
1214 |
|
|
1215 |
!
|
|
1216 |
|
|
1217 |
withoutSelectionDo:aBlock
|
|
1218 |
"evaluate aBlock while selection is nilled
|
|
1219 |
"
|
60
|
1220 |
|sel|
|
|
1221 |
|
128
|
1222 |
self hasSelection ifFalse:[
|
60
|
1223 |
aBlock value
|
128
|
1224 |
] ifTrue:[
|
|
1225 |
sel := self selection.
|
|
1226 |
self setSelection:nil withRedraw:true.
|
60
|
1227 |
aBlock value.
|
128
|
1228 |
self setSelection:sel withRedraw:true.
|
60
|
1229 |
]
|
|
1230 |
|
|
1231 |
|
|
1232 |
! !
|
|
1233 |
|
131
|
1234 |
!UIObjectView methodsFor:'selections basic'!
|
|
1235 |
|
|
1236 |
selection
|
|
1237 |
"returns the current selection
|
|
1238 |
"
|
|
1239 |
^ selection
|
|
1240 |
|
|
1241 |
|
|
1242 |
!
|
|
1243 |
|
|
1244 |
setSelection:aNewSelection withRedraw:doRedraw
|
|
1245 |
"set a new selection without change notifications
|
|
1246 |
"
|
225
|
1247 |
|sel|
|
|
1248 |
|
|
1249 |
(sel := aNewSelection) == self ifTrue:[
|
|
1250 |
sel := nil
|
|
1251 |
].
|
|
1252 |
|
131
|
1253 |
doRedraw ifTrue:[
|
|
1254 |
self hideSelection.
|
225
|
1255 |
selection := sel.
|
131
|
1256 |
self showSelection
|
|
1257 |
] ifFalse:[
|
225
|
1258 |
selection := sel
|
131
|
1259 |
]
|
|
1260 |
! !
|
|
1261 |
|
60
|
1262 |
!UIObjectView methodsFor:'testing'!
|
|
1263 |
|
|
1264 |
canMove:something
|
61
|
1265 |
"returns always true; all contained views can be moved
|
|
1266 |
"
|
|
1267 |
|sv|
|
|
1268 |
|
|
1269 |
something notNil ifTrue:[
|
|
1270 |
self forEach:something do:[:v|
|
|
1271 |
sv ~~ v superView ifTrue:[
|
|
1272 |
(sv notNil or:[v superView specClass isLayoutContainer]) ifTrue:[
|
|
1273 |
^ false
|
|
1274 |
].
|
|
1275 |
sv := v superView
|
|
1276 |
]
|
|
1277 |
].
|
|
1278 |
^ true
|
|
1279 |
].
|
|
1280 |
^ false
|
60
|
1281 |
|
|
1282 |
!
|
|
1283 |
|
128
|
1284 |
hasSelection
|
|
1285 |
"returns true if any selected object exists
|
61
|
1286 |
"
|
128
|
1287 |
^ self numberOfSelections ~~ 0
|
60
|
1288 |
|
|
1289 |
!
|
|
1290 |
|
134
|
1291 |
isModified
|
|
1292 |
"returns true if painter is modified
|
|
1293 |
"
|
|
1294 |
^ undoHistory isModified
|
|
1295 |
!
|
|
1296 |
|
128
|
1297 |
isSelected:anObject
|
|
1298 |
"return true, if the argument, anObject is selected
|
|
1299 |
"
|
|
1300 |
anObject notNil ifTrue:[
|
|
1301 |
self selectionDo:[:el| el == anObject ifTrue:[^ true]]
|
|
1302 |
].
|
|
1303 |
^ false
|
|
1304 |
|
60
|
1305 |
! !
|
|
1306 |
|
|
1307 |
!UIObjectView methodsFor:'transaction'!
|
|
1308 |
|
134
|
1309 |
createUndoLayout:aView
|
|
1310 |
"prepare undo action for a view changing its layout
|
|
1311 |
"
|
|
1312 |
self subclassResponsibility
|
|
1313 |
|
|
1314 |
!
|
|
1315 |
|
60
|
1316 |
transaction:aType objects:something do:aOneArgBlock
|
|
1317 |
"opens a transaction and evaluates a block within the transaction; the
|
|
1318 |
argument to the block is a view from derived from something
|
|
1319 |
"
|
|
1320 |
self subclassResponsibility
|
|
1321 |
|
|
1322 |
|
|
1323 |
!
|
|
1324 |
|
|
1325 |
transaction:aType selectionDo:aOneArgBlock
|
|
1326 |
"opens a transaction and evaluates a block within the transaction; the
|
|
1327 |
argument to the block is a view from the selection
|
|
1328 |
"
|
128
|
1329 |
self transaction:aType objects:(self selection) do:aOneArgBlock
|
60
|
1330 |
|
|
1331 |
|
|
1332 |
! !
|
|
1333 |
|
|
1334 |
!UIObjectView methodsFor:'user actions - dimension'!
|
|
1335 |
|
|
1336 |
copyExtent
|
61
|
1337 |
"copy the extent from the selected object
|
|
1338 |
"
|
60
|
1339 |
|object|
|
|
1340 |
|
|
1341 |
object := self singleSelection.
|
|
1342 |
|
|
1343 |
object notNil ifTrue:[
|
|
1344 |
copiedExtent := object computeExtent
|
|
1345 |
] ifFalse:[
|
|
1346 |
self warn:'exactly one element must be selected'.
|
|
1347 |
]
|
|
1348 |
|
|
1349 |
|
|
1350 |
|
|
1351 |
!
|
|
1352 |
|
89
|
1353 |
copyLayout
|
|
1354 |
"copy the layout from the selected object
|
|
1355 |
"
|
|
1356 |
|object|
|
|
1357 |
|
|
1358 |
object := self singleSelection.
|
|
1359 |
|
|
1360 |
object notNil ifTrue:[
|
|
1361 |
copiedLayout := object geometryLayout copy
|
|
1362 |
] ifFalse:[
|
|
1363 |
self warn:'exactly one element must be selected'.
|
|
1364 |
]
|
|
1365 |
|
|
1366 |
|
|
1367 |
|
|
1368 |
!
|
|
1369 |
|
60
|
1370 |
pasteExtent
|
61
|
1371 |
"paste the copied extent to all objects in the selection
|
|
1372 |
"
|
60
|
1373 |
copiedExtent notNil ifTrue:[
|
134
|
1374 |
self transaction:#pasteExtent dimensionDo:[:v|
|
60
|
1375 |
self resize:v corner:(v computeOrigin + copiedExtent)
|
|
1376 |
]
|
|
1377 |
]
|
|
1378 |
!
|
|
1379 |
|
|
1380 |
pasteHeight
|
61
|
1381 |
"paste the copied extent height to all objects in the selection
|
|
1382 |
"
|
60
|
1383 |
copiedExtent notNil ifTrue:[
|
134
|
1384 |
self transaction:#pasteHeight dimensionDo:[:v|
|
60
|
1385 |
self resize:v bottom:(v computeOrigin + copiedExtent)
|
|
1386 |
]
|
|
1387 |
]
|
|
1388 |
|
|
1389 |
!
|
|
1390 |
|
89
|
1391 |
pasteLayout
|
|
1392 |
"paste layout to all objects in the selection
|
|
1393 |
"
|
|
1394 |
copiedLayout notNil ifTrue:[
|
134
|
1395 |
self transaction:#pasteLayout dimensionDo:[:v|
|
89
|
1396 |
v geometryLayout:(copiedLayout copy)
|
|
1397 |
]
|
|
1398 |
]
|
|
1399 |
!
|
|
1400 |
|
60
|
1401 |
pasteWidth
|
61
|
1402 |
"paste the copied extent width to all objects in the selection
|
|
1403 |
"
|
60
|
1404 |
copiedExtent notNil ifTrue:[
|
134
|
1405 |
self transaction:#pasteWidth dimensionDo:[:v|
|
60
|
1406 |
self resize:v right:(v computeOrigin + copiedExtent)
|
|
1407 |
]
|
|
1408 |
]
|
|
1409 |
|
|
1410 |
!
|
|
1411 |
|
61
|
1412 |
setExtent:anExtent
|
|
1413 |
"change extent for all selected objects
|
|
1414 |
"
|
134
|
1415 |
self transaction:#extent dimensionDo:[:v|
|
67
|
1416 |
v geometryLayout:nil.
|
61
|
1417 |
v extent:anExtent.
|
67
|
1418 |
].
|
|
1419 |
|
|
1420 |
"Modified: 28.2.1997 / 12:49:00 / cg"
|
60
|
1421 |
!
|
|
1422 |
|
149
|
1423 |
setLayout:aLayout
|
|
1424 |
"change layout for all selected objects
|
|
1425 |
"
|
|
1426 |
self transaction:#layout dimensionDo:[:v|
|
|
1427 |
v geometryLayout:(aLayout copy)
|
|
1428 |
].
|
|
1429 |
|
|
1430 |
!
|
|
1431 |
|
60
|
1432 |
setToDefaultExtent
|
61
|
1433 |
"change extent of all selected views to their default extent
|
|
1434 |
"
|
134
|
1435 |
self transaction:#defaultExtent dimensionDo:[:v|
|
149
|
1436 |
self resize:v corner:(v computeOrigin + (v preferredExtent)).
|
60
|
1437 |
]
|
|
1438 |
|
|
1439 |
!
|
|
1440 |
|
|
1441 |
setToDefaultHeight
|
61
|
1442 |
"change height of all selected views to their default height
|
|
1443 |
"
|
134
|
1444 |
self transaction:#defaultHeight dimensionDo:[:v|
|
60
|
1445 |
self resize:v bottom:(v computeOrigin + (v preferredExtent))
|
|
1446 |
]
|
|
1447 |
|
|
1448 |
!
|
|
1449 |
|
|
1450 |
setToDefaultWidth
|
61
|
1451 |
"change width of all selected views to their default width
|
|
1452 |
"
|
134
|
1453 |
self transaction:#defaultWidth dimensionDo:[:v|
|
60
|
1454 |
self resize:v right:(v computeOrigin + (v preferredExtent))
|
|
1455 |
]
|
|
1456 |
|
|
1457 |
!
|
|
1458 |
|
134
|
1459 |
transaction:aType dimensionDo:aOneArgBlock
|
60
|
1460 |
"change dimension within a transaction for the selected elements by evaluating
|
|
1461 |
the block with the argument a view.
|
|
1462 |
"
|
61
|
1463 |
self withSelectionHiddenDo:[
|
60
|
1464 |
self transaction:aType selectionDo:[:aView|
|
61
|
1465 |
(self class layoutType:aView) notNil ifTrue:[
|
134
|
1466 |
self createUndoLayout:aView.
|
61
|
1467 |
aOneArgBlock value:aView.
|
|
1468 |
self elementChangedSize:aView.
|
|
1469 |
]
|
|
1470 |
]
|
|
1471 |
].
|
225
|
1472 |
self layoutChanged
|
61
|
1473 |
|
60
|
1474 |
! !
|
|
1475 |
|
|
1476 |
!UIObjectView methodsFor:'user actions - move'!
|
|
1477 |
|
138
|
1478 |
moveDo:aOneArgBlock
|
|
1479 |
"perform a move operation
|
|
1480 |
"
|
|
1481 |
|sensor tm|
|
|
1482 |
|
|
1483 |
self moveableSelection isNil ifTrue:[
|
|
1484 |
^ self
|
|
1485 |
].
|
|
1486 |
sensor := self sensor.
|
|
1487 |
|
|
1488 |
tm := 0.15.
|
|
1489 |
|
|
1490 |
self withSelectionHiddenDo:[
|
|
1491 |
self transaction:#move selectionDo:[:aView|self createUndoLayout:aView].
|
|
1492 |
|
|
1493 |
[
|
|
1494 |
self selectionDo:[:aView| aOneArgBlock value:aView ].
|
|
1495 |
Delay waitForSeconds:tm.
|
|
1496 |
tm := 0.02.
|
225
|
1497 |
self layoutChanged.
|
138
|
1498 |
sensor leftButtonPressed.
|
|
1499 |
] whileTrue.
|
|
1500 |
|
|
1501 |
"/ handle any expose events (for subcomponents) before
|
|
1502 |
"/ redrawing the handles.
|
|
1503 |
Delay waitForSeconds:0.05.
|
|
1504 |
[self sensor hasExposeEventFor:nil] whileTrue:[
|
|
1505 |
self windowGroup processExposeEvents
|
|
1506 |
]
|
|
1507 |
].
|
|
1508 |
!
|
|
1509 |
|
113
|
1510 |
moveSelectionDown
|
61
|
1511 |
"move selection down
|
|
1512 |
"
|
138
|
1513 |
|gridY n|
|
|
1514 |
|
|
1515 |
gridAlign notNil ifTrue:[gridY := gridAlign y]
|
|
1516 |
ifFalse:[gridY := 1].
|
|
1517 |
|
|
1518 |
self moveDo:[:aView|
|
|
1519 |
aligning ifTrue:[
|
|
1520 |
n := ((aView computeCorner y) \\ gridY).
|
|
1521 |
|
|
1522 |
n ~~ 0 ifTrue:[
|
|
1523 |
n := gridY - n + 1.
|
|
1524 |
] ifFalse:[
|
|
1525 |
n := gridY
|
61
|
1526 |
]
|
138
|
1527 |
] ifFalse:[
|
|
1528 |
n := 1
|
60
|
1529 |
].
|
138
|
1530 |
self shiftLayout:aView top:n bottom:n
|
60
|
1531 |
]
|
|
1532 |
!
|
|
1533 |
|
113
|
1534 |
moveSelectionLeft
|
60
|
1535 |
"move selection left
|
|
1536 |
"
|
113
|
1537 |
|gridX n|
|
60
|
1538 |
|
138
|
1539 |
gridAlign notNil ifTrue:[gridX := gridAlign x]
|
|
1540 |
ifFalse:[gridX := 1].
|
|
1541 |
|
|
1542 |
self moveDo:[:aView|
|
|
1543 |
aligning ifTrue:[
|
|
1544 |
n := ((aView computeOrigin x) \\ gridX).
|
|
1545 |
n == 0 ifTrue:[n := gridX].
|
|
1546 |
n := n negated.
|
|
1547 |
] ifFalse:[
|
|
1548 |
n := -1
|
60
|
1549 |
].
|
138
|
1550 |
self shiftLayout:aView left:n right:n
|
60
|
1551 |
]
|
|
1552 |
!
|
|
1553 |
|
113
|
1554 |
moveSelectionRight
|
|
1555 |
"move selection right
|
|
1556 |
"
|
|
1557 |
|gridX n|
|
|
1558 |
|
138
|
1559 |
gridAlign notNil ifTrue:[gridX := gridAlign x]
|
|
1560 |
ifFalse:[gridX := 1].
|
|
1561 |
|
|
1562 |
self moveDo:[:aView|
|
|
1563 |
aligning ifTrue:[
|
|
1564 |
n := ((aView computeCorner x) \\ gridX).
|
|
1565 |
|
|
1566 |
n ~~ 0 ifTrue:[n := n negated]
|
|
1567 |
ifFalse:[n := gridX]
|
|
1568 |
] ifFalse:[
|
|
1569 |
n := 1
|
113
|
1570 |
].
|
138
|
1571 |
self shiftLayout:aView left:n right:n
|
113
|
1572 |
]
|
|
1573 |
!
|
|
1574 |
|
|
1575 |
moveSelectionUp
|
60
|
1576 |
"move selection up
|
|
1577 |
"
|
113
|
1578 |
|gridY n|
|
60
|
1579 |
|
138
|
1580 |
gridAlign notNil ifTrue:[gridY := gridAlign y]
|
|
1581 |
ifFalse:[gridY := 1].
|
|
1582 |
|
|
1583 |
self moveDo:[:aView|
|
|
1584 |
aligning ifTrue:[
|
|
1585 |
n := ((aView computeOrigin x) \\ gridY).
|
|
1586 |
n == 0 ifTrue:[n := gridY].
|
|
1587 |
n := n negated.
|
|
1588 |
] ifFalse:[
|
|
1589 |
n := -1
|
60
|
1590 |
].
|
138
|
1591 |
self shiftLayout:aView top:n bottom:n
|
60
|
1592 |
]
|
|
1593 |
|
|
1594 |
! !
|
|
1595 |
|
|
1596 |
!UIObjectView methodsFor:'user actions - position'!
|
|
1597 |
|
|
1598 |
alignSelectionBottom
|
61
|
1599 |
"align selection to the bottom of the first object in the selection; in case
|
|
1600 |
of one selection the object is aligned to the bottom of its superview
|
|
1601 |
"
|
128
|
1602 |
|bmost delta sel|
|
|
1603 |
|
|
1604 |
(sel := self moveableSelection) notNil ifTrue:[
|
61
|
1605 |
self withSelectionHiddenDo:[
|
60
|
1606 |
self numberOfSelections > 1 ifTrue:[
|
128
|
1607 |
bmost := (sel first) computeCorner y.
|
60
|
1608 |
|
72
|
1609 |
self transaction:#alignBottom selectionDo:[:v|
|
60
|
1610 |
(delta := bmost - (v computeCorner y)) ~~ 0 ifTrue:[
|
|
1611 |
self shiftLayout:v top:delta bottom:delta.
|
|
1612 |
]
|
|
1613 |
]
|
|
1614 |
] ifFalse:[
|
72
|
1615 |
self extentToFrame:#Bottom do:[:aLayout|
|
63
|
1616 |
aLayout bottomOffset:0.
|
|
1617 |
aLayout bottomFraction:1.0
|
60
|
1618 |
]
|
|
1619 |
]
|
|
1620 |
].
|
225
|
1621 |
self layoutChanged
|
60
|
1622 |
]
|
|
1623 |
|
|
1624 |
|
|
1625 |
|
|
1626 |
!
|
|
1627 |
|
|
1628 |
alignSelectionCenterHor
|
61
|
1629 |
"align selection to the center/horizontal of the first object in the selection; in case
|
|
1630 |
of one selection the object is aligned to the center/horizontal of its superview
|
|
1631 |
"
|
128
|
1632 |
|view center sel|
|
|
1633 |
|
|
1634 |
(sel := self moveableSelection) notNil ifTrue:[
|
61
|
1635 |
self withSelectionHiddenDo:[
|
60
|
1636 |
view := self singleSelection.
|
|
1637 |
|
|
1638 |
view notNil ifTrue:[
|
|
1639 |
view := view superView.
|
|
1640 |
center := view computeExtent
|
|
1641 |
] ifFalse:[
|
128
|
1642 |
view := sel first.
|
60
|
1643 |
center := view computeCorner + view computeOrigin.
|
|
1644 |
].
|
|
1645 |
center := center x // 2.
|
|
1646 |
|
72
|
1647 |
self transaction:#alignCenterHorizontal selectionDo:[:v|
|
60
|
1648 |
|newX oldX delta|
|
|
1649 |
|
|
1650 |
oldX := v computeOrigin x.
|
|
1651 |
newX := center - ((v computeCorner x - oldX) // 2).
|
|
1652 |
delta := newX - oldX.
|
|
1653 |
|
|
1654 |
self shiftLayout:v left:delta right:delta
|
61
|
1655 |
]
|
|
1656 |
].
|
225
|
1657 |
self layoutChanged
|
60
|
1658 |
]
|
|
1659 |
|
|
1660 |
|
|
1661 |
|
|
1662 |
!
|
|
1663 |
|
|
1664 |
alignSelectionCenterVer
|
61
|
1665 |
"align selection to the center/vertical of the first object in the selection; in case
|
|
1666 |
of one selection the object is aligned to the center/vertical of its superview
|
|
1667 |
"
|
128
|
1668 |
|view center sel|
|
|
1669 |
|
|
1670 |
(sel := self moveableSelection) notNil ifTrue:[
|
61
|
1671 |
self withSelectionHiddenDo:[
|
60
|
1672 |
view := self singleSelection.
|
|
1673 |
|
|
1674 |
view notNil ifTrue:[
|
|
1675 |
view := view superView.
|
|
1676 |
center := view computeExtent
|
|
1677 |
] ifFalse:[
|
128
|
1678 |
view := sel first.
|
60
|
1679 |
center := view computeCorner + view computeOrigin.
|
|
1680 |
].
|
|
1681 |
center := center y // 2.
|
|
1682 |
|
72
|
1683 |
self transaction:#alignCenterVertical selectionDo:[:v|
|
60
|
1684 |
|newY oldY delta|
|
|
1685 |
|
|
1686 |
oldY := v computeOrigin y.
|
|
1687 |
newY := center - ((v computeCorner y - oldY) // 2).
|
|
1688 |
delta := newY - oldY.
|
|
1689 |
|
|
1690 |
self shiftLayout:v top:delta bottom:delta
|
61
|
1691 |
]
|
|
1692 |
].
|
225
|
1693 |
self layoutChanged
|
60
|
1694 |
]
|
|
1695 |
!
|
|
1696 |
|
|
1697 |
alignSelectionLeft
|
61
|
1698 |
"align selection to the left of the first object in the selection; in case
|
|
1699 |
of one selection the object is aligned to the left of its superview
|
|
1700 |
"
|
128
|
1701 |
|lmost delta sel|
|
|
1702 |
|
|
1703 |
(sel := self moveableSelection) notNil ifTrue:[
|
61
|
1704 |
self withSelectionHiddenDo:[
|
60
|
1705 |
self numberOfSelections > 1 ifTrue:[
|
128
|
1706 |
lmost := (sel first) computeOrigin x.
|
60
|
1707 |
|
72
|
1708 |
self transaction:#alignLeft selectionDo:[:v|
|
60
|
1709 |
(delta := lmost - (v computeOrigin x)) ~~ 0 ifTrue:[
|
|
1710 |
self shiftLayout:v left:delta right:delta
|
|
1711 |
]
|
|
1712 |
]
|
|
1713 |
] ifFalse:[
|
72
|
1714 |
self extentToFrame:#Left do:[:aLayout|
|
63
|
1715 |
aLayout leftOffset:0.
|
|
1716 |
aLayout leftFraction:0.0.
|
60
|
1717 |
]
|
|
1718 |
]
|
|
1719 |
].
|
225
|
1720 |
self layoutChanged
|
60
|
1721 |
]
|
|
1722 |
!
|
|
1723 |
|
|
1724 |
alignSelectionLeftAndRight
|
61
|
1725 |
"align selection to the left/right of the first object in the selection; in case
|
|
1726 |
of one selection the object is aligned to the left/right of its superview
|
|
1727 |
"
|
128
|
1728 |
|lmost rmost sel|
|
|
1729 |
|
|
1730 |
(sel := self moveableSelection) notNil ifTrue:[
|
61
|
1731 |
self withSelectionHiddenDo:[
|
60
|
1732 |
self numberOfSelections > 1 ifTrue:[
|
128
|
1733 |
lmost := (sel first) computeOrigin x.
|
|
1734 |
rmost := (sel first) computeCorner x.
|
60
|
1735 |
|
72
|
1736 |
self transaction:#alignLeftRight selectionDo:[:aView|
|
|
1737 |
|layout|
|
|
1738 |
layout := self class asLayoutFrameFromView:aView.
|
|
1739 |
|
|
1740 |
layout notNil ifTrue:[
|
134
|
1741 |
self createUndoLayout:aView.
|
72
|
1742 |
aView geometryLayout:layout.
|
|
1743 |
|
134
|
1744 |
undoHistory withoutTransactionDo:[
|
72
|
1745 |
self shiftLayout:aView left:(lmost - (aView computeOrigin x))
|
|
1746 |
right:(rmost - (aView computeCorner x)).
|
|
1747 |
].
|
|
1748 |
self elementChangedSize:aView
|
|
1749 |
]
|
60
|
1750 |
]
|
|
1751 |
] ifFalse:[
|
72
|
1752 |
self extentToFrame:#LeftRight do:[:aLayout|
|
63
|
1753 |
aLayout leftOffset:0.
|
|
1754 |
aLayout leftFraction:0.0.
|
|
1755 |
aLayout rightOffset:0.
|
|
1756 |
aLayout rightFraction:1.0.
|
60
|
1757 |
]
|
|
1758 |
]
|
|
1759 |
].
|
225
|
1760 |
self layoutChanged
|
61
|
1761 |
].
|
|
1762 |
|
60
|
1763 |
!
|
|
1764 |
|
|
1765 |
alignSelectionRight
|
61
|
1766 |
"align selection to the right of the first object in the selection; in case
|
|
1767 |
of one selection the object is aligned to the right of its superview
|
|
1768 |
"
|
128
|
1769 |
|rmost delta sel|
|
|
1770 |
|
|
1771 |
(sel := self moveableSelection) notNil ifTrue:[
|
61
|
1772 |
self withSelectionHiddenDo:[
|
60
|
1773 |
self numberOfSelections > 1 ifTrue:[
|
128
|
1774 |
rmost := (sel first) computeCorner x.
|
60
|
1775 |
|
72
|
1776 |
self transaction:#alignRight selectionDo:[:v|
|
60
|
1777 |
(delta := rmost - (v computeCorner x)) ~~ 0 ifTrue:[
|
|
1778 |
self shiftLayout:v left:delta right:delta
|
|
1779 |
]
|
|
1780 |
]
|
|
1781 |
] ifFalse:[
|
72
|
1782 |
self extentToFrame:#Right do:[:aLayout|
|
63
|
1783 |
aLayout rightOffset:0.
|
|
1784 |
aLayout rightFraction:1.0.
|
60
|
1785 |
]
|
|
1786 |
]
|
|
1787 |
].
|
225
|
1788 |
self layoutChanged
|
60
|
1789 |
]
|
|
1790 |
!
|
|
1791 |
|
|
1792 |
alignSelectionTop
|
61
|
1793 |
"align selection to the top of the first object in the selection; in case
|
|
1794 |
of one selection the object is aligned to the top of its superview
|
|
1795 |
"
|
128
|
1796 |
|tmost delta sel|
|
|
1797 |
|
|
1798 |
(sel := self moveableSelection) notNil ifTrue:[
|
61
|
1799 |
self withSelectionHiddenDo:[
|
60
|
1800 |
self numberOfSelections > 1 ifTrue:[
|
128
|
1801 |
tmost := (sel first) computeOrigin y.
|
60
|
1802 |
|
72
|
1803 |
self transaction:#alignTop selectionDo:[:v|
|
60
|
1804 |
(delta := tmost - (v computeOrigin y)) ~~ 0 ifTrue:[
|
|
1805 |
self shiftLayout:v top:delta bottom:delta
|
|
1806 |
]
|
|
1807 |
]
|
|
1808 |
] ifFalse:[
|
72
|
1809 |
self extentToFrame:#Top do:[:aLayout|
|
63
|
1810 |
aLayout topOffset:0.
|
|
1811 |
aLayout topFraction:0.0.
|
60
|
1812 |
]
|
|
1813 |
]
|
|
1814 |
].
|
225
|
1815 |
self layoutChanged
|
60
|
1816 |
]
|
|
1817 |
|
|
1818 |
!
|
|
1819 |
|
|
1820 |
alignSelectionTopAndBottom
|
61
|
1821 |
"align selection to the top/bottom of the first object in the selection; in case
|
|
1822 |
of one selection the object is aligned to the top/bottom of its superview
|
|
1823 |
"
|
128
|
1824 |
|tmost bmost sel|
|
|
1825 |
|
|
1826 |
(sel := self moveableSelection) notNil ifTrue:[
|
61
|
1827 |
self withSelectionHiddenDo:[
|
60
|
1828 |
self numberOfSelections > 1 ifTrue:[
|
128
|
1829 |
tmost := (sel first) computeOrigin y.
|
|
1830 |
bmost := (sel first) computeCorner y.
|
60
|
1831 |
|
72
|
1832 |
self transaction:#alignTopBottom selectionDo:[:aView|
|
|
1833 |
|layout|
|
|
1834 |
layout := self class asLayoutFrameFromView:aView.
|
|
1835 |
|
|
1836 |
layout notNil ifTrue:[
|
134
|
1837 |
self createUndoLayout:aView.
|
72
|
1838 |
aView geometryLayout:layout.
|
|
1839 |
|
134
|
1840 |
undoHistory withoutTransactionDo:[
|
72
|
1841 |
self shiftLayout:aView top:(tmost - (aView computeOrigin y))
|
|
1842 |
bottom:(bmost - (aView computeCorner y)).
|
|
1843 |
].
|
|
1844 |
self elementChangedSize:aView
|
|
1845 |
]
|
60
|
1846 |
]
|
|
1847 |
] ifFalse:[
|
72
|
1848 |
self extentToFrame:#TopBottom do:[:aLayout|
|
63
|
1849 |
aLayout topOffset:0.
|
|
1850 |
aLayout topFraction:0.0.
|
|
1851 |
aLayout bottomOffset:0.
|
|
1852 |
aLayout bottomFraction:1.0.
|
60
|
1853 |
]
|
|
1854 |
]
|
|
1855 |
].
|
225
|
1856 |
self layoutChanged
|
60
|
1857 |
]
|
|
1858 |
!
|
|
1859 |
|
|
1860 |
centerSelection:aOneArgBlockXorY orientation:orientation
|
|
1861 |
"center selection horizontal or vertical dependant on the block result( x or y).
|
|
1862 |
The argument to the block is the point.
|
|
1863 |
"
|
|
1864 |
|superview min max delta val|
|
|
1865 |
|
128
|
1866 |
(self moveableSelection) isNil ifTrue:[
|
61
|
1867 |
^ self
|
|
1868 |
].
|
|
1869 |
|
|
1870 |
self withSelectionHiddenDo:[
|
60
|
1871 |
max := 0.
|
|
1872 |
|
|
1873 |
self selectionDo:[:aView |
|
|
1874 |
superview isNil ifTrue:[
|
|
1875 |
superview := aView superView
|
|
1876 |
] ifFalse:[
|
|
1877 |
(aView superView == superview) ifFalse:[
|
|
1878 |
^ self notify:'views must have same superview'.
|
|
1879 |
]
|
|
1880 |
].
|
|
1881 |
val := aOneArgBlockXorY value:(aView computeOrigin).
|
|
1882 |
|
|
1883 |
min isNil ifTrue:[min := val]
|
|
1884 |
ifFalse:[min := min min:val].
|
|
1885 |
|
|
1886 |
val := aOneArgBlockXorY value:(aView computeCorner).
|
|
1887 |
max := max max:val.
|
|
1888 |
].
|
|
1889 |
|
|
1890 |
val := aOneArgBlockXorY value:(superview computeExtent).
|
|
1891 |
max := (min + val - max) // 2.
|
|
1892 |
|
|
1893 |
max == min ifFalse:[
|
72
|
1894 |
|type|
|
|
1895 |
(orientation == #y) ifTrue:[type := #centerVertical]
|
|
1896 |
ifFalse:[type := #centerHorizontal].
|
60
|
1897 |
delta := max - min.
|
|
1898 |
|
72
|
1899 |
self transaction:type selectionDo:[:v|
|
60
|
1900 |
orientation == #y ifTrue:[
|
|
1901 |
self shiftLayout:v top:delta bottom:delta
|
|
1902 |
] ifFalse:[
|
|
1903 |
self shiftLayout:v left:delta right:delta
|
|
1904 |
]
|
61
|
1905 |
]
|
|
1906 |
].
|
225
|
1907 |
self layoutChanged
|
60
|
1908 |
]
|
|
1909 |
|
|
1910 |
|
|
1911 |
!
|
|
1912 |
|
|
1913 |
centerSelectionHor
|
|
1914 |
"center selection horizontal
|
|
1915 |
"
|
|
1916 |
self centerSelection:[:aPoint| aPoint x] orientation:#x
|
|
1917 |
|
|
1918 |
|
|
1919 |
!
|
|
1920 |
|
|
1921 |
centerSelectionVer
|
|
1922 |
"center selection vertical
|
|
1923 |
"
|
|
1924 |
self centerSelection:[:aPoint| aPoint y] orientation:#y
|
|
1925 |
!
|
|
1926 |
|
72
|
1927 |
extentToFrame:toWhat do:aBlock
|
|
1928 |
"align to frame (Left Right ...) and perform the block on a frameLayout
|
|
1929 |
"
|
|
1930 |
|layout type|
|
|
1931 |
|
|
1932 |
type := ('extent', toWhat asString) asSymbol.
|
|
1933 |
|
|
1934 |
self transaction:type selectionDo:[:aView|
|
|
1935 |
layout := self class asLayoutFrameFromView:aView.
|
|
1936 |
|
|
1937 |
layout notNil ifTrue:[
|
134
|
1938 |
self createUndoLayout:aView.
|
72
|
1939 |
aBlock value:layout.
|
|
1940 |
aView geometryLayout:layout.
|
|
1941 |
self elementChangedSize:aView.
|
|
1942 |
]
|
|
1943 |
]
|
|
1944 |
!
|
|
1945 |
|
60
|
1946 |
spreadSelectionHor
|
61
|
1947 |
"spread multiple selection horizontal
|
|
1948 |
"
|
128
|
1949 |
|sumWidths min max viewsInOrder topsInOrder count space sel|
|
|
1950 |
|
|
1951 |
sel := self moveableSelection.
|
|
1952 |
|
|
1953 |
(sel notNil and:[self numberOfSelections > 1]) ifFalse:[
|
60
|
1954 |
^ self
|
|
1955 |
].
|
|
1956 |
|
61
|
1957 |
self withSelectionHiddenDo:[
|
60
|
1958 |
count := 0.
|
|
1959 |
sumWidths := 0.
|
|
1960 |
max := 0.
|
|
1961 |
|
|
1962 |
self selectionDo:[:aView |
|
|
1963 |
sumWidths := sumWidths + aView width.
|
|
1964 |
|
|
1965 |
min isNil ifTrue:[min := aView left]
|
|
1966 |
ifFalse:[min := min min:(aView left)].
|
|
1967 |
|
|
1968 |
max := max max:(aView right).
|
|
1969 |
count := count + 1
|
|
1970 |
].
|
128
|
1971 |
viewsInOrder := Array withAll:sel.
|
60
|
1972 |
topsInOrder := viewsInOrder collect:[:aView | aView left].
|
|
1973 |
topsInOrder sortWith:viewsInOrder.
|
|
1974 |
|
|
1975 |
space := (((max - min) - sumWidths) / (count - 1)) rounded asInteger.
|
|
1976 |
|
72
|
1977 |
self transaction:#spreadHorizontal objects:viewsInOrder do:[:aView|
|
60
|
1978 |
|delta|
|
|
1979 |
|
|
1980 |
delta := min - aView computeOrigin x.
|
|
1981 |
self shiftLayout:aView left:delta right:delta.
|
|
1982 |
min := min + aView computeExtent x + space
|
61
|
1983 |
]
|
|
1984 |
].
|
225
|
1985 |
self layoutChanged
|
60
|
1986 |
|
|
1987 |
!
|
|
1988 |
|
|
1989 |
spreadSelectionVer
|
61
|
1990 |
"spread multiple selection vertical
|
|
1991 |
"
|
128
|
1992 |
|sumHeights min max viewsInOrder topsInOrder count space sel|
|
|
1993 |
|
|
1994 |
sel := self moveableSelection.
|
|
1995 |
|
|
1996 |
(sel notNil and:[self numberOfSelections > 1]) ifFalse:[
|
60
|
1997 |
^ self
|
|
1998 |
].
|
|
1999 |
|
61
|
2000 |
self withSelectionHiddenDo:[
|
60
|
2001 |
count := 0.
|
|
2002 |
sumHeights := 0.
|
|
2003 |
max := 0.
|
|
2004 |
|
|
2005 |
self selectionDo:[:aView |
|
|
2006 |
sumHeights := sumHeights + aView height.
|
|
2007 |
|
|
2008 |
min isNil ifTrue:[min := aView top]
|
|
2009 |
ifFalse:[min := min min:(aView top)].
|
|
2010 |
|
|
2011 |
max := max max:(aView bottom).
|
|
2012 |
count := count + 1
|
|
2013 |
].
|
128
|
2014 |
viewsInOrder := Array withAll:sel.
|
60
|
2015 |
topsInOrder := viewsInOrder collect:[:aView|aView top].
|
|
2016 |
topsInOrder sortWith:viewsInOrder.
|
|
2017 |
|
|
2018 |
space := (((max - min) - sumHeights) / (count - 1)) rounded asInteger.
|
|
2019 |
|
72
|
2020 |
self transaction:#spreadVertical objects:viewsInOrder do:[:aView|
|
60
|
2021 |
|delta|
|
|
2022 |
|
|
2023 |
delta := min - aView computeOrigin y.
|
|
2024 |
self shiftLayout:aView top:delta bottom:delta.
|
|
2025 |
min := min + aView height + space
|
61
|
2026 |
]
|
|
2027 |
].
|
225
|
2028 |
self layoutChanged
|
60
|
2029 |
! !
|
|
2030 |
|
|
2031 |
!UIObjectView methodsFor:'user actions - undo history'!
|
|
2032 |
|
72
|
2033 |
enableUndoHistory:aState
|
|
2034 |
"enable or disable undo history
|
|
2035 |
"
|
|
2036 |
undoHistory enabled:aState
|
|
2037 |
!
|
|
2038 |
|
60
|
2039 |
openUndoMenu
|
61
|
2040 |
"open undo menu
|
|
2041 |
"
|
149
|
2042 |
self select:nil.
|
138
|
2043 |
undoHistory openUndoMenu
|
60
|
2044 |
!
|
|
2045 |
|
|
2046 |
removeUndoHistory
|
|
2047 |
"delete total undo history
|
|
2048 |
"
|
134
|
2049 |
undoHistory on:self
|
60
|
2050 |
!
|
|
2051 |
|
|
2052 |
undoLast
|
61
|
2053 |
"undo last action
|
|
2054 |
"
|
138
|
2055 |
|newSel oldSel|
|
|
2056 |
|
134
|
2057 |
undoHistory isEmpty ifFalse:[
|
138
|
2058 |
self hasSelection ifTrue:[
|
|
2059 |
oldSel := OrderedCollection new.
|
|
2060 |
newSel := OrderedCollection new.
|
|
2061 |
|
|
2062 |
self selectionDo:[:aView||p|
|
|
2063 |
(p := self propertyOfView:aView) notNil ifTrue:[
|
|
2064 |
oldSel add:(p identifier)
|
|
2065 |
]
|
|
2066 |
].
|
|
2067 |
self setSelection:nil withRedraw:true.
|
|
2068 |
].
|
|
2069 |
|
|
2070 |
self withSelectionHiddenDo:[undoHistory undoLast:1].
|
|
2071 |
|
|
2072 |
oldSel notNil ifTrue:[
|
|
2073 |
oldSel do:[:id||v|
|
145
|
2074 |
(v := self findViewWithId:id) notNil ifTrue:[newSel add:v]
|
138
|
2075 |
].
|
|
2076 |
self select:newSel.
|
134
|
2077 |
]
|
61
|
2078 |
].
|
60
|
2079 |
! !
|
|
2080 |
|
|
2081 |
!UIObjectView::UndoHistory class methodsFor:'constants'!
|
|
2082 |
|
|
2083 |
maxHistorySize
|
|
2084 |
"returns maximum size of history before removing oldest
|
|
2085 |
record
|
|
2086 |
"
|
134
|
2087 |
^ 100
|
60
|
2088 |
|
|
2089 |
|
|
2090 |
! !
|
|
2091 |
|
131
|
2092 |
!UIObjectView::UndoHistory class methodsFor:'documentation'!
|
|
2093 |
|
|
2094 |
documentation
|
|
2095 |
"
|
|
2096 |
undo history used by the UIPainter-Tool; to each operation, an undo block
|
|
2097 |
and some text is stored. In case of a required undo, the corresponding
|
|
2098 |
undo block will be performed.
|
|
2099 |
|
|
2100 |
[see also:]
|
|
2101 |
UIObjectView
|
|
2102 |
UIPainterView
|
156
|
2103 |
|
|
2104 |
[author:]
|
|
2105 |
Claus Atzkern
|
131
|
2106 |
"
|
|
2107 |
|
|
2108 |
|
|
2109 |
! !
|
|
2110 |
|
60
|
2111 |
!UIObjectView::UndoHistory class methodsFor:'instance creation'!
|
|
2112 |
|
134
|
2113 |
on:aPainter
|
|
2114 |
|history|
|
|
2115 |
|
|
2116 |
history := self new.
|
|
2117 |
history on:aPainter.
|
|
2118 |
^ history
|
60
|
2119 |
|
|
2120 |
|
|
2121 |
! !
|
|
2122 |
|
|
2123 |
!UIObjectView::UndoHistory methodsFor:'accessing'!
|
|
2124 |
|
134
|
2125 |
addUndoSelector:aSelector withArgs:anArray
|
|
2126 |
"add a selector with arguments to the current opened transaction; in case that no
|
|
2127 |
transaction is opened or disabled the block will not be kept in the history.
|
|
2128 |
"
|
|
2129 |
self isTransactionOpen ifTrue:[
|
|
2130 |
transaction add:(Association key:aSelector value:anArray)
|
|
2131 |
]
|
|
2132 |
|
|
2133 |
|
|
2134 |
! !
|
|
2135 |
|
|
2136 |
!UIObjectView::UndoHistory methodsFor:'accessing behavior'!
|
|
2137 |
|
72
|
2138 |
enabled
|
|
2139 |
^ enabled
|
|
2140 |
!
|
|
2141 |
|
|
2142 |
enabled:aState
|
|
2143 |
enabled := aState
|
|
2144 |
!
|
|
2145 |
|
134
|
2146 |
resetModification
|
|
2147 |
"set modification state to false
|
|
2148 |
"
|
|
2149 |
startIdentifier := identifier
|
|
2150 |
! !
|
|
2151 |
|
|
2152 |
!UIObjectView::UndoHistory methodsFor:'activation'!
|
|
2153 |
|
|
2154 |
withinTransaction:aType text:aTextOrNil do:aBlock
|
|
2155 |
"open a transaction; perform the block; at least close the transaction
|
72
|
2156 |
"
|
134
|
2157 |
(enabled and:[transaction isNil]) ifTrue:[
|
|
2158 |
transaction := Transaction type:aType text:aTextOrNil.
|
|
2159 |
|
|
2160 |
aBlock value.
|
|
2161 |
|
|
2162 |
transaction isEmpty ifFalse:[
|
|
2163 |
identifier := identifier + 1.
|
|
2164 |
transaction identifier:identifier.
|
|
2165 |
history addLast:transaction.
|
|
2166 |
history size > (self class maxHistorySize) ifTrue:[history removeFirst]
|
|
2167 |
].
|
|
2168 |
transaction := nil
|
|
2169 |
|
|
2170 |
] ifFalse:[
|
|
2171 |
aBlock value
|
|
2172 |
]
|
|
2173 |
!
|
|
2174 |
|
|
2175 |
withoutTransactionDo:aNoneArgBlock
|
|
2176 |
"evaluate the block without opening a transaction or keeping changes
|
|
2177 |
within a still opened transaction
|
|
2178 |
"
|
|
2179 |
|oldState|
|
|
2180 |
|
|
2181 |
oldState := enabled.
|
|
2182 |
enabled := false.
|
|
2183 |
aNoneArgBlock value.
|
|
2184 |
enabled := oldState.
|
60
|
2185 |
! !
|
|
2186 |
|
|
2187 |
!UIObjectView::UndoHistory methodsFor:'initialization'!
|
|
2188 |
|
134
|
2189 |
on:aPainter
|
|
2190 |
"setup for a painter and delete all existing history records
|
60
|
2191 |
"
|
134
|
2192 |
identifier := 0.
|
|
2193 |
startIdentifier := 0.
|
|
2194 |
|
|
2195 |
painter := aPainter.
|
60
|
2196 |
history := OrderedCollection new.
|
|
2197 |
transaction := nil.
|
|
2198 |
enabled := true.
|
|
2199 |
|
|
2200 |
|
|
2201 |
! !
|
|
2202 |
|
|
2203 |
!UIObjectView::UndoHistory methodsFor:'menu'!
|
|
2204 |
|
|
2205 |
openUndoMenu
|
72
|
2206 |
|list tabs top slv hzp inset selection okButton|
|
60
|
2207 |
|
|
2208 |
history isEmpty ifTrue:[
|
|
2209 |
^ self
|
|
2210 |
].
|
|
2211 |
|
|
2212 |
top := StandardSystemView new label:'undo history'; extent:250@350.
|
|
2213 |
slv := ScrollableView for:SelectionInListView origin:0.0@0.0 corner:1.0@1.0 in:top.
|
|
2214 |
hzp := HorizontalPanelView origin:0.0@1.0 corner:1.0@1.0 in:top.
|
|
2215 |
hzp horizontalLayout:#fitSpace.
|
|
2216 |
|
|
2217 |
(Button abortButtonIn:hzp) action:[ selection := nil. top destroy ].
|
|
2218 |
okButton := Button okButtonIn:hzp.
|
|
2219 |
okButton label:'undo to end'.
|
|
2220 |
okButton action:[ top destroy ].
|
|
2221 |
|
|
2222 |
inset := hzp preferredExtent y.
|
|
2223 |
hzp topInset:(inset negated).
|
|
2224 |
slv bottomInset:inset.
|
|
2225 |
slv := slv scrolledView.
|
|
2226 |
|
72
|
2227 |
tabs := TabulatorSpecification new.
|
|
2228 |
tabs unit:#cm.
|
|
2229 |
tabs positions:#(0 5).
|
208
|
2230 |
tabs align:#(#left #left).
|
72
|
2231 |
|
60
|
2232 |
list := history collect:[:aTrans||e|
|
|
2233 |
e := MultiColListEntry new.
|
72
|
2234 |
e colAt:1 put:(aTrans typeAsString).
|
60
|
2235 |
e colAt:2 put:(aTrans text ? '').
|
72
|
2236 |
e tabulatorSpecification:tabs.
|
60
|
2237 |
e
|
|
2238 |
].
|
|
2239 |
|
|
2240 |
slv list:list.
|
|
2241 |
slv action:[:index | selection := index ].
|
|
2242 |
top openModal.
|
|
2243 |
|
|
2244 |
selection notNil ifTrue:[
|
|
2245 |
self undoLast:(history size - selection + 1).
|
|
2246 |
]
|
|
2247 |
! !
|
|
2248 |
|
|
2249 |
!UIObjectView::UndoHistory methodsFor:'testing'!
|
|
2250 |
|
|
2251 |
isEmpty
|
|
2252 |
"returns true if undo history is empty
|
|
2253 |
"
|
|
2254 |
^ history isEmpty
|
|
2255 |
|
|
2256 |
|
|
2257 |
!
|
|
2258 |
|
134
|
2259 |
isModified
|
|
2260 |
"returns true if history is modified
|
|
2261 |
"
|
|
2262 |
self isEmpty ifTrue:[
|
|
2263 |
^ false
|
|
2264 |
].
|
|
2265 |
^ history last identifier ~~ startIdentifier
|
|
2266 |
!
|
|
2267 |
|
60
|
2268 |
isTransactionOpen
|
|
2269 |
^ (enabled and:[transaction notNil])
|
|
2270 |
! !
|
|
2271 |
|
|
2272 |
!UIObjectView::UndoHistory methodsFor:'undo'!
|
|
2273 |
|
|
2274 |
undoLast:nTransactions
|
|
2275 |
"undo last n transactions; an open transaction will be closed;
|
|
2276 |
transactions during undo are disabled
|
|
2277 |
"
|
134
|
2278 |
|repeatTimes transaction actions|
|
60
|
2279 |
|
|
2280 |
transaction := nil.
|
134
|
2281 |
enabled := false.
|
|
2282 |
repeatTimes := nTransactions min:(history size).
|
|
2283 |
|
|
2284 |
repeatTimes timesRepeat:[
|
|
2285 |
transaction := history removeLast.
|
|
2286 |
actions := transaction actions.
|
|
2287 |
|
|
2288 |
actions isCollection ifTrue:[
|
|
2289 |
actions reverseDo:[:aBlock|
|
|
2290 |
painter perform:(aBlock key) with:(aBlock value)
|
|
2291 |
]
|
|
2292 |
] ifFalse:[
|
|
2293 |
painter perform:(actions key) with:(actions value)
|
|
2294 |
]
|
|
2295 |
].
|
|
2296 |
enabled := true.
|
60
|
2297 |
! !
|
|
2298 |
|
|
2299 |
!UIObjectView::UndoHistory::Transaction class methodsFor:'documentation'!
|
|
2300 |
|
131
|
2301 |
documentation
|
|
2302 |
"
|
|
2303 |
represents one undo record, keeping the associated type and printable text
|
|
2304 |
and the undo action performed on an undo request
|
|
2305 |
|
|
2306 |
[see also:]
|
|
2307 |
UndoHistory
|
156
|
2308 |
|
|
2309 |
[author:]
|
|
2310 |
Claus Atzkern
|
131
|
2311 |
"
|
|
2312 |
|
60
|
2313 |
! !
|
|
2314 |
|
54
|
2315 |
!UIObjectView::UndoHistory::Transaction class methodsFor:'instance creation'!
|
|
2316 |
|
|
2317 |
type:aType text:aTextOrNil
|
|
2318 |
^ self new type:aType text:aTextOrNil
|
|
2319 |
|
|
2320 |
|
|
2321 |
! !
|
|
2322 |
|
|
2323 |
!UIObjectView::UndoHistory::Transaction methodsFor:'accessing'!
|
|
2324 |
|
134
|
2325 |
actions
|
|
2326 |
"returns actions associated with transaction
|
|
2327 |
"
|
|
2328 |
^ actions
|
|
2329 |
!
|
|
2330 |
|
|
2331 |
identifier
|
|
2332 |
"gets my identifier
|
|
2333 |
"
|
|
2334 |
^ identifier
|
|
2335 |
!
|
|
2336 |
|
|
2337 |
identifier:anIdentifier
|
|
2338 |
"sets my identifier
|
|
2339 |
"
|
|
2340 |
identifier := anIdentifier
|
|
2341 |
!
|
|
2342 |
|
54
|
2343 |
text
|
134
|
2344 |
"returns text or nil assigned to transaction
|
54
|
2345 |
"
|
|
2346 |
^ text
|
|
2347 |
!
|
|
2348 |
|
|
2349 |
type
|
134
|
2350 |
"returns type assigned to transaction
|
54
|
2351 |
"
|
|
2352 |
^ type
|
|
2353 |
!
|
|
2354 |
|
|
2355 |
type:aType
|
134
|
2356 |
"change type assigned to transaction
|
54
|
2357 |
"
|
|
2358 |
type := aType
|
72
|
2359 |
!
|
|
2360 |
|
|
2361 |
typeAsString
|
|
2362 |
"returns type as printable string
|
|
2363 |
"
|
|
2364 |
|line name size sep|
|
|
2365 |
|
|
2366 |
line := type asString.
|
|
2367 |
size := 0.
|
|
2368 |
line do:[:c| (c isUppercase) ifTrue:[size := size+1] ].
|
|
2369 |
name := String new:(line size + size).
|
|
2370 |
size := 1.
|
|
2371 |
sep := Character space.
|
|
2372 |
|
|
2373 |
line do:[:c|
|
|
2374 |
(c isUppercase) ifFalse:[
|
|
2375 |
name at:size put:c
|
|
2376 |
] ifTrue:[
|
|
2377 |
name at:size put:sep.
|
|
2378 |
sep := $&.
|
|
2379 |
size := size + 1.
|
|
2380 |
name at:size put:(c asLowercase)
|
|
2381 |
].
|
|
2382 |
size := size + 1
|
|
2383 |
].
|
|
2384 |
^ name
|
54
|
2385 |
! !
|
|
2386 |
|
134
|
2387 |
!UIObjectView::UndoHistory::Transaction methodsFor:'adding'!
|
54
|
2388 |
|
|
2389 |
add:anUndoBlock
|
134
|
2390 |
"add an undo action to the current transaction
|
54
|
2391 |
"
|
|
2392 |
actions isNil ifTrue:[
|
|
2393 |
actions := anUndoBlock
|
|
2394 |
] ifFalse:[
|
|
2395 |
actions isCollection ifFalse:[
|
134
|
2396 |
actions := OrderedCollection with:actions
|
47
|
2397 |
].
|
54
|
2398 |
actions add:anUndoBlock.
|
|
2399 |
]
|
|
2400 |
! !
|
|
2401 |
|
|
2402 |
!UIObjectView::UndoHistory::Transaction methodsFor:'initialization'!
|
|
2403 |
|
|
2404 |
type:aType text:aTextOrNil
|
134
|
2405 |
"initialize transaction
|
54
|
2406 |
"
|
|
2407 |
type := aType.
|
|
2408 |
text := aTextOrNil.
|
|
2409 |
! !
|
|
2410 |
|
|
2411 |
!UIObjectView::UndoHistory::Transaction methodsFor:'testing'!
|
|
2412 |
|
|
2413 |
isEmpty
|
|
2414 |
"returns true if no undo action is registered
|
|
2415 |
"
|
|
2416 |
^ actions isNil
|
47
|
2417 |
! !
|
|
2418 |
|
60
|
2419 |
!UIObjectView class methodsFor:'documentation'!
|
|
2420 |
|
|
2421 |
version
|
|
2422 |
^ '$Header$'
|
|
2423 |
! !
|