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