51
|
1 |
ObjectView subclass:#UIObjectView
|
54
|
2 |
instanceVariableNames:'inputView testMode undoHistory copiedExtent actionData
|
52
|
3 |
createClass clipChildren'
|
|
4 |
classVariableNames:''
|
|
5 |
poolDictionaries:''
|
|
6 |
category:'Interface-UIPainter'
|
51
|
7 |
!
|
|
8 |
|
47
|
9 |
Object subclass:#UndoHistory
|
54
|
10 |
instanceVariableNames:'history transaction enabled'
|
52
|
11 |
classVariableNames:''
|
|
12 |
poolDictionaries:''
|
|
13 |
privateIn:UIObjectView
|
51
|
14 |
!
|
|
15 |
|
54
|
16 |
Object subclass:#Transaction
|
|
17 |
instanceVariableNames:'type text actions'
|
|
18 |
classVariableNames:''
|
|
19 |
poolDictionaries:''
|
|
20 |
privateIn:UIObjectView::UndoHistory
|
|
21 |
!
|
|
22 |
|
51
|
23 |
|
|
24 |
!UIObjectView class methodsFor:'defaults'!
|
|
25 |
|
|
26 |
defaultGrid
|
|
27 |
^ 4 @ 4
|
|
28 |
|
|
29 |
!
|
|
30 |
|
|
31 |
gridShown
|
|
32 |
^ false
|
|
33 |
|
|
34 |
!
|
|
35 |
|
|
36 |
handleSize
|
|
37 |
"size of blob drawn for handles"
|
|
38 |
^ 4
|
|
39 |
|
|
40 |
!
|
|
41 |
|
|
42 |
hitDelta
|
|
43 |
^ 4
|
|
44 |
|
|
45 |
! !
|
|
46 |
|
|
47 |
!UIObjectView methodsFor:'accessing'!
|
|
48 |
|
|
49 |
gridParameters
|
|
50 |
"used by defineGrid, and in a separate method for
|
|
51 |
easier redefinition in subclasses.
|
|
52 |
Returns the grid parameters in an array of 7 elements,
|
|
53 |
which control the appearance of the grid-pattern.
|
|
54 |
the elements are:
|
|
55 |
|
|
56 |
bigStepH number of pixels horizontally between 2 major steps
|
|
57 |
bigStepV number of pixels vertically between 2 major steps
|
|
58 |
littleStepH number of pixels horizontally between 2 minor steps
|
|
59 |
littleStepV number of pixels vertically between 2 minor steps
|
|
60 |
gridAlignH number of pixels for horizontal grid align (pointer snap)
|
|
61 |
gridAlignV number of pixels for vertical grid align (pointer snap)
|
|
62 |
docBounds true, if document boundary should be shown
|
|
63 |
|
|
64 |
if littleStepH/V are nil, only bigSteps are drawn.
|
|
65 |
"
|
|
66 |
|
|
67 |
^ #(10 10 nil nil 10 10 false)
|
|
68 |
|
|
69 |
|
|
70 |
!
|
|
71 |
|
|
72 |
hideGrid
|
|
73 |
gridShown ifTrue:[
|
|
74 |
self withSelectionHiddenDo:[
|
|
75 |
super hideGrid
|
|
76 |
]
|
|
77 |
]
|
|
78 |
|
|
79 |
|
|
80 |
!
|
|
81 |
|
|
82 |
showGrid
|
|
83 |
self withSelectionHiddenDo:[
|
|
84 |
super showGrid
|
|
85 |
]
|
|
86 |
|
|
87 |
"Modified: 5.9.1995 / 12:47:46 / claus"
|
|
88 |
|
|
89 |
|
|
90 |
!
|
|
91 |
|
|
92 |
testMode
|
|
93 |
"returns testMode
|
|
94 |
"
|
|
95 |
^ testMode
|
|
96 |
|
|
97 |
|
|
98 |
!
|
|
99 |
|
|
100 |
testMode:aBoolean
|
|
101 |
"change testMode
|
|
102 |
"
|
|
103 |
(aBoolean == testMode) ifFalse:[
|
|
104 |
testMode := aBoolean.
|
|
105 |
|
|
106 |
testMode ifTrue:[
|
|
107 |
self unselect.
|
|
108 |
inputView unrealize
|
|
109 |
] ifFalse:[
|
|
110 |
inputView raise.
|
|
111 |
inputView realize
|
|
112 |
]
|
|
113 |
]
|
|
114 |
|
|
115 |
|
|
116 |
! !
|
|
117 |
|
54
|
118 |
!UIObjectView methodsFor:'blocked'!
|
|
119 |
|
|
120 |
addObject:anObject
|
|
121 |
"add the argument, anObject to the contents - with redraw"
|
|
122 |
|
|
123 |
self halt
|
|
124 |
|
|
125 |
!
|
|
126 |
|
|
127 |
addObjectWithoutRedraw:anObject
|
|
128 |
"add the argument, anObject to the contents - with redraw"
|
|
129 |
|
|
130 |
self halt
|
|
131 |
|
|
132 |
! !
|
|
133 |
|
51
|
134 |
!UIObjectView methodsFor:'event handling'!
|
|
135 |
|
|
136 |
doKeyInput:key
|
|
137 |
^ self
|
|
138 |
|
|
139 |
|
|
140 |
!
|
|
141 |
|
|
142 |
elementChanged:aView
|
|
143 |
"some element has been changed - kludge to force a resizing
|
|
144 |
operation (for child layout recomputation) in its superView"
|
|
145 |
|
|
146 |
aView superView sizeChanged:nil.
|
|
147 |
self changed:#any.
|
|
148 |
|
|
149 |
|
|
150 |
!
|
|
151 |
|
|
152 |
elementChangedLayout:aView
|
|
153 |
"some element has been changed - kludge to force a resizing
|
|
154 |
operation (for child layout recomputation) in its superView"
|
|
155 |
|
|
156 |
aView superView sizeChanged:nil.
|
|
157 |
self changed:#layout.
|
|
158 |
|
|
159 |
|
|
160 |
!
|
|
161 |
|
|
162 |
exposeX:x y:y width:w height:h
|
|
163 |
"handle an expose event from device; redraw selection
|
|
164 |
"
|
|
165 |
super exposeX:x y:y width:w height:h.
|
|
166 |
|
|
167 |
selection notNil ifTrue:[
|
|
168 |
self selectionDo:[:v | self showSelected:v]
|
|
169 |
]
|
|
170 |
|
|
171 |
|
|
172 |
!
|
|
173 |
|
|
174 |
keyPress:key x:x y:y
|
|
175 |
|
|
176 |
key == #InspectIt ifTrue:[
|
|
177 |
^ self inspectSelection
|
|
178 |
].
|
|
179 |
|
|
180 |
(key == #Delete or:[key == #BackSpace]) ifTrue: [
|
|
181 |
selection notNil ifTrue:[
|
|
182 |
self deleteSelection
|
|
183 |
]
|
|
184 |
] ifFalse:[
|
|
185 |
keyPressAction notNil ifTrue:[
|
|
186 |
keyPressAction value:key
|
|
187 |
]
|
|
188 |
]
|
|
189 |
|
|
190 |
|
|
191 |
!
|
|
192 |
|
|
193 |
processEvent:anEvent
|
|
194 |
"catch expose events for components, and redraw its handles after
|
|
195 |
the redraw when this happens
|
|
196 |
"
|
|
197 |
|view|
|
|
198 |
|
|
199 |
selection notNil ifTrue:[
|
|
200 |
anEvent type == #damage ifTrue:[
|
|
201 |
view := anEvent view.
|
|
202 |
(selection == view
|
|
203 |
or:[selection isCollection
|
|
204 |
and:[selection includes:view]]) ifTrue:[
|
|
205 |
self showSelected:view
|
|
206 |
]
|
|
207 |
]
|
|
208 |
].
|
|
209 |
^ false.
|
|
210 |
|
|
211 |
|
|
212 |
!
|
|
213 |
|
|
214 |
sizeChanged:how
|
|
215 |
self withSelectionHiddenDo:[
|
|
216 |
super sizeChanged:how
|
|
217 |
]
|
|
218 |
|
|
219 |
|
|
220 |
! !
|
|
221 |
|
|
222 |
!UIObjectView methodsFor:'initialization'!
|
|
223 |
|
|
224 |
initialize
|
|
225 |
super initialize.
|
|
226 |
|
|
227 |
"funny: since I do not want the created widgets to get pointer
|
|
228 |
events, I put an InputView on top of them, which catches those events
|
|
229 |
and passes them back to me - have to take care, that this inputView
|
|
230 |
is always on top
|
|
231 |
"
|
|
232 |
inputView := InputView origin:0.0@0.0 extent:1.0@1.0 in:self.
|
|
233 |
|
|
234 |
inputView eventReceiver:self.
|
|
235 |
inputView enableButtonEvents.
|
|
236 |
inputView enableButtonMotionEvents.
|
|
237 |
|
|
238 |
self setDefaultActions.
|
|
239 |
|
54
|
240 |
undoHistory := UndoHistory new.
|
|
241 |
testMode := false.
|
51
|
242 |
clipChildren := true.
|
|
243 |
|
|
244 |
(self class gridShown) ifTrue:[
|
|
245 |
super showGrid
|
|
246 |
].
|
|
247 |
|
|
248 |
!
|
|
249 |
|
|
250 |
realize
|
|
251 |
super realize.
|
|
252 |
self windowGroup postEventHook:self
|
|
253 |
|
|
254 |
! !
|
|
255 |
|
|
256 |
!UIObjectView methodsFor:'misc'!
|
|
257 |
|
|
258 |
cursor:aCursor
|
|
259 |
inputView realized ifTrue:[
|
|
260 |
inputView cursor:aCursor
|
|
261 |
].
|
|
262 |
super cursor:aCursor
|
|
263 |
|
|
264 |
|
|
265 |
!
|
|
266 |
|
|
267 |
invertOutlineOf:anObject
|
|
268 |
|wasClipped delta|
|
|
269 |
|
|
270 |
(wasClipped := clipChildren) ifTrue:[
|
|
271 |
self clippedByChildren:(clipChildren := false).
|
|
272 |
].
|
|
273 |
delta := (anObject originRelativeTo:self) - anObject origin.
|
|
274 |
|
|
275 |
self xoring:[
|
|
276 |
self displayRectangle:((anObject origin + delta) extent:anObject extent).
|
|
277 |
].
|
|
278 |
|
|
279 |
wasClipped ifTrue:[
|
|
280 |
self clippedByChildren:(clipChildren := true).
|
|
281 |
].
|
|
282 |
|
|
283 |
"Modified: 5.9.1995 / 12:25:25 / claus"
|
|
284 |
|
|
285 |
|
|
286 |
!
|
|
287 |
|
|
288 |
setDefaultActions
|
|
289 |
|
|
290 |
pressAction := [:pressPoint | self startSelectOrMove:pressPoint].
|
|
291 |
shiftPressAction := [:pressPoint | self startSelectMoreOrMove:pressPoint].
|
|
292 |
motionAction := [:movePoint | nil].
|
|
293 |
releaseAction := [nil].
|
|
294 |
keyPressAction := [:key | self doKeyInput:key].
|
|
295 |
|
|
296 |
self cursor:Cursor normal.
|
|
297 |
|
|
298 |
!
|
|
299 |
|
|
300 |
showDragging:something offset:anOffset
|
|
301 |
"drag around a View"
|
|
302 |
|
|
303 |
|top|
|
|
304 |
|
|
305 |
self forEach:something do:[:anObject |
|
|
306 |
self drawRectangle:((anObject origin + anOffset) extent:(anObject extent))
|
|
307 |
]
|
|
308 |
|
|
309 |
! !
|
|
310 |
|
|
311 |
!UIObjectView methodsFor:'object creation'!
|
|
312 |
|
54
|
313 |
actionCreate:anObject frame:aFrame delta:aDelta
|
|
314 |
"create and initialize action data
|
|
315 |
"
|
|
316 |
|extent x y selectors values|
|
|
317 |
|
|
318 |
"minimum extent
|
|
319 |
"
|
|
320 |
extent := self extent.
|
|
321 |
x := extent x // 3.
|
|
322 |
y := extent y // 3.
|
|
323 |
extent := anObject preferredExtent.
|
|
324 |
|
|
325 |
(extent x > x) ifTrue:[extent x:x].
|
|
326 |
(extent y > y) ifTrue:[extent y:y].
|
|
327 |
|
|
328 |
"setup structure
|
|
329 |
"
|
|
330 |
selectors := #( object frame delta vertical horizontal minExtent ).
|
|
331 |
values := Array new:(selectors size).
|
|
332 |
|
|
333 |
values at:1 put:anObject.
|
|
334 |
values at:2 put:aFrame.
|
|
335 |
values at:3 put:aDelta.
|
|
336 |
values at:4 put:(self isVerticalResizable:anObject).
|
|
337 |
values at:5 put:(self isHorizontalResizable:anObject).
|
|
338 |
values at:6 put:extent.
|
|
339 |
|
|
340 |
actionData := Structure newWith:selectors values:values.
|
|
341 |
|
|
342 |
|
|
343 |
"can change cursor dependent on vertical/horizontal resizing
|
|
344 |
"
|
|
345 |
oldCursor := cursor.
|
|
346 |
self cursor:(Cursor leftHand).
|
|
347 |
|
|
348 |
|
|
349 |
|
|
350 |
!
|
|
351 |
|
|
352 |
createWidgetWithClass:aClass
|
|
353 |
"prepare to create new widgets
|
|
354 |
"
|
|
355 |
createClass := aClass.
|
|
356 |
pressAction := [:pressPoint | self startCreate:pressPoint].
|
|
357 |
self cursor:Cursor origin.
|
|
358 |
|
|
359 |
|
|
360 |
!
|
|
361 |
|
51
|
362 |
doDragCreate:aPoint
|
|
363 |
"do a widget create drag
|
|
364 |
"
|
54
|
365 |
|frame object extent minimum|
|
|
366 |
|
|
367 |
frame := actionData frame.
|
|
368 |
frame corner:((self alignToGrid:aPoint) - (actionData delta)).
|
|
369 |
|
|
370 |
object := actionData object.
|
|
371 |
minimum := actionData minExtent.
|
|
372 |
extent := frame extent.
|
|
373 |
|
|
374 |
((extent x < minimum x) or:[actionData horizontal not]) ifTrue:[
|
|
375 |
extent x:(minimum x)
|
51
|
376 |
].
|
|
377 |
|
54
|
378 |
((extent y < minimum y) or:[actionData vertical not]) ifTrue:[
|
|
379 |
extent y:(minimum y)
|
51
|
380 |
].
|
|
381 |
|
54
|
382 |
frame extent:extent.
|
|
383 |
|
|
384 |
self invertOutlineOf:object.
|
|
385 |
object origin:(frame origin) extent:(frame extent).
|
|
386 |
self invertOutlineOf:object.
|
51
|
387 |
!
|
|
388 |
|
|
389 |
endCreate
|
|
390 |
"end a widget create drag
|
|
391 |
"
|
|
392 |
|layout x y|
|
|
393 |
|
54
|
394 |
self invertOutlineOf:(actionData object).
|
51
|
395 |
inputView raise.
|
|
396 |
|
54
|
397 |
layout := (actionData object) bounds asLayout.
|
|
398 |
(actionData object) geometryLayout:layout.
|
51
|
399 |
|
|
400 |
self changed:#tree.
|
54
|
401 |
self select:(actionData object).
|
|
402 |
actionData := nil.
|
51
|
403 |
|
|
404 |
self setDefaultActions.
|
|
405 |
|
|
406 |
!
|
|
407 |
|
|
408 |
setupCreatedObject:anObject
|
|
409 |
self subclassResponsibility
|
|
410 |
!
|
|
411 |
|
|
412 |
startCreate:aPoint
|
|
413 |
"start a widget create
|
|
414 |
"
|
54
|
415 |
|widget object start frame delta|
|
51
|
416 |
|
|
417 |
createClass isNil ifTrue:[
|
|
418 |
^ self setDefaultActions
|
|
419 |
].
|
|
420 |
(selection isKindOf:Collection) ifTrue:[
|
|
421 |
self unselect.
|
|
422 |
^ self setDefaultActions.
|
|
423 |
].
|
|
424 |
|
|
425 |
motionAction := [:movePoint| self doDragCreate:movePoint].
|
|
426 |
releaseAction := [ self endCreate].
|
|
427 |
|
|
428 |
selection notNil ifTrue:[
|
|
429 |
( (self isPoint:aPoint containedIn:selection)
|
54
|
430 |
and:[self supportsSubComponents:selection]
|
51
|
431 |
) ifFalse:[
|
|
432 |
self unselect
|
|
433 |
]
|
|
434 |
].
|
|
435 |
|
54
|
436 |
widget := selection ? self.
|
|
437 |
object := createClass new.
|
|
438 |
widget addSubView:object.
|
|
439 |
|
|
440 |
start := self alignToGrid:aPoint.
|
|
441 |
delta := widget originRelativeTo:self.
|
|
442 |
frame := Rectangle origin:(start - delta) corner:start.
|
|
443 |
|
|
444 |
object origin:(frame origin).
|
|
445 |
self setupCreatedObject:object.
|
|
446 |
object realize.
|
|
447 |
|
|
448 |
self actionCreate:object frame:frame delta:delta.
|
|
449 |
self invertOutlineOf:object.
|
|
450 |
|
|
451 |
|
51
|
452 |
! !
|
|
453 |
|
|
454 |
!UIObjectView methodsFor:'object moving'!
|
|
455 |
|
|
456 |
doObjectMove:aPoint
|
|
457 |
"move selection
|
|
458 |
"
|
|
459 |
movedObject notNil ifTrue:[
|
|
460 |
movedObject keysAndValuesDo:[:nr :aView|
|
|
461 |
self invertOutlineOf:aView.
|
|
462 |
self moveObject:aView to:(aPoint - (moveDelta at:nr)).
|
|
463 |
self invertOutlineOf:aView.
|
|
464 |
]
|
|
465 |
]
|
|
466 |
|
|
467 |
!
|
|
468 |
|
|
469 |
endObjectMove
|
|
470 |
"cleanup after object move"
|
|
471 |
|
|
472 |
movedObject notNil ifTrue:[
|
|
473 |
movedObject do:[:aView|
|
|
474 |
self invertOutlineOf:aView
|
|
475 |
].
|
|
476 |
|
|
477 |
movedObject do:[:aView|
|
|
478 |
self showSelected:aView
|
|
479 |
].
|
|
480 |
movedObject size == 1 ifTrue:[
|
|
481 |
selection := movedObject at:1
|
|
482 |
] ifFalse:[
|
|
483 |
selection := movedObject
|
|
484 |
].
|
|
485 |
|
|
486 |
movedObject := nil.
|
|
487 |
self setDefaultActions.
|
|
488 |
self changed:#layout.
|
|
489 |
].
|
|
490 |
!
|
|
491 |
|
54
|
492 |
moveObject:anObject to:aPoint
|
|
493 |
"move anObject to newOrigin, aPoint
|
|
494 |
"
|
|
495 |
|dX dY org delta|
|
|
496 |
|
|
497 |
anObject notNil ifTrue:[
|
|
498 |
org := anObject computeOrigin.
|
|
499 |
|
|
500 |
delta := aPoint - org.
|
|
501 |
delta := (self alignToGrid:aPoint) - org.
|
|
502 |
dX := delta x.
|
|
503 |
dY := delta y.
|
|
504 |
|
|
505 |
undoHistory disabledTransitionDo:[
|
|
506 |
self shifLayout:anObject top:dY bottom:dY left:dX right:dX
|
|
507 |
]
|
|
508 |
]
|
|
509 |
|
|
510 |
!
|
|
511 |
|
51
|
512 |
startObjectMoveAt:aPoint
|
|
513 |
|
|
514 |
self startObjectMove:selection at:aPoint.
|
|
515 |
|
|
516 |
selection size == 0 ifTrue:[
|
|
517 |
movedObject := Array with:selection
|
|
518 |
] ifFalse:[
|
|
519 |
movedObject := selection
|
|
520 |
].
|
|
521 |
super unselect.
|
|
522 |
|
|
523 |
moveDelta := movedObject collect:[:aView|
|
|
524 |
aPoint - aView computeOrigin
|
|
525 |
].
|
|
526 |
|
54
|
527 |
selection := movedObject.
|
|
528 |
self transaction:#move selectionDo:[:aView|
|
|
529 |
self invertOutlineOf:aView.
|
|
530 |
self undoBlockPositionChanged:aView
|
|
531 |
].
|
|
532 |
selection := nil
|
|
533 |
|
51
|
534 |
!
|
|
535 |
|
|
536 |
startSelectMoreOrMove:aPoint
|
|
537 |
"add/remove to/from selection"
|
|
538 |
|
|
539 |
|anObject|
|
|
540 |
|
|
541 |
testMode ifTrue:[^ self].
|
|
542 |
|
|
543 |
anObject := self findObjectAt:aPoint.
|
|
544 |
anObject notNil ifTrue:[
|
|
545 |
(self isSelected:anObject) ifTrue:[
|
|
546 |
self removeFromSelection:anObject
|
|
547 |
] ifFalse:[
|
|
548 |
self addToSelection:anObject
|
|
549 |
]
|
|
550 |
]
|
|
551 |
!
|
|
552 |
|
|
553 |
startSelectOrMove:aPoint
|
|
554 |
"a button is pressed at a point
|
|
555 |
"
|
|
556 |
|anObject b|
|
|
557 |
|
|
558 |
testMode ifTrue:[^ self].
|
|
559 |
|
|
560 |
"if there is one selection and point hits handle, start a resize
|
|
561 |
"
|
|
562 |
self singleSelection notNil ifTrue:[
|
|
563 |
b := self whichHandleOf:selection isHitBy:aPoint.
|
|
564 |
|
|
565 |
(b notNil and:[b ~~ #view]) ifTrue:[
|
54
|
566 |
^ self startResizeBorder:b of:selection.
|
51
|
567 |
]
|
|
568 |
].
|
|
569 |
|
|
570 |
anObject := self findObjectAt:aPoint.
|
|
571 |
|
|
572 |
"nothing is selected
|
|
573 |
"
|
|
574 |
anObject isNil ifTrue:[
|
|
575 |
^ self unselect
|
|
576 |
].
|
|
577 |
|
|
578 |
(self isSelected:anObject) ifFalse:[
|
|
579 |
super unselect.
|
|
580 |
self select:anObject.
|
|
581 |
].
|
|
582 |
|
|
583 |
selection isCollection ifTrue:[
|
|
584 |
releaseAction := [
|
|
585 |
self setDefaultActions.
|
|
586 |
self select:anObject
|
|
587 |
]
|
|
588 |
] ifFalse:[
|
|
589 |
releaseAction := [self setDefaultActions]
|
|
590 |
].
|
|
591 |
|
|
592 |
"prepare move operation for an object
|
|
593 |
"
|
|
594 |
motionAction := [:movePoint|
|
54
|
595 |
(aPoint dist:movePoint) > 4.0 ifTrue:[
|
51
|
596 |
self startObjectMoveAt:aPoint
|
|
597 |
]
|
|
598 |
].
|
|
599 |
! !
|
|
600 |
|
54
|
601 |
!UIObjectView methodsFor:'object resize'!
|
|
602 |
|
|
603 |
actionResize:anObject selector:aSelector
|
|
604 |
"create and initialize action for resize
|
|
605 |
"
|
|
606 |
|selector delta|
|
|
607 |
|
|
608 |
delta := anObject container originRelativeTo:self.
|
|
609 |
selector := ('resize:', aSelector, ':') asSymbol.
|
|
610 |
|
|
611 |
actionData := Structure with:(#object->anObject)
|
|
612 |
with:(#selector->selector)
|
|
613 |
with:(#delta->delta).
|
|
614 |
|
|
615 |
"can change cursor dependent on vertical/horizontal resizing
|
|
616 |
"
|
|
617 |
oldCursor := cursor.
|
|
618 |
self cursor:(Cursor leftHand).
|
|
619 |
|
|
620 |
|
|
621 |
|
|
622 |
!
|
|
623 |
|
|
624 |
doDragResize:aPoint
|
|
625 |
"do a widget resize drag"
|
|
626 |
|
|
627 |
|p object|
|
|
628 |
|
|
629 |
object := actionData object.
|
|
630 |
|
|
631 |
self invertOutlineOf:object.
|
|
632 |
p := (self alignToGrid:aPoint) - (actionData delta).
|
|
633 |
self perform:(actionData selector) with:object with:p.
|
|
634 |
object geometryLayout:(object geometryLayout).
|
|
635 |
self invertOutlineOf:object
|
|
636 |
|
|
637 |
!
|
|
638 |
|
|
639 |
endResize
|
|
640 |
"cleanup after object resize"
|
|
641 |
|
|
642 |
self invertOutlineOf:(actionData object).
|
|
643 |
self setDefaultActions.
|
|
644 |
self select:(actionData object).
|
|
645 |
actionData := nil
|
|
646 |
|
|
647 |
"Modified: 5.9.1995 / 17:11:17 / claus"
|
|
648 |
|
|
649 |
!
|
|
650 |
|
|
651 |
startResizeBorder:b of:selection
|
|
652 |
"resize selected view
|
|
653 |
"
|
|
654 |
|object|
|
|
655 |
|
|
656 |
object := self singleSelection.
|
|
657 |
self actionResize:object selector:b.
|
|
658 |
|
|
659 |
self transaction:#extent selectionDo:[:aView|
|
|
660 |
self undoBlockDimensionChanged:aView
|
|
661 |
].
|
|
662 |
super unselect.
|
|
663 |
|
|
664 |
motionAction := [:movePoint | self doDragResize:movePoint].
|
|
665 |
releaseAction := [self endResize].
|
|
666 |
self invertOutlineOf:object
|
|
667 |
! !
|
|
668 |
|
51
|
669 |
!UIObjectView methodsFor:'private handles'!
|
|
670 |
|
|
671 |
handlesOf:aComponent do:aBlock
|
|
672 |
|delta layout vertical horizontal|
|
|
673 |
|
|
674 |
layout := aComponent geometryLayout.
|
|
675 |
delta := (aComponent originRelativeTo:self) - aComponent origin.
|
|
676 |
|
|
677 |
(layout isLayout not or:[layout isLayoutFrame]) ifTrue:[
|
|
678 |
vertical := self isVerticalResizable:aComponent.
|
|
679 |
horizontal := self isHorizontalResizable:aComponent.
|
|
680 |
] ifFalse:[
|
|
681 |
vertical := false.
|
|
682 |
horizontal := false.
|
|
683 |
].
|
|
684 |
|
|
685 |
horizontal ifTrue:[
|
|
686 |
aBlock value:(aComponent leftCenter + delta) value:#left.
|
|
687 |
aBlock value:(aComponent rightCenter + delta) value:#right.
|
|
688 |
].
|
|
689 |
|
|
690 |
vertical ifTrue:[
|
|
691 |
aBlock value:(aComponent topCenter + delta) value:#top.
|
|
692 |
aBlock value:(aComponent bottomCenter + delta) value:#bottom.
|
|
693 |
].
|
|
694 |
|
|
695 |
(horizontal and:[vertical]) ifTrue:[
|
|
696 |
aBlock value:(aComponent origin + delta) value:#origin.
|
|
697 |
aBlock value:(aComponent corner + delta) value:#corner.
|
|
698 |
aBlock value:(aComponent topRight + delta) value:#topRight.
|
|
699 |
aBlock value:(aComponent bottomLeft + delta) value:#bottomLeft.
|
|
700 |
] ifFalse:[
|
|
701 |
aBlock value:(aComponent origin + delta) value:#view.
|
|
702 |
aBlock value:(aComponent corner + delta) value:#view.
|
|
703 |
aBlock value:(aComponent topRight + delta) value:#view.
|
|
704 |
aBlock value:(aComponent bottomLeft + delta) value:#view.
|
|
705 |
].
|
|
706 |
|
|
707 |
!
|
|
708 |
|
|
709 |
showSelected:aComponent
|
|
710 |
|wasClipped delta oldPaint|
|
|
711 |
|
|
712 |
self paint:Color black.
|
|
713 |
|
|
714 |
(wasClipped := clipChildren) ifTrue:[
|
|
715 |
self clippedByChildren:(clipChildren := false).
|
|
716 |
].
|
|
717 |
|
|
718 |
self handlesOf:aComponent do:[:pnt :what |
|
|
719 |
what == #view ifTrue:[self displayRectangle:(pnt - (4@4) extent:7@7)]
|
|
720 |
ifFalse:[self fillRectangle:(pnt - (4@4) extent:7@7)]
|
|
721 |
].
|
|
722 |
|
|
723 |
wasClipped ifTrue:[
|
|
724 |
self clippedByChildren:(clipChildren := true).
|
|
725 |
].
|
|
726 |
self paint:oldPaint.
|
|
727 |
!
|
|
728 |
|
|
729 |
showUnselected:aComponent
|
|
730 |
|wasClipped delta r oldPaint|
|
|
731 |
|
|
732 |
r := aComponent origin extent:8@8.
|
|
733 |
|
|
734 |
(wasClipped := clipChildren) ifTrue:[
|
|
735 |
self clippedByChildren:(clipChildren := false).
|
|
736 |
].
|
|
737 |
|
|
738 |
self handlesOf:aComponent do:[:pnt :what |
|
|
739 |
self clearRectangle:(pnt - (4@4) extent:7@7).
|
|
740 |
].
|
|
741 |
|
|
742 |
wasClipped ifTrue:[
|
|
743 |
self clippedByChildren:(clipChildren := true).
|
|
744 |
].
|
|
745 |
|
|
746 |
"/ must redraw all components which are affected b the handles
|
|
747 |
|
|
748 |
r := (aComponent originRelativeTo:self) - (4@4)
|
|
749 |
extent:(aComponent extent + (4@4)).
|
|
750 |
|
|
751 |
subViews do:[:anotherComponent |
|
|
752 |
|absOrg absFrame|
|
|
753 |
|
|
754 |
anotherComponent ~~ inputView ifTrue:[
|
|
755 |
absOrg := anotherComponent originRelativeTo:self.
|
|
756 |
absFrame := absOrg extent:(anotherComponent extent).
|
|
757 |
(absFrame intersects:r) ifTrue:[
|
|
758 |
anotherComponent withAllSubViewsDo:[:v |
|
|
759 |
v clear.
|
|
760 |
v exposeX:0 y:0 width:9999 height:9999.
|
|
761 |
]
|
|
762 |
]
|
|
763 |
]
|
|
764 |
]
|
|
765 |
|
|
766 |
!
|
|
767 |
|
|
768 |
whichHandleOf:aView isHitBy:aPoint
|
|
769 |
|bounds|
|
|
770 |
|
|
771 |
self handlesOf:aView do:[:pnt :what |
|
|
772 |
((pnt - (4@4) extent:7@7) containsPoint:aPoint) ifTrue:[
|
|
773 |
^ what
|
|
774 |
].
|
|
775 |
].
|
|
776 |
|
54
|
777 |
^ nil
|
51
|
778 |
|
|
779 |
"Modified: 5.9.1995 / 14:39:34 / claus"
|
|
780 |
|
|
781 |
! !
|
|
782 |
|
|
783 |
!UIObjectView methodsFor:'private resizing-subviews'!
|
|
784 |
|
|
785 |
resize:aView bottom:aPoint
|
|
786 |
|
|
787 |
undoHistory disabledTransitionDo:[
|
|
788 |
self shifLayout:aView top:0 bottom:((aPoint y) - (aView computeCorner y))
|
|
789 |
]
|
|
790 |
!
|
|
791 |
|
54
|
792 |
resize:aView bottomLeft:aPoint
|
|
793 |
|
|
794 |
undoHistory disabledTransitionDo:[
|
|
795 |
self shifLayout:aView top:0
|
|
796 |
bottom:((aPoint y) - (aView computeCorner y))
|
|
797 |
left:((aPoint x) - (aView computeOrigin x))
|
|
798 |
right:0
|
|
799 |
|
|
800 |
]
|
|
801 |
|
|
802 |
|
|
803 |
!
|
|
804 |
|
51
|
805 |
resize:aView corner:aPoint
|
|
806 |
|delta|
|
|
807 |
|
|
808 |
delta := aPoint - aView computeCorner.
|
|
809 |
|
|
810 |
undoHistory disabledTransitionDo:[
|
|
811 |
self shifLayout:aView top:0 bottom:(delta y) left:0 right:(delta x)
|
|
812 |
]
|
|
813 |
!
|
|
814 |
|
|
815 |
resize:aView left:aPoint
|
|
816 |
|
|
817 |
undoHistory disabledTransitionDo:[
|
|
818 |
self shifLayout:aView left:((aPoint x) - (aView computeOrigin x)) right:0
|
|
819 |
]
|
|
820 |
|
|
821 |
!
|
|
822 |
|
54
|
823 |
resize:aView origin:aPoint
|
|
824 |
|delta|
|
|
825 |
|
|
826 |
delta := aPoint - aView computeOrigin.
|
|
827 |
|
|
828 |
undoHistory disabledTransitionDo:[
|
|
829 |
self shifLayout:aView top:(delta y) bottom:0 left:(delta x) right:0
|
|
830 |
]
|
|
831 |
|
|
832 |
!
|
|
833 |
|
51
|
834 |
resize:aView right:aPoint
|
|
835 |
|
|
836 |
undoHistory disabledTransitionDo:[
|
|
837 |
self shifLayout:aView left:0 right:((aPoint x) - (aView computeCorner x))
|
|
838 |
]
|
|
839 |
!
|
|
840 |
|
|
841 |
resize:aView top:aPoint
|
|
842 |
|
|
843 |
undoHistory disabledTransitionDo:[
|
|
844 |
self shifLayout:aView top:((aPoint y) - (aView computeOrigin y)) bottom:0
|
|
845 |
]
|
54
|
846 |
!
|
|
847 |
|
|
848 |
resize:aView topRight:aPoint
|
|
849 |
|
|
850 |
undoHistory disabledTransitionDo:[
|
|
851 |
self shifLayout:aView top:((aPoint y) - (aView computeOrigin y))
|
|
852 |
bottom:0
|
|
853 |
left:0
|
|
854 |
right:((aPoint x) - (aView computeCorner x))
|
|
855 |
|
|
856 |
]
|
|
857 |
|
51
|
858 |
! !
|
|
859 |
|
|
860 |
!UIObjectView methodsFor:'private shift-layout'!
|
|
861 |
|
|
862 |
shifLayout:aView left:l right:r
|
54
|
863 |
"shift layout for a view; in case of an open transaction, the undo
|
|
864 |
action is registered
|
51
|
865 |
"
|
|
866 |
self shifLayout:aView top:0 bottom:0 left:l right:r
|
|
867 |
|
|
868 |
!
|
|
869 |
|
|
870 |
shifLayout:aView top:t bottom:b
|
54
|
871 |
"shift layout for a view; in case of an open transaction, the undo
|
|
872 |
action is registered
|
51
|
873 |
"
|
|
874 |
self shifLayout:aView top:t bottom:b left:0 right:0
|
|
875 |
|
|
876 |
|
|
877 |
!
|
|
878 |
|
|
879 |
shifLayout:aView top:t bottom:b left:l right:r
|
54
|
880 |
"shift layout for a view; in case of an open transaction, the undo
|
|
881 |
action is registered
|
51
|
882 |
"
|
|
883 |
|layout|
|
|
884 |
|
|
885 |
self undoBlockPositionChanged:aView.
|
|
886 |
|
|
887 |
layout := aView geometryLayout.
|
|
888 |
|
|
889 |
layout leftOffset:(layout leftOffset + l)
|
|
890 |
topOffset:(layout topOffset + t).
|
|
891 |
|
|
892 |
layout isLayoutFrame ifTrue:[
|
|
893 |
layout bottomOffset:(layout bottomOffset + b).
|
|
894 |
layout rightOffset:(layout rightOffset + r).
|
|
895 |
].
|
|
896 |
|
|
897 |
aView geometryLayout:layout.
|
|
898 |
|
|
899 |
|
|
900 |
|
|
901 |
! !
|
|
902 |
|
|
903 |
!UIObjectView methodsFor:'searching'!
|
|
904 |
|
|
905 |
findObjectAt:aPoint
|
|
906 |
"find the origin/corner of the currentWidget
|
|
907 |
"
|
|
908 |
|view viewId lastId point|
|
|
909 |
|
|
910 |
viewId := rootView id.
|
|
911 |
point := aPoint + (device translatePoint:0@0 from:(self id) to:viewId).
|
|
912 |
|
|
913 |
inputView lower.
|
|
914 |
|
|
915 |
[viewId notNil] whileTrue:[
|
|
916 |
lastId := viewId.
|
|
917 |
viewId := device viewIdFromPoint:point in:lastId
|
|
918 |
].
|
|
919 |
|
|
920 |
inputView raise.
|
|
921 |
|
|
922 |
view := device viewFromId:lastId.
|
|
923 |
|
|
924 |
view ~~ inputView ifTrue:[^ view]
|
|
925 |
ifFalse:[^ nil]
|
|
926 |
|
|
927 |
|
|
928 |
!
|
|
929 |
|
|
930 |
isPoint:aPoint containedIn:aView
|
|
931 |
"checks whether a point is covered by a view.
|
|
932 |
"
|
|
933 |
|org ext|
|
|
934 |
|
|
935 |
org := aView computeOrigin.
|
|
936 |
ext := aView computeExtent.
|
|
937 |
|
|
938 |
^ ((org extent:ext) containsPoint:aPoint)
|
47
|
939 |
!
|
|
940 |
|
51
|
941 |
whichBorderOf:aView isHitBy:aPoint
|
|
942 |
|p r bw org|
|
|
943 |
|
|
944 |
bw := aView borderWidth.
|
|
945 |
p := aPoint - (aView superView originRelativeTo:self).
|
|
946 |
|
|
947 |
r := Rectangle origin:(aView origin)
|
|
948 |
extent:(aView width @ bw).
|
|
949 |
(r containsPoint:p) ifTrue:[^ #top:].
|
|
950 |
|
|
951 |
r origin:(aView left @ (aView bottom + bw)) extent:(aView width @ bw).
|
|
952 |
(r containsPoint:p) ifTrue:[^ #bottom:].
|
|
953 |
|
|
954 |
r top:(aView top).
|
|
955 |
r extent:(bw @ aView height).
|
|
956 |
(r containsPoint:p) ifTrue:[^ #left:].
|
|
957 |
|
|
958 |
r origin:((aView right + bw) @ aView top).
|
|
959 |
(r containsPoint:p) ifTrue:[^ #right:].
|
|
960 |
|
|
961 |
^ nil
|
|
962 |
|
|
963 |
|
|
964 |
! !
|
|
965 |
|
|
966 |
!UIObjectView methodsFor:'selections'!
|
|
967 |
|
|
968 |
addToSelection:something
|
|
969 |
(testMode or:[something == selection]) ifFalse:[
|
|
970 |
super addToSelection:something.
|
|
971 |
self changed:#selection.
|
|
972 |
]
|
|
973 |
!
|
|
974 |
|
|
975 |
inspectSelection
|
|
976 |
self singleSelectionDo:[:aView |
|
|
977 |
aView inspect
|
|
978 |
]
|
|
979 |
!
|
|
980 |
|
|
981 |
removeFromSelection:something
|
|
982 |
super removeFromSelection:something.
|
|
983 |
self changed:#selection
|
|
984 |
|
|
985 |
!
|
|
986 |
|
|
987 |
select:something
|
|
988 |
(testMode or:[something == selection]) ifFalse:[
|
|
989 |
super select:something.
|
|
990 |
self changed:#selection
|
|
991 |
]
|
|
992 |
|
|
993 |
!
|
|
994 |
|
|
995 |
selection
|
|
996 |
^ selection
|
|
997 |
|
|
998 |
|
|
999 |
!
|
|
1000 |
|
|
1001 |
selectionFindMinimum:aOneArgBlock
|
|
1002 |
"returns the minimum value from the block evaluated on each view
|
|
1003 |
in the selection
|
|
1004 |
"
|
|
1005 |
|min val|
|
|
1006 |
|
|
1007 |
self selectionDo:[:aView|
|
|
1008 |
val := aOneArgBlock value:aView.
|
|
1009 |
|
|
1010 |
min isNil ifTrue:[min := val]
|
|
1011 |
ifFalse:[min := min min:val]
|
|
1012 |
].
|
|
1013 |
^ min
|
|
1014 |
!
|
|
1015 |
|
|
1016 |
selectionHiddenDo:aBlock
|
|
1017 |
"apply block to every object in selection"
|
|
1018 |
|
|
1019 |
self selectionDo:[:aView |
|
|
1020 |
self showUnselected:aView.
|
|
1021 |
].
|
|
1022 |
device flush.
|
|
1023 |
aBlock value.
|
|
1024 |
self selectionDo:[:aView |
|
|
1025 |
self showSelected:aView
|
|
1026 |
]
|
|
1027 |
|
|
1028 |
|
|
1029 |
!
|
|
1030 |
|
|
1031 |
singleSelection
|
|
1032 |
"returns single selection or nil
|
|
1033 |
"
|
|
1034 |
(selection isKindOf:SimpleView) ifTrue:[^ selection]
|
|
1035 |
ifFalse:[^ nil]
|
|
1036 |
!
|
|
1037 |
|
|
1038 |
singleSelectionDo:aBlock
|
|
1039 |
|
|
1040 |
self singleSelection notNil ifTrue:[
|
|
1041 |
aBlock value:selection
|
|
1042 |
]
|
|
1043 |
!
|
|
1044 |
|
|
1045 |
unselect
|
|
1046 |
selection notNil ifTrue:[
|
|
1047 |
super unselect.
|
|
1048 |
self changed:#selection
|
|
1049 |
]
|
|
1050 |
|
|
1051 |
!
|
|
1052 |
|
|
1053 |
withSelectionHiddenDo:aBlock
|
|
1054 |
"evaluate aBlock while selection is hidden"
|
|
1055 |
|
|
1056 |
|sel|
|
|
1057 |
|
|
1058 |
selection isNil ifTrue:[
|
|
1059 |
aBlock value
|
|
1060 |
] ifFalse:[
|
|
1061 |
sel := selection.
|
|
1062 |
super unselect.
|
|
1063 |
aBlock value.
|
|
1064 |
super select:sel
|
|
1065 |
]
|
|
1066 |
|
|
1067 |
"Modified: 6.9.1995 / 01:46:16 / claus"
|
|
1068 |
|
|
1069 |
|
|
1070 |
! !
|
|
1071 |
|
|
1072 |
!UIObjectView methodsFor:'testing'!
|
|
1073 |
|
|
1074 |
canMove:something
|
|
1075 |
^ true
|
|
1076 |
|
|
1077 |
|
|
1078 |
!
|
|
1079 |
|
|
1080 |
isHorizontalResizable:aComponent
|
|
1081 |
^ self subclassResponsibility
|
|
1082 |
|
|
1083 |
|
|
1084 |
!
|
|
1085 |
|
|
1086 |
isVerticalResizable:aComponent
|
|
1087 |
^ self subclassResponsibility
|
|
1088 |
|
|
1089 |
|
54
|
1090 |
!
|
|
1091 |
|
|
1092 |
supportsSubComponents:something
|
|
1093 |
"returns true if somrthing supports subcomponents
|
|
1094 |
"
|
|
1095 |
|specClass|
|
|
1096 |
|
|
1097 |
something notNil ifTrue:[
|
|
1098 |
something isCollection ifFalse:[
|
|
1099 |
specClass := something specClass
|
|
1100 |
] ifTrue:[
|
|
1101 |
something size == 1 ifTrue:[
|
|
1102 |
specClass := (something at:1) specClass
|
|
1103 |
]
|
|
1104 |
].
|
|
1105 |
specClass notNil ifTrue:[
|
|
1106 |
^ specClass basicNew supportsSubComponents
|
|
1107 |
]
|
|
1108 |
].
|
|
1109 |
^ false
|
51
|
1110 |
! !
|
|
1111 |
|
54
|
1112 |
!UIObjectView methodsFor:'transaction & undo'!
|
|
1113 |
|
|
1114 |
transaction:aType objects:something do:aOneArgBlock
|
|
1115 |
"opens a transaction and evaluates a block within the transaction; the
|
|
1116 |
argument to the block is a view from derived from something
|
51
|
1117 |
"
|
54
|
1118 |
self subclassResponsibility
|
51
|
1119 |
|
|
1120 |
|
|
1121 |
!
|
|
1122 |
|
54
|
1123 |
transaction:aType selectionDo:aOneArgBlock
|
|
1124 |
"opens a transaction and evaluates a block within the transaction; the
|
|
1125 |
argument to the block is a view from the selection
|
|
1126 |
"
|
|
1127 |
self transaction:aType objects:selection do:aOneArgBlock
|
|
1128 |
|
|
1129 |
|
|
1130 |
!
|
|
1131 |
|
|
1132 |
undoBlockDimensionChanged:aView
|
|
1133 |
|
|
1134 |
undoHistory isTransactionOpen ifTrue:[
|
|
1135 |
|layout|
|
|
1136 |
|
|
1137 |
layout := aView geometryLayout copy.
|
|
1138 |
|
|
1139 |
undoHistory addUndoBlock:[
|
|
1140 |
aView geometryLayout:layout.
|
|
1141 |
aView superView sizeChanged:nil.
|
|
1142 |
]
|
51
|
1143 |
]
|
|
1144 |
|
54
|
1145 |
!
|
|
1146 |
|
|
1147 |
undoBlockPositionChanged:aView
|
|
1148 |
|
|
1149 |
undoHistory isTransactionOpen ifTrue:[
|
|
1150 |
|layout|
|
|
1151 |
|
|
1152 |
layout := aView geometryLayout copy.
|
|
1153 |
undoHistory addUndoBlock:[aView geometryLayout:layout]
|
|
1154 |
]
|
|
1155 |
|
|
1156 |
!
|
|
1157 |
|
|
1158 |
undoLast
|
|
1159 |
self undoLast:1
|
|
1160 |
!
|
|
1161 |
|
|
1162 |
undoLast:n
|
|
1163 |
|
|
1164 |
self unselect.
|
|
1165 |
undoHistory undoLast:n.
|
|
1166 |
self changed:#tree
|
|
1167 |
|
51
|
1168 |
|
|
1169 |
! !
|
|
1170 |
|
|
1171 |
!UIObjectView methodsFor:'user actions - dimension'!
|
|
1172 |
|
|
1173 |
copyExtent
|
|
1174 |
(selection isNil or:[selection isKindOf:Collection]) ifTrue:[
|
|
1175 |
^ self warn:'exactly one element must be selected'.
|
|
1176 |
].
|
|
1177 |
copiedExtent := selection computeExtent
|
|
1178 |
|
|
1179 |
|
|
1180 |
|
|
1181 |
!
|
|
1182 |
|
|
1183 |
pasteExtent
|
|
1184 |
copiedExtent notNil ifTrue:[
|
54
|
1185 |
self transition:#extent dimensionDo:[:v|
|
51
|
1186 |
self resize:v corner:(v computeOrigin + copiedExtent)
|
|
1187 |
]
|
|
1188 |
]
|
|
1189 |
!
|
|
1190 |
|
|
1191 |
pasteHeight
|
|
1192 |
copiedExtent notNil ifTrue:[
|
|
1193 |
self transition:'paste height' dimensionDo:[:v|
|
|
1194 |
self resize:v bottom:(v computeOrigin + copiedExtent)
|
|
1195 |
]
|
|
1196 |
]
|
|
1197 |
|
|
1198 |
!
|
|
1199 |
|
|
1200 |
pasteWidth
|
|
1201 |
copiedExtent notNil ifTrue:[
|
|
1202 |
self transition:'paste width' dimensionDo:[:v|
|
|
1203 |
self resize:v right:(v computeOrigin + copiedExtent)
|
|
1204 |
]
|
|
1205 |
]
|
|
1206 |
|
|
1207 |
!
|
|
1208 |
|
|
1209 |
setDimension:aLayout
|
54
|
1210 |
|type|
|
|
1211 |
|
51
|
1212 |
aLayout isLayout ifTrue:[
|
54
|
1213 |
aLayout isLayoutFrame ifTrue:[
|
|
1214 |
type := #layoutFrame
|
51
|
1215 |
] ifFalse:[
|
|
1216 |
aLayout isAlignmentOrigin ifTrue:[
|
54
|
1217 |
type := #layoutAlignOrigin.
|
|
1218 |
] ifFalse:[
|
|
1219 |
type := #layoutOrigin
|
51
|
1220 |
]
|
|
1221 |
]
|
54
|
1222 |
] ifFalse:[
|
|
1223 |
type := #layout
|
51
|
1224 |
].
|
|
1225 |
|
54
|
1226 |
self transition:type dimensionDo:[:v| v geometryLayout:(aLayout copy)]
|
51
|
1227 |
|
|
1228 |
!
|
|
1229 |
|
|
1230 |
setToDefaultExtent
|
54
|
1231 |
self transition:#extent dimensionDo:[:v|
|
51
|
1232 |
self resize:v corner:(v computeOrigin + (v preferredExtent))
|
|
1233 |
]
|
|
1234 |
|
|
1235 |
!
|
|
1236 |
|
|
1237 |
setToDefaultHeight
|
|
1238 |
self transition:'default height' dimensionDo:[:v|
|
|
1239 |
self resize:v bottom:(v computeOrigin + (v preferredExtent))
|
|
1240 |
]
|
|
1241 |
|
|
1242 |
!
|
|
1243 |
|
|
1244 |
setToDefaultWidth
|
|
1245 |
self transition:'default width' dimensionDo:[:v|
|
|
1246 |
self resize:v right:(v computeOrigin + (v preferredExtent))
|
|
1247 |
]
|
|
1248 |
|
|
1249 |
!
|
|
1250 |
|
54
|
1251 |
transition:aType dimensionDo:aOneArgBlock
|
51
|
1252 |
"change dimension within a transaction for the selected elements by evaluating
|
|
1253 |
the block with the argument a view.
|
|
1254 |
"
|
|
1255 |
self selectionHiddenDo:[
|
54
|
1256 |
self transaction:aType selectionDo:[:aView|
|
|
1257 |
self undoBlockDimensionChanged:aView.
|
|
1258 |
aOneArgBlock value:aView.
|
|
1259 |
aView superView sizeChanged:nil
|
|
1260 |
].
|
|
1261 |
self changed:#layout
|
51
|
1262 |
]
|
|
1263 |
! !
|
|
1264 |
|
|
1265 |
!UIObjectView methodsFor:'user actions - move'!
|
|
1266 |
|
|
1267 |
basicMoveSelectionHorizontal:n
|
|
1268 |
"move left: n < 0
|
|
1269 |
move right: n > 0
|
|
1270 |
"
|
|
1271 |
self selectionHiddenDo:[
|
54
|
1272 |
self transaction:#move selectionDo:[:v| self shifLayout:v left:n right:n].
|
51
|
1273 |
self changed:#layout
|
|
1274 |
]
|
|
1275 |
|
|
1276 |
|
|
1277 |
!
|
|
1278 |
|
|
1279 |
basicMoveSelectionVertical:n
|
|
1280 |
"move up: n < 0
|
|
1281 |
move down: n > 0
|
|
1282 |
"
|
|
1283 |
self selectionHiddenDo:[
|
54
|
1284 |
self transaction:#move selectionDo:[:v| self shifLayout:v top:n bottom:n ].
|
51
|
1285 |
self changed:#layout
|
|
1286 |
]
|
|
1287 |
|
|
1288 |
|
|
1289 |
|
|
1290 |
!
|
|
1291 |
|
|
1292 |
moveSelectionDown
|
|
1293 |
self moveSelectionDown:1
|
|
1294 |
|
|
1295 |
|
|
1296 |
!
|
|
1297 |
|
|
1298 |
moveSelectionDown10
|
|
1299 |
self moveSelectionDown:10
|
|
1300 |
|
|
1301 |
|
|
1302 |
!
|
|
1303 |
|
|
1304 |
moveSelectionDown:n
|
|
1305 |
self basicMoveSelectionVertical:n
|
|
1306 |
|
|
1307 |
|
|
1308 |
!
|
|
1309 |
|
|
1310 |
moveSelectionLeft
|
|
1311 |
self moveSelectionLeft:1
|
|
1312 |
|
|
1313 |
|
|
1314 |
!
|
|
1315 |
|
|
1316 |
moveSelectionLeft10
|
|
1317 |
self moveSelectionLeft:10
|
|
1318 |
|
|
1319 |
|
|
1320 |
!
|
|
1321 |
|
|
1322 |
moveSelectionLeft:n
|
|
1323 |
self basicMoveSelectionHorizontal:(n negated)
|
|
1324 |
|
|
1325 |
|
|
1326 |
!
|
|
1327 |
|
|
1328 |
moveSelectionRight
|
|
1329 |
self moveSelectionRight:1
|
|
1330 |
|
|
1331 |
|
|
1332 |
!
|
|
1333 |
|
|
1334 |
moveSelectionRight10
|
|
1335 |
self moveSelectionRight:10
|
|
1336 |
|
|
1337 |
|
|
1338 |
!
|
|
1339 |
|
|
1340 |
moveSelectionRight:n
|
|
1341 |
self basicMoveSelectionHorizontal:n
|
|
1342 |
|
|
1343 |
|
|
1344 |
!
|
|
1345 |
|
|
1346 |
moveSelectionUp
|
|
1347 |
self moveSelectionUp:1
|
|
1348 |
|
|
1349 |
|
|
1350 |
!
|
|
1351 |
|
|
1352 |
moveSelectionUp10
|
|
1353 |
self moveSelectionUp:10
|
|
1354 |
|
|
1355 |
|
|
1356 |
!
|
|
1357 |
|
|
1358 |
moveSelectionUp:n
|
|
1359 |
self basicMoveSelectionVertical:(n negated)
|
|
1360 |
|
|
1361 |
|
|
1362 |
! !
|
|
1363 |
|
|
1364 |
!UIObjectView methodsFor:'user actions - position'!
|
44
|
1365 |
|
51
|
1366 |
alignSelectionBottom
|
|
1367 |
|bmost delta|
|
|
1368 |
|
|
1369 |
self selectionHiddenDo:[
|
|
1370 |
bmost := 0.
|
|
1371 |
self selectionDo:[:v| bmost := bmost max:(v computeCorner y)].
|
|
1372 |
|
54
|
1373 |
self transaction:#align selectionDo:[:v|
|
|
1374 |
(delta := bmost - (v computeCorner y)) ~~ 0 ifTrue:[
|
|
1375 |
self shifLayout:v top:delta bottom:delta.
|
51
|
1376 |
]
|
|
1377 |
].
|
|
1378 |
self changed:#layout
|
|
1379 |
]
|
|
1380 |
|
|
1381 |
|
|
1382 |
|
|
1383 |
!
|
|
1384 |
|
|
1385 |
alignSelectionCenterHor
|
|
1386 |
|counter centerX|
|
|
1387 |
|
|
1388 |
self selectionHiddenDo:[
|
|
1389 |
counter := 0.
|
|
1390 |
centerX := 0.
|
|
1391 |
|
|
1392 |
self selectionDo:[:v |
|
|
1393 |
centerX := centerX + (v computeCorner x + v computeOrigin x).
|
|
1394 |
counter := counter + 1.
|
|
1395 |
].
|
|
1396 |
centerX := centerX // (counter * 2).
|
|
1397 |
|
54
|
1398 |
self transaction:#align selectionDo:[:v|
|
51
|
1399 |
|newX oldX delta|
|
|
1400 |
|
54
|
1401 |
oldX := v computeOrigin x.
|
|
1402 |
newX := centerX - ((v computeCorner x - oldX) // 2).
|
|
1403 |
delta := newX - oldX.
|
|
1404 |
|
|
1405 |
self shifLayout:v left:delta right:delta
|
51
|
1406 |
].
|
|
1407 |
self changed:#layout
|
|
1408 |
]
|
|
1409 |
|
|
1410 |
|
|
1411 |
|
|
1412 |
!
|
|
1413 |
|
|
1414 |
alignSelectionCenterVer
|
|
1415 |
|counter centerY|
|
|
1416 |
|
|
1417 |
self selectionHiddenDo:[
|
|
1418 |
counter := 0.
|
|
1419 |
centerY := 0.
|
|
1420 |
|
|
1421 |
self selectionDo:[:v |
|
|
1422 |
centerY := centerY + (v computeCorner y + v computeOrigin y).
|
|
1423 |
counter := counter + 1.
|
|
1424 |
].
|
|
1425 |
centerY := centerY // (counter * 2).
|
|
1426 |
|
54
|
1427 |
self transaction:#align selectionDo:[:v|
|
51
|
1428 |
|newY oldY delta|
|
|
1429 |
|
54
|
1430 |
oldY := v computeOrigin y.
|
|
1431 |
newY := centerY - ((v computeCorner y - oldY) // 2).
|
|
1432 |
delta := newY - oldY.
|
|
1433 |
|
|
1434 |
self shifLayout:v top:delta bottom:delta
|
51
|
1435 |
].
|
|
1436 |
self changed:#layout
|
|
1437 |
]
|
|
1438 |
!
|
|
1439 |
|
|
1440 |
alignSelectionLeft
|
|
1441 |
|lmost delta|
|
|
1442 |
|
|
1443 |
self selectionHiddenDo:[
|
|
1444 |
lmost := self selectionFindMinimum:[:v| v computeOrigin x].
|
|
1445 |
|
54
|
1446 |
self transaction:#align selectionDo:[:v|
|
|
1447 |
(delta := lmost - (v computeOrigin x)) ~~ 0 ifTrue:[
|
|
1448 |
self shifLayout:v left:delta right:delta
|
51
|
1449 |
]
|
|
1450 |
].
|
|
1451 |
self changed:#layout
|
|
1452 |
]
|
|
1453 |
|
|
1454 |
!
|
|
1455 |
|
|
1456 |
alignSelectionLeftAndRight
|
|
1457 |
|lmost rmost|
|
|
1458 |
|
|
1459 |
self selectionHiddenDo:[
|
|
1460 |
lmost := self selectionFindMinimum:[:v| v computeOrigin x].
|
|
1461 |
rmost := 0.
|
|
1462 |
self selectionDo:[:v | rmost := rmost max:(v computeCorner x)].
|
|
1463 |
|
54
|
1464 |
self transaction:#align selectionDo:[:v|
|
|
1465 |
self shifLayout:v left:(lmost - (v computeOrigin x))
|
|
1466 |
right:(rmost - (v computeCorner x))
|
51
|
1467 |
].
|
|
1468 |
self changed:#layout
|
|
1469 |
]
|
|
1470 |
!
|
|
1471 |
|
|
1472 |
alignSelectionRight
|
|
1473 |
|rmost delta|
|
|
1474 |
|
|
1475 |
self selectionHiddenDo:[
|
|
1476 |
rmost := 0.
|
|
1477 |
self selectionDo:[:v| rmost := rmost max:(v computeCorner x)].
|
|
1478 |
|
54
|
1479 |
self transaction:#align selectionDo:[:v|
|
|
1480 |
(delta := rmost - (v computeCorner x)) ~~ 0 ifTrue:[
|
|
1481 |
self shifLayout:v left:delta right:delta
|
51
|
1482 |
]
|
|
1483 |
].
|
|
1484 |
self changed:#layout
|
|
1485 |
]
|
|
1486 |
|
|
1487 |
!
|
|
1488 |
|
|
1489 |
alignSelectionTop
|
|
1490 |
|tmost delta|
|
|
1491 |
|
|
1492 |
self selectionHiddenDo:[
|
|
1493 |
tmost := self selectionFindMinimum:[:v| v computeOrigin y].
|
|
1494 |
|
54
|
1495 |
self transaction:#align selectionDo:[:v|
|
|
1496 |
(delta := tmost - (v computeOrigin y)) ~~ 0 ifTrue:[
|
|
1497 |
self shifLayout:v top:delta bottom:delta
|
51
|
1498 |
]
|
|
1499 |
].
|
|
1500 |
self changed:#layout
|
|
1501 |
]
|
|
1502 |
|
|
1503 |
!
|
|
1504 |
|
|
1505 |
alignSelectionTopAndBottom
|
|
1506 |
|tmost bmost|
|
|
1507 |
|
|
1508 |
self selectionHiddenDo:[
|
|
1509 |
tmost := self selectionFindMinimum:[:v| v computeOrigin y].
|
|
1510 |
bmost := 0.
|
|
1511 |
self selectionDo:[:v| bmost := bmost max:(v computeCorner y)].
|
|
1512 |
|
54
|
1513 |
self transaction:#align selectionDo:[:v|
|
|
1514 |
self shifLayout:v top:(tmost - (v computeOrigin y))
|
|
1515 |
bottom:(bmost - (v computeCorner y))
|
51
|
1516 |
].
|
|
1517 |
self changed:#layout
|
|
1518 |
]
|
|
1519 |
!
|
|
1520 |
|
54
|
1521 |
centerSelection:aOneArgBlockXorY orientation:orientation
|
51
|
1522 |
"center selection horizontal or vertical dependant on the block result( x or y).
|
|
1523 |
The argument to the block is the point.
|
|
1524 |
"
|
|
1525 |
|superview min max delta val|
|
|
1526 |
|
|
1527 |
self selectionHiddenDo:[
|
|
1528 |
max := 0.
|
|
1529 |
|
|
1530 |
self selectionDo:[:aView |
|
|
1531 |
superview isNil ifTrue:[
|
|
1532 |
superview := aView superView
|
|
1533 |
] ifFalse:[
|
|
1534 |
(aView superView == superview) ifFalse:[
|
|
1535 |
^ self notify:'views must have same superview'.
|
|
1536 |
]
|
|
1537 |
].
|
|
1538 |
val := aOneArgBlockXorY value:(aView computeOrigin).
|
|
1539 |
|
|
1540 |
min isNil ifTrue:[min := val]
|
|
1541 |
ifFalse:[min := min min:val].
|
44
|
1542 |
|
51
|
1543 |
val := aOneArgBlockXorY value:(aView computeCorner).
|
|
1544 |
max := max max:val.
|
|
1545 |
].
|
|
1546 |
|
|
1547 |
val := aOneArgBlockXorY value:(superview computeExtent).
|
|
1548 |
max := (min + val - max) // 2.
|
|
1549 |
|
|
1550 |
max == min ifFalse:[
|
|
1551 |
delta := max - min.
|
|
1552 |
|
54
|
1553 |
self transaction:#center selectionDo:[:v|
|
|
1554 |
orientation == #y ifTrue:[
|
|
1555 |
self shifLayout:v top:delta bottom:delta
|
|
1556 |
] ifFalse:[
|
|
1557 |
self shifLayout:v left:delta right:delta
|
|
1558 |
]
|
|
1559 |
].
|
|
1560 |
self changed:#layout
|
|
1561 |
]
|
51
|
1562 |
]
|
|
1563 |
|
|
1564 |
|
|
1565 |
!
|
|
1566 |
|
|
1567 |
centerSelectionHor
|
|
1568 |
"center selection horizontal
|
|
1569 |
"
|
54
|
1570 |
self centerSelection:[:aPoint| aPoint x] orientation:#x
|
51
|
1571 |
|
|
1572 |
|
|
1573 |
!
|
|
1574 |
|
|
1575 |
centerSelectionVer
|
|
1576 |
"center selection vertical
|
|
1577 |
"
|
54
|
1578 |
self centerSelection:[:aPoint| aPoint y] orientation:#y
|
51
|
1579 |
!
|
|
1580 |
|
|
1581 |
spreadSelectionHor
|
|
1582 |
|sumWidths min max viewsInOrder topsInOrder count space|
|
|
1583 |
|
|
1584 |
(selection isKindOf:Collection) ifFalse:[^ self].
|
|
1585 |
|
|
1586 |
self selectionHiddenDo:[
|
|
1587 |
count := 0.
|
|
1588 |
sumWidths := 0.
|
|
1589 |
max := 0.
|
|
1590 |
|
|
1591 |
self selectionDo:[:aView |
|
|
1592 |
sumWidths := sumWidths + aView width.
|
|
1593 |
|
|
1594 |
min isNil ifTrue:[min := aView left]
|
|
1595 |
ifFalse:[min := min min:(aView left)].
|
|
1596 |
|
|
1597 |
max := max max:(aView right).
|
|
1598 |
count := count + 1
|
|
1599 |
].
|
|
1600 |
viewsInOrder := Array withAll:selection.
|
|
1601 |
topsInOrder := viewsInOrder collect:[:aView | aView left].
|
|
1602 |
topsInOrder sortWith:viewsInOrder.
|
|
1603 |
|
|
1604 |
space := (((max - min) - sumWidths) / (count - 1)) rounded asInteger.
|
|
1605 |
|
54
|
1606 |
self transaction:#spread objects:viewsInOrder do:[:aView|
|
|
1607 |
|delta|
|
|
1608 |
|
|
1609 |
delta := min - aView computeOrigin x.
|
|
1610 |
self shifLayout:aView left:delta right:delta.
|
|
1611 |
min := min + aView computeExtent x + space
|
51
|
1612 |
].
|
|
1613 |
self changed:#layout
|
|
1614 |
]
|
|
1615 |
|
|
1616 |
!
|
|
1617 |
|
|
1618 |
spreadSelectionVer
|
|
1619 |
|sumHeights min max viewsInOrder topsInOrder count space|
|
|
1620 |
|
|
1621 |
(selection isKindOf:Collection) ifFalse:[^ self].
|
|
1622 |
|
|
1623 |
self selectionHiddenDo:[
|
|
1624 |
count := 0.
|
|
1625 |
sumHeights := 0.
|
|
1626 |
max := 0.
|
|
1627 |
|
|
1628 |
self selectionDo:[:aView |
|
|
1629 |
sumHeights := sumHeights + aView height.
|
|
1630 |
|
|
1631 |
min isNil ifTrue:[min := aView top]
|
|
1632 |
ifFalse:[min := min min:(aView top)].
|
|
1633 |
|
|
1634 |
max := max max:(aView bottom).
|
|
1635 |
count := count + 1
|
|
1636 |
].
|
|
1637 |
viewsInOrder := Array withAll:selection.
|
|
1638 |
topsInOrder := viewsInOrder collect:[:aView|aView top].
|
|
1639 |
topsInOrder sortWith:viewsInOrder.
|
|
1640 |
|
|
1641 |
space := (((max - min) - sumHeights) / (count - 1)) rounded asInteger.
|
|
1642 |
|
54
|
1643 |
self transaction:#spread objects:viewsInOrder do:[:aView|
|
|
1644 |
|delta|
|
|
1645 |
|
|
1646 |
delta := min - aView computeOrigin y.
|
|
1647 |
self shifLayout:aView top:delta bottom:delta.
|
|
1648 |
min := min + aView height + space
|
51
|
1649 |
].
|
|
1650 |
self changed:#layout
|
|
1651 |
]
|
|
1652 |
! !
|
|
1653 |
|
47
|
1654 |
!UIObjectView::UndoHistory class methodsFor:'constants'!
|
|
1655 |
|
|
1656 |
maxHistorySize
|
|
1657 |
"returns maximum size of history before removing oldest
|
|
1658 |
record
|
|
1659 |
"
|
|
1660 |
^ 50
|
|
1661 |
|
|
1662 |
|
|
1663 |
! !
|
|
1664 |
|
51
|
1665 |
!UIObjectView::UndoHistory class methodsFor:'instance creation'!
|
|
1666 |
|
|
1667 |
new
|
|
1668 |
^ self basicNew initialize
|
|
1669 |
|
|
1670 |
|
|
1671 |
! !
|
|
1672 |
|
47
|
1673 |
!UIObjectView::UndoHistory methodsFor:'accessing'!
|
|
1674 |
|
54
|
1675 |
historySize
|
|
1676 |
^ history size
|
47
|
1677 |
! !
|
|
1678 |
|
|
1679 |
!UIObjectView::UndoHistory methodsFor:'initialization'!
|
|
1680 |
|
|
1681 |
initialize
|
|
1682 |
super initialize.
|
|
1683 |
self reinitialize.
|
|
1684 |
|
|
1685 |
|
|
1686 |
!
|
|
1687 |
|
|
1688 |
reinitialize
|
|
1689 |
"reinitialize all attributes
|
|
1690 |
"
|
54
|
1691 |
history := OrderedCollection new.
|
47
|
1692 |
transaction := nil.
|
54
|
1693 |
enabled := true.
|
47
|
1694 |
|
|
1695 |
|
|
1696 |
! !
|
|
1697 |
|
54
|
1698 |
!UIObjectView::UndoHistory methodsFor:'menu'!
|
|
1699 |
|
|
1700 |
popupMenu
|
|
1701 |
"returns a submenu for undo
|
47
|
1702 |
"
|
54
|
1703 |
|labels|
|
|
1704 |
|
|
1705 |
labels := OrderedCollection new:(history size).
|
|
1706 |
history reverseDo:[:aRecord| labels add:(aRecord asString) ].
|
|
1707 |
|
|
1708 |
^ PopUpMenu labels:labels selectors:#undoLast:.
|
47
|
1709 |
|
|
1710 |
! !
|
|
1711 |
|
|
1712 |
!UIObjectView::UndoHistory methodsFor:'testing'!
|
|
1713 |
|
|
1714 |
isEmpty
|
|
1715 |
"returns true if undo history is empty
|
|
1716 |
"
|
|
1717 |
^ history isEmpty
|
|
1718 |
|
|
1719 |
|
|
1720 |
!
|
|
1721 |
|
|
1722 |
isTransactionOpen
|
|
1723 |
^ (enabled and:[transaction notNil])
|
|
1724 |
!
|
|
1725 |
|
|
1726 |
notEmpty
|
|
1727 |
"returns true if undo history is not empty
|
|
1728 |
"
|
|
1729 |
^ history notEmpty
|
|
1730 |
|
|
1731 |
|
|
1732 |
! !
|
|
1733 |
|
|
1734 |
!UIObjectView::UndoHistory methodsFor:'transaction'!
|
|
1735 |
|
|
1736 |
addUndoBlock:anUndoBlock
|
|
1737 |
"undo block to restore changes; add block to current transaction
|
|
1738 |
"
|
|
1739 |
self isTransactionOpen ifTrue:[
|
54
|
1740 |
transaction add:anUndoBlock
|
47
|
1741 |
]
|
|
1742 |
|
|
1743 |
|
|
1744 |
!
|
|
1745 |
|
|
1746 |
disabledTransitionDo:aBlock
|
|
1747 |
"disable transitions during evaluating the block
|
|
1748 |
"
|
|
1749 |
|oldState|
|
|
1750 |
|
|
1751 |
oldState := enabled.
|
|
1752 |
enabled := false.
|
|
1753 |
aBlock value.
|
|
1754 |
enabled := oldState.
|
|
1755 |
!
|
|
1756 |
|
54
|
1757 |
transaction:aType do:aBlock
|
|
1758 |
self transaction:aType text:nil do:aBlock
|
47
|
1759 |
!
|
|
1760 |
|
54
|
1761 |
transaction:aType text:aTextOrNil do:aBlock
|
47
|
1762 |
"open a transaction; perform the block; at least close the transaction
|
|
1763 |
"
|
54
|
1764 |
(enabled and:[transaction isNil]) ifTrue:[
|
|
1765 |
transaction := Transaction type:aType text:aTextOrNil.
|
|
1766 |
|
47
|
1767 |
aBlock value.
|
54
|
1768 |
|
|
1769 |
transaction isEmpty ifFalse:[
|
|
1770 |
history addLast:transaction.
|
|
1771 |
history size > (self class maxHistorySize) ifTrue:[history removeFirst]
|
|
1772 |
].
|
|
1773 |
transaction := nil
|
|
1774 |
|
|
1775 |
] ifFalse:[
|
47
|
1776 |
aBlock value
|
|
1777 |
]
|
|
1778 |
! !
|
|
1779 |
|
|
1780 |
!UIObjectView::UndoHistory methodsFor:'undo'!
|
|
1781 |
|
|
1782 |
undoLast:nTransactions
|
|
1783 |
"undo last n transactions; an open transaction will be closed;
|
|
1784 |
transactions during undo are disabled
|
|
1785 |
"
|
54
|
1786 |
|n|
|
47
|
1787 |
|
|
1788 |
transaction := nil.
|
|
1789 |
n := nTransactions min:(history size).
|
|
1790 |
|
|
1791 |
n ~~ 0 ifTrue:[
|
|
1792 |
enabled := false.
|
54
|
1793 |
n timesRepeat:[ (history removeLast) undo ].
|
|
1794 |
enabled := true.
|
|
1795 |
]
|
|
1796 |
|
|
1797 |
|
|
1798 |
! !
|
|
1799 |
|
|
1800 |
!UIObjectView::UndoHistory::Transaction class methodsFor:'instance creation'!
|
|
1801 |
|
|
1802 |
type:aType text:aTextOrNil
|
|
1803 |
^ self new type:aType text:aTextOrNil
|
|
1804 |
|
|
1805 |
|
|
1806 |
! !
|
|
1807 |
|
|
1808 |
!UIObjectView::UndoHistory::Transaction methodsFor:'accessing'!
|
|
1809 |
|
|
1810 |
asString
|
|
1811 |
"returns printable string
|
|
1812 |
"
|
|
1813 |
|string|
|
|
1814 |
|
|
1815 |
string := type asString.
|
|
1816 |
|
|
1817 |
text notNil ifTrue:[^ string, ' ', text ]
|
|
1818 |
ifFalse:[^ string ]
|
|
1819 |
!
|
|
1820 |
|
|
1821 |
text
|
|
1822 |
"returns text or nil assigned to transition
|
|
1823 |
"
|
|
1824 |
^ text
|
|
1825 |
!
|
|
1826 |
|
|
1827 |
type
|
|
1828 |
"returns type assigned to transition
|
|
1829 |
"
|
|
1830 |
^ type
|
|
1831 |
!
|
|
1832 |
|
|
1833 |
type:aType
|
|
1834 |
"change type assigned to transition
|
|
1835 |
"
|
|
1836 |
type := aType
|
|
1837 |
! !
|
|
1838 |
|
|
1839 |
!UIObjectView::UndoHistory::Transaction methodsFor:'add & undo'!
|
|
1840 |
|
|
1841 |
add:anUndoBlock
|
|
1842 |
"add an undo action to the transition
|
|
1843 |
"
|
|
1844 |
actions isNil ifTrue:[
|
|
1845 |
actions := anUndoBlock
|
|
1846 |
] ifFalse:[
|
|
1847 |
actions isCollection ifFalse:[
|
|
1848 |
|temp|
|
|
1849 |
|
|
1850 |
temp := OrderedCollection new.
|
|
1851 |
temp add:actions.
|
|
1852 |
actions := temp.
|
47
|
1853 |
].
|
54
|
1854 |
actions add:anUndoBlock.
|
|
1855 |
]
|
|
1856 |
!
|
|
1857 |
|
|
1858 |
undo
|
|
1859 |
"undo transition
|
|
1860 |
"
|
|
1861 |
actions notNil ifTrue:[
|
|
1862 |
actions isCollection ifFalse:[
|
|
1863 |
actions value
|
|
1864 |
] ifTrue:[
|
|
1865 |
actions reverseDo:[:anUndoBlock| anUndoBlock value ]
|
|
1866 |
]
|
47
|
1867 |
]
|
54
|
1868 |
! !
|
|
1869 |
|
|
1870 |
!UIObjectView::UndoHistory::Transaction methodsFor:'initialization'!
|
|
1871 |
|
|
1872 |
type:aType text:aTextOrNil
|
|
1873 |
"initialize transition
|
|
1874 |
"
|
|
1875 |
type := aType.
|
|
1876 |
text := aTextOrNil.
|
|
1877 |
! !
|
|
1878 |
|
|
1879 |
!UIObjectView::UndoHistory::Transaction methodsFor:'testing'!
|
|
1880 |
|
|
1881 |
isEmpty
|
|
1882 |
"returns true if no undo action is registered
|
|
1883 |
"
|
|
1884 |
^ actions isNil
|
|
1885 |
!
|
|
1886 |
|
|
1887 |
notEmpty
|
|
1888 |
"returns true if any undo action is registered
|
|
1889 |
"
|
|
1890 |
^ actions notNil
|
47
|
1891 |
! !
|
|
1892 |
|
51
|
1893 |
!UIObjectView class methodsFor:'documentation'!
|
|
1894 |
|
|
1895 |
version
|
|
1896 |
^ '$Header$'
|
|
1897 |
! !
|