changeset 61 | 85ef247db6b1 |
parent 60 | 7542ab7fbbfe |
child 63 | 6714daee4b26 |
60:7542ab7fbbfe | 61:85ef247db6b1 |
---|---|
1 'From Smalltalk/X, Version:3.1.4 on 25-feb-1997 at 2:17:24 pm' ! |
|
2 |
|
3 ObjectView subclass:#UIObjectView |
1 ObjectView subclass:#UIObjectView |
4 instanceVariableNames:'inputView testMode undoHistory copiedExtent actionData |
2 instanceVariableNames:'inputView testMode undoHistory copiedExtent actionData |
5 createClass clipChildren' |
3 createClass clipChildren selectionHiddenLevel |
4 setOfSuperViewsSizeChanged' |
|
6 classVariableNames:'' |
5 classVariableNames:'' |
7 poolDictionaries:'' |
6 poolDictionaries:'' |
8 category:'Interface-UIPainter' |
7 category:'Interface-UIPainter' |
9 ! |
8 ! |
10 |
9 |
44 hitDelta |
43 hitDelta |
45 ^ 4 |
44 ^ 4 |
46 |
45 |
47 ! ! |
46 ! ! |
48 |
47 |
48 !UIObjectView class methodsFor:'queries'! |
|
49 |
|
50 layoutType:aView |
|
51 "returns layout type of aView or nil |
|
52 " |
|
53 |layout spec| |
|
54 |
|
55 layout := aView geometryLayout. |
|
56 |
|
57 layout notNil ifTrue:[ |
|
58 layout isLayout ifTrue:[ |
|
59 layout isLayoutFrame ifTrue:[ ^ #LayoutFrame ]. |
|
60 layout isLayoutOrigin ifTrue:[ ^ #LayoutOrigin ]. |
|
61 layout isAlignmentOrigin ifTrue:[ ^ #AlignmentOrigin ]. |
|
62 ] ifFalse:[ |
|
63 layout isRectangle ifTrue:[ ^ #Rectangle ]. |
|
64 layout isPoint ifTrue:[ ^ #Point ]. |
|
65 ] |
|
66 ] ifFalse:[ |
|
67 spec := aView superView specClass. |
|
68 |
|
69 spec canResizeSubComponents ifTrue:[ ^ #Extent ]. |
|
70 ]. |
|
71 ^ nil |
|
72 |
|
73 ! ! |
|
74 |
|
49 !UIObjectView methodsFor:'accessing'! |
75 !UIObjectView methodsFor:'accessing'! |
50 |
76 |
51 gridAlign |
77 gridAlign |
78 "returns state of aligning to grid |
|
79 " |
|
52 ^ aligning |
80 ^ aligning |
53 |
81 |
54 ! |
82 ! |
55 |
83 |
56 gridAlign:aBool |
84 gridAlign:aBool |
85 "change state of aligning to grid |
|
86 " |
|
57 aBool ifTrue:[self alignOn] |
87 aBool ifTrue:[self alignOn] |
58 ifFalse:[self alignOff] |
88 ifFalse:[self alignOff] |
59 |
89 |
60 ! |
90 ! |
61 |
91 |
81 |
111 |
82 |
112 |
83 ! |
113 ! |
84 |
114 |
85 gridShown:aBool |
115 gridShown:aBool |
116 "change visibility of grid |
|
117 " |
|
86 aBool ifTrue:[self showGrid] |
118 aBool ifTrue:[self showGrid] |
87 ifFalse:[self hideGrid] |
119 ifFalse:[self hideGrid] |
88 ! |
120 ! |
89 |
121 |
90 hideGrid |
122 hideGrid |
123 "hide grid |
|
124 " |
|
91 gridShown ifTrue:[ |
125 gridShown ifTrue:[ |
92 self withSelectionHiddenDo:[ |
126 self withSelectionHiddenDo:[super hideGrid] |
93 super hideGrid |
|
94 ] |
|
95 ] |
127 ] |
96 |
128 |
97 |
129 |
98 ! |
130 ! |
99 |
131 |
100 showGrid |
132 showGrid |
101 self withSelectionHiddenDo:[ |
133 "show grid |
102 super showGrid |
134 " |
103 ] |
135 self withSelectionHiddenDo:[super showGrid] |
104 |
|
105 "Modified: 5.9.1995 / 12:47:46 / claus" |
|
106 |
|
107 |
|
108 ! |
136 ! |
109 |
137 |
110 testMode |
138 testMode |
111 "returns testMode |
139 "returns true if running test |
112 " |
140 " |
113 ^ testMode |
141 ^ testMode |
114 |
142 |
115 |
143 |
116 ! |
144 ! |
117 |
145 |
118 testMode:aBoolean |
146 testMode:aBoolean |
119 "change testMode |
147 "change test mode |
120 " |
148 " |
121 (aBoolean == testMode) ifFalse:[ |
149 (aBoolean == testMode) ifFalse:[ |
122 testMode := aBoolean. |
150 testMode := aBoolean. |
123 |
151 |
124 testMode ifTrue:[ |
152 testMode ifTrue:[ |
134 ! ! |
162 ! ! |
135 |
163 |
136 !UIObjectView methodsFor:'blocked'! |
164 !UIObjectView methodsFor:'blocked'! |
137 |
165 |
138 addObject:anObject |
166 addObject:anObject |
139 "add the argument, anObject to the contents - with redraw" |
167 "add the argument, anObject to the contents - with redraw |
140 |
168 " |
141 self halt |
169 self halt |
142 |
170 |
143 ! |
171 ! |
144 |
172 |
145 addObjectWithoutRedraw:anObject |
173 addObjectWithoutRedraw:anObject |
146 "add the argument, anObject to the contents - with redraw" |
174 "add the argument, anObject to the contents - with redraw |
147 |
175 " |
148 self halt |
176 self halt |
149 |
177 |
150 ! ! |
178 ! ! |
151 |
179 |
152 !UIObjectView methodsFor:'event handling'! |
180 !UIObjectView methodsFor:'event handling'! |
153 |
181 |
154 elementChanged:aView |
182 elementChangedSize:aView |
155 "some element has been changed - kludge to force a resizing |
183 "some element has changed its size; collect them during selectionHiddenLevel |
156 operation (for child layout recomputation) in its superView" |
184 is on |
157 |
185 " |
158 aView superView sizeChanged:nil. |
186 selectionHiddenLevel ~~ 0 ifTrue:[ |
159 self changed:#any. |
187 setOfSuperViewsSizeChanged add:aView superView |
160 |
188 ] ifFalse:[ |
161 |
189 aView superView sizeChanged:nil |
162 ! |
190 ] |
163 |
|
164 elementChangedLayout:aView |
|
165 "some element has been changed - kludge to force a resizing |
|
166 operation (for child layout recomputation) in its superView" |
|
167 |
|
168 aView superView sizeChanged:nil. |
|
169 self changed:#layout. |
|
170 |
|
171 |
|
172 ! |
191 ! |
173 |
192 |
174 exposeX:x y:y width:w height:h |
193 exposeX:x y:y width:w height:h |
175 "handle an expose event from device; redraw selection |
194 "handle an expose event from device; redraw selection |
176 " |
195 " |
177 super exposeX:x y:y width:w height:h. |
196 super exposeX:x y:y width:w height:h. |
178 self selectionDo:[:v | self showSelected:v] |
197 "/ selectionHiddenLevel == 0 ifTrue:[ |
179 |
198 self selectionDo:[:v | self showSelected:v] |
199 "/ ] |
|
180 |
200 |
181 ! |
201 ! |
182 |
202 |
183 keyPress:key x:x y:y |
203 keyPress:key x:x y:y |
204 "any key pressed |
|
205 " |
|
184 <resource: #keyboard ( #InspectIt #Delete #BackSpace #Cut) > |
206 <resource: #keyboard ( #InspectIt #Delete #BackSpace #Cut) > |
185 |
207 |
186 key == #InspectIt ifTrue:[ |
208 key == #InspectIt ifTrue:[ |
187 ^ self inspectSelection |
209 ^ self inspectSelection |
188 ]. |
210 ]. |
216 |
238 |
217 |
239 |
218 ! |
240 ! |
219 |
241 |
220 sizeChanged:how |
242 sizeChanged:how |
243 "size of a view(s) changed |
|
244 " |
|
221 self withSelectionHiddenDo:[ |
245 self withSelectionHiddenDo:[ |
222 super sizeChanged:how |
246 super sizeChanged:how |
223 ] |
247 ] |
224 |
248 |
225 |
249 |
226 ! ! |
250 ! ! |
227 |
251 |
228 !UIObjectView methodsFor:'initialization'! |
252 !UIObjectView methodsFor:'initialization'! |
229 |
253 |
230 initialize |
254 initialize |
255 "setup attributes |
|
256 " |
|
231 super initialize. |
257 super initialize. |
232 |
258 |
233 "funny: since I do not want the created widgets to get pointer |
259 "funny: since I do not want the created widgets to get pointer |
234 events, I put an InputView on top of them, which catches those events |
260 events, I put an InputView on top of them, which catches those events |
235 and passes them back to me - have to take care, that this inputView |
261 and passes them back to me - have to take care, that this inputView |
236 is always on top |
262 is always on top |
237 " |
263 " |
238 inputView := InputView origin:0.0@0.0 extent:1.0@1.0 in:self. |
264 inputView := InputView origin:0.0@0.0 extent:1.0@1.0 in:self. |
265 setOfSuperViewsSizeChanged := IdentitySet new. |
|
239 |
266 |
240 inputView eventReceiver:self. |
267 inputView eventReceiver:self. |
241 inputView enableButtonEvents. |
268 inputView enableButtonEvents. |
242 inputView enableButtonMotionEvents. |
269 inputView enableButtonMotionEvents. |
243 |
270 |
244 self setDefaultActions. |
271 self setDefaultActions. |
245 |
272 |
246 undoHistory := UndoHistory new. |
273 undoHistory := UndoHistory new. |
247 testMode := false. |
274 testMode := false. |
248 clipChildren := true. |
275 clipChildren := true. |
276 selectionHiddenLevel := 0. |
|
249 |
277 |
250 (self class gridShown) ifTrue:[ |
278 (self class gridShown) ifTrue:[ |
251 super showGrid |
279 super showGrid |
252 ]. |
280 ]. |
253 |
281 |
260 ! ! |
288 ! ! |
261 |
289 |
262 !UIObjectView methodsFor:'misc'! |
290 !UIObjectView methodsFor:'misc'! |
263 |
291 |
264 cursor:aCursor |
292 cursor:aCursor |
293 "set cursor |
|
294 " |
|
265 inputView realized ifTrue:[ |
295 inputView realized ifTrue:[ |
266 inputView cursor:aCursor |
296 inputView cursor:aCursor |
267 ]. |
297 ]. |
268 super cursor:aCursor |
298 super cursor:aCursor |
269 |
299 |
270 |
300 |
271 ! |
301 ! |
272 |
302 |
273 invertOutlineOf:anObject |
303 invertOutlineOf:anObject |
304 "invert outline of an object |
|
305 " |
|
274 |wasClipped delta| |
306 |wasClipped delta| |
275 |
307 |
276 (wasClipped := clipChildren) ifTrue:[ |
308 (wasClipped := clipChildren) ifTrue:[ |
277 self clippedByChildren:(clipChildren := false). |
309 self clippedByChildren:(clipChildren := false). |
278 ]. |
310 ]. |
290 |
322 |
291 |
323 |
292 ! |
324 ! |
293 |
325 |
294 setDefaultActions |
326 setDefaultActions |
295 |
327 "set default actions |
328 " |
|
296 pressAction := [:pressPoint | self startSelectOrMove:pressPoint]. |
329 pressAction := [:pressPoint | self startSelectOrMove:pressPoint]. |
297 shiftPressAction := [:pressPoint | self startSelectMoreOrMove:pressPoint]. |
330 shiftPressAction := [:pressPoint | self startSelectMoreOrMove:pressPoint]. |
298 motionAction := [:movePoint | nil]. |
331 motionAction := [:movePoint | nil]. |
299 releaseAction := [nil]. |
332 releaseAction := [nil]. |
300 keyPressAction := nil. |
333 keyPressAction := nil. |
301 |
334 |
302 self cursor:Cursor normal. |
335 self cursor:Cursor normal. |
303 |
336 |
304 ! |
|
305 |
|
306 showDragging:something offset:anOffset |
|
307 "drag around a View" |
|
308 |
|
309 |top| |
|
310 |
|
311 self forEach:something do:[:anObject | |
|
312 self drawRectangle:((anObject origin + anOffset) extent:(anObject extent)) |
|
313 ] |
|
314 |
|
315 ! ! |
337 ! ! |
316 |
338 |
317 !UIObjectView methodsFor:'object creation'! |
339 !UIObjectView methodsFor:'object creation'! |
318 |
|
319 XXstartCreate:aPoint |
|
320 "start a widget create |
|
321 " |
|
322 |widget object start frame delta| |
|
323 |
|
324 (createClass isNil or:[self numberOfSelections > 1]) ifTrue:[ |
|
325 self unselect. |
|
326 ^ self setDefaultActions. |
|
327 ]. |
|
328 |
|
329 motionAction := [:movePoint| self doDragCreate:movePoint]. |
|
330 releaseAction := [ self endCreate]. |
|
331 |
|
332 widget := self singleSelection. |
|
333 |
|
334 ( widget notNil |
|
335 and:[(self isPoint:aPoint containedIn:widget) |
|
336 and:[self supportsSubComponents:widget]] |
|
337 ) ifFalse:[ |
|
338 self unselect. |
|
339 widget := self. |
|
340 ]. |
|
341 |
|
342 object := createClass new. |
|
343 widget addSubView:object. |
|
344 |
|
345 start := self alignToGrid:aPoint. |
|
346 delta := widget originRelativeTo:self. |
|
347 frame := Rectangle origin:(start - delta) corner:start. |
|
348 |
|
349 object origin:(frame origin). |
|
350 self setupCreatedObject:object. |
|
351 object realize. |
|
352 |
|
353 self actionCreate:object frame:frame delta:delta. |
|
354 self invertOutlineOf:object. |
|
355 |
|
356 |
|
357 ! |
|
358 |
340 |
359 actionCreate:anObject frame:aFrame delta:aDelta |
341 actionCreate:anObject frame:aFrame delta:aDelta |
360 "create and initialize action data |
342 "create and initialize action data |
361 " |
343 " |
362 |extent x y selectors values| |
344 |extent x y selectors values| |
469 self unselect. |
451 self unselect. |
470 |
452 |
471 (self isPoint:aPoint containedIn:widget) ifFalse:[ |
453 (self isPoint:aPoint containedIn:widget) ifFalse:[ |
472 widget := self |
454 widget := self |
473 ] ifTrue:[ |
455 ] ifTrue:[ |
474 (self supportsSubComponents:widget) ifFalse:[ |
456 widget specClass supportsSubComponents ifFalse:[ |
475 ^ self setDefaultActions. |
457 ^ self setDefaultActions. |
476 ] |
458 ] |
477 ] |
459 ] |
478 ] ifFalse:[ |
460 ] ifFalse:[ |
479 widget := self |
461 widget := self |
513 ] |
495 ] |
514 |
496 |
515 ! |
497 ! |
516 |
498 |
517 endObjectMove |
499 endObjectMove |
518 "cleanup after object move" |
500 "cleanup after object(s) move |
519 |
501 " |
520 movedObject notNil ifTrue:[ |
502 movedObject notNil ifTrue:[ |
521 movedObject do:[:aView| |
503 movedObject do:[:aView| |
522 self invertOutlineOf:aView |
504 self invertOutlineOf:aView |
523 ]. |
505 ]. |
524 |
506 |
556 ] |
538 ] |
557 |
539 |
558 ! |
540 ! |
559 |
541 |
560 startObjectMoveAt:aPoint |
542 startObjectMoveAt:aPoint |
561 |
543 "start object(s) move at a point |
544 " |
|
562 self startObjectMove:selection at:aPoint. |
545 self startObjectMove:selection at:aPoint. |
563 |
546 |
564 selection isCollection ifTrue:[ |
547 selection isCollection ifTrue:[ |
565 movedObject := selection |
548 movedObject := selection |
566 ] ifFalse:[ |
549 ] ifFalse:[ |
595 ] |
578 ] |
596 ] |
579 ] |
597 ! |
580 ! |
598 |
581 |
599 startSelectOrMove:aPoint |
582 startSelectOrMove:aPoint |
600 "a button is pressed at a point |
583 "a button is pressed at a point; start moving or selection |
601 " |
584 " |
602 |anObject b| |
585 |aView b| |
603 |
586 |
604 testMode ifTrue:[^ self]. |
587 testMode ifTrue:[^ self]. |
605 |
588 |
606 "if there is one object selected and point hits a handle, start a resize |
589 aView := self singleSelection. |
607 " |
590 |
608 anObject := self singleSelection. |
591 aView notNil ifTrue:[ |
609 |
592 (aView superView specClass canResizeSubComponents) ifTrue:[ |
610 anObject notNil ifTrue:[ |
593 b := self whichHandleOf:aView isHitBy:aPoint. |
611 b := self whichHandleOf:anObject isHitBy:aPoint. |
594 |
612 |
595 (b notNil and:[b ~~ #view]) ifTrue:[ |
613 (b notNil and:[b ~~ #view]) ifTrue:[ |
596 ^ self startResizeBorder:b of:aView. |
614 ^ self startResizeBorder:b of:anObject. |
597 ] |
615 ] |
598 ] |
616 ]. |
599 ]. |
617 |
600 |
618 anObject := self findObjectAt:aPoint. |
601 (aView := self findObjectAt:aPoint) isNil ifTrue:[ |
619 |
|
620 "nothing is selected |
|
621 " |
|
622 anObject isNil ifTrue:[ |
|
623 ^ self unselect |
602 ^ self unselect |
624 ]. |
603 ]. |
625 |
604 |
626 (self isSelected:anObject) ifFalse:[ |
605 (self canMove:aView) ifFalse:[ |
627 super unselect. |
606 super unselect. |
628 self select:anObject. |
607 ^ self select:aView |
608 ]. |
|
609 |
|
610 (self isSelected:aView) ifFalse:[ |
|
611 super unselect. |
|
612 self select:aView. |
|
629 ]. |
613 ]. |
630 |
614 |
631 (self numberOfSelections ~~ 1) ifTrue:[ |
615 (self numberOfSelections ~~ 1) ifTrue:[ |
632 releaseAction := [ |
616 releaseAction := [ |
633 self setDefaultActions. |
617 self setDefaultActions. |
634 self select:anObject |
618 self select:aView |
635 ] |
619 ] |
636 ] ifFalse:[ |
620 ] ifFalse:[ |
637 releaseAction := [self setDefaultActions] |
621 releaseAction := [self setDefaultActions] |
638 ]. |
622 ]. |
639 |
623 |
640 "prepare move operation for an object |
624 "prepare move operation for an object |
641 " |
625 " |
626 |
|
642 motionAction := [:movePoint| |
627 motionAction := [:movePoint| |
643 (aPoint dist:movePoint) > 4.0 ifTrue:[ |
628 (aPoint dist:movePoint) > 4.0 ifTrue:[ |
644 self startObjectMoveAt:aPoint |
629 self startObjectMoveAt:aPoint |
645 ] |
630 ] |
646 ]. |
631 ]. |
668 |
653 |
669 |
654 |
670 ! |
655 ! |
671 |
656 |
672 doDragResize:aPoint |
657 doDragResize:aPoint |
673 "do a widget resize drag" |
658 "do a widget resize drag |
674 |
659 " |
675 |p object| |
660 |p object| |
676 |
661 |
677 object := actionData object. |
662 object := actionData object. |
678 |
663 |
679 self invertOutlineOf:object. |
664 self invertOutlineOf:object. |
683 self invertOutlineOf:object |
668 self invertOutlineOf:object |
684 |
669 |
685 ! |
670 ! |
686 |
671 |
687 endResize |
672 endResize |
688 "cleanup after object resize" |
673 "cleanup after object resize |
689 |
674 " |
690 self invertOutlineOf:(actionData object). |
675 |object| |
676 |
|
677 object := actionData object. |
|
678 actionData := nil. |
|
679 |
|
680 self invertOutlineOf:object. |
|
691 self setDefaultActions. |
681 self setDefaultActions. |
692 super select:(actionData object). |
682 self elementChangedSize:object. |
683 super select:object. |
|
693 self changed:#layout. |
684 self changed:#layout. |
694 actionData := nil |
|
695 ! |
685 ! |
696 |
686 |
697 startResizeBorder:b of:selection |
687 startResizeBorder:b of:selection |
698 "resize selected view |
688 "resize selected view |
699 " |
689 " |
700 |object| |
690 |object| |
701 |
691 |
702 object := self singleSelection. |
692 object := self singleSelection. |
703 |
|
704 (object geometryLayout) isNil ifTrue:[ |
|
705 ^ self setDefaultActions. |
|
706 ]. |
|
707 |
|
708 self actionResize:object selector:b. |
693 self actionResize:object selector:b. |
709 |
694 |
710 self transaction:#extent selectionDo:[:aView| |
695 self transaction:#extent selectionDo:[:aView| |
711 self undoLayoutView:aView |
696 self undoLayoutView:aView |
712 ]. |
697 ]. |
717 self invertOutlineOf:object |
702 self invertOutlineOf:object |
718 ! ! |
703 ! ! |
719 |
704 |
720 !UIObjectView methodsFor:'private handles'! |
705 !UIObjectView methodsFor:'private handles'! |
721 |
706 |
722 handlesOf:aComponent do:aBlock |
707 handlesOf:aView do:aBlock |
723 |delta layout vertical horizontal| |
708 |dlta type v h| |
724 |
709 |
725 layout := aComponent geometryLayout. |
710 dlta := (aView originRelativeTo:self) - aView origin. |
726 delta := (aComponent originRelativeTo:self) - aComponent origin. |
711 type := self class layoutType:aView. |
727 |
712 |
728 (layout isLayout not or:[layout isLayoutFrame]) ifTrue:[ |
713 (type == #LayoutFrame or:[type == #Rectangle]) ifTrue:[ |
729 vertical := self isVerticalResizable:aComponent. |
714 v := self isVerticalResizable:aView. |
730 horizontal := self isHorizontalResizable:aComponent. |
715 h := self isHorizontalResizable:aView. |
731 ] ifFalse:[ |
716 |
732 vertical := false. |
717 h ifTrue:[ aBlock value:(aView leftCenter + dlta) value:#left. |
733 horizontal := false. |
718 aBlock value:(aView rightCenter + dlta) value:#right. |
734 ]. |
719 ]. |
735 |
720 v ifTrue:[ aBlock value:(aView topCenter + dlta) value:#top. |
736 horizontal ifTrue:[ |
721 aBlock value:(aView bottomCenter + dlta) value:#bottom. |
737 aBlock value:(aComponent leftCenter + delta) value:#left. |
722 ]. |
738 aBlock value:(aComponent rightCenter + delta) value:#right. |
723 |
739 ]. |
724 (h and:[v]) ifTrue:[ |
740 |
725 aBlock value:(aView origin + dlta) value:#origin. |
741 vertical ifTrue:[ |
726 aBlock value:(aView topRight + dlta) value:#topRight. |
742 aBlock value:(aComponent topCenter + delta) value:#top. |
727 aBlock value:(aView bottomLeft + dlta) value:#bottomLeft. |
743 aBlock value:(aComponent bottomCenter + delta) value:#bottom. |
728 aBlock value:(aView corner + dlta) value:#corner. |
744 ]. |
729 ^ self |
745 |
730 ] |
746 (horizontal and:[vertical]) ifTrue:[ |
731 ]. |
747 aBlock value:(aComponent origin + delta) value:#origin. |
732 |
748 aBlock value:(aComponent corner + delta) value:#corner. |
733 aBlock value:(aView origin + dlta) value:#view. |
749 aBlock value:(aComponent topRight + delta) value:#topRight. |
734 aBlock value:(aView topRight + dlta) value:#view. |
750 aBlock value:(aComponent bottomLeft + delta) value:#bottomLeft. |
735 aBlock value:(aView bottomLeft + dlta) value:#view. |
751 ] ifFalse:[ |
736 |
752 aBlock value:(aComponent origin + delta) value:#view. |
737 type == #Extent ifTrue:[ |
753 aBlock value:(aComponent corner + delta) value:#view. |
738 v := self isVerticalResizable:aView. |
754 aBlock value:(aComponent topRight + delta) value:#view. |
739 h := self isHorizontalResizable:aView. |
755 aBlock value:(aComponent bottomLeft + delta) value:#view. |
740 |
756 ]. |
741 v ifTrue:[aBlock value:(aView bottomCenter + dlta) value:#bottom]. |
757 |
742 h ifTrue:[aBlock value:(aView rightCenter + dlta) value:#right ]. |
743 |
|
744 (h and:[v]) ifTrue:[ |
|
745 aBlock value:(aView corner + dlta) value:#corner. |
|
746 ^ self |
|
747 ] |
|
748 ]. |
|
749 aBlock value:(aView corner + dlta) value:#view. |
|
758 ! |
750 ! |
759 |
751 |
760 showSelected:aComponent |
752 showSelected:aComponent |
753 "show object selected |
|
754 " |
|
761 |wasClipped delta oldPaint| |
755 |wasClipped delta oldPaint| |
762 |
756 |
763 self paint:Color black. |
757 self paint:Color black. |
764 |
758 |
765 (wasClipped := clipChildren) ifTrue:[ |
759 (wasClipped := clipChildren) ifTrue:[ |
776 ]. |
770 ]. |
777 self paint:oldPaint. |
771 self paint:oldPaint. |
778 ! |
772 ! |
779 |
773 |
780 showUnselected:aComponent |
774 showUnselected:aComponent |
775 "show object unselected |
|
776 " |
|
781 |wasClipped delta r oldPaint| |
777 |wasClipped delta r oldPaint| |
782 |
778 |
783 r := aComponent origin extent:8@8. |
779 r := aComponent origin extent:8@8. |
784 |
780 |
785 (wasClipped := clipChildren) ifTrue:[ |
781 (wasClipped := clipChildren) ifTrue:[ |
815 ] |
811 ] |
816 |
812 |
817 ! |
813 ! |
818 |
814 |
819 whichHandleOf:aView isHitBy:aPoint |
815 whichHandleOf:aView isHitBy:aPoint |
816 "returns kind of handle or nil |
|
817 " |
|
820 |bounds| |
818 |bounds| |
821 |
819 |
822 self handlesOf:aView do:[:pnt :what | |
820 self handlesOf:aView do:[:pnt :what | |
823 ((pnt - (4@4) extent:7@7) containsPoint:aPoint) ifTrue:[ |
821 ((pnt - (4@4) extent:7@7) containsPoint:aPoint) ifTrue:[ |
824 ^ what |
822 ^ what |
832 ! ! |
830 ! ! |
833 |
831 |
834 !UIObjectView methodsFor:'private resizing-subviews'! |
832 !UIObjectView methodsFor:'private resizing-subviews'! |
835 |
833 |
836 resize:aView bottom:aPoint |
834 resize:aView bottom:aPoint |
837 |
835 "resize a views bottom |
836 " |
|
838 undoHistory disabledTransitionDo:[ |
837 undoHistory disabledTransitionDo:[ |
839 self shiftLayout:aView top:0 bottom:((aPoint y) - (aView computeCorner y)) |
838 self shiftLayout:aView top:0 bottom:((aPoint y) - (aView computeCorner y)) |
840 ] |
839 ] |
841 ! |
840 ! |
842 |
841 |
843 resize:aView bottomLeft:aPoint |
842 resize:aView bottomLeft:aPoint |
844 |
843 "resize a views bottom and left |
844 " |
|
845 undoHistory disabledTransitionDo:[ |
845 undoHistory disabledTransitionDo:[ |
846 self shiftLayout:aView top:0 |
846 self shiftLayout:aView top:0 |
847 bottom:((aPoint y) - (aView computeCorner y)) |
847 bottom:((aPoint y) - (aView computeCorner y)) |
848 left:((aPoint x) - (aView computeOrigin x)) |
848 left:((aPoint x) - (aView computeOrigin x)) |
849 right:0 |
849 right:0 |
852 |
852 |
853 |
853 |
854 ! |
854 ! |
855 |
855 |
856 resize:aView corner:aPoint |
856 resize:aView corner:aPoint |
857 "resize a views corner |
|
858 " |
|
857 |delta| |
859 |delta| |
858 |
860 |
859 delta := aPoint - aView computeCorner. |
861 delta := aPoint - aView computeCorner. |
860 |
862 |
861 undoHistory disabledTransitionDo:[ |
863 undoHistory disabledTransitionDo:[ |
862 self shiftLayout:aView top:0 bottom:(delta y) left:0 right:(delta x) |
864 self shiftLayout:aView top:0 bottom:(delta y) left:0 right:(delta x) |
863 ] |
865 ] |
864 ! |
866 ! |
865 |
867 |
866 resize:aView left:aPoint |
868 resize:aView left:aPoint |
867 |
869 "resize a views left |
870 " |
|
868 undoHistory disabledTransitionDo:[ |
871 undoHistory disabledTransitionDo:[ |
869 self shiftLayout:aView left:((aPoint x) - (aView computeOrigin x)) right:0 |
872 self shiftLayout:aView left:((aPoint x) - (aView computeOrigin x)) right:0 |
870 ] |
873 ] |
871 |
874 |
872 ! |
875 ! |
873 |
876 |
874 resize:aView origin:aPoint |
877 resize:aView origin:aPoint |
878 "resize a views origin |
|
879 " |
|
875 |delta| |
880 |delta| |
876 |
881 |
877 delta := aPoint - aView computeOrigin. |
882 delta := aPoint - aView computeOrigin. |
878 |
883 |
879 undoHistory disabledTransitionDo:[ |
884 undoHistory disabledTransitionDo:[ |
881 ] |
886 ] |
882 |
887 |
883 ! |
888 ! |
884 |
889 |
885 resize:aView right:aPoint |
890 resize:aView right:aPoint |
886 |
891 "resize a views right |
892 " |
|
887 undoHistory disabledTransitionDo:[ |
893 undoHistory disabledTransitionDo:[ |
888 self shiftLayout:aView left:0 right:((aPoint x) - (aView computeCorner x)) |
894 self shiftLayout:aView left:0 right:((aPoint x) - (aView computeCorner x)) |
889 ] |
895 ] |
890 ! |
896 ! |
891 |
897 |
892 resize:aView top:aPoint |
898 resize:aView top:aPoint |
893 |
899 "resize a views top |
900 " |
|
894 undoHistory disabledTransitionDo:[ |
901 undoHistory disabledTransitionDo:[ |
895 self shiftLayout:aView top:((aPoint y) - (aView computeOrigin y)) bottom:0 |
902 self shiftLayout:aView top:((aPoint y) - (aView computeOrigin y)) bottom:0 |
896 ] |
903 ] |
897 ! |
904 ! |
898 |
905 |
899 resize:aView topRight:aPoint |
906 resize:aView topRight:aPoint |
900 |
907 "resize a views top and right |
908 " |
|
901 undoHistory disabledTransitionDo:[ |
909 undoHistory disabledTransitionDo:[ |
902 self shiftLayout:aView top:((aPoint y) - (aView computeOrigin y)) |
910 self shiftLayout:aView top:((aPoint y) - (aView computeOrigin y)) |
903 bottom:0 |
911 bottom:0 |
904 left:0 |
912 left:0 |
905 right:((aPoint x) - (aView computeCorner x)) |
913 right:((aPoint x) - (aView computeCorner x)) |
929 |
937 |
930 shiftLayout:aView top:t bottom:b left:l right:r |
938 shiftLayout:aView top:t bottom:b left:l right:r |
931 "shift layout for a view; in case of an open transaction, the undo |
939 "shift layout for a view; in case of an open transaction, the undo |
932 action is registered |
940 action is registered |
933 " |
941 " |
934 |layout| |
942 |type layout| |
935 |
943 |
936 layout := aView geometryLayout. |
944 type := self class layoutType:aView. |
937 |
945 |
938 self undoLayoutView:aView. |
946 type notNil ifTrue:[ |
939 |
947 self undoLayoutView:aView. |
940 layout isLayout ifTrue:[ |
948 |
941 layout leftOffset:(layout leftOffset + l) |
949 type == #Extent ifTrue:[ |
942 topOffset:(layout topOffset + t). |
950 ^ aView geometryLayout:layout |
943 |
951 ]. |
944 layout isLayoutFrame ifTrue:[ |
952 |
945 layout bottomOffset:(layout bottomOffset + b). |
953 layout := aView geometryLayout. |
946 layout rightOffset:(layout rightOffset + r). |
954 |
947 ]. |
955 layout isLayout ifTrue:[ |
948 aView geometryLayout:layout. |
956 layout leftOffset:(layout leftOffset + l) |
949 ] ifFalse:[ |
957 topOffset:(layout topOffset + t). |
950 |pixelOrigin| |
958 |
951 |
959 type == #LayoutFrame ifTrue:[ |
952 pixelOrigin := aView pixelOrigin. |
960 layout bottomOffset:(layout bottomOffset + b). |
953 pixelOrigin := pixelOrigin + (l@t). |
961 layout rightOffset:(layout rightOffset + r). |
954 aView pixelOrigin:pixelOrigin |
962 ] |
955 ] |
963 ] ifFalse:[ |
956 |
964 type == #Rectangle ifTrue:[ |
957 |
965 layout left:(layout left + l) |
966 right:(layout right + r) |
|
967 top:(layout top + t) |
|
968 bottom:(layout bottom + b). |
|
969 ] ifFalse:[ "POINT" |
|
970 layout x:(layout x + l) y:(layout y + t). |
|
971 ] |
|
972 ]. |
|
973 aView geometryLayout:layout |
|
974 ] |
|
958 ! ! |
975 ! ! |
959 |
976 |
960 !UIObjectView methodsFor:'searching'! |
977 !UIObjectView methodsFor:'searching'! |
961 |
978 |
962 findObjectAt:aPoint |
979 findObjectAt:aPoint |
1045 ! ! |
1062 ! ! |
1046 |
1063 |
1047 !UIObjectView methodsFor:'selections'! |
1064 !UIObjectView methodsFor:'selections'! |
1048 |
1065 |
1049 addToSelection:something |
1066 addToSelection:something |
1067 "add something to selection |
|
1068 " |
|
1050 (self canSelect:something) ifTrue:[ |
1069 (self canSelect:something) ifTrue:[ |
1051 super addToSelection:something. |
1070 super addToSelection:something. |
1052 self changed:#selection. |
1071 self changed:#selection. |
1053 ] |
1072 ] |
1054 ! |
1073 ! |
1055 |
1074 |
1056 inspectSelection |
1075 inspectSelection |
1076 "inspect selection |
|
1077 " |
|
1057 self singleSelectionDo:[:aView | |
1078 self singleSelectionDo:[:aView | |
1058 aView inspect |
1079 aView inspect |
1059 ] |
1080 ] |
1060 ! |
1081 ! |
1061 |
1082 |
1062 numberOfSelections |
1083 numberOfSelections |
1063 "return the number of selected entries" |
1084 "return the number of selected entries |
1064 |
1085 " |
1065 |sz| |
1086 |sz| |
1066 |
1087 |
1067 selection isNil ifTrue:[^ 0]. |
1088 selection isNil ifTrue:[^ 0]. |
1068 |
1089 |
1069 selection isCollection ifTrue:[^ selection size] |
1090 selection isCollection ifTrue:[^ selection size] |
1070 ifFalse:[^ 1 ] |
1091 ifFalse:[^ 1 ] |
1071 ! |
1092 ! |
1072 |
1093 |
1073 removeFromSelection:something |
1094 removeFromSelection:something |
1095 "remove something from selection |
|
1096 " |
|
1074 super removeFromSelection:something. |
1097 super removeFromSelection:something. |
1075 self changed:#selection |
1098 self changed:#selection |
1076 |
1099 |
1077 ! |
1100 ! |
1078 |
1101 |
1079 select:something |
1102 select:something |
1103 "change selection to something |
|
1104 " |
|
1080 (self canSelect:something) ifTrue:[ |
1105 (self canSelect:something) ifTrue:[ |
1081 super select:something. |
1106 super select:something. |
1082 self changed:#selection |
1107 self changed:#selection |
1083 ] |
1108 ] |
1084 |
1109 |
1085 ! |
1110 ! |
1086 |
1111 |
1087 selection |
1112 selection |
1113 "returns selection |
|
1114 " |
|
1088 ^ selection |
1115 ^ selection |
1089 |
1116 |
1090 |
1117 |
1091 ! |
1118 ! |
1092 |
1119 |
1093 selectionHiddenDo:aBlock |
1120 showSelection |
1094 "apply block to every object in selection" |
1121 selectionHiddenLevel == 0 ifTrue:[ |
1095 |
1122 super showSelection. |
1096 self selectionDo:[:aView | |
1123 ]. |
1097 self showUnselected:aView. |
|
1098 ]. |
|
1099 device flush. |
|
1100 aBlock value. |
|
1101 self selectionDo:[:aView | |
|
1102 self showSelected:aView |
|
1103 ] |
|
1104 |
|
1105 |
|
1106 ! |
1124 ! |
1107 |
1125 |
1108 singleSelection |
1126 singleSelection |
1109 "returns single selection or nil |
1127 "returns single selection or nil |
1110 " |
1128 " |
1114 selection size == 1 ifTrue:[ ^ selection at:1] |
1132 selection size == 1 ifTrue:[ ^ selection at:1] |
1115 ifFalse:[ ^ nil]. |
1133 ifFalse:[ ^ nil]. |
1116 ! |
1134 ! |
1117 |
1135 |
1118 singleSelectionDo:aBlock |
1136 singleSelectionDo:aBlock |
1137 "perform block with argument a view in case of one selection |
|
1138 " |
|
1119 |view| |
1139 |view| |
1120 |
1140 |
1121 (view := self singleSelection) notNil ifTrue:[ |
1141 (view := self singleSelection) notNil ifTrue:[ |
1122 aBlock value:view |
1142 aBlock value:view |
1123 ] |
1143 ] |
1124 ! |
1144 ! |
1125 |
1145 |
1126 unselect |
1146 unselect |
1147 "clear selection |
|
1148 " |
|
1127 selection notNil ifTrue:[ |
1149 selection notNil ifTrue:[ |
1128 super unselect. |
1150 super unselect. |
1129 self changed:#selection |
1151 self changed:#selection |
1130 ] |
1152 ] |
1131 |
1153 |
1132 ! |
1154 ! |
1133 |
1155 |
1134 withSelectionHiddenDo:aBlock |
1156 withSelectionHiddenDo:aBlock |
1135 "evaluate aBlock while selection is hidden" |
1157 "apply block with selection hidden (no handles) |
1136 |
1158 " |
1159 selectionHiddenLevel := selectionHiddenLevel + 1. |
|
1160 |
|
1161 selectionHiddenLevel == 1 ifTrue:[ |
|
1162 self selectionDo:[:aView| self showUnselected:aView]. |
|
1163 device flush. |
|
1164 ]. |
|
1165 |
|
1166 aBlock valueNowOrOnUnwindDo:[ |
|
1167 selectionHiddenLevel == 1 ifTrue:[ |
|
1168 setOfSuperViewsSizeChanged notEmpty ifTrue:[ |
|
1169 setOfSuperViewsSizeChanged do:[:aSuperView| |
|
1170 aSuperView sizeChanged:nil |
|
1171 ]. |
|
1172 setOfSuperViewsSizeChanged := IdentitySet new |
|
1173 ]. |
|
1174 self selectionDo:[:aView| self showSelected:aView]. |
|
1175 ]. |
|
1176 selectionHiddenLevel := selectionHiddenLevel - 1. |
|
1177 ] |
|
1178 |
|
1179 ! |
|
1180 |
|
1181 withoutSelectionDo:aBlock |
|
1182 "evaluate aBlock while selection is nilled |
|
1183 " |
|
1137 |sel| |
1184 |sel| |
1138 |
1185 |
1139 selection isNil ifTrue:[ |
1186 selection isNil ifTrue:[ |
1140 aBlock value |
1187 aBlock value |
1141 ] ifFalse:[ |
1188 ] ifFalse:[ |
1143 super unselect. |
1190 super unselect. |
1144 aBlock value. |
1191 aBlock value. |
1145 super select:sel |
1192 super select:sel |
1146 ] |
1193 ] |
1147 |
1194 |
1148 "Modified: 6.9.1995 / 01:46:16 / claus" |
|
1149 |
|
1150 |
1195 |
1151 ! ! |
1196 ! ! |
1152 |
1197 |
1153 !UIObjectView methodsFor:'testing'! |
1198 !UIObjectView methodsFor:'testing'! |
1154 |
1199 |
1155 canMove:something |
1200 canMove:something |
1156 ^ true |
1201 "returns always true; all contained views can be moved |
1157 |
1202 " |
1203 |sv| |
|
1204 |
|
1205 something notNil ifTrue:[ |
|
1206 self forEach:something do:[:v| |
|
1207 sv ~~ v superView ifTrue:[ |
|
1208 (sv notNil or:[v superView specClass isLayoutContainer]) ifTrue:[ |
|
1209 ^ false |
|
1210 ]. |
|
1211 sv := v superView |
|
1212 ] |
|
1213 ]. |
|
1214 ^ true |
|
1215 ]. |
|
1216 ^ false |
|
1158 |
1217 |
1159 ! |
1218 ! |
1160 |
1219 |
1161 canPaste:something |
1220 canPaste:something |
1162 "returns true if something could be paste |
1221 "returns true if something could be paste |
1172 ]. |
1231 ]. |
1173 ^ false |
1232 ^ false |
1174 |
1233 |
1175 ! |
1234 ! |
1176 |
1235 |
1236 canPasteInto:something |
|
1237 "can paste into something ? |
|
1238 " |
|
1239 something notNil ifTrue:[ |
|
1240 something isCollection ifFalse:[ |
|
1241 ^ something specClass supportsSubComponents |
|
1242 ]. |
|
1243 something size == 1 ifTrue:[ |
|
1244 ^ (something at:1) specClass supportsSubComponents |
|
1245 ] |
|
1246 ]. |
|
1247 ^ false |
|
1248 ! |
|
1249 |
|
1177 canSelect:something |
1250 canSelect:something |
1251 "returns true if something can be selected and testMode is disabled |
|
1252 " |
|
1178 ^ (testMode not and:[something ~~ selection]) |
1253 ^ (testMode not and:[something ~~ selection]) |
1179 |
1254 |
1180 ! |
1255 ! |
1181 |
1256 |
1182 hasUndos |
1257 hasUndos |
1184 " |
1259 " |
1185 ^ undoHistory notEmpty |
1260 ^ undoHistory notEmpty |
1186 ! |
1261 ! |
1187 |
1262 |
1188 isHorizontalResizable:aComponent |
1263 isHorizontalResizable:aComponent |
1264 "returns true if instance is horizontal resizeable |
|
1265 " |
|
1189 ^ self subclassResponsibility |
1266 ^ self subclassResponsibility |
1190 |
1267 |
1191 |
1268 |
1192 ! |
1269 ! |
1193 |
1270 |
1194 isVerticalResizable:aComponent |
1271 isVerticalResizable:aComponent |
1272 "returns true if instance is vertical resizeable |
|
1273 " |
|
1195 ^ self subclassResponsibility |
1274 ^ self subclassResponsibility |
1196 |
1275 |
1197 |
1276 |
1198 ! |
|
1199 |
|
1200 supportsSubComponents:something |
|
1201 "returns true if somrthing supports subcomponents |
|
1202 " |
|
1203 |specClass| |
|
1204 |
|
1205 something notNil ifTrue:[ |
|
1206 something isCollection ifFalse:[ |
|
1207 specClass := something specClass |
|
1208 ] ifTrue:[ |
|
1209 something size == 1 ifTrue:[ |
|
1210 specClass := (something at:1) specClass |
|
1211 ] |
|
1212 ]. |
|
1213 specClass notNil ifTrue:[ |
|
1214 ^ specClass basicNew supportsSubComponents |
|
1215 ] |
|
1216 ]. |
|
1217 ^ false |
|
1218 ! ! |
1277 ! ! |
1219 |
1278 |
1220 !UIObjectView methodsFor:'transaction'! |
1279 !UIObjectView methodsFor:'transaction'! |
1221 |
1280 |
1222 transaction:aType objects:something do:aOneArgBlock |
1281 transaction:aType objects:something do:aOneArgBlock |
1245 ! ! |
1304 ! ! |
1246 |
1305 |
1247 !UIObjectView methodsFor:'user actions - arrange'! |
1306 !UIObjectView methodsFor:'user actions - arrange'! |
1248 |
1307 |
1249 lowerSelection |
1308 lowerSelection |
1309 "lower all objects in the selection |
|
1310 " |
|
1250 self selectionDo:[:aView| aView lower ]. |
1311 self selectionDo:[:aView| aView lower ]. |
1251 |
1312 |
1252 |
1313 |
1253 ! |
1314 ! |
1254 |
1315 |
1255 raiseSelection |
1316 raiseSelection |
1317 "raise all objects in the selection |
|
1318 " |
|
1256 self selectionDo:[:aView| aView raise ]. |
1319 self selectionDo:[:aView| aView raise ]. |
1257 inputView raise. |
1320 inputView raise. |
1258 |
1321 |
1259 |
1322 |
1260 ! ! |
1323 ! ! |
1261 |
1324 |
1262 !UIObjectView methodsFor:'user actions - dimension'! |
1325 !UIObjectView methodsFor:'user actions - dimension'! |
1263 |
1326 |
1264 copyExtent |
1327 copyExtent |
1328 "copy the extent from the selected object |
|
1329 " |
|
1265 |object| |
1330 |object| |
1266 |
1331 |
1267 object := self singleSelection. |
1332 object := self singleSelection. |
1268 |
1333 |
1269 object notNil ifTrue:[ |
1334 object notNil ifTrue:[ |
1275 |
1340 |
1276 |
1341 |
1277 ! |
1342 ! |
1278 |
1343 |
1279 pasteExtent |
1344 pasteExtent |
1345 "paste the copied extent to all objects in the selection |
|
1346 " |
|
1280 copiedExtent notNil ifTrue:[ |
1347 copiedExtent notNil ifTrue:[ |
1281 self transition:#extent dimensionDo:[:v| |
1348 self transition:#extent dimensionDo:[:v| |
1282 self resize:v corner:(v computeOrigin + copiedExtent) |
1349 self resize:v corner:(v computeOrigin + copiedExtent) |
1283 ] |
1350 ] |
1284 ] |
1351 ] |
1285 ! |
1352 ! |
1286 |
1353 |
1287 pasteHeight |
1354 pasteHeight |
1355 "paste the copied extent height to all objects in the selection |
|
1356 " |
|
1288 copiedExtent notNil ifTrue:[ |
1357 copiedExtent notNil ifTrue:[ |
1289 self transition:'paste height' dimensionDo:[:v| |
1358 self transition:'paste height' dimensionDo:[:v| |
1290 self resize:v bottom:(v computeOrigin + copiedExtent) |
1359 self resize:v bottom:(v computeOrigin + copiedExtent) |
1291 ] |
1360 ] |
1292 ] |
1361 ] |
1293 |
1362 |
1294 ! |
1363 ! |
1295 |
1364 |
1296 pasteWidth |
1365 pasteWidth |
1366 "paste the copied extent width to all objects in the selection |
|
1367 " |
|
1297 copiedExtent notNil ifTrue:[ |
1368 copiedExtent notNil ifTrue:[ |
1298 self transition:'paste width' dimensionDo:[:v| |
1369 self transition:'paste width' dimensionDo:[:v| |
1299 self resize:v right:(v computeOrigin + copiedExtent) |
1370 self resize:v right:(v computeOrigin + copiedExtent) |
1300 ] |
1371 ] |
1301 ] |
1372 ] |
1302 |
1373 |
1303 ! |
1374 ! |
1304 |
1375 |
1305 setDimension:aLayout |
1376 setDimension:aLayout |
1306 |type| |
1377 "change layout for all selected objects |
1307 |
1378 " |
1308 aLayout isLayout ifTrue:[ |
1379 self transition:#layout dimensionDo:[:v| |
1309 aLayout isLayoutFrame ifTrue:[ |
1380 v geometryLayout:(aLayout copy) |
1310 type := #layoutFrame |
1381 ]. |
1311 ] ifFalse:[ |
1382 |
1312 aLayout isAlignmentOrigin ifTrue:[ |
1383 ! |
1313 type := #layoutAlignOrigin. |
1384 |
1314 ] ifFalse:[ |
1385 setExtent:anExtent |
1315 type := #layoutOrigin |
1386 "change extent for all selected objects |
1316 ] |
1387 " |
1317 ] |
1388 self transition:#layout dimensionDo:[:v| |
1318 ] ifFalse:[ |
1389 v extent:anExtent. |
1319 type := #layout |
1390 ]. |
1320 ]. |
|
1321 |
|
1322 self transition:type dimensionDo:[:v| v geometryLayout:(aLayout copy)] |
|
1323 |
|
1324 ! |
1391 ! |
1325 |
1392 |
1326 setToDefaultExtent |
1393 setToDefaultExtent |
1394 "change extent of all selected views to their default extent |
|
1395 " |
|
1327 self transition:#extent dimensionDo:[:v| |
1396 self transition:#extent dimensionDo:[:v| |
1328 self resize:v corner:(v computeOrigin + (v preferredExtent)) |
1397 self resize:v corner:(v computeOrigin + (v preferredExtent)) |
1329 ] |
1398 ] |
1330 |
1399 |
1331 ! |
1400 ! |
1332 |
1401 |
1333 setToDefaultHeight |
1402 setToDefaultHeight |
1403 "change height of all selected views to their default height |
|
1404 " |
|
1334 self transition:'default height' dimensionDo:[:v| |
1405 self transition:'default height' dimensionDo:[:v| |
1335 self resize:v bottom:(v computeOrigin + (v preferredExtent)) |
1406 self resize:v bottom:(v computeOrigin + (v preferredExtent)) |
1336 ] |
1407 ] |
1337 |
1408 |
1338 ! |
1409 ! |
1339 |
1410 |
1340 setToDefaultWidth |
1411 setToDefaultWidth |
1412 "change width of all selected views to their default width |
|
1413 " |
|
1341 self transition:'default width' dimensionDo:[:v| |
1414 self transition:'default width' dimensionDo:[:v| |
1342 self resize:v right:(v computeOrigin + (v preferredExtent)) |
1415 self resize:v right:(v computeOrigin + (v preferredExtent)) |
1343 ] |
1416 ] |
1344 |
1417 |
1345 ! |
1418 ! |
1346 |
1419 |
1347 transition:aType dimensionDo:aOneArgBlock |
1420 transition:aType dimensionDo:aOneArgBlock |
1348 "change dimension within a transaction for the selected elements by evaluating |
1421 "change dimension within a transaction for the selected elements by evaluating |
1349 the block with the argument a view. |
1422 the block with the argument a view. |
1350 " |
1423 " |
1351 self selectionHiddenDo:[ |
1424 self withSelectionHiddenDo:[ |
1352 self transaction:aType selectionDo:[:aView| |
1425 self transaction:aType selectionDo:[:aView| |
1353 self undoLayoutView:aView. |
1426 (self class layoutType:aView) notNil ifTrue:[ |
1354 aOneArgBlock value:aView. |
1427 self undoLayoutView:aView. |
1428 aOneArgBlock value:aView. |
|
1429 self elementChangedSize:aView. |
|
1430 ] |
|
1431 ] |
|
1432 ]. |
|
1433 self changed:#layout |
|
1434 |
|
1435 ! ! |
|
1436 |
|
1437 !UIObjectView methodsFor:'user actions - move'! |
|
1438 |
|
1439 moveSelectionDown:aNumber |
|
1440 "move selection down |
|
1441 " |
|
1442 |gridY| |
|
1443 |
|
1444 (self canMove:selection) ifTrue:[ |
|
1445 gridAlign notNil ifTrue:[gridY := gridAlign y]. |
|
1446 |
|
1447 self withSelectionHiddenDo:[ |
|
1448 self transaction:#move selectionDo:[:aView| |
|
1449 |n d| |
|
1450 |
|
1451 n := aNumber. |
|
1452 |
|
1453 aligning ifTrue:[ |
|
1454 d := ((aView computeCorner y) \\ gridY). |
|
1455 n := n * gridY. |
|
1456 |
|
1457 d ~~ 0 ifTrue:[ |
|
1458 n := n - d + 1. |
|
1459 ] |
|
1460 ]. |
|
1461 self shiftLayout:aView top:n bottom:n |
|
1462 ] |
|
1355 ]. |
1463 ]. |
1356 self changed:#layout |
1464 self changed:#layout |
1357 ] |
1465 ] |
1358 ! ! |
|
1359 |
|
1360 !UIObjectView methodsFor:'user actions - move'! |
|
1361 |
|
1362 moveSelectionDown:aNumber |
|
1363 |gridY| |
|
1364 |
|
1365 gridAlign notNil ifTrue:[ |
|
1366 gridY := gridAlign y. |
|
1367 ]. |
|
1368 |
|
1369 self selectionHiddenDo:[ |
|
1370 self transaction:#move selectionDo:[:aView| |
|
1371 |n d| |
|
1372 |
|
1373 n := aNumber. |
|
1374 |
|
1375 aligning ifTrue:[ |
|
1376 d := ((aView computeCorner y) \\ gridY). |
|
1377 n := n * gridY. |
|
1378 |
|
1379 d ~~ 0 ifTrue:[ |
|
1380 n := n - d + 1. |
|
1381 ] |
|
1382 ]. |
|
1383 self shiftLayout:aView top:n bottom:n |
|
1384 ]. |
|
1385 self changed:#layout |
|
1386 ] |
|
1387 |
|
1388 |
1466 |
1389 ! |
1467 ! |
1390 |
1468 |
1391 moveSelectionLeft:aNumber |
1469 moveSelectionLeft:aNumber |
1392 "move selection left |
1470 "move selection left |
1393 " |
1471 " |
1394 |gridX| |
1472 |gridX| |
1395 |
1473 |
1396 gridAlign notNil ifTrue:[ |
1474 (self canMove:selection) ifTrue:[ |
1397 gridX := gridAlign x. |
1475 gridAlign notNil ifTrue:[gridX := gridAlign x]. |
1398 ]. |
1476 |
1399 |
1477 self withSelectionHiddenDo:[ |
1400 self selectionHiddenDo:[ |
1478 self transaction:#move selectionDo:[:aView| |
1401 self transaction:#move selectionDo:[:aView| |
1479 |n d| |
1402 |n d| |
1480 |
1403 |
1481 n := aNumber. |
1404 n := aNumber. |
1482 |
1405 |
1483 aligning ifTrue:[ |
1406 aligning ifTrue:[ |
1484 d := ((aView computeOrigin x) \\ gridX). |
1407 d := ((aView computeOrigin x) \\ gridX). |
1485 d ~~ 0 ifTrue:[ |
1408 d ~~ 0 ifTrue:[ |
1486 n := n-1. |
1409 n := n-1. |
1487 ]. |
1488 n := (n * gridX) + d. |
|
1410 ]. |
1489 ]. |
1411 n := (n * gridX) + d. |
1490 n := n negated. |
1412 ]. |
1491 self shiftLayout:aView left:n right:n |
1413 n := n negated. |
1492 ] |
1414 self shiftLayout:aView left:n right:n |
|
1415 |
|
1416 ]. |
1493 ]. |
1417 self changed:#layout |
1494 self changed:#layout |
1418 ] |
1495 ] |
1419 ! |
1496 ! |
1420 |
1497 |
1421 moveSelectionRight:aNumber |
1498 moveSelectionRight:aNumber |
1422 "move selection right |
1499 "move selection right |
1423 " |
1500 " |
1424 |gridX| |
1501 |gridX| |
1425 |
1502 |
1426 gridAlign notNil ifTrue:[ |
1503 (self canMove:selection) ifTrue:[ |
1427 gridX := gridAlign x. |
1504 gridAlign notNil ifTrue:[gridX := gridAlign x]. |
1428 ]. |
1505 |
1429 |
1506 self withSelectionHiddenDo:[ |
1430 self selectionHiddenDo:[ |
1507 self transaction:#move selectionDo:[:aView| |
1431 self transaction:#move selectionDo:[:aView| |
1508 |n d| |
1432 |n d| |
1509 |
1433 |
1510 n := aNumber. |
1434 n := aNumber. |
1511 |
1435 |
1512 aligning ifTrue:[ |
1436 aligning ifTrue:[ |
1513 d := ((aView computeCorner x) \\ gridX). |
1437 d := ((aView computeCorner x) \\ gridX). |
1514 n := n * gridX. |
1438 n := n * gridX. |
1515 |
1439 |
1516 d ~~ 0 ifTrue:[ |
1440 d ~~ 0 ifTrue:[ |
1517 n := n - d + 1. |
1441 n := n - d + 1. |
1518 ] |
1442 ] |
1519 ]. |
1443 ]. |
1520 self shiftLayout:aView left:n right:n |
1444 self shiftLayout:aView left:n right:n |
1521 ] |
1445 |
|
1446 ]. |
1522 ]. |
1447 self changed:#layout |
1523 self changed:#layout |
1448 ] |
1524 ] |
1449 ! |
1525 ! |
1450 |
1526 |
1451 moveSelectionUp:aNumber |
1527 moveSelectionUp:aNumber |
1452 "move selection up |
1528 "move selection up |
1453 " |
1529 " |
1454 |gridY| |
1530 |gridY| |
1455 |
1531 |
1456 gridAlign notNil ifTrue:[ |
1532 (self canMove:selection) ifTrue:[ |
1457 gridY := gridAlign y. |
1533 gridAlign notNil ifTrue:[gridY := gridAlign y]. |
1458 ]. |
1534 |
1459 |
1535 self withSelectionHiddenDo:[ |
1460 self selectionHiddenDo:[ |
1536 self transaction:#move selectionDo:[:aView| |
1461 self transaction:#move selectionDo:[:aView| |
1537 |n d| |
1462 |n d| |
1538 |
1463 |
1539 n := aNumber. |
1464 n := aNumber. |
1540 |
1465 |
1541 aligning ifTrue:[ |
1466 aligning ifTrue:[ |
1542 d := ((aView computeOrigin x) \\ gridY). |
1467 d := ((aView computeOrigin x) \\ gridY). |
1543 d ~~ 0 ifTrue:[ |
1468 d ~~ 0 ifTrue:[ |
1544 n := n-1. |
1469 n := n-1. |
1545 ]. |
1546 n := (n * gridY) + d. |
|
1470 ]. |
1547 ]. |
1471 n := (n * gridY) + d. |
1548 n := n negated. |
1472 ]. |
1549 self shiftLayout:aView top:n bottom:n |
1473 n := n negated. |
1550 ] |
1474 self shiftLayout:aView top:n bottom:n |
|
1475 ]. |
1551 ]. |
1476 self changed:#layout |
1552 self changed:#layout |
1477 ] |
1553 ] |
1478 |
1554 |
1479 |
|
1480 ! ! |
1555 ! ! |
1481 |
1556 |
1482 !UIObjectView methodsFor:'user actions - position'! |
1557 !UIObjectView methodsFor:'user actions - position'! |
1483 |
1558 |
1484 alignSelectionBottom |
1559 alignSelectionBottom |
1560 "align selection to the bottom of the first object in the selection; in case |
|
1561 of one selection the object is aligned to the bottom of its superview |
|
1562 " |
|
1485 |bmost delta layout| |
1563 |bmost delta layout| |
1486 |
1564 |
1487 selection notNil ifTrue:[ |
1565 (self canMove:selection) ifTrue:[ |
1488 self selectionHiddenDo:[ |
1566 self withSelectionHiddenDo:[ |
1489 self numberOfSelections > 1 ifTrue:[ |
1567 self numberOfSelections > 1 ifTrue:[ |
1490 bmost := (selection at:1) computeCorner y. |
1568 bmost := (selection at:1) computeCorner y. |
1491 |
1569 |
1492 self transaction:#align selectionDo:[:v| |
1570 self transaction:#align selectionDo:[:v| |
1493 (delta := bmost - (v computeCorner y)) ~~ 0 ifTrue:[ |
1571 (delta := bmost - (v computeCorner y)) ~~ 0 ifTrue:[ |
1495 ] |
1573 ] |
1496 ] |
1574 ] |
1497 ] ifFalse:[ |
1575 ] ifFalse:[ |
1498 layout := selection geometryLayout. |
1576 layout := selection geometryLayout. |
1499 |
1577 |
1500 (layout isLayout and:[layout isLayoutFrame]) ifFalse:[ |
1578 (layout isLayout and:[layout isLayoutFrame]) ifTrue:[ |
1501 ^ self |
1579 self transaction:#layout selectionDo:[:aView| |
1502 ]. |
1580 self undoLayoutView:aView. |
1503 |
1581 layout := aView geometryLayout. |
1504 self transaction:#layout selectionDo:[:aView| |
1582 layout bottomOffset:0. |
1505 self undoLayoutView:aView. |
1583 layout bottomFraction:1.0. |
1506 layout := aView geometryLayout. |
1584 aView geometryLayout:layout. |
1507 layout bottomOffset:0. |
1585 ] |
1508 layout bottomFraction:1.0. |
|
1509 aView geometryLayout:layout. |
|
1510 ] |
1586 ] |
1511 ] |
1587 ] |
1512 ]. |
1588 ]. |
1513 self changed:#layout |
1589 self changed:#layout |
1514 ] |
1590 ] |
1516 |
1592 |
1517 |
1593 |
1518 ! |
1594 ! |
1519 |
1595 |
1520 alignSelectionCenterHor |
1596 alignSelectionCenterHor |
1597 "align selection to the center/horizontal of the first object in the selection; in case |
|
1598 of one selection the object is aligned to the center/horizontal of its superview |
|
1599 " |
|
1521 |view center| |
1600 |view center| |
1522 |
1601 |
1523 selection notNil ifTrue:[ |
1602 (self canMove:selection) ifTrue:[ |
1524 self selectionHiddenDo:[ |
1603 self withSelectionHiddenDo:[ |
1525 view := self singleSelection. |
1604 view := self singleSelection. |
1526 |
1605 |
1527 view notNil ifTrue:[ |
1606 view notNil ifTrue:[ |
1528 view := view superView. |
1607 view := view superView. |
1529 center := view computeExtent |
1608 center := view computeExtent |
1539 oldX := v computeOrigin x. |
1618 oldX := v computeOrigin x. |
1540 newX := center - ((v computeCorner x - oldX) // 2). |
1619 newX := center - ((v computeCorner x - oldX) // 2). |
1541 delta := newX - oldX. |
1620 delta := newX - oldX. |
1542 |
1621 |
1543 self shiftLayout:v left:delta right:delta |
1622 self shiftLayout:v left:delta right:delta |
1544 ]. |
1623 ] |
1545 self changed:#layout |
1624 ]. |
1546 ] |
1625 self changed:#layout |
1547 ] |
1626 ] |
1548 |
1627 |
1549 |
1628 |
1550 |
1629 |
1551 ! |
1630 ! |
1552 |
1631 |
1553 alignSelectionCenterVer |
1632 alignSelectionCenterVer |
1633 "align selection to the center/vertical of the first object in the selection; in case |
|
1634 of one selection the object is aligned to the center/vertical of its superview |
|
1635 " |
|
1554 |view center| |
1636 |view center| |
1555 |
1637 |
1556 selection notNil ifTrue:[ |
1638 (self canMove:selection) ifTrue:[ |
1557 self selectionHiddenDo:[ |
1639 self withSelectionHiddenDo:[ |
1558 view := self singleSelection. |
1640 view := self singleSelection. |
1559 |
1641 |
1560 view notNil ifTrue:[ |
1642 view notNil ifTrue:[ |
1561 view := view superView. |
1643 view := view superView. |
1562 center := view computeExtent |
1644 center := view computeExtent |
1572 oldY := v computeOrigin y. |
1654 oldY := v computeOrigin y. |
1573 newY := center - ((v computeCorner y - oldY) // 2). |
1655 newY := center - ((v computeCorner y - oldY) // 2). |
1574 delta := newY - oldY. |
1656 delta := newY - oldY. |
1575 |
1657 |
1576 self shiftLayout:v top:delta bottom:delta |
1658 self shiftLayout:v top:delta bottom:delta |
1577 ]. |
1659 ] |
1578 self changed:#layout |
1660 ]. |
1579 ] |
1661 self changed:#layout |
1580 ] |
1662 ] |
1581 ! |
1663 ! |
1582 |
1664 |
1583 alignSelectionLeft |
1665 alignSelectionLeft |
1666 "align selection to the left of the first object in the selection; in case |
|
1667 of one selection the object is aligned to the left of its superview |
|
1668 " |
|
1584 |lmost delta layout| |
1669 |lmost delta layout| |
1585 |
1670 |
1586 selection notNil ifTrue:[ |
1671 (self canMove:selection) ifTrue:[ |
1587 self selectionHiddenDo:[ |
1672 self withSelectionHiddenDo:[ |
1588 self numberOfSelections > 1 ifTrue:[ |
1673 self numberOfSelections > 1 ifTrue:[ |
1589 lmost := (selection at:1) computeOrigin x. |
1674 lmost := (selection at:1) computeOrigin x. |
1590 |
1675 |
1591 self transaction:#align selectionDo:[:v| |
1676 self transaction:#align selectionDo:[:v| |
1592 (delta := lmost - (v computeOrigin x)) ~~ 0 ifTrue:[ |
1677 (delta := lmost - (v computeOrigin x)) ~~ 0 ifTrue:[ |
1609 self changed:#layout |
1694 self changed:#layout |
1610 ] |
1695 ] |
1611 ! |
1696 ! |
1612 |
1697 |
1613 alignSelectionLeftAndRight |
1698 alignSelectionLeftAndRight |
1699 "align selection to the left/right of the first object in the selection; in case |
|
1700 of one selection the object is aligned to the left/right of its superview |
|
1701 " |
|
1614 |lmost rmost layout| |
1702 |lmost rmost layout| |
1615 |
1703 |
1616 selection notNil ifTrue:[ |
1704 (self canMove:selection) ifTrue:[ |
1617 self selectionHiddenDo:[ |
1705 self withSelectionHiddenDo:[ |
1618 self numberOfSelections > 1 ifTrue:[ |
1706 self numberOfSelections > 1 ifTrue:[ |
1619 lmost := (selection at:1) computeOrigin x. |
1707 lmost := (selection at:1) computeOrigin x. |
1620 rmost := (selection at:1) computeCorner x. |
1708 rmost := (selection at:1) computeCorner x. |
1621 |
1709 |
1622 self transaction:#align selectionDo:[:v| |
1710 self transaction:#align selectionDo:[:v| |
1623 self shiftLayout:v left:(lmost - (v computeOrigin x)) |
1711 self shiftLayout:v left:(lmost - (v computeOrigin x)) |
1624 right:(rmost - (v computeCorner x)) |
1712 right:(rmost - (v computeCorner x)). |
1713 |
|
1714 self elementChangedSize:v. |
|
1625 ] |
1715 ] |
1626 ] ifFalse:[ |
1716 ] ifFalse:[ |
1627 self transaction:#layout selectionDo:[:aView| |
1717 self transaction:#layout selectionDo:[:aView| |
1628 layout := aView geometryLayout. |
1718 layout := aView geometryLayout. |
1629 |
1719 |
1635 (layout isLayout and:[layout isLayoutFrame]) ifTrue:[ |
1725 (layout isLayout and:[layout isLayoutFrame]) ifTrue:[ |
1636 layout rightOffset:0. |
1726 layout rightOffset:0. |
1637 layout rightFraction:1.0. |
1727 layout rightFraction:1.0. |
1638 ]. |
1728 ]. |
1639 aView geometryLayout:layout. |
1729 aView geometryLayout:layout. |
1730 self elementChangedSize:aView. |
|
1640 ] |
1731 ] |
1641 ] |
1732 ] |
1642 ] |
1733 ] |
1643 ]. |
1734 ]. |
1644 self changed:#layout |
1735 self changed:#layout |
1645 ] |
1736 ]. |
1737 |
|
1646 ! |
1738 ! |
1647 |
1739 |
1648 alignSelectionRight |
1740 alignSelectionRight |
1741 "align selection to the right of the first object in the selection; in case |
|
1742 of one selection the object is aligned to the right of its superview |
|
1743 " |
|
1649 |rmost delta layout| |
1744 |rmost delta layout| |
1650 |
1745 |
1651 selection notNil ifTrue:[ |
1746 (self canMove:selection) ifTrue:[ |
1652 self selectionHiddenDo:[ |
1747 self withSelectionHiddenDo:[ |
1653 self numberOfSelections > 1 ifTrue:[ |
1748 self numberOfSelections > 1 ifTrue:[ |
1654 rmost := (selection at:1) computeCorner x. |
1749 rmost := (selection at:1) computeCorner x. |
1655 |
1750 |
1656 self transaction:#align selectionDo:[:v| |
1751 self transaction:#align selectionDo:[:v| |
1657 (delta := rmost - (v computeCorner x)) ~~ 0 ifTrue:[ |
1752 (delta := rmost - (v computeCorner x)) ~~ 0 ifTrue:[ |
1659 ] |
1754 ] |
1660 ] |
1755 ] |
1661 ] ifFalse:[ |
1756 ] ifFalse:[ |
1662 layout := selection geometryLayout. |
1757 layout := selection geometryLayout. |
1663 |
1758 |
1664 (layout isLayout and:[layout isLayoutFrame]) ifFalse:[ |
1759 (layout isLayout and:[layout isLayoutFrame]) ifTrue:[ |
1665 ^ self |
1760 self transaction:#layout selectionDo:[:aView| |
1666 ]. |
1761 self undoLayoutView:aView. |
1667 |
1762 layout := aView geometryLayout. |
1668 self transaction:#layout selectionDo:[:aView| |
1763 layout rightOffset:0. |
1669 self undoLayoutView:aView. |
1764 layout rightFraction:1.0. |
1670 layout := aView geometryLayout. |
1765 aView geometryLayout:layout. |
1671 layout rightOffset:0. |
1766 ] |
1672 layout rightFraction:1.0. |
|
1673 aView geometryLayout:layout. |
|
1674 ] |
1767 ] |
1675 ] |
1768 ] |
1676 ]. |
1769 ]. |
1677 self changed:#layout |
1770 self changed:#layout |
1678 ] |
1771 ] |
1679 ! |
1772 ! |
1680 |
1773 |
1681 alignSelectionTop |
1774 alignSelectionTop |
1775 "align selection to the top of the first object in the selection; in case |
|
1776 of one selection the object is aligned to the top of its superview |
|
1777 " |
|
1682 |tmost delta layout| |
1778 |tmost delta layout| |
1683 |
1779 |
1684 selection notNil ifTrue:[ |
1780 (self canMove:selection) ifTrue:[ |
1685 self selectionHiddenDo:[ |
1781 self withSelectionHiddenDo:[ |
1686 self numberOfSelections > 1 ifTrue:[ |
1782 self numberOfSelections > 1 ifTrue:[ |
1687 tmost := (selection at:1) computeOrigin y. |
1783 tmost := (selection at:1) computeOrigin y. |
1688 |
1784 |
1689 self transaction:#align selectionDo:[:v| |
1785 self transaction:#align selectionDo:[:v| |
1690 (delta := tmost - (v computeOrigin y)) ~~ 0 ifTrue:[ |
1786 (delta := tmost - (v computeOrigin y)) ~~ 0 ifTrue:[ |
1708 ] |
1804 ] |
1709 |
1805 |
1710 ! |
1806 ! |
1711 |
1807 |
1712 alignSelectionTopAndBottom |
1808 alignSelectionTopAndBottom |
1809 "align selection to the top/bottom of the first object in the selection; in case |
|
1810 of one selection the object is aligned to the top/bottom of its superview |
|
1811 " |
|
1713 |tmost bmost layout| |
1812 |tmost bmost layout| |
1714 |
1813 |
1715 selection notNil ifTrue:[ |
1814 (self canMove:selection) ifTrue:[ |
1716 self selectionHiddenDo:[ |
1815 self withSelectionHiddenDo:[ |
1717 self numberOfSelections > 1 ifTrue:[ |
1816 self numberOfSelections > 1 ifTrue:[ |
1718 tmost := (selection at:1) computeOrigin y. |
1817 tmost := (selection at:1) computeOrigin y. |
1719 bmost := (selection at:1) computeCorner y. |
1818 bmost := (selection at:1) computeCorner y. |
1720 |
1819 |
1721 self transaction:#align selectionDo:[:v| |
1820 self transaction:#align selectionDo:[:v| |
1722 self shiftLayout:v top:(tmost - (v computeOrigin y)) |
1821 self shiftLayout:v top:(tmost - (v computeOrigin y)) |
1723 bottom:(bmost - (v computeCorner y)) |
1822 bottom:(bmost - (v computeCorner y)). |
1823 self elementChangedSize:v. |
|
1724 ] |
1824 ] |
1725 ] ifFalse:[ |
1825 ] ifFalse:[ |
1726 self transaction:#layout selectionDo:[:aView| |
1826 self transaction:#align selectionDo:[:aView| |
1727 layout := aView geometryLayout. |
1827 layout := aView geometryLayout. |
1728 |
1828 |
1729 layout isLayout ifTrue:[ |
1829 layout isLayout ifTrue:[ |
1730 self undoLayoutView:aView. |
1830 self undoLayoutView:aView. |
1731 layout topOffset:0. |
1831 layout topOffset:0. |
1734 (layout isLayout and:[layout isLayoutFrame]) ifTrue:[ |
1834 (layout isLayout and:[layout isLayoutFrame]) ifTrue:[ |
1735 layout bottomOffset:0. |
1835 layout bottomOffset:0. |
1736 layout bottomFraction:1.0. |
1836 layout bottomFraction:1.0. |
1737 ]. |
1837 ]. |
1738 aView geometryLayout:layout. |
1838 aView geometryLayout:layout. |
1739 ] |
1839 ] ifFalse:[ |
1840 |y x| |
|
1841 |
|
1842 self undoLayoutView:aView. |
|
1843 x := aView extent x. |
|
1844 y := aView superView extent y. |
|
1845 aView extent:(x @ y) |
|
1846 ]. |
|
1847 self elementChangedSize:aView. |
|
1740 ] |
1848 ] |
1741 ] |
1849 ] |
1742 ]. |
1850 ]. |
1743 self changed:#layout |
1851 self changed:#layout |
1744 ] |
1852 ] |
1853 ! |
|
1854 |
|
1855 alignSingleSelection:aBlock |
|
1856 |
|
1857 |type layout| |
|
1858 |
|
1859 self withSelectionHiddenDo:[ |
|
1860 self transaction:#align selectionDo:[:aView| |
|
1861 type := self class layoutType:aView. |
|
1862 |
|
1863 type notNil ifTrue:[ |
|
1864 self undoLayoutView:aView. |
|
1865 |
|
1866 layout := aView layout. |
|
1867 |
|
1868 type == #LayoutFrame ifFalse:[ |
|
1869 layout := aView bounds asLayout |
|
1870 ]. |
|
1871 aBlock value:layout. |
|
1872 aView geometryLayout:layout. |
|
1873 ] |
|
1874 ] |
|
1875 ]. |
|
1876 self changed:#layout |
|
1877 |
|
1878 |
|
1879 |
|
1745 ! |
1880 ! |
1746 |
1881 |
1747 centerSelection:aOneArgBlockXorY orientation:orientation |
1882 centerSelection:aOneArgBlockXorY orientation:orientation |
1748 "center selection horizontal or vertical dependant on the block result( x or y). |
1883 "center selection horizontal or vertical dependant on the block result( x or y). |
1749 The argument to the block is the point. |
1884 The argument to the block is the point. |
1750 " |
1885 " |
1751 |superview min max delta val| |
1886 |superview min max delta val| |
1752 |
1887 |
1753 self selectionHiddenDo:[ |
1888 (self canMove:selection) ifFalse:[ |
1889 ^ self |
|
1890 ]. |
|
1891 |
|
1892 self withSelectionHiddenDo:[ |
|
1754 max := 0. |
1893 max := 0. |
1755 |
1894 |
1756 self selectionDo:[:aView | |
1895 self selectionDo:[:aView | |
1757 superview isNil ifTrue:[ |
1896 superview isNil ifTrue:[ |
1758 superview := aView superView |
1897 superview := aView superView |
1780 orientation == #y ifTrue:[ |
1919 orientation == #y ifTrue:[ |
1781 self shiftLayout:v top:delta bottom:delta |
1920 self shiftLayout:v top:delta bottom:delta |
1782 ] ifFalse:[ |
1921 ] ifFalse:[ |
1783 self shiftLayout:v left:delta right:delta |
1922 self shiftLayout:v left:delta right:delta |
1784 ] |
1923 ] |
1785 ]. |
1924 ] |
1786 self changed:#layout |
1925 ]. |
1787 ] |
1926 self changed:#layout |
1788 ] |
1927 ] |
1789 |
1928 |
1790 |
1929 |
1791 ! |
1930 ! |
1792 |
1931 |
1803 " |
1942 " |
1804 self centerSelection:[:aPoint| aPoint y] orientation:#y |
1943 self centerSelection:[:aPoint| aPoint y] orientation:#y |
1805 ! |
1944 ! |
1806 |
1945 |
1807 spreadSelectionHor |
1946 spreadSelectionHor |
1947 "spread multiple selection horizontal |
|
1948 " |
|
1808 |sumWidths min max viewsInOrder topsInOrder count space| |
1949 |sumWidths min max viewsInOrder topsInOrder count space| |
1809 |
1950 |
1810 (self numberOfSelections > 1) ifFalse:[ |
1951 (self numberOfSelections > 1 and:[self canMove:selection]) ifFalse:[ |
1811 ^ self |
1952 ^ self |
1812 ]. |
1953 ]. |
1813 |
1954 |
1814 self selectionHiddenDo:[ |
1955 self withSelectionHiddenDo:[ |
1815 count := 0. |
1956 count := 0. |
1816 sumWidths := 0. |
1957 sumWidths := 0. |
1817 max := 0. |
1958 max := 0. |
1818 |
1959 |
1819 self selectionDo:[:aView | |
1960 self selectionDo:[:aView | |
1835 |delta| |
1976 |delta| |
1836 |
1977 |
1837 delta := min - aView computeOrigin x. |
1978 delta := min - aView computeOrigin x. |
1838 self shiftLayout:aView left:delta right:delta. |
1979 self shiftLayout:aView left:delta right:delta. |
1839 min := min + aView computeExtent x + space |
1980 min := min + aView computeExtent x + space |
1840 ]. |
1981 ] |
1841 self changed:#layout |
1982 ]. |
1842 ] |
1983 self changed:#layout |
1843 |
1984 |
1844 ! |
1985 ! |
1845 |
1986 |
1846 spreadSelectionVer |
1987 spreadSelectionVer |
1988 "spread multiple selection vertical |
|
1989 " |
|
1847 |sumHeights min max viewsInOrder topsInOrder count space| |
1990 |sumHeights min max viewsInOrder topsInOrder count space| |
1848 |
1991 |
1849 (self numberOfSelections > 1) ifFalse:[ |
1992 (self numberOfSelections > 1 and:[self canMove:selection]) ifFalse:[ |
1850 ^ self |
1993 ^ self |
1851 ]. |
1994 ]. |
1852 |
1995 |
1853 self selectionHiddenDo:[ |
1996 self withSelectionHiddenDo:[ |
1854 count := 0. |
1997 count := 0. |
1855 sumHeights := 0. |
1998 sumHeights := 0. |
1856 max := 0. |
1999 max := 0. |
1857 |
2000 |
1858 self selectionDo:[:aView | |
2001 self selectionDo:[:aView | |
1874 |delta| |
2017 |delta| |
1875 |
2018 |
1876 delta := min - aView computeOrigin y. |
2019 delta := min - aView computeOrigin y. |
1877 self shiftLayout:aView top:delta bottom:delta. |
2020 self shiftLayout:aView top:delta bottom:delta. |
1878 min := min + aView height + space |
2021 min := min + aView height + space |
1879 ]. |
2022 ] |
1880 self changed:#layout |
2023 ]. |
1881 ] |
2024 self changed:#layout |
1882 ! ! |
2025 ! ! |
1883 |
2026 |
1884 !UIObjectView methodsFor:'user actions - undo history'! |
2027 !UIObjectView methodsFor:'user actions - undo history'! |
1885 |
2028 |
1886 openUndoMenu |
2029 openUndoMenu |
2030 "open undo menu |
|
2031 " |
|
1887 self unselect. |
2032 self unselect. |
1888 undoHistory openUndoMenu. |
2033 |
2034 self withSelectionHiddenDo:[ |
|
2035 undoHistory openUndoMenu |
|
2036 ]. |
|
1889 self changed:#tree |
2037 self changed:#tree |
1890 |
2038 |
1891 ! |
2039 ! |
1892 |
2040 |
1893 removeUndoHistory |
2041 removeUndoHistory |
1895 " |
2043 " |
1896 undoHistory reinitialize |
2044 undoHistory reinitialize |
1897 ! |
2045 ! |
1898 |
2046 |
1899 undoLast |
2047 undoLast |
2048 "undo last action |
|
2049 " |
|
1900 self unselect. |
2050 self unselect. |
1901 undoHistory undoLast:1. |
2051 |
2052 self withSelectionHiddenDo:[ |
|
2053 undoHistory undoLast:1 |
|
2054 ]. |
|
1902 self changed:#tree |
2055 self changed:#tree |
1903 ! ! |
2056 ! ! |
1904 |
2057 |
1905 !UIObjectView::UndoHistory class methodsFor:'constants'! |
2058 !UIObjectView::UndoHistory class methodsFor:'constants'! |
1906 |
2059 |