60
|
1 |
ObjectView subclass:#UIObjectView
|
|
2 |
instanceVariableNames:'inputView testMode undoHistory copiedExtent actionData
|
61
|
3 |
createClass clipChildren selectionHiddenLevel
|
|
4 |
setOfSuperViewsSizeChanged'
|
60
|
5 |
classVariableNames:''
|
|
6 |
poolDictionaries:''
|
|
7 |
category:'Interface-UIPainter'
|
|
8 |
!
|
|
9 |
|
|
10 |
Object subclass:#UndoHistory
|
|
11 |
instanceVariableNames:'history transaction enabled'
|
|
12 |
classVariableNames:''
|
|
13 |
poolDictionaries:''
|
|
14 |
privateIn:UIObjectView
|
|
15 |
!
|
|
16 |
|
54
|
17 |
Object subclass:#Transaction
|
|
18 |
instanceVariableNames:'type text actions'
|
|
19 |
classVariableNames:''
|
|
20 |
poolDictionaries:''
|
|
21 |
privateIn:UIObjectView::UndoHistory
|
|
22 |
!
|
|
23 |
|
60
|
24 |
|
63
|
25 |
!UIObjectView class methodsFor:'conversion'!
|
|
26 |
|
|
27 |
asLayoutFrameFromView:aView
|
|
28 |
"convert layout from aView to a frameLayout. On success the frameLayout is
|
|
29 |
returned otherwise nil
|
|
30 |
"
|
68
|
31 |
|lF lO rF rO tF tO bF bO type layout newLyt|
|
|
32 |
|
|
33 |
type := self layoutType:aView.
|
|
34 |
layout := aView geometryLayout.
|
|
35 |
|
|
36 |
(type isNil or:[layout isNil]) ifTrue:[
|
63
|
37 |
^ nil
|
|
38 |
].
|
|
39 |
|
68
|
40 |
type == #LayoutFrame ifTrue:[
|
|
41 |
^ layout copy
|
|
42 |
].
|
|
43 |
|
|
44 |
layout isLayout ifFalse:[
|
|
45 |
type == #Rectangle ifTrue:[
|
63
|
46 |
lO := layout left.
|
|
47 |
tO := layout top.
|
|
48 |
rO := layout right.
|
|
49 |
bO := layout bottom.
|
|
50 |
] ifFalse:[
|
|
51 |
lO := layout x.
|
|
52 |
tO := layout y.
|
|
53 |
rO := lO + aView extent x.
|
|
54 |
bO := tO + aView extent y.
|
|
55 |
].
|
68
|
56 |
|
|
57 |
^ LayoutFrame leftFraction:0 offset:lO rightFraction:0 offset:rO
|
|
58 |
topFraction:0 offset:tO bottomFraction:0 offset:bO
|
63
|
59 |
].
|
|
60 |
|
68
|
61 |
lF := layout leftFraction.
|
|
62 |
lO := layout leftOffset.
|
|
63 |
tF := layout topFraction.
|
|
64 |
tO := layout topOffset.
|
|
65 |
bF := tF.
|
|
66 |
bO := tO + aView extent y.
|
|
67 |
rF := lF.
|
|
68 |
rO := lO + aView extent x.
|
|
69 |
|
|
70 |
newLyt := LayoutFrame leftFraction:lF offset:lO rightFraction:rF offset:rO
|
|
71 |
topFraction:tF offset:tO bottomFraction:bF offset:bO.
|
|
72 |
|
|
73 |
( (type == #AlignmentOrigin)
|
|
74 |
and:[layout leftAlignmentFraction ~~ 0
|
|
75 |
or:[layout topAlignmentFraction ~~ 0]]
|
|
76 |
) ifTrue:[
|
|
77 |
|svRc prBd dlta|
|
|
78 |
|
|
79 |
svRc := aView superView viewRectangle.
|
|
80 |
prBd := aView preferredBounds.
|
|
81 |
dlta := ( ((layout rectangleRelativeTo:svRc preferred:prBd) corner)
|
|
82 |
- ((newLyt rectangleRelativeTo:svRc preferred:prBd) corner)
|
|
83 |
) rounded.
|
|
84 |
|
|
85 |
newLyt leftOffset:(lO + dlta x).
|
|
86 |
newLyt rightOffset:(rO + dlta x).
|
|
87 |
newLyt topOffset:(tO + dlta y).
|
|
88 |
newLyt bottomOffset:(bO + dlta y).
|
|
89 |
].
|
|
90 |
^ newLyt.
|
63
|
91 |
! !
|
|
92 |
|
60
|
93 |
!UIObjectView class methodsFor:'defaults'!
|
|
94 |
|
|
95 |
defaultGrid
|
|
96 |
^ 4 @ 4
|
|
97 |
|
|
98 |
!
|
|
99 |
|
|
100 |
gridShown
|
|
101 |
^ false
|
|
102 |
|
|
103 |
!
|
|
104 |
|
|
105 |
handleSize
|
|
106 |
"size of blob drawn for handles"
|
|
107 |
^ 4
|
|
108 |
|
|
109 |
!
|
|
110 |
|
|
111 |
hitDelta
|
|
112 |
^ 4
|
|
113 |
|
|
114 |
! !
|
|
115 |
|
61
|
116 |
!UIObjectView class methodsFor:'queries'!
|
|
117 |
|
|
118 |
layoutType:aView
|
|
119 |
"returns layout type of aView or nil
|
|
120 |
"
|
|
121 |
|layout spec|
|
|
122 |
|
|
123 |
layout := aView geometryLayout.
|
|
124 |
|
|
125 |
layout notNil ifTrue:[
|
|
126 |
layout isLayout ifTrue:[
|
|
127 |
layout isLayoutFrame ifTrue:[ ^ #LayoutFrame ].
|
67
|
128 |
layout isAlignmentOrigin ifTrue:[ ^ #AlignmentOrigin ].
|
61
|
129 |
layout isLayoutOrigin ifTrue:[ ^ #LayoutOrigin ].
|
|
130 |
] ifFalse:[
|
|
131 |
layout isRectangle ifTrue:[ ^ #Rectangle ].
|
|
132 |
layout isPoint ifTrue:[ ^ #Point ].
|
|
133 |
]
|
|
134 |
] ifFalse:[
|
|
135 |
spec := aView superView specClass.
|
|
136 |
|
|
137 |
spec canResizeSubComponents ifTrue:[ ^ #Extent ].
|
|
138 |
].
|
|
139 |
^ nil
|
|
140 |
|
67
|
141 |
"Modified: 28.2.1997 / 13:02:16 / cg"
|
61
|
142 |
! !
|
|
143 |
|
60
|
144 |
!UIObjectView methodsFor:'accessing'!
|
|
145 |
|
|
146 |
gridAlign
|
61
|
147 |
"returns state of aligning to grid
|
|
148 |
"
|
60
|
149 |
^ aligning
|
|
150 |
|
|
151 |
!
|
|
152 |
|
|
153 |
gridAlign:aBool
|
61
|
154 |
"change state of aligning to grid
|
|
155 |
"
|
60
|
156 |
aBool ifTrue:[self alignOn]
|
|
157 |
ifFalse:[self alignOff]
|
|
158 |
|
|
159 |
!
|
|
160 |
|
|
161 |
gridParameters
|
|
162 |
"used by defineGrid, and in a separate method for
|
|
163 |
easier redefinition in subclasses.
|
|
164 |
Returns the grid parameters in an array of 7 elements,
|
|
165 |
which control the appearance of the grid-pattern.
|
|
166 |
the elements are:
|
|
167 |
|
|
168 |
bigStepH number of pixels horizontally between 2 major steps
|
|
169 |
bigStepV number of pixels vertically between 2 major steps
|
|
170 |
littleStepH number of pixels horizontally between 2 minor steps
|
|
171 |
littleStepV number of pixels vertically between 2 minor steps
|
|
172 |
gridAlignH number of pixels for horizontal grid align (pointer snap)
|
|
173 |
gridAlignV number of pixels for vertical grid align (pointer snap)
|
|
174 |
docBounds true, if document boundary should be shown
|
|
175 |
|
|
176 |
if littleStepH/V are nil, only bigSteps are drawn.
|
|
177 |
"
|
|
178 |
|
|
179 |
^ #(10 10 nil nil 10 10 false)
|
|
180 |
|
|
181 |
|
|
182 |
!
|
|
183 |
|
|
184 |
gridShown:aBool
|
61
|
185 |
"change visibility of grid
|
|
186 |
"
|
60
|
187 |
aBool ifTrue:[self showGrid]
|
|
188 |
ifFalse:[self hideGrid]
|
|
189 |
!
|
|
190 |
|
|
191 |
hideGrid
|
61
|
192 |
"hide grid
|
|
193 |
"
|
60
|
194 |
gridShown ifTrue:[
|
61
|
195 |
self withSelectionHiddenDo:[super hideGrid]
|
60
|
196 |
]
|
|
197 |
|
|
198 |
|
|
199 |
!
|
|
200 |
|
|
201 |
showGrid
|
61
|
202 |
"show grid
|
|
203 |
"
|
|
204 |
self withSelectionHiddenDo:[super showGrid]
|
60
|
205 |
!
|
|
206 |
|
|
207 |
testMode
|
61
|
208 |
"returns true if running test
|
60
|
209 |
"
|
|
210 |
^ testMode
|
|
211 |
|
|
212 |
|
|
213 |
!
|
|
214 |
|
|
215 |
testMode:aBoolean
|
61
|
216 |
"change test mode
|
60
|
217 |
"
|
|
218 |
(aBoolean == testMode) ifFalse:[
|
|
219 |
testMode := aBoolean.
|
|
220 |
|
|
221 |
testMode ifTrue:[
|
|
222 |
self unselect.
|
|
223 |
inputView unrealize
|
|
224 |
] ifFalse:[
|
|
225 |
inputView raise.
|
|
226 |
inputView realize
|
|
227 |
]
|
|
228 |
]
|
|
229 |
|
|
230 |
|
|
231 |
! !
|
|
232 |
|
|
233 |
!UIObjectView methodsFor:'blocked'!
|
|
234 |
|
|
235 |
addObject:anObject
|
61
|
236 |
"add the argument, anObject to the contents - with redraw
|
|
237 |
"
|
60
|
238 |
self halt
|
|
239 |
|
|
240 |
!
|
|
241 |
|
|
242 |
addObjectWithoutRedraw:anObject
|
61
|
243 |
"add the argument, anObject to the contents - with redraw
|
|
244 |
"
|
60
|
245 |
self halt
|
|
246 |
|
|
247 |
! !
|
|
248 |
|
|
249 |
!UIObjectView methodsFor:'event handling'!
|
|
250 |
|
61
|
251 |
elementChangedSize:aView
|
|
252 |
"some element has changed its size; collect them during selectionHiddenLevel
|
|
253 |
is on
|
|
254 |
"
|
|
255 |
selectionHiddenLevel ~~ 0 ifTrue:[
|
|
256 |
setOfSuperViewsSizeChanged add:aView superView
|
|
257 |
] ifFalse:[
|
|
258 |
aView superView sizeChanged:nil
|
|
259 |
]
|
60
|
260 |
!
|
|
261 |
|
|
262 |
exposeX:x y:y width:w height:h
|
|
263 |
"handle an expose event from device; redraw selection
|
|
264 |
"
|
|
265 |
super exposeX:x y:y width:w height:h.
|
61
|
266 |
"/ selectionHiddenLevel == 0 ifTrue:[
|
|
267 |
self selectionDo:[:v | self showSelected:v]
|
|
268 |
"/ ]
|
60
|
269 |
|
|
270 |
!
|
|
271 |
|
|
272 |
keyPress:key x:x y:y
|
61
|
273 |
"any key pressed
|
|
274 |
"
|
78
|
275 |
<resource: #keyboard ( #Delete #BackSpace #Cut #Copy #Paste ) >
|
60
|
276 |
|
|
277 |
(key == #Cut or:[key == #Delete or:[key == #BackSpace]]) ifTrue: [
|
|
278 |
^ self deleteSelection
|
|
279 |
].
|
|
280 |
|
78
|
281 |
key == #Copy ifTrue:[ ^ self copySelection].
|
|
282 |
key == #Paste ifTrue:[ ^ self pasteBuffer].
|
|
283 |
|
60
|
284 |
super keyPress:key x:x y:y
|
|
285 |
|
|
286 |
|
|
287 |
!
|
|
288 |
|
|
289 |
processEvent:anEvent
|
|
290 |
"catch expose events for components, and redraw its handles after
|
|
291 |
the redraw when this happens
|
|
292 |
"
|
|
293 |
|view|
|
|
294 |
|
|
295 |
selection notNil ifTrue:[
|
|
296 |
anEvent type == #damage ifTrue:[
|
|
297 |
view := anEvent view.
|
|
298 |
(selection == view
|
|
299 |
or:[selection isCollection
|
|
300 |
and:[selection includes:view]]) ifTrue:[
|
|
301 |
self showSelected:view
|
|
302 |
]
|
|
303 |
]
|
|
304 |
].
|
|
305 |
^ false.
|
|
306 |
|
|
307 |
|
|
308 |
!
|
|
309 |
|
|
310 |
sizeChanged:how
|
61
|
311 |
"size of a view(s) changed
|
|
312 |
"
|
60
|
313 |
self withSelectionHiddenDo:[
|
|
314 |
super sizeChanged:how
|
|
315 |
]
|
|
316 |
|
|
317 |
|
|
318 |
! !
|
|
319 |
|
|
320 |
!UIObjectView methodsFor:'initialization'!
|
|
321 |
|
|
322 |
initialize
|
61
|
323 |
"setup attributes
|
|
324 |
"
|
60
|
325 |
super initialize.
|
|
326 |
|
|
327 |
"funny: since I do not want the created widgets to get pointer
|
|
328 |
events, I put an InputView on top of them, which catches those events
|
|
329 |
and passes them back to me - have to take care, that this inputView
|
|
330 |
is always on top
|
|
331 |
"
|
|
332 |
inputView := InputView origin:0.0@0.0 extent:1.0@1.0 in:self.
|
61
|
333 |
setOfSuperViewsSizeChanged := IdentitySet new.
|
60
|
334 |
|
|
335 |
inputView eventReceiver:self.
|
|
336 |
inputView enableButtonEvents.
|
|
337 |
inputView enableButtonMotionEvents.
|
|
338 |
|
|
339 |
self setDefaultActions.
|
|
340 |
|
|
341 |
undoHistory := UndoHistory new.
|
|
342 |
testMode := false.
|
|
343 |
clipChildren := true.
|
61
|
344 |
selectionHiddenLevel := 0.
|
60
|
345 |
|
|
346 |
(self class gridShown) ifTrue:[
|
|
347 |
super showGrid
|
|
348 |
].
|
|
349 |
|
|
350 |
!
|
|
351 |
|
|
352 |
realize
|
|
353 |
super realize.
|
|
354 |
self windowGroup postEventHook:self
|
|
355 |
|
|
356 |
! !
|
|
357 |
|
|
358 |
!UIObjectView methodsFor:'misc'!
|
|
359 |
|
|
360 |
cursor:aCursor
|
61
|
361 |
"set cursor
|
|
362 |
"
|
60
|
363 |
inputView realized ifTrue:[
|
|
364 |
inputView cursor:aCursor
|
|
365 |
].
|
|
366 |
super cursor:aCursor
|
|
367 |
|
|
368 |
|
|
369 |
!
|
|
370 |
|
|
371 |
invertOutlineOf:anObject
|
61
|
372 |
"invert outline of an object
|
|
373 |
"
|
60
|
374 |
|wasClipped delta|
|
|
375 |
|
|
376 |
(wasClipped := clipChildren) ifTrue:[
|
|
377 |
self clippedByChildren:(clipChildren := false).
|
|
378 |
].
|
|
379 |
delta := (anObject originRelativeTo:self) - anObject origin.
|
|
380 |
|
|
381 |
self xoring:[
|
|
382 |
self displayRectangle:((anObject origin + delta) extent:anObject extent).
|
|
383 |
].
|
|
384 |
|
|
385 |
wasClipped ifTrue:[
|
|
386 |
self clippedByChildren:(clipChildren := true).
|
|
387 |
].
|
|
388 |
|
|
389 |
"Modified: 5.9.1995 / 12:25:25 / claus"
|
|
390 |
|
|
391 |
|
|
392 |
!
|
|
393 |
|
78
|
394 |
minSetOfSuperViews:setOfViews
|
|
395 |
|
|
396 |
setOfViews isCollection ifFalse:[
|
|
397 |
setOfViews notNil ifTrue:[^ Array with:setOfViews]
|
|
398 |
ifFalse:[^ nil]
|
72
|
399 |
].
|
|
400 |
|
78
|
401 |
^ setOfViews select:[:aView|
|
|
402 |
(setOfViews detect:[:v|aView isComponentOf:v] ifNone:nil) isNil
|
|
403 |
]
|
72
|
404 |
!
|
|
405 |
|
60
|
406 |
setDefaultActions
|
61
|
407 |
"set default actions
|
|
408 |
"
|
60
|
409 |
pressAction := [:pressPoint | self startSelectOrMove:pressPoint].
|
|
410 |
shiftPressAction := [:pressPoint | self startSelectMoreOrMove:pressPoint].
|
|
411 |
motionAction := [:movePoint | nil].
|
|
412 |
releaseAction := [nil].
|
|
413 |
keyPressAction := nil.
|
|
414 |
|
|
415 |
self cursor:Cursor normal.
|
|
416 |
|
|
417 |
! !
|
|
418 |
|
|
419 |
!UIObjectView methodsFor:'object creation'!
|
|
420 |
|
|
421 |
actionCreate:anObject frame:aFrame delta:aDelta
|
|
422 |
"create and initialize action data
|
|
423 |
"
|
|
424 |
|extent x y selectors values|
|
|
425 |
|
|
426 |
"minimum extent
|
|
427 |
"
|
82
|
428 |
(anObject specClass supportsSubComponents) ifTrue:[
|
84
|
429 |
extent := 25@25
|
82
|
430 |
] ifFalse:[
|
|
431 |
extent := self extent.
|
|
432 |
x := extent x // 3.
|
|
433 |
y := extent y // 3.
|
|
434 |
extent := anObject preferredExtent.
|
|
435 |
|
|
436 |
(extent x > x) ifTrue:[extent x:x].
|
|
437 |
(extent y > y) ifTrue:[extent y:y].
|
|
438 |
].
|
60
|
439 |
|
|
440 |
"setup structure
|
|
441 |
"
|
|
442 |
selectors := #( object frame delta vertical horizontal minExtent ).
|
|
443 |
values := Array new:(selectors size).
|
|
444 |
|
|
445 |
values at:1 put:anObject.
|
|
446 |
values at:2 put:aFrame.
|
|
447 |
values at:3 put:aDelta.
|
|
448 |
values at:4 put:(self isVerticalResizable:anObject).
|
|
449 |
values at:5 put:(self isHorizontalResizable:anObject).
|
|
450 |
values at:6 put:extent.
|
|
451 |
|
|
452 |
actionData := Structure newWith:selectors values:values.
|
|
453 |
|
|
454 |
|
|
455 |
"can change cursor dependent on vertical/horizontal resizing
|
|
456 |
"
|
|
457 |
oldCursor := cursor.
|
|
458 |
self cursor:(Cursor leftHand).
|
|
459 |
|
|
460 |
|
|
461 |
|
|
462 |
!
|
|
463 |
|
|
464 |
createWidgetWithClass:aClass
|
|
465 |
"prepare to create new widgets
|
|
466 |
"
|
|
467 |
createClass := aClass.
|
|
468 |
pressAction := [:pressPoint | self startCreate:pressPoint].
|
|
469 |
self cursor:Cursor origin.
|
|
470 |
|
|
471 |
|
|
472 |
!
|
|
473 |
|
|
474 |
doDragCreate:aPoint
|
|
475 |
"do a widget create drag
|
|
476 |
"
|
|
477 |
|frame object extent minimum|
|
|
478 |
|
|
479 |
frame := actionData frame.
|
|
480 |
frame corner:((self alignToGrid:aPoint) - (actionData delta)).
|
|
481 |
|
|
482 |
object := actionData object.
|
|
483 |
minimum := actionData minExtent.
|
|
484 |
extent := frame extent.
|
|
485 |
|
|
486 |
((extent x < minimum x) or:[actionData horizontal not]) ifTrue:[
|
|
487 |
extent x:(minimum x)
|
|
488 |
].
|
|
489 |
|
|
490 |
((extent y < minimum y) or:[actionData vertical not]) ifTrue:[
|
|
491 |
extent y:(minimum y)
|
|
492 |
].
|
|
493 |
|
|
494 |
frame extent:extent.
|
|
495 |
|
|
496 |
self invertOutlineOf:object.
|
|
497 |
object origin:(frame origin) extent:(frame extent).
|
|
498 |
self invertOutlineOf:object.
|
|
499 |
!
|
|
500 |
|
|
501 |
endCreate
|
|
502 |
"end a widget create drag
|
|
503 |
"
|
|
504 |
|layout x y object|
|
|
505 |
|
|
506 |
object := actionData object.
|
|
507 |
self invertOutlineOf:object.
|
|
508 |
inputView raise.
|
|
509 |
|
|
510 |
object superView specClass basicNew setupInitialLayoutFor:object.
|
|
511 |
|
|
512 |
self changed:#tree.
|
|
513 |
self select:object.
|
|
514 |
actionData := nil.
|
|
515 |
|
|
516 |
self setDefaultActions.
|
|
517 |
|
|
518 |
!
|
|
519 |
|
78
|
520 |
initializeCreatedObject:anObject
|
60
|
521 |
self subclassResponsibility
|
|
522 |
!
|
|
523 |
|
|
524 |
startCreate:aPoint
|
|
525 |
"start a widget create
|
|
526 |
"
|
|
527 |
|widget object start frame delta|
|
|
528 |
|
84
|
529 |
self selection notNil ifTrue:[
|
|
530 |
self numberOfSelections > 1 ifTrue:[
|
|
531 |
self warn:'to much elements selected'.
|
|
532 |
^ self setDefaultActions.
|
|
533 |
].
|
|
534 |
self unselect
|
60
|
535 |
].
|
|
536 |
|
84
|
537 |
( (widget := self findObjectAt:aPoint) notNil
|
|
538 |
and:[widget specClass supportsSubComponents]
|
|
539 |
) ifFalse:[
|
60
|
540 |
widget := self
|
|
541 |
].
|
|
542 |
|
|
543 |
motionAction := [:movePoint| self doDragCreate:movePoint].
|
|
544 |
releaseAction := [ self endCreate].
|
|
545 |
|
|
546 |
object := createClass new.
|
76
|
547 |
(widget isKindOf:ScrollableView) ifTrue:[
|
|
548 |
widget scrolledView:object
|
|
549 |
] ifFalse:[
|
|
550 |
widget addSubView:object.
|
|
551 |
].
|
60
|
552 |
|
|
553 |
start := self alignToGrid:aPoint.
|
|
554 |
delta := widget originRelativeTo:self.
|
|
555 |
frame := Rectangle origin:(start - delta) corner:start.
|
|
556 |
|
|
557 |
object origin:(frame origin).
|
78
|
558 |
self initializeCreatedObject:object.
|
82
|
559 |
self actionCreate:object frame:frame delta:delta.
|
|
560 |
object extent:(actionData minExtent).
|
60
|
561 |
object realize.
|
|
562 |
|
|
563 |
self actionCreate:object frame:frame delta:delta.
|
|
564 |
self invertOutlineOf:object.
|
|
565 |
! !
|
|
566 |
|
|
567 |
!UIObjectView methodsFor:'object moving'!
|
|
568 |
|
|
569 |
doObjectMove:aPoint
|
|
570 |
"move selection
|
|
571 |
"
|
|
572 |
movedObject notNil ifTrue:[
|
|
573 |
movedObject keysAndValuesDo:[:nr :aView|
|
|
574 |
self invertOutlineOf:aView.
|
|
575 |
self moveObject:aView to:(aPoint - (moveDelta at:nr)).
|
|
576 |
self invertOutlineOf:aView.
|
|
577 |
]
|
|
578 |
]
|
|
579 |
|
|
580 |
!
|
|
581 |
|
|
582 |
endObjectMove
|
61
|
583 |
"cleanup after object(s) move
|
|
584 |
"
|
60
|
585 |
movedObject notNil ifTrue:[
|
|
586 |
movedObject do:[:aView|
|
|
587 |
self invertOutlineOf:aView
|
|
588 |
].
|
|
589 |
|
|
590 |
movedObject do:[:aView|
|
|
591 |
self showSelected:aView
|
|
592 |
].
|
|
593 |
movedObject size == 1 ifTrue:[
|
|
594 |
selection := movedObject at:1
|
|
595 |
] ifFalse:[
|
|
596 |
selection := movedObject
|
|
597 |
].
|
|
598 |
|
|
599 |
movedObject := nil.
|
|
600 |
self setDefaultActions.
|
|
601 |
self changed:#layout.
|
|
602 |
].
|
|
603 |
!
|
|
604 |
|
|
605 |
moveObject:anObject to:aPoint
|
|
606 |
"move anObject to newOrigin, aPoint
|
|
607 |
"
|
|
608 |
|dX dY org delta|
|
|
609 |
|
|
610 |
anObject notNil ifTrue:[
|
|
611 |
org := anObject computeOrigin.
|
|
612 |
|
|
613 |
delta := aPoint - org.
|
|
614 |
delta := (self alignToGrid:aPoint) - org.
|
|
615 |
dX := delta x.
|
|
616 |
dY := delta y.
|
|
617 |
|
|
618 |
undoHistory disabledTransitionDo:[
|
|
619 |
self shiftLayout:anObject top:dY bottom:dY left:dX right:dX
|
|
620 |
]
|
|
621 |
]
|
|
622 |
|
|
623 |
!
|
|
624 |
|
|
625 |
startObjectMoveAt:aPoint
|
61
|
626 |
"start object(s) move at a point
|
|
627 |
"
|
60
|
628 |
self startObjectMove:selection at:aPoint.
|
|
629 |
|
|
630 |
selection isCollection ifTrue:[
|
|
631 |
movedObject := selection
|
|
632 |
] ifFalse:[
|
|
633 |
movedObject := Array with:selection
|
|
634 |
].
|
|
635 |
super unselect.
|
|
636 |
|
|
637 |
moveDelta := movedObject collect:[:aView|
|
|
638 |
aPoint - aView computeOrigin
|
|
639 |
].
|
|
640 |
|
|
641 |
self transaction:#move objects:movedObject do:[:aView|
|
|
642 |
self invertOutlineOf:aView.
|
|
643 |
self undoLayoutView:aView
|
|
644 |
].
|
|
645 |
|
|
646 |
!
|
|
647 |
|
|
648 |
startSelectMoreOrMove:aPoint
|
|
649 |
"add/remove to/from selection"
|
|
650 |
|
|
651 |
|anObject|
|
|
652 |
|
|
653 |
testMode ifTrue:[^ self].
|
|
654 |
|
|
655 |
anObject := self findObjectAt:aPoint.
|
|
656 |
anObject notNil ifTrue:[
|
|
657 |
(self isSelected:anObject) ifTrue:[
|
|
658 |
self removeFromSelection:anObject
|
|
659 |
] ifFalse:[
|
|
660 |
self addToSelection:anObject
|
|
661 |
]
|
|
662 |
]
|
|
663 |
!
|
|
664 |
|
|
665 |
startSelectOrMove:aPoint
|
61
|
666 |
"a button is pressed at a point; start moving or selection
|
60
|
667 |
"
|
61
|
668 |
|aView b|
|
60
|
669 |
|
|
670 |
testMode ifTrue:[^ self].
|
|
671 |
|
61
|
672 |
aView := self singleSelection.
|
|
673 |
|
|
674 |
aView notNil ifTrue:[
|
|
675 |
(aView superView specClass canResizeSubComponents) ifTrue:[
|
|
676 |
b := self whichHandleOf:aView isHitBy:aPoint.
|
|
677 |
|
|
678 |
(b notNil and:[b ~~ #view]) ifTrue:[
|
|
679 |
^ self startResizeBorder:b of:aView.
|
|
680 |
]
|
60
|
681 |
]
|
|
682 |
].
|
|
683 |
|
61
|
684 |
(aView := self findObjectAt:aPoint) isNil ifTrue:[
|
60
|
685 |
^ self unselect
|
|
686 |
].
|
|
687 |
|
61
|
688 |
(self canMove:aView) ifFalse:[
|
60
|
689 |
super unselect.
|
61
|
690 |
^ self select:aView
|
|
691 |
].
|
|
692 |
|
|
693 |
(self isSelected:aView) ifFalse:[
|
|
694 |
super unselect.
|
|
695 |
self select:aView.
|
60
|
696 |
].
|
|
697 |
|
|
698 |
(self numberOfSelections ~~ 1) ifTrue:[
|
|
699 |
releaseAction := [
|
|
700 |
self setDefaultActions.
|
61
|
701 |
self select:aView
|
60
|
702 |
]
|
|
703 |
] ifFalse:[
|
|
704 |
releaseAction := [self setDefaultActions]
|
|
705 |
].
|
|
706 |
|
|
707 |
"prepare move operation for an object
|
|
708 |
"
|
61
|
709 |
|
60
|
710 |
motionAction := [:movePoint|
|
72
|
711 |
(aPoint dist:movePoint) > 8.0 ifTrue:[
|
60
|
712 |
self startObjectMoveAt:aPoint
|
|
713 |
]
|
|
714 |
].
|
|
715 |
! !
|
|
716 |
|
|
717 |
!UIObjectView methodsFor:'object resize'!
|
|
718 |
|
|
719 |
actionResize:anObject selector:aSelector
|
|
720 |
"create and initialize action for resize
|
|
721 |
"
|
|
722 |
|selector delta|
|
|
723 |
|
|
724 |
delta := anObject container originRelativeTo:self.
|
|
725 |
selector := ('resize:', aSelector, ':') asSymbol.
|
|
726 |
|
|
727 |
actionData := Structure with:(#object->anObject)
|
|
728 |
with:(#selector->selector)
|
|
729 |
with:(#delta->delta).
|
|
730 |
|
|
731 |
"can change cursor dependent on vertical/horizontal resizing
|
|
732 |
"
|
|
733 |
oldCursor := cursor.
|
|
734 |
self cursor:(Cursor leftHand).
|
|
735 |
|
|
736 |
|
|
737 |
|
|
738 |
!
|
|
739 |
|
|
740 |
doDragResize:aPoint
|
61
|
741 |
"do a widget resize drag
|
|
742 |
"
|
60
|
743 |
|p object|
|
|
744 |
|
|
745 |
object := actionData object.
|
|
746 |
|
|
747 |
self invertOutlineOf:object.
|
|
748 |
p := (self alignToGrid:aPoint) - (actionData delta).
|
79
|
749 |
|
60
|
750 |
self perform:(actionData selector) with:object with:p.
|
79
|
751 |
"/ object geometryLayout:(object geometryLayout).
|
60
|
752 |
self invertOutlineOf:object
|
|
753 |
|
|
754 |
!
|
|
755 |
|
|
756 |
endResize
|
61
|
757 |
"cleanup after object resize
|
|
758 |
"
|
|
759 |
|object|
|
|
760 |
|
|
761 |
object := actionData object.
|
|
762 |
actionData := nil.
|
|
763 |
|
|
764 |
self invertOutlineOf:object.
|
60
|
765 |
self setDefaultActions.
|
61
|
766 |
self elementChangedSize:object.
|
|
767 |
super select:object.
|
60
|
768 |
self changed:#layout.
|
|
769 |
!
|
|
770 |
|
|
771 |
startResizeBorder:b of:selection
|
|
772 |
"resize selected view
|
|
773 |
"
|
|
774 |
|object|
|
|
775 |
|
|
776 |
object := self singleSelection.
|
|
777 |
self actionResize:object selector:b.
|
|
778 |
|
72
|
779 |
self transaction:#resize selectionDo:[:aView|
|
60
|
780 |
self undoLayoutView:aView
|
|
781 |
].
|
|
782 |
super unselect.
|
|
783 |
|
|
784 |
motionAction := [:movePoint | self doDragResize:movePoint].
|
|
785 |
releaseAction := [self endResize].
|
|
786 |
self invertOutlineOf:object
|
|
787 |
! !
|
|
788 |
|
|
789 |
!UIObjectView methodsFor:'private handles'!
|
|
790 |
|
61
|
791 |
handlesOf:aView do:aBlock
|
|
792 |
|dlta type v h|
|
|
793 |
|
|
794 |
dlta := (aView originRelativeTo:self) - aView origin.
|
|
795 |
type := self class layoutType:aView.
|
|
796 |
|
|
797 |
(type == #LayoutFrame or:[type == #Rectangle]) ifTrue:[
|
|
798 |
v := self isVerticalResizable:aView.
|
|
799 |
h := self isHorizontalResizable:aView.
|
|
800 |
|
|
801 |
h ifTrue:[ aBlock value:(aView leftCenter + dlta) value:#left.
|
|
802 |
aBlock value:(aView rightCenter + dlta) value:#right.
|
|
803 |
].
|
|
804 |
v ifTrue:[ aBlock value:(aView topCenter + dlta) value:#top.
|
|
805 |
aBlock value:(aView bottomCenter + dlta) value:#bottom.
|
|
806 |
].
|
|
807 |
|
|
808 |
(h and:[v]) ifTrue:[
|
|
809 |
aBlock value:(aView origin + dlta) value:#origin.
|
|
810 |
aBlock value:(aView topRight + dlta) value:#topRight.
|
|
811 |
aBlock value:(aView bottomLeft + dlta) value:#bottomLeft.
|
|
812 |
aBlock value:(aView corner + dlta) value:#corner.
|
|
813 |
^ self
|
|
814 |
]
|
60
|
815 |
].
|
|
816 |
|
61
|
817 |
aBlock value:(aView origin + dlta) value:#view.
|
|
818 |
aBlock value:(aView topRight + dlta) value:#view.
|
|
819 |
aBlock value:(aView bottomLeft + dlta) value:#view.
|
|
820 |
|
|
821 |
type == #Extent ifTrue:[
|
|
822 |
v := self isVerticalResizable:aView.
|
|
823 |
h := self isHorizontalResizable:aView.
|
|
824 |
|
|
825 |
v ifTrue:[aBlock value:(aView bottomCenter + dlta) value:#bottom].
|
|
826 |
h ifTrue:[aBlock value:(aView rightCenter + dlta) value:#right ].
|
|
827 |
|
|
828 |
(h and:[v]) ifTrue:[
|
|
829 |
aBlock value:(aView corner + dlta) value:#corner.
|
|
830 |
^ self
|
|
831 |
]
|
60
|
832 |
].
|
61
|
833 |
aBlock value:(aView corner + dlta) value:#view.
|
60
|
834 |
!
|
|
835 |
|
|
836 |
showSelected:aComponent
|
61
|
837 |
"show object selected
|
|
838 |
"
|
60
|
839 |
|wasClipped delta oldPaint|
|
|
840 |
|
|
841 |
self paint:Color black.
|
|
842 |
|
|
843 |
(wasClipped := clipChildren) ifTrue:[
|
|
844 |
self clippedByChildren:(clipChildren := false).
|
|
845 |
].
|
|
846 |
|
|
847 |
self handlesOf:aComponent do:[:pnt :what |
|
|
848 |
what == #view ifTrue:[self displayRectangle:(pnt - (4@4) extent:7@7)]
|
|
849 |
ifFalse:[self fillRectangle:(pnt - (4@4) extent:7@7)]
|
|
850 |
].
|
|
851 |
|
|
852 |
wasClipped ifTrue:[
|
|
853 |
self clippedByChildren:(clipChildren := true).
|
|
854 |
].
|
|
855 |
self paint:oldPaint.
|
|
856 |
!
|
|
857 |
|
|
858 |
showUnselected:aComponent
|
61
|
859 |
"show object unselected
|
|
860 |
"
|
60
|
861 |
|wasClipped delta r oldPaint|
|
|
862 |
|
|
863 |
r := aComponent origin extent:8@8.
|
|
864 |
|
|
865 |
(wasClipped := clipChildren) ifTrue:[
|
|
866 |
self clippedByChildren:(clipChildren := false).
|
|
867 |
].
|
|
868 |
|
|
869 |
self handlesOf:aComponent do:[:pnt :what |
|
|
870 |
self clearRectangle:(pnt - (4@4) extent:7@7).
|
|
871 |
].
|
|
872 |
|
|
873 |
wasClipped ifTrue:[
|
|
874 |
self clippedByChildren:(clipChildren := true).
|
|
875 |
].
|
|
876 |
|
|
877 |
"/ must redraw all components which are affected b the handles
|
|
878 |
|
|
879 |
r := (aComponent originRelativeTo:self) - (4@4)
|
|
880 |
extent:(aComponent extent + (4@4)).
|
|
881 |
|
|
882 |
subViews do:[:anotherComponent |
|
|
883 |
|absOrg absFrame|
|
|
884 |
|
|
885 |
anotherComponent ~~ inputView ifTrue:[
|
|
886 |
absOrg := anotherComponent originRelativeTo:self.
|
|
887 |
absFrame := absOrg extent:(anotherComponent extent).
|
|
888 |
(absFrame intersects:r) ifTrue:[
|
|
889 |
anotherComponent withAllSubViewsDo:[:v |
|
|
890 |
v clear.
|
|
891 |
v exposeX:0 y:0 width:9999 height:9999.
|
|
892 |
]
|
|
893 |
]
|
|
894 |
]
|
|
895 |
]
|
|
896 |
|
|
897 |
!
|
|
898 |
|
|
899 |
whichHandleOf:aView isHitBy:aPoint
|
61
|
900 |
"returns kind of handle or nil
|
|
901 |
"
|
60
|
902 |
|bounds|
|
|
903 |
|
|
904 |
self handlesOf:aView do:[:pnt :what |
|
|
905 |
((pnt - (4@4) extent:7@7) containsPoint:aPoint) ifTrue:[
|
|
906 |
^ what
|
|
907 |
].
|
|
908 |
].
|
|
909 |
|
|
910 |
^ nil
|
|
911 |
|
|
912 |
"Modified: 5.9.1995 / 14:39:34 / claus"
|
|
913 |
|
|
914 |
! !
|
|
915 |
|
|
916 |
!UIObjectView methodsFor:'private resizing-subviews'!
|
|
917 |
|
|
918 |
resize:aView bottom:aPoint
|
61
|
919 |
"resize a views bottom
|
|
920 |
"
|
60
|
921 |
undoHistory disabledTransitionDo:[
|
|
922 |
self shiftLayout:aView top:0 bottom:((aPoint y) - (aView computeCorner y))
|
|
923 |
]
|
|
924 |
!
|
|
925 |
|
|
926 |
resize:aView bottomLeft:aPoint
|
61
|
927 |
"resize a views bottom and left
|
|
928 |
"
|
60
|
929 |
undoHistory disabledTransitionDo:[
|
|
930 |
self shiftLayout:aView top:0
|
|
931 |
bottom:((aPoint y) - (aView computeCorner y))
|
|
932 |
left:((aPoint x) - (aView computeOrigin x))
|
|
933 |
right:0
|
|
934 |
|
|
935 |
]
|
|
936 |
|
|
937 |
|
|
938 |
!
|
|
939 |
|
|
940 |
resize:aView corner:aPoint
|
61
|
941 |
"resize a views corner
|
|
942 |
"
|
60
|
943 |
|delta|
|
|
944 |
|
|
945 |
delta := aPoint - aView computeCorner.
|
|
946 |
|
|
947 |
undoHistory disabledTransitionDo:[
|
|
948 |
self shiftLayout:aView top:0 bottom:(delta y) left:0 right:(delta x)
|
|
949 |
]
|
|
950 |
!
|
|
951 |
|
|
952 |
resize:aView left:aPoint
|
61
|
953 |
"resize a views left
|
|
954 |
"
|
60
|
955 |
undoHistory disabledTransitionDo:[
|
|
956 |
self shiftLayout:aView left:((aPoint x) - (aView computeOrigin x)) right:0
|
|
957 |
]
|
|
958 |
|
|
959 |
!
|
|
960 |
|
|
961 |
resize:aView origin:aPoint
|
61
|
962 |
"resize a views origin
|
|
963 |
"
|
60
|
964 |
|delta|
|
|
965 |
|
|
966 |
delta := aPoint - aView computeOrigin.
|
|
967 |
|
|
968 |
undoHistory disabledTransitionDo:[
|
|
969 |
self shiftLayout:aView top:(delta y) bottom:0 left:(delta x) right:0
|
|
970 |
]
|
|
971 |
|
|
972 |
!
|
|
973 |
|
|
974 |
resize:aView right:aPoint
|
61
|
975 |
"resize a views right
|
|
976 |
"
|
60
|
977 |
undoHistory disabledTransitionDo:[
|
|
978 |
self shiftLayout:aView left:0 right:((aPoint x) - (aView computeCorner x))
|
|
979 |
]
|
|
980 |
!
|
|
981 |
|
|
982 |
resize:aView top:aPoint
|
61
|
983 |
"resize a views top
|
|
984 |
"
|
60
|
985 |
undoHistory disabledTransitionDo:[
|
|
986 |
self shiftLayout:aView top:((aPoint y) - (aView computeOrigin y)) bottom:0
|
|
987 |
]
|
|
988 |
!
|
|
989 |
|
|
990 |
resize:aView topRight:aPoint
|
61
|
991 |
"resize a views top and right
|
|
992 |
"
|
60
|
993 |
undoHistory disabledTransitionDo:[
|
|
994 |
self shiftLayout:aView top:((aPoint y) - (aView computeOrigin y))
|
|
995 |
bottom:0
|
|
996 |
left:0
|
|
997 |
right:((aPoint x) - (aView computeCorner x))
|
|
998 |
|
|
999 |
]
|
|
1000 |
|
|
1001 |
! !
|
|
1002 |
|
|
1003 |
!UIObjectView methodsFor:'private shift-layout'!
|
|
1004 |
|
|
1005 |
shiftLayout:aView left:l right:r
|
|
1006 |
"shift layout for a view; in case of an open transaction, the undo
|
|
1007 |
action is registered
|
|
1008 |
"
|
|
1009 |
self shiftLayout:aView top:0 bottom:0 left:l right:r
|
|
1010 |
|
|
1011 |
!
|
|
1012 |
|
|
1013 |
shiftLayout:aView top:t bottom:b
|
|
1014 |
"shift layout for a view; in case of an open transaction, the undo
|
|
1015 |
action is registered
|
|
1016 |
"
|
|
1017 |
self shiftLayout:aView top:t bottom:b left:0 right:0
|
|
1018 |
|
|
1019 |
|
|
1020 |
!
|
|
1021 |
|
|
1022 |
shiftLayout:aView top:t bottom:b left:l right:r
|
|
1023 |
"shift layout for a view; in case of an open transaction, the undo
|
|
1024 |
action is registered
|
|
1025 |
"
|
79
|
1026 |
|type layout oldExt|
|
61
|
1027 |
|
|
1028 |
type := self class layoutType:aView.
|
|
1029 |
|
|
1030 |
type notNil ifTrue:[
|
|
1031 |
self undoLayoutView:aView.
|
|
1032 |
|
|
1033 |
type == #Extent ifTrue:[
|
79
|
1034 |
oldExt := aView extent.
|
|
1035 |
aView extent:(oldExt + ((r-l) @ (b-t))).
|
|
1036 |
^ self
|
60
|
1037 |
].
|
61
|
1038 |
|
78
|
1039 |
layout := aView geometryLayout copy.
|
61
|
1040 |
|
|
1041 |
layout isLayout ifTrue:[
|
|
1042 |
layout leftOffset:(layout leftOffset + l)
|
|
1043 |
topOffset:(layout topOffset + t).
|
|
1044 |
|
|
1045 |
type == #LayoutFrame ifTrue:[
|
|
1046 |
layout bottomOffset:(layout bottomOffset + b).
|
|
1047 |
layout rightOffset:(layout rightOffset + r).
|
|
1048 |
]
|
|
1049 |
] ifFalse:[
|
|
1050 |
type == #Rectangle ifTrue:[
|
|
1051 |
layout left:(layout left + l)
|
|
1052 |
right:(layout right + r)
|
|
1053 |
top:(layout top + t)
|
|
1054 |
bottom:(layout bottom + b).
|
|
1055 |
] ifFalse:[ "POINT"
|
|
1056 |
layout x:(layout x + l) y:(layout y + t).
|
|
1057 |
]
|
|
1058 |
].
|
|
1059 |
aView geometryLayout:layout
|
60
|
1060 |
]
|
|
1061 |
! !
|
|
1062 |
|
|
1063 |
!UIObjectView methodsFor:'searching'!
|
|
1064 |
|
|
1065 |
findObjectAt:aPoint
|
|
1066 |
"find the origin/corner of the currentWidget
|
|
1067 |
"
|
|
1068 |
|view viewId lastId point listOfViews|
|
|
1069 |
|
|
1070 |
viewId := rootView id.
|
|
1071 |
point := aPoint + (device translatePoint:0@0 from:(self id) to:viewId).
|
|
1072 |
|
|
1073 |
inputView lower.
|
|
1074 |
|
|
1075 |
[viewId notNil] whileTrue:[
|
|
1076 |
lastId := viewId.
|
|
1077 |
viewId := device viewIdFromPoint:point in:lastId
|
|
1078 |
].
|
|
1079 |
|
|
1080 |
inputView raise.
|
|
1081 |
|
|
1082 |
view := device viewFromId:lastId.
|
|
1083 |
|
|
1084 |
view ~~ inputView ifTrue:[^ view].
|
|
1085 |
|
|
1086 |
"/ look for 'hidden' views ...
|
|
1087 |
|
|
1088 |
listOfViews := OrderedCollection new.
|
|
1089 |
self allSubViewsDo:[:aView |
|
|
1090 |
|org|
|
|
1091 |
|
|
1092 |
aView ~~ inputView ifTrue:[
|
|
1093 |
org := device translatePoint:0@0 from:(aView id) to:self id.
|
|
1094 |
((org extent:aView extent) containsPoint:aPoint) ifTrue:[
|
|
1095 |
listOfViews add:aView.
|
|
1096 |
]
|
|
1097 |
]
|
|
1098 |
].
|
|
1099 |
|
|
1100 |
listOfViews size > 0 ifTrue:[
|
|
1101 |
^ listOfViews last
|
|
1102 |
].
|
|
1103 |
^ nil
|
|
1104 |
|
|
1105 |
|
|
1106 |
!
|
|
1107 |
|
|
1108 |
isPoint:aPoint containedIn:aView
|
|
1109 |
"checks whether a point is covered by a view.
|
|
1110 |
"
|
|
1111 |
|p|
|
|
1112 |
|
|
1113 |
p := device translatePoint:aPoint from:inputView id to:aView id.
|
|
1114 |
|
|
1115 |
(p x >= 0 and:[p y >= 0]) ifTrue:[
|
|
1116 |
p := aView extent - p.
|
|
1117 |
|
|
1118 |
(p x >= 0 and:[p y >= 0]) ifTrue:[
|
|
1119 |
^ true
|
|
1120 |
]
|
|
1121 |
].
|
|
1122 |
^ false
|
|
1123 |
!
|
|
1124 |
|
|
1125 |
whichBorderOf:aView isHitBy:aPoint
|
|
1126 |
|p r bw org|
|
|
1127 |
|
|
1128 |
bw := aView borderWidth.
|
|
1129 |
p := aPoint - (aView superView originRelativeTo:self).
|
|
1130 |
|
|
1131 |
r := Rectangle origin:(aView origin)
|
|
1132 |
extent:(aView width @ bw).
|
|
1133 |
(r containsPoint:p) ifTrue:[^ #top:].
|
|
1134 |
|
|
1135 |
r origin:(aView left @ (aView bottom + bw)) extent:(aView width @ bw).
|
|
1136 |
(r containsPoint:p) ifTrue:[^ #bottom:].
|
|
1137 |
|
|
1138 |
r top:(aView top).
|
|
1139 |
r extent:(bw @ aView height).
|
|
1140 |
(r containsPoint:p) ifTrue:[^ #left:].
|
|
1141 |
|
|
1142 |
r origin:((aView right + bw) @ aView top).
|
|
1143 |
(r containsPoint:p) ifTrue:[^ #right:].
|
|
1144 |
|
|
1145 |
^ nil
|
|
1146 |
|
|
1147 |
|
|
1148 |
! !
|
|
1149 |
|
|
1150 |
!UIObjectView methodsFor:'selections'!
|
|
1151 |
|
|
1152 |
addToSelection:something
|
61
|
1153 |
"add something to selection
|
|
1154 |
"
|
60
|
1155 |
(self canSelect:something) ifTrue:[
|
|
1156 |
super addToSelection:something.
|
|
1157 |
self changed:#selection.
|
|
1158 |
]
|
|
1159 |
!
|
|
1160 |
|
|
1161 |
numberOfSelections
|
61
|
1162 |
"return the number of selected entries
|
|
1163 |
"
|
60
|
1164 |
|sz|
|
|
1165 |
|
|
1166 |
selection isNil ifTrue:[^ 0].
|
|
1167 |
|
|
1168 |
selection isCollection ifTrue:[^ selection size]
|
|
1169 |
ifFalse:[^ 1 ]
|
|
1170 |
!
|
|
1171 |
|
|
1172 |
removeFromSelection:something
|
61
|
1173 |
"remove something from selection
|
|
1174 |
"
|
60
|
1175 |
super removeFromSelection:something.
|
|
1176 |
self changed:#selection
|
|
1177 |
|
|
1178 |
!
|
|
1179 |
|
|
1180 |
select:something
|
61
|
1181 |
"change selection to something
|
|
1182 |
"
|
60
|
1183 |
(self canSelect:something) ifTrue:[
|
|
1184 |
super select:something.
|
|
1185 |
self changed:#selection
|
|
1186 |
]
|
|
1187 |
|
|
1188 |
!
|
|
1189 |
|
|
1190 |
selection
|
61
|
1191 |
"returns selection
|
|
1192 |
"
|
60
|
1193 |
^ selection
|
|
1194 |
|
|
1195 |
|
|
1196 |
!
|
|
1197 |
|
61
|
1198 |
showSelection
|
|
1199 |
selectionHiddenLevel == 0 ifTrue:[
|
|
1200 |
super showSelection.
|
60
|
1201 |
].
|
|
1202 |
!
|
|
1203 |
|
|
1204 |
singleSelection
|
|
1205 |
"returns single selection or nil
|
|
1206 |
"
|
|
1207 |
selection isCollection ifFalse:[
|
|
1208 |
^ selection
|
|
1209 |
].
|
|
1210 |
selection size == 1 ifTrue:[ ^ selection at:1]
|
|
1211 |
ifFalse:[ ^ nil].
|
|
1212 |
!
|
|
1213 |
|
|
1214 |
singleSelectionDo:aBlock
|
61
|
1215 |
"perform block with argument a view in case of one selection
|
|
1216 |
"
|
60
|
1217 |
|view|
|
|
1218 |
|
|
1219 |
(view := self singleSelection) notNil ifTrue:[
|
|
1220 |
aBlock value:view
|
|
1221 |
]
|
|
1222 |
!
|
|
1223 |
|
|
1224 |
unselect
|
61
|
1225 |
"clear selection
|
|
1226 |
"
|
60
|
1227 |
selection notNil ifTrue:[
|
|
1228 |
super unselect.
|
|
1229 |
self changed:#selection
|
|
1230 |
]
|
|
1231 |
|
|
1232 |
!
|
|
1233 |
|
|
1234 |
withSelectionHiddenDo:aBlock
|
61
|
1235 |
"apply block with selection hidden (no handles)
|
|
1236 |
"
|
78
|
1237 |
|coll|
|
|
1238 |
|
61
|
1239 |
selectionHiddenLevel := selectionHiddenLevel + 1.
|
|
1240 |
|
|
1241 |
selectionHiddenLevel == 1 ifTrue:[
|
|
1242 |
self selectionDo:[:aView| self showUnselected:aView].
|
|
1243 |
device flush.
|
|
1244 |
].
|
|
1245 |
|
|
1246 |
aBlock valueNowOrOnUnwindDo:[
|
|
1247 |
selectionHiddenLevel == 1 ifTrue:[
|
|
1248 |
setOfSuperViewsSizeChanged notEmpty ifTrue:[
|
78
|
1249 |
coll := self minSetOfSuperViews:setOfSuperViewsSizeChanged.
|
|
1250 |
coll do:[:aView| aView sizeChanged:nil].
|
61
|
1251 |
setOfSuperViewsSizeChanged := IdentitySet new
|
|
1252 |
].
|
|
1253 |
self selectionDo:[:aView| self showSelected:aView].
|
|
1254 |
].
|
|
1255 |
selectionHiddenLevel := selectionHiddenLevel - 1.
|
|
1256 |
]
|
|
1257 |
|
|
1258 |
!
|
|
1259 |
|
|
1260 |
withoutSelectionDo:aBlock
|
|
1261 |
"evaluate aBlock while selection is nilled
|
|
1262 |
"
|
60
|
1263 |
|sel|
|
|
1264 |
|
|
1265 |
selection isNil ifTrue:[
|
|
1266 |
aBlock value
|
|
1267 |
] ifFalse:[
|
|
1268 |
sel := selection.
|
|
1269 |
super unselect.
|
|
1270 |
aBlock value.
|
|
1271 |
super select:sel
|
|
1272 |
]
|
|
1273 |
|
|
1274 |
|
|
1275 |
! !
|
|
1276 |
|
|
1277 |
!UIObjectView methodsFor:'testing'!
|
|
1278 |
|
|
1279 |
canMove:something
|
61
|
1280 |
"returns always true; all contained views can be moved
|
|
1281 |
"
|
|
1282 |
|sv|
|
|
1283 |
|
|
1284 |
something notNil ifTrue:[
|
|
1285 |
self forEach:something do:[:v|
|
|
1286 |
sv ~~ v superView ifTrue:[
|
|
1287 |
(sv notNil or:[v superView specClass isLayoutContainer]) ifTrue:[
|
|
1288 |
^ false
|
|
1289 |
].
|
|
1290 |
sv := v superView
|
|
1291 |
]
|
|
1292 |
].
|
|
1293 |
^ true
|
|
1294 |
].
|
|
1295 |
^ false
|
60
|
1296 |
|
|
1297 |
!
|
|
1298 |
|
|
1299 |
canPaste:something
|
|
1300 |
"returns true if something could be paste
|
|
1301 |
"
|
|
1302 |
something notNil ifTrue:[
|
|
1303 |
something isCollection ifTrue:[
|
|
1304 |
something notEmpty ifTrue:[
|
|
1305 |
^ (something at:1) isKindOf:UISpecification
|
|
1306 |
]
|
|
1307 |
] ifFalse:[
|
|
1308 |
^ something isKindOf:UISpecification
|
|
1309 |
]
|
|
1310 |
].
|
|
1311 |
^ false
|
|
1312 |
|
|
1313 |
!
|
|
1314 |
|
61
|
1315 |
canPasteInto:something
|
|
1316 |
"can paste into something ?
|
|
1317 |
"
|
|
1318 |
something notNil ifTrue:[
|
|
1319 |
something isCollection ifFalse:[
|
|
1320 |
^ something specClass supportsSubComponents
|
|
1321 |
].
|
|
1322 |
something size == 1 ifTrue:[
|
|
1323 |
^ (something at:1) specClass supportsSubComponents
|
|
1324 |
]
|
|
1325 |
].
|
|
1326 |
^ false
|
|
1327 |
!
|
|
1328 |
|
60
|
1329 |
canSelect:something
|
61
|
1330 |
"returns true if something can be selected and testMode is disabled
|
|
1331 |
"
|
60
|
1332 |
^ (testMode not and:[something ~~ selection])
|
|
1333 |
|
|
1334 |
!
|
|
1335 |
|
|
1336 |
hasUndos
|
|
1337 |
"returns true if undoHistory not empty
|
|
1338 |
"
|
|
1339 |
^ undoHistory notEmpty
|
|
1340 |
!
|
|
1341 |
|
|
1342 |
isHorizontalResizable:aComponent
|
61
|
1343 |
"returns true if instance is horizontal resizeable
|
|
1344 |
"
|
60
|
1345 |
^ self subclassResponsibility
|
|
1346 |
|
|
1347 |
|
|
1348 |
!
|
|
1349 |
|
|
1350 |
isVerticalResizable:aComponent
|
61
|
1351 |
"returns true if instance is vertical resizeable
|
60
|
1352 |
"
|
61
|
1353 |
^ self subclassResponsibility
|
|
1354 |
|
|
1355 |
|
82
|
1356 |
!
|
|
1357 |
|
|
1358 |
supportsLabel:aComponent
|
|
1359 |
"returns true if component supports label
|
|
1360 |
"
|
|
1361 |
^ self subclassResponsibility
|
|
1362 |
|
|
1363 |
|
60
|
1364 |
! !
|
|
1365 |
|
|
1366 |
!UIObjectView methodsFor:'transaction'!
|
|
1367 |
|
|
1368 |
transaction:aType objects:something do:aOneArgBlock
|
|
1369 |
"opens a transaction and evaluates a block within the transaction; the
|
|
1370 |
argument to the block is a view from derived from something
|
|
1371 |
"
|
|
1372 |
self subclassResponsibility
|
|
1373 |
|
|
1374 |
|
|
1375 |
!
|
|
1376 |
|
|
1377 |
transaction:aType selectionDo:aOneArgBlock
|
|
1378 |
"opens a transaction and evaluates a block within the transaction; the
|
|
1379 |
argument to the block is a view from the selection
|
|
1380 |
"
|
|
1381 |
self transaction:aType objects:selection do:aOneArgBlock
|
|
1382 |
|
|
1383 |
|
|
1384 |
!
|
|
1385 |
|
|
1386 |
undoLayoutView:aView
|
|
1387 |
"prepare undo action for a view changing its layout
|
|
1388 |
"
|
|
1389 |
self subclassResponsibility
|
|
1390 |
|
|
1391 |
! !
|
|
1392 |
|
|
1393 |
!UIObjectView methodsFor:'user actions - arrange'!
|
|
1394 |
|
|
1395 |
lowerSelection
|
61
|
1396 |
"lower all objects in the selection
|
|
1397 |
"
|
60
|
1398 |
self selectionDo:[:aView| aView lower ].
|
|
1399 |
|
|
1400 |
|
|
1401 |
!
|
|
1402 |
|
|
1403 |
raiseSelection
|
61
|
1404 |
"raise all objects in the selection
|
|
1405 |
"
|
60
|
1406 |
self selectionDo:[:aView| aView raise ].
|
|
1407 |
inputView raise.
|
|
1408 |
|
|
1409 |
|
|
1410 |
! !
|
|
1411 |
|
|
1412 |
!UIObjectView methodsFor:'user actions - dimension'!
|
|
1413 |
|
|
1414 |
copyExtent
|
61
|
1415 |
"copy the extent from the selected object
|
|
1416 |
"
|
60
|
1417 |
|object|
|
|
1418 |
|
|
1419 |
object := self singleSelection.
|
|
1420 |
|
|
1421 |
object notNil ifTrue:[
|
|
1422 |
copiedExtent := object computeExtent
|
|
1423 |
] ifFalse:[
|
|
1424 |
self warn:'exactly one element must be selected'.
|
|
1425 |
]
|
|
1426 |
|
|
1427 |
|
|
1428 |
|
|
1429 |
!
|
|
1430 |
|
|
1431 |
pasteExtent
|
61
|
1432 |
"paste the copied extent to all objects in the selection
|
|
1433 |
"
|
60
|
1434 |
copiedExtent notNil ifTrue:[
|
72
|
1435 |
self transition:#pasteExtent dimensionDo:[:v|
|
60
|
1436 |
self resize:v corner:(v computeOrigin + copiedExtent)
|
|
1437 |
]
|
|
1438 |
]
|
|
1439 |
!
|
|
1440 |
|
|
1441 |
pasteHeight
|
61
|
1442 |
"paste the copied extent height to all objects in the selection
|
|
1443 |
"
|
60
|
1444 |
copiedExtent notNil ifTrue:[
|
72
|
1445 |
self transition:#pasteHeight dimensionDo:[:v|
|
60
|
1446 |
self resize:v bottom:(v computeOrigin + copiedExtent)
|
|
1447 |
]
|
|
1448 |
]
|
|
1449 |
|
|
1450 |
!
|
|
1451 |
|
|
1452 |
pasteWidth
|
61
|
1453 |
"paste the copied extent width to all objects in the selection
|
|
1454 |
"
|
60
|
1455 |
copiedExtent notNil ifTrue:[
|
72
|
1456 |
self transition:#pasteWidth dimensionDo:[:v|
|
60
|
1457 |
self resize:v right:(v computeOrigin + copiedExtent)
|
|
1458 |
]
|
|
1459 |
]
|
|
1460 |
|
|
1461 |
!
|
|
1462 |
|
|
1463 |
setDimension:aLayout
|
61
|
1464 |
"change layout for all selected objects
|
|
1465 |
"
|
|
1466 |
self transition:#layout dimensionDo:[:v|
|
|
1467 |
v geometryLayout:(aLayout copy)
|
|
1468 |
].
|
|
1469 |
|
|
1470 |
!
|
|
1471 |
|
|
1472 |
setExtent:anExtent
|
|
1473 |
"change extent for all selected objects
|
|
1474 |
"
|
72
|
1475 |
self transition:#extent dimensionDo:[:v|
|
67
|
1476 |
v geometryLayout:nil.
|
61
|
1477 |
v extent:anExtent.
|
67
|
1478 |
].
|
|
1479 |
|
|
1480 |
"Modified: 28.2.1997 / 12:49:00 / cg"
|
60
|
1481 |
!
|
|
1482 |
|
|
1483 |
setToDefaultExtent
|
61
|
1484 |
"change extent of all selected views to their default extent
|
|
1485 |
"
|
72
|
1486 |
self transition:#defaultExtent dimensionDo:[:v|
|
60
|
1487 |
self resize:v corner:(v computeOrigin + (v preferredExtent))
|
|
1488 |
]
|
|
1489 |
|
|
1490 |
!
|
|
1491 |
|
|
1492 |
setToDefaultHeight
|
61
|
1493 |
"change height of all selected views to their default height
|
|
1494 |
"
|
72
|
1495 |
self transition:#defaultHeight dimensionDo:[:v|
|
60
|
1496 |
self resize:v bottom:(v computeOrigin + (v preferredExtent))
|
|
1497 |
]
|
|
1498 |
|
|
1499 |
!
|
|
1500 |
|
|
1501 |
setToDefaultWidth
|
61
|
1502 |
"change width of all selected views to their default width
|
|
1503 |
"
|
72
|
1504 |
self transition:#defaultWidth dimensionDo:[:v|
|
60
|
1505 |
self resize:v right:(v computeOrigin + (v preferredExtent))
|
|
1506 |
]
|
|
1507 |
|
|
1508 |
!
|
|
1509 |
|
|
1510 |
transition:aType dimensionDo:aOneArgBlock
|
|
1511 |
"change dimension within a transaction for the selected elements by evaluating
|
|
1512 |
the block with the argument a view.
|
|
1513 |
"
|
61
|
1514 |
self withSelectionHiddenDo:[
|
60
|
1515 |
self transaction:aType selectionDo:[:aView|
|
61
|
1516 |
(self class layoutType:aView) notNil ifTrue:[
|
|
1517 |
self undoLayoutView:aView.
|
|
1518 |
aOneArgBlock value:aView.
|
|
1519 |
self elementChangedSize:aView.
|
|
1520 |
]
|
|
1521 |
]
|
|
1522 |
].
|
|
1523 |
self changed:#layout
|
|
1524 |
|
60
|
1525 |
! !
|
|
1526 |
|
|
1527 |
!UIObjectView methodsFor:'user actions - move'!
|
|
1528 |
|
|
1529 |
moveSelectionDown:aNumber
|
61
|
1530 |
"move selection down
|
|
1531 |
"
|
60
|
1532 |
|gridY|
|
|
1533 |
|
61
|
1534 |
(self canMove:selection) ifTrue:[
|
|
1535 |
gridAlign notNil ifTrue:[gridY := gridAlign y].
|
|
1536 |
|
|
1537 |
self withSelectionHiddenDo:[
|
72
|
1538 |
self transaction:#moveDown selectionDo:[:aView|
|
61
|
1539 |
|n d|
|
|
1540 |
|
|
1541 |
n := aNumber.
|
|
1542 |
|
|
1543 |
aligning ifTrue:[
|
|
1544 |
d := ((aView computeCorner y) \\ gridY).
|
|
1545 |
n := n * gridY.
|
|
1546 |
|
|
1547 |
d ~~ 0 ifTrue:[
|
|
1548 |
n := n - d + 1.
|
|
1549 |
]
|
|
1550 |
].
|
|
1551 |
self shiftLayout:aView top:n bottom:n
|
|
1552 |
]
|
60
|
1553 |
].
|
|
1554 |
self changed:#layout
|
|
1555 |
]
|
|
1556 |
|
|
1557 |
!
|
|
1558 |
|
|
1559 |
moveSelectionLeft:aNumber
|
|
1560 |
"move selection left
|
|
1561 |
"
|
|
1562 |
|gridX|
|
|
1563 |
|
61
|
1564 |
(self canMove:selection) ifTrue:[
|
|
1565 |
gridAlign notNil ifTrue:[gridX := gridAlign x].
|
|
1566 |
|
|
1567 |
self withSelectionHiddenDo:[
|
72
|
1568 |
self transaction:#moveLeft selectionDo:[:aView|
|
61
|
1569 |
|n d|
|
|
1570 |
|
|
1571 |
n := aNumber.
|
|
1572 |
|
|
1573 |
aligning ifTrue:[
|
|
1574 |
d := ((aView computeOrigin x) \\ gridX).
|
|
1575 |
d ~~ 0 ifTrue:[
|
|
1576 |
n := n-1.
|
|
1577 |
].
|
|
1578 |
n := (n * gridX) + d.
|
60
|
1579 |
].
|
61
|
1580 |
n := n negated.
|
|
1581 |
self shiftLayout:aView left:n right:n
|
|
1582 |
]
|
60
|
1583 |
].
|
|
1584 |
self changed:#layout
|
|
1585 |
]
|
|
1586 |
!
|
|
1587 |
|
|
1588 |
moveSelectionRight:aNumber
|
|
1589 |
"move selection right
|
|
1590 |
"
|
|
1591 |
|gridX|
|
|
1592 |
|
61
|
1593 |
(self canMove:selection) ifTrue:[
|
|
1594 |
gridAlign notNil ifTrue:[gridX := gridAlign x].
|
|
1595 |
|
|
1596 |
self withSelectionHiddenDo:[
|
72
|
1597 |
self transaction:#moveRight selectionDo:[:aView|
|
61
|
1598 |
|n d|
|
|
1599 |
|
|
1600 |
n := aNumber.
|
|
1601 |
|
|
1602 |
aligning ifTrue:[
|
|
1603 |
d := ((aView computeCorner x) \\ gridX).
|
|
1604 |
n := n * gridX.
|
|
1605 |
|
|
1606 |
d ~~ 0 ifTrue:[
|
|
1607 |
n := n - d + 1.
|
|
1608 |
]
|
|
1609 |
].
|
|
1610 |
self shiftLayout:aView left:n right:n
|
|
1611 |
]
|
60
|
1612 |
].
|
|
1613 |
self changed:#layout
|
|
1614 |
]
|
|
1615 |
!
|
|
1616 |
|
|
1617 |
moveSelectionUp:aNumber
|
|
1618 |
"move selection up
|
|
1619 |
"
|
|
1620 |
|gridY|
|
|
1621 |
|
61
|
1622 |
(self canMove:selection) ifTrue:[
|
|
1623 |
gridAlign notNil ifTrue:[gridY := gridAlign y].
|
|
1624 |
|
|
1625 |
self withSelectionHiddenDo:[
|
72
|
1626 |
self transaction:#moveUp selectionDo:[:aView|
|
61
|
1627 |
|n d|
|
|
1628 |
|
|
1629 |
n := aNumber.
|
|
1630 |
|
|
1631 |
aligning ifTrue:[
|
|
1632 |
d := ((aView computeOrigin x) \\ gridY).
|
|
1633 |
d ~~ 0 ifTrue:[
|
|
1634 |
n := n-1.
|
|
1635 |
].
|
|
1636 |
n := (n * gridY) + d.
|
60
|
1637 |
].
|
61
|
1638 |
n := n negated.
|
|
1639 |
self shiftLayout:aView top:n bottom:n
|
|
1640 |
]
|
60
|
1641 |
].
|
|
1642 |
self changed:#layout
|
|
1643 |
]
|
|
1644 |
|
|
1645 |
! !
|
|
1646 |
|
|
1647 |
!UIObjectView methodsFor:'user actions - position'!
|
|
1648 |
|
|
1649 |
alignSelectionBottom
|
61
|
1650 |
"align selection to the bottom of the first object in the selection; in case
|
|
1651 |
of one selection the object is aligned to the bottom of its superview
|
|
1652 |
"
|
63
|
1653 |
|bmost delta|
|
60
|
1654 |
|
61
|
1655 |
(self canMove:selection) ifTrue:[
|
|
1656 |
self withSelectionHiddenDo:[
|
60
|
1657 |
self numberOfSelections > 1 ifTrue:[
|
|
1658 |
bmost := (selection at:1) computeCorner y.
|
|
1659 |
|
72
|
1660 |
self transaction:#alignBottom selectionDo:[:v|
|
60
|
1661 |
(delta := bmost - (v computeCorner y)) ~~ 0 ifTrue:[
|
|
1662 |
self shiftLayout:v top:delta bottom:delta.
|
|
1663 |
]
|
|
1664 |
]
|
|
1665 |
] ifFalse:[
|
72
|
1666 |
self extentToFrame:#Bottom do:[:aLayout|
|
63
|
1667 |
aLayout bottomOffset:0.
|
|
1668 |
aLayout bottomFraction:1.0
|
60
|
1669 |
]
|
|
1670 |
]
|
|
1671 |
].
|
|
1672 |
self changed:#layout
|
|
1673 |
]
|
|
1674 |
|
|
1675 |
|
|
1676 |
|
|
1677 |
!
|
|
1678 |
|
|
1679 |
alignSelectionCenterHor
|
61
|
1680 |
"align selection to the center/horizontal of the first object in the selection; in case
|
|
1681 |
of one selection the object is aligned to the center/horizontal of its superview
|
|
1682 |
"
|
60
|
1683 |
|view center|
|
|
1684 |
|
61
|
1685 |
(self canMove:selection) ifTrue:[
|
|
1686 |
self withSelectionHiddenDo:[
|
60
|
1687 |
view := self singleSelection.
|
|
1688 |
|
|
1689 |
view notNil ifTrue:[
|
|
1690 |
view := view superView.
|
|
1691 |
center := view computeExtent
|
|
1692 |
] ifFalse:[
|
|
1693 |
view := selection at:1.
|
|
1694 |
center := view computeCorner + view computeOrigin.
|
|
1695 |
].
|
|
1696 |
center := center x // 2.
|
|
1697 |
|
72
|
1698 |
self transaction:#alignCenterHorizontal selectionDo:[:v|
|
60
|
1699 |
|newX oldX delta|
|
|
1700 |
|
|
1701 |
oldX := v computeOrigin x.
|
|
1702 |
newX := center - ((v computeCorner x - oldX) // 2).
|
|
1703 |
delta := newX - oldX.
|
|
1704 |
|
|
1705 |
self shiftLayout:v left:delta right:delta
|
61
|
1706 |
]
|
|
1707 |
].
|
|
1708 |
self changed:#layout
|
60
|
1709 |
]
|
|
1710 |
|
|
1711 |
|
|
1712 |
|
|
1713 |
!
|
|
1714 |
|
|
1715 |
alignSelectionCenterVer
|
61
|
1716 |
"align selection to the center/vertical of the first object in the selection; in case
|
|
1717 |
of one selection the object is aligned to the center/vertical of its superview
|
|
1718 |
"
|
60
|
1719 |
|view center|
|
|
1720 |
|
61
|
1721 |
(self canMove:selection) ifTrue:[
|
|
1722 |
self withSelectionHiddenDo:[
|
60
|
1723 |
view := self singleSelection.
|
|
1724 |
|
|
1725 |
view notNil ifTrue:[
|
|
1726 |
view := view superView.
|
|
1727 |
center := view computeExtent
|
|
1728 |
] ifFalse:[
|
|
1729 |
view := selection at:1.
|
|
1730 |
center := view computeCorner + view computeOrigin.
|
|
1731 |
].
|
|
1732 |
center := center y // 2.
|
|
1733 |
|
72
|
1734 |
self transaction:#alignCenterVertical selectionDo:[:v|
|
60
|
1735 |
|newY oldY delta|
|
|
1736 |
|
|
1737 |
oldY := v computeOrigin y.
|
|
1738 |
newY := center - ((v computeCorner y - oldY) // 2).
|
|
1739 |
delta := newY - oldY.
|
|
1740 |
|
|
1741 |
self shiftLayout:v top:delta bottom:delta
|
61
|
1742 |
]
|
|
1743 |
].
|
|
1744 |
self changed:#layout
|
60
|
1745 |
]
|
|
1746 |
!
|
|
1747 |
|
|
1748 |
alignSelectionLeft
|
61
|
1749 |
"align selection to the left of the first object in the selection; in case
|
|
1750 |
of one selection the object is aligned to the left of its superview
|
|
1751 |
"
|
63
|
1752 |
|lmost delta|
|
60
|
1753 |
|
61
|
1754 |
(self canMove:selection) ifTrue:[
|
|
1755 |
self withSelectionHiddenDo:[
|
60
|
1756 |
self numberOfSelections > 1 ifTrue:[
|
|
1757 |
lmost := (selection at:1) computeOrigin x.
|
|
1758 |
|
72
|
1759 |
self transaction:#alignLeft selectionDo:[:v|
|
60
|
1760 |
(delta := lmost - (v computeOrigin x)) ~~ 0 ifTrue:[
|
|
1761 |
self shiftLayout:v left:delta right:delta
|
|
1762 |
]
|
|
1763 |
]
|
|
1764 |
] ifFalse:[
|
72
|
1765 |
self extentToFrame:#Left do:[:aLayout|
|
63
|
1766 |
aLayout leftOffset:0.
|
|
1767 |
aLayout leftFraction:0.0.
|
60
|
1768 |
]
|
|
1769 |
]
|
|
1770 |
].
|
|
1771 |
self changed:#layout
|
|
1772 |
]
|
|
1773 |
!
|
|
1774 |
|
|
1775 |
alignSelectionLeftAndRight
|
61
|
1776 |
"align selection to the left/right of the first object in the selection; in case
|
|
1777 |
of one selection the object is aligned to the left/right of its superview
|
|
1778 |
"
|
63
|
1779 |
|lmost rmost|
|
60
|
1780 |
|
61
|
1781 |
(self canMove:selection) ifTrue:[
|
|
1782 |
self withSelectionHiddenDo:[
|
60
|
1783 |
self numberOfSelections > 1 ifTrue:[
|
|
1784 |
lmost := (selection at:1) computeOrigin x.
|
|
1785 |
rmost := (selection at:1) computeCorner x.
|
|
1786 |
|
72
|
1787 |
self transaction:#alignLeftRight selectionDo:[:aView|
|
|
1788 |
|layout|
|
|
1789 |
layout := self class asLayoutFrameFromView:aView.
|
|
1790 |
|
|
1791 |
layout notNil ifTrue:[
|
|
1792 |
self undoLayoutView:aView.
|
|
1793 |
aView geometryLayout:layout.
|
|
1794 |
|
|
1795 |
undoHistory disabledTransitionDo:[
|
|
1796 |
self shiftLayout:aView left:(lmost - (aView computeOrigin x))
|
|
1797 |
right:(rmost - (aView computeCorner x)).
|
|
1798 |
].
|
|
1799 |
self elementChangedSize:aView
|
|
1800 |
]
|
60
|
1801 |
]
|
|
1802 |
] ifFalse:[
|
72
|
1803 |
self extentToFrame:#LeftRight do:[:aLayout|
|
63
|
1804 |
aLayout leftOffset:0.
|
|
1805 |
aLayout leftFraction:0.0.
|
|
1806 |
aLayout rightOffset:0.
|
|
1807 |
aLayout rightFraction:1.0.
|
60
|
1808 |
]
|
|
1809 |
]
|
|
1810 |
].
|
|
1811 |
self changed:#layout
|
61
|
1812 |
].
|
|
1813 |
|
60
|
1814 |
!
|
|
1815 |
|
|
1816 |
alignSelectionRight
|
61
|
1817 |
"align selection to the right of the first object in the selection; in case
|
|
1818 |
of one selection the object is aligned to the right of its superview
|
|
1819 |
"
|
63
|
1820 |
|rmost delta|
|
60
|
1821 |
|
61
|
1822 |
(self canMove:selection) ifTrue:[
|
|
1823 |
self withSelectionHiddenDo:[
|
60
|
1824 |
self numberOfSelections > 1 ifTrue:[
|
|
1825 |
rmost := (selection at:1) computeCorner x.
|
|
1826 |
|
72
|
1827 |
self transaction:#alignRight selectionDo:[:v|
|
60
|
1828 |
(delta := rmost - (v computeCorner x)) ~~ 0 ifTrue:[
|
|
1829 |
self shiftLayout:v left:delta right:delta
|
|
1830 |
]
|
|
1831 |
]
|
|
1832 |
] ifFalse:[
|
72
|
1833 |
self extentToFrame:#Right do:[:aLayout|
|
63
|
1834 |
aLayout rightOffset:0.
|
|
1835 |
aLayout rightFraction:1.0.
|
60
|
1836 |
]
|
|
1837 |
]
|
|
1838 |
].
|
|
1839 |
self changed:#layout
|
|
1840 |
]
|
|
1841 |
!
|
|
1842 |
|
|
1843 |
alignSelectionTop
|
61
|
1844 |
"align selection to the top of the first object in the selection; in case
|
|
1845 |
of one selection the object is aligned to the top of its superview
|
|
1846 |
"
|
63
|
1847 |
|tmost delta|
|
60
|
1848 |
|
61
|
1849 |
(self canMove:selection) ifTrue:[
|
|
1850 |
self withSelectionHiddenDo:[
|
60
|
1851 |
self numberOfSelections > 1 ifTrue:[
|
|
1852 |
tmost := (selection at:1) computeOrigin y.
|
|
1853 |
|
72
|
1854 |
self transaction:#alignTop selectionDo:[:v|
|
60
|
1855 |
(delta := tmost - (v computeOrigin y)) ~~ 0 ifTrue:[
|
|
1856 |
self shiftLayout:v top:delta bottom:delta
|
|
1857 |
]
|
|
1858 |
]
|
|
1859 |
] ifFalse:[
|
72
|
1860 |
self extentToFrame:#Top do:[:aLayout|
|
63
|
1861 |
aLayout topOffset:0.
|
|
1862 |
aLayout topFraction:0.0.
|
60
|
1863 |
]
|
|
1864 |
]
|
|
1865 |
].
|
|
1866 |
self changed:#layout
|
|
1867 |
]
|
|
1868 |
|
|
1869 |
!
|
|
1870 |
|
|
1871 |
alignSelectionTopAndBottom
|
61
|
1872 |
"align selection to the top/bottom of the first object in the selection; in case
|
|
1873 |
of one selection the object is aligned to the top/bottom of its superview
|
|
1874 |
"
|
63
|
1875 |
|tmost bmost|
|
60
|
1876 |
|
61
|
1877 |
(self canMove:selection) ifTrue:[
|
|
1878 |
self withSelectionHiddenDo:[
|
60
|
1879 |
self numberOfSelections > 1 ifTrue:[
|
|
1880 |
tmost := (selection at:1) computeOrigin y.
|
|
1881 |
bmost := (selection at:1) computeCorner y.
|
|
1882 |
|
72
|
1883 |
self transaction:#alignTopBottom selectionDo:[:aView|
|
|
1884 |
|layout|
|
|
1885 |
layout := self class asLayoutFrameFromView:aView.
|
|
1886 |
|
|
1887 |
layout notNil ifTrue:[
|
|
1888 |
self undoLayoutView:aView.
|
|
1889 |
aView geometryLayout:layout.
|
|
1890 |
|
|
1891 |
undoHistory disabledTransitionDo:[
|
|
1892 |
self shiftLayout:aView top:(tmost - (aView computeOrigin y))
|
|
1893 |
bottom:(bmost - (aView computeCorner y)).
|
|
1894 |
].
|
|
1895 |
self elementChangedSize:aView
|
|
1896 |
]
|
60
|
1897 |
]
|
|
1898 |
] ifFalse:[
|
72
|
1899 |
self extentToFrame:#TopBottom do:[:aLayout|
|
63
|
1900 |
aLayout topOffset:0.
|
|
1901 |
aLayout topFraction:0.0.
|
|
1902 |
aLayout bottomOffset:0.
|
|
1903 |
aLayout bottomFraction:1.0.
|
60
|
1904 |
]
|
|
1905 |
]
|
|
1906 |
].
|
|
1907 |
self changed:#layout
|
|
1908 |
]
|
|
1909 |
!
|
|
1910 |
|
|
1911 |
centerSelection:aOneArgBlockXorY orientation:orientation
|
|
1912 |
"center selection horizontal or vertical dependant on the block result( x or y).
|
|
1913 |
The argument to the block is the point.
|
|
1914 |
"
|
|
1915 |
|superview min max delta val|
|
|
1916 |
|
61
|
1917 |
(self canMove:selection) ifFalse:[
|
|
1918 |
^ self
|
|
1919 |
].
|
|
1920 |
|
|
1921 |
self withSelectionHiddenDo:[
|
60
|
1922 |
max := 0.
|
|
1923 |
|
|
1924 |
self selectionDo:[:aView |
|
|
1925 |
superview isNil ifTrue:[
|
|
1926 |
superview := aView superView
|
|
1927 |
] ifFalse:[
|
|
1928 |
(aView superView == superview) ifFalse:[
|
|
1929 |
^ self notify:'views must have same superview'.
|
|
1930 |
]
|
|
1931 |
].
|
|
1932 |
val := aOneArgBlockXorY value:(aView computeOrigin).
|
|
1933 |
|
|
1934 |
min isNil ifTrue:[min := val]
|
|
1935 |
ifFalse:[min := min min:val].
|
|
1936 |
|
|
1937 |
val := aOneArgBlockXorY value:(aView computeCorner).
|
|
1938 |
max := max max:val.
|
|
1939 |
].
|
|
1940 |
|
|
1941 |
val := aOneArgBlockXorY value:(superview computeExtent).
|
|
1942 |
max := (min + val - max) // 2.
|
|
1943 |
|
|
1944 |
max == min ifFalse:[
|
72
|
1945 |
|type|
|
|
1946 |
(orientation == #y) ifTrue:[type := #centerVertical]
|
|
1947 |
ifFalse:[type := #centerHorizontal].
|
60
|
1948 |
delta := max - min.
|
|
1949 |
|
72
|
1950 |
self transaction:type selectionDo:[:v|
|
60
|
1951 |
orientation == #y ifTrue:[
|
|
1952 |
self shiftLayout:v top:delta bottom:delta
|
|
1953 |
] ifFalse:[
|
|
1954 |
self shiftLayout:v left:delta right:delta
|
|
1955 |
]
|
61
|
1956 |
]
|
|
1957 |
].
|
|
1958 |
self changed:#layout
|
60
|
1959 |
]
|
|
1960 |
|
|
1961 |
|
|
1962 |
!
|
|
1963 |
|
|
1964 |
centerSelectionHor
|
|
1965 |
"center selection horizontal
|
|
1966 |
"
|
|
1967 |
self centerSelection:[:aPoint| aPoint x] orientation:#x
|
|
1968 |
|
|
1969 |
|
|
1970 |
!
|
|
1971 |
|
|
1972 |
centerSelectionVer
|
|
1973 |
"center selection vertical
|
|
1974 |
"
|
|
1975 |
self centerSelection:[:aPoint| aPoint y] orientation:#y
|
|
1976 |
!
|
|
1977 |
|
72
|
1978 |
extentToFrame:toWhat do:aBlock
|
|
1979 |
"align to frame (Left Right ...) and perform the block on a frameLayout
|
|
1980 |
"
|
|
1981 |
|layout type|
|
|
1982 |
|
|
1983 |
type := ('extent', toWhat asString) asSymbol.
|
|
1984 |
|
|
1985 |
self transaction:type selectionDo:[:aView|
|
|
1986 |
layout := self class asLayoutFrameFromView:aView.
|
|
1987 |
|
|
1988 |
layout notNil ifTrue:[
|
|
1989 |
self undoLayoutView:aView.
|
|
1990 |
aBlock value:layout.
|
|
1991 |
aView geometryLayout:layout.
|
|
1992 |
self elementChangedSize:aView.
|
|
1993 |
]
|
|
1994 |
]
|
|
1995 |
!
|
|
1996 |
|
60
|
1997 |
spreadSelectionHor
|
61
|
1998 |
"spread multiple selection horizontal
|
|
1999 |
"
|
60
|
2000 |
|sumWidths min max viewsInOrder topsInOrder count space|
|
|
2001 |
|
61
|
2002 |
(self numberOfSelections > 1 and:[self canMove:selection]) ifFalse:[
|
60
|
2003 |
^ self
|
|
2004 |
].
|
|
2005 |
|
61
|
2006 |
self withSelectionHiddenDo:[
|
60
|
2007 |
count := 0.
|
|
2008 |
sumWidths := 0.
|
|
2009 |
max := 0.
|
|
2010 |
|
|
2011 |
self selectionDo:[:aView |
|
|
2012 |
sumWidths := sumWidths + aView width.
|
|
2013 |
|
|
2014 |
min isNil ifTrue:[min := aView left]
|
|
2015 |
ifFalse:[min := min min:(aView left)].
|
|
2016 |
|
|
2017 |
max := max max:(aView right).
|
|
2018 |
count := count + 1
|
|
2019 |
].
|
|
2020 |
viewsInOrder := Array withAll:selection.
|
|
2021 |
topsInOrder := viewsInOrder collect:[:aView | aView left].
|
|
2022 |
topsInOrder sortWith:viewsInOrder.
|
|
2023 |
|
|
2024 |
space := (((max - min) - sumWidths) / (count - 1)) rounded asInteger.
|
|
2025 |
|
72
|
2026 |
self transaction:#spreadHorizontal objects:viewsInOrder do:[:aView|
|
60
|
2027 |
|delta|
|
|
2028 |
|
|
2029 |
delta := min - aView computeOrigin x.
|
|
2030 |
self shiftLayout:aView left:delta right:delta.
|
|
2031 |
min := min + aView computeExtent x + space
|
61
|
2032 |
]
|
|
2033 |
].
|
|
2034 |
self changed:#layout
|
60
|
2035 |
|
|
2036 |
!
|
|
2037 |
|
|
2038 |
spreadSelectionVer
|
61
|
2039 |
"spread multiple selection vertical
|
|
2040 |
"
|
60
|
2041 |
|sumHeights min max viewsInOrder topsInOrder count space|
|
|
2042 |
|
61
|
2043 |
(self numberOfSelections > 1 and:[self canMove:selection]) ifFalse:[
|
60
|
2044 |
^ self
|
|
2045 |
].
|
|
2046 |
|
61
|
2047 |
self withSelectionHiddenDo:[
|
60
|
2048 |
count := 0.
|
|
2049 |
sumHeights := 0.
|
|
2050 |
max := 0.
|
|
2051 |
|
|
2052 |
self selectionDo:[:aView |
|
|
2053 |
sumHeights := sumHeights + aView height.
|
|
2054 |
|
|
2055 |
min isNil ifTrue:[min := aView top]
|
|
2056 |
ifFalse:[min := min min:(aView top)].
|
|
2057 |
|
|
2058 |
max := max max:(aView bottom).
|
|
2059 |
count := count + 1
|
|
2060 |
].
|
|
2061 |
viewsInOrder := Array withAll:selection.
|
|
2062 |
topsInOrder := viewsInOrder collect:[:aView|aView top].
|
|
2063 |
topsInOrder sortWith:viewsInOrder.
|
|
2064 |
|
|
2065 |
space := (((max - min) - sumHeights) / (count - 1)) rounded asInteger.
|
|
2066 |
|
72
|
2067 |
self transaction:#spreadVertical objects:viewsInOrder do:[:aView|
|
60
|
2068 |
|delta|
|
|
2069 |
|
|
2070 |
delta := min - aView computeOrigin y.
|
|
2071 |
self shiftLayout:aView top:delta bottom:delta.
|
|
2072 |
min := min + aView height + space
|
61
|
2073 |
]
|
|
2074 |
].
|
|
2075 |
self changed:#layout
|
60
|
2076 |
! !
|
|
2077 |
|
|
2078 |
!UIObjectView methodsFor:'user actions - undo history'!
|
|
2079 |
|
72
|
2080 |
enableUndoHistory:aState
|
|
2081 |
"enable or disable undo history
|
|
2082 |
"
|
|
2083 |
undoHistory enabled:aState
|
|
2084 |
!
|
|
2085 |
|
60
|
2086 |
openUndoMenu
|
61
|
2087 |
"open undo menu
|
|
2088 |
"
|
60
|
2089 |
self unselect.
|
61
|
2090 |
|
|
2091 |
self withSelectionHiddenDo:[
|
|
2092 |
undoHistory openUndoMenu
|
|
2093 |
].
|
60
|
2094 |
self changed:#tree
|
|
2095 |
|
|
2096 |
!
|
|
2097 |
|
|
2098 |
removeUndoHistory
|
|
2099 |
"delete total undo history
|
|
2100 |
"
|
|
2101 |
undoHistory reinitialize
|
|
2102 |
!
|
|
2103 |
|
|
2104 |
undoLast
|
61
|
2105 |
"undo last action
|
|
2106 |
"
|
60
|
2107 |
self unselect.
|
61
|
2108 |
|
|
2109 |
self withSelectionHiddenDo:[
|
|
2110 |
undoHistory undoLast:1
|
|
2111 |
].
|
60
|
2112 |
self changed:#tree
|
|
2113 |
! !
|
|
2114 |
|
|
2115 |
!UIObjectView::UndoHistory class methodsFor:'constants'!
|
|
2116 |
|
|
2117 |
maxHistorySize
|
|
2118 |
"returns maximum size of history before removing oldest
|
|
2119 |
record
|
|
2120 |
"
|
|
2121 |
^ 50
|
|
2122 |
|
|
2123 |
|
|
2124 |
! !
|
|
2125 |
|
|
2126 |
!UIObjectView::UndoHistory class methodsFor:'instance creation'!
|
|
2127 |
|
|
2128 |
new
|
|
2129 |
^ self basicNew initialize
|
|
2130 |
|
|
2131 |
|
|
2132 |
! !
|
|
2133 |
|
|
2134 |
!UIObjectView::UndoHistory methodsFor:'accessing'!
|
|
2135 |
|
72
|
2136 |
enabled
|
|
2137 |
^ enabled
|
|
2138 |
!
|
|
2139 |
|
|
2140 |
enabled:aState
|
|
2141 |
enabled := aState
|
|
2142 |
!
|
|
2143 |
|
60
|
2144 |
historySize
|
|
2145 |
^ history size
|
72
|
2146 |
!
|
|
2147 |
|
|
2148 |
lastTypeAsString
|
|
2149 |
"returns type of last undo asString or nil
|
|
2150 |
"
|
|
2151 |
history notEmpty ifTrue:[
|
|
2152 |
^ history last typeAsString
|
|
2153 |
].
|
|
2154 |
^ nil
|
|
2155 |
|
|
2156 |
|
60
|
2157 |
! !
|
|
2158 |
|
|
2159 |
!UIObjectView::UndoHistory methodsFor:'initialization'!
|
|
2160 |
|
|
2161 |
initialize
|
|
2162 |
super initialize.
|
|
2163 |
self reinitialize.
|
|
2164 |
|
|
2165 |
|
|
2166 |
!
|
|
2167 |
|
|
2168 |
reinitialize
|
|
2169 |
"reinitialize all attributes
|
|
2170 |
"
|
|
2171 |
history := OrderedCollection new.
|
|
2172 |
transaction := nil.
|
|
2173 |
enabled := true.
|
|
2174 |
|
|
2175 |
|
|
2176 |
! !
|
|
2177 |
|
|
2178 |
!UIObjectView::UndoHistory methodsFor:'menu'!
|
|
2179 |
|
|
2180 |
openUndoMenu
|
72
|
2181 |
|list tabs top slv hzp inset selection okButton|
|
60
|
2182 |
|
|
2183 |
history isEmpty ifTrue:[
|
|
2184 |
^ self
|
|
2185 |
].
|
|
2186 |
|
|
2187 |
top := StandardSystemView new label:'undo history'; extent:250@350.
|
|
2188 |
slv := ScrollableView for:SelectionInListView origin:0.0@0.0 corner:1.0@1.0 in:top.
|
|
2189 |
hzp := HorizontalPanelView origin:0.0@1.0 corner:1.0@1.0 in:top.
|
|
2190 |
hzp horizontalLayout:#fitSpace.
|
|
2191 |
|
|
2192 |
(Button abortButtonIn:hzp) action:[ selection := nil. top destroy ].
|
|
2193 |
okButton := Button okButtonIn:hzp.
|
|
2194 |
okButton label:'undo to end'.
|
|
2195 |
okButton action:[ top destroy ].
|
|
2196 |
|
|
2197 |
inset := hzp preferredExtent y.
|
|
2198 |
hzp topInset:(inset negated).
|
|
2199 |
slv bottomInset:inset.
|
|
2200 |
slv := slv scrolledView.
|
|
2201 |
|
72
|
2202 |
tabs := TabulatorSpecification new.
|
|
2203 |
tabs unit:#cm.
|
|
2204 |
tabs positions:#(0 5).
|
|
2205 |
tabs align:#(#left ##left).
|
|
2206 |
|
60
|
2207 |
list := history collect:[:aTrans||e|
|
|
2208 |
e := MultiColListEntry new.
|
72
|
2209 |
e colAt:1 put:(aTrans typeAsString).
|
60
|
2210 |
e colAt:2 put:(aTrans text ? '').
|
72
|
2211 |
e tabulatorSpecification:tabs.
|
60
|
2212 |
e
|
|
2213 |
].
|
|
2214 |
|
|
2215 |
slv list:list.
|
|
2216 |
slv action:[:index | selection := index ].
|
|
2217 |
top openModal.
|
|
2218 |
|
|
2219 |
selection notNil ifTrue:[
|
|
2220 |
self undoLast:(history size - selection + 1).
|
|
2221 |
]
|
|
2222 |
! !
|
|
2223 |
|
|
2224 |
!UIObjectView::UndoHistory methodsFor:'testing'!
|
|
2225 |
|
|
2226 |
isEmpty
|
|
2227 |
"returns true if undo history is empty
|
|
2228 |
"
|
|
2229 |
^ history isEmpty
|
|
2230 |
|
|
2231 |
|
|
2232 |
!
|
|
2233 |
|
|
2234 |
isTransactionOpen
|
|
2235 |
^ (enabled and:[transaction notNil])
|
|
2236 |
!
|
|
2237 |
|
|
2238 |
notEmpty
|
|
2239 |
"returns true if undo history is not empty
|
|
2240 |
"
|
|
2241 |
^ history notEmpty
|
|
2242 |
|
|
2243 |
|
|
2244 |
! !
|
|
2245 |
|
|
2246 |
!UIObjectView::UndoHistory methodsFor:'transaction'!
|
|
2247 |
|
|
2248 |
addUndoBlock:anUndoBlock
|
|
2249 |
"undo block to restore changes; add block to current transaction
|
|
2250 |
"
|
|
2251 |
self isTransactionOpen ifTrue:[
|
|
2252 |
transaction add:anUndoBlock
|
|
2253 |
]
|
|
2254 |
|
|
2255 |
|
|
2256 |
!
|
|
2257 |
|
|
2258 |
disabledTransitionDo:aBlock
|
|
2259 |
"disable transitions during evaluating the block
|
|
2260 |
"
|
|
2261 |
|oldState|
|
|
2262 |
|
|
2263 |
oldState := enabled.
|
|
2264 |
enabled := false.
|
|
2265 |
aBlock value.
|
|
2266 |
enabled := oldState.
|
|
2267 |
!
|
|
2268 |
|
|
2269 |
transaction:aType do:aBlock
|
|
2270 |
self transaction:aType text:nil do:aBlock
|
|
2271 |
!
|
|
2272 |
|
|
2273 |
transaction:aType text:aTextOrNil do:aBlock
|
|
2274 |
"open a transaction; perform the block; at least close the transaction
|
|
2275 |
"
|
|
2276 |
(enabled and:[transaction isNil]) ifTrue:[
|
|
2277 |
transaction := Transaction type:aType text:aTextOrNil.
|
|
2278 |
|
|
2279 |
aBlock value.
|
|
2280 |
|
|
2281 |
transaction isEmpty ifFalse:[
|
|
2282 |
history addLast:transaction.
|
|
2283 |
history size > (self class maxHistorySize) ifTrue:[history removeFirst]
|
|
2284 |
].
|
|
2285 |
transaction := nil
|
|
2286 |
|
|
2287 |
] ifFalse:[
|
|
2288 |
aBlock value
|
|
2289 |
]
|
|
2290 |
! !
|
|
2291 |
|
|
2292 |
!UIObjectView::UndoHistory methodsFor:'undo'!
|
|
2293 |
|
|
2294 |
undoLast:nTransactions
|
|
2295 |
"undo last n transactions; an open transaction will be closed;
|
|
2296 |
transactions during undo are disabled
|
|
2297 |
"
|
|
2298 |
|n|
|
|
2299 |
|
|
2300 |
transaction := nil.
|
|
2301 |
n := nTransactions min:(history size).
|
|
2302 |
|
|
2303 |
n ~~ 0 ifTrue:[
|
|
2304 |
enabled := false.
|
|
2305 |
n timesRepeat:[ (history removeLast) undo ].
|
|
2306 |
enabled := true.
|
|
2307 |
]
|
|
2308 |
|
|
2309 |
|
|
2310 |
! !
|
|
2311 |
|
|
2312 |
!UIObjectView::UndoHistory::Transaction class methodsFor:'documentation'!
|
|
2313 |
|
|
2314 |
version
|
|
2315 |
^ '$Header$'
|
|
2316 |
! !
|
|
2317 |
|
54
|
2318 |
!UIObjectView::UndoHistory::Transaction class methodsFor:'instance creation'!
|
|
2319 |
|
|
2320 |
type:aType text:aTextOrNil
|
|
2321 |
^ self new type:aType text:aTextOrNil
|
|
2322 |
|
|
2323 |
|
|
2324 |
! !
|
|
2325 |
|
|
2326 |
!UIObjectView::UndoHistory::Transaction methodsFor:'accessing'!
|
|
2327 |
|
|
2328 |
text
|
|
2329 |
"returns text or nil assigned to transition
|
|
2330 |
"
|
|
2331 |
^ text
|
|
2332 |
!
|
|
2333 |
|
|
2334 |
type
|
|
2335 |
"returns type assigned to transition
|
|
2336 |
"
|
|
2337 |
^ type
|
|
2338 |
!
|
|
2339 |
|
|
2340 |
type:aType
|
|
2341 |
"change type assigned to transition
|
|
2342 |
"
|
|
2343 |
type := aType
|
72
|
2344 |
!
|
|
2345 |
|
|
2346 |
typeAsString
|
|
2347 |
"returns type as printable string
|
|
2348 |
"
|
|
2349 |
|line name size sep|
|
|
2350 |
|
|
2351 |
line := type asString.
|
|
2352 |
size := 0.
|
|
2353 |
line do:[:c| (c isUppercase) ifTrue:[size := size+1] ].
|
|
2354 |
name := String new:(line size + size).
|
|
2355 |
size := 1.
|
|
2356 |
sep := Character space.
|
|
2357 |
|
|
2358 |
line do:[:c|
|
|
2359 |
(c isUppercase) ifFalse:[
|
|
2360 |
name at:size put:c
|
|
2361 |
] ifTrue:[
|
|
2362 |
name at:size put:sep.
|
|
2363 |
sep := $&.
|
|
2364 |
size := size + 1.
|
|
2365 |
name at:size put:(c asLowercase)
|
|
2366 |
].
|
|
2367 |
size := size + 1
|
|
2368 |
].
|
|
2369 |
^ name
|
54
|
2370 |
! !
|
|
2371 |
|
|
2372 |
!UIObjectView::UndoHistory::Transaction methodsFor:'add & undo'!
|
|
2373 |
|
|
2374 |
add:anUndoBlock
|
|
2375 |
"add an undo action to the transition
|
|
2376 |
"
|
|
2377 |
actions isNil ifTrue:[
|
|
2378 |
actions := anUndoBlock
|
|
2379 |
] ifFalse:[
|
|
2380 |
actions isCollection ifFalse:[
|
|
2381 |
|temp|
|
|
2382 |
|
|
2383 |
temp := OrderedCollection new.
|
|
2384 |
temp add:actions.
|
|
2385 |
actions := temp.
|
47
|
2386 |
].
|
54
|
2387 |
actions add:anUndoBlock.
|
|
2388 |
]
|
|
2389 |
!
|
|
2390 |
|
|
2391 |
undo
|
|
2392 |
"undo transition
|
|
2393 |
"
|
|
2394 |
actions notNil ifTrue:[
|
|
2395 |
actions isCollection ifFalse:[
|
|
2396 |
actions value
|
|
2397 |
] ifTrue:[
|
|
2398 |
actions reverseDo:[:anUndoBlock| anUndoBlock value ]
|
|
2399 |
]
|
47
|
2400 |
]
|
54
|
2401 |
! !
|
|
2402 |
|
|
2403 |
!UIObjectView::UndoHistory::Transaction methodsFor:'initialization'!
|
|
2404 |
|
|
2405 |
type:aType text:aTextOrNil
|
|
2406 |
"initialize transition
|
|
2407 |
"
|
|
2408 |
type := aType.
|
|
2409 |
text := aTextOrNil.
|
|
2410 |
! !
|
|
2411 |
|
|
2412 |
!UIObjectView::UndoHistory::Transaction methodsFor:'testing'!
|
|
2413 |
|
|
2414 |
isEmpty
|
|
2415 |
"returns true if no undo action is registered
|
|
2416 |
"
|
|
2417 |
^ actions isNil
|
|
2418 |
!
|
|
2419 |
|
|
2420 |
notEmpty
|
|
2421 |
"returns true if any undo action is registered
|
|
2422 |
"
|
|
2423 |
^ actions notNil
|
47
|
2424 |
! !
|
|
2425 |
|
60
|
2426 |
!UIObjectView class methodsFor:'documentation'!
|
|
2427 |
|
|
2428 |
version
|
|
2429 |
^ '$Header$'
|
|
2430 |
! !
|