diff -r ffa9ea02d276 -r 715b3dbba87d UIObjectView.st --- a/UIObjectView.st Tue May 27 11:12:11 1997 +0200 +++ b/UIObjectView.st Tue May 27 11:16:45 1997 +0200 @@ -25,8 +25,8 @@ documentation " - buildIn view used by the UIPainter; from this view, the layout of the - new application derives from. + buildIn view used by the UIPainter; it provides all services for creating, deleting + moving and changing layouts of painted components on a canvas. [see also:] UIBuilder @@ -246,8 +246,8 @@ " (aState == enableChannel value) ifFalse:[ aState ifFalse:[ - saveSelection := self selection copy. - self unselect. + saveSelection := self selection. + self select:nil. enableChannel value:aState. inputView unrealize. ] ifTrue:[ @@ -582,7 +582,7 @@ " |widget object start frame delta| - self unselect. + self select:nil. widget := self findContainerViewAt:aPoint. motionAction := [:movePoint| self doDragCreate:movePoint]. @@ -723,7 +723,7 @@ aView isNil ifTrue:[ (aView := self findObjectAt:aPoint) isNil ifTrue:[ - ^ self unselect + ^ self select:nil ]. (self canMove:aView) ifFalse:[ @@ -900,8 +900,6 @@ " |wasClipped delta r oldPaint| - r := aComponent origin extent:8@8. - (wasClipped := clipChildren) ifTrue:[ self clippedByChildren:(clipChildren := false). ]. @@ -1200,31 +1198,9 @@ !UIObjectView methodsFor:'selections'! -addToSelection:anObject - "add anObject to selection - " - |coll| - - self enabled ifTrue:[ - self hasSelection ifFalse:[ - self select:anObject - ] ifTrue:[ - (self isSelected:anObject) ifFalse:[ - (coll := self selection) isCollection ifFalse:[ - coll := OrderedCollection with:coll - ]. - coll add:anObject. - self setSelection:coll withRedraw:false. - self showSelected:anObject. - self selectionChanged. - ] - ] - ] -! - moveableSelection - "tests whether all selected objects are moveable and in case - of true the selection is returned, otherwise nil + "checks whether the selection is not empty and all selected instances + can be moved. If true the selection is returned otherwise nil " |coll| @@ -1237,7 +1213,7 @@ ! numberOfSelections - "return the number of selected entries + "return the number of selected instances " |coll size| @@ -1248,27 +1224,6 @@ ^ 1 ! -removeFromSelection:anObject - "remove anObject from selection - " - |sel| - - (self isSelected:anObject) ifFalse:[ - ^ self - ]. - - sel := self selection. - - sel size > 1 ifTrue:[ - sel := sel copy. - sel remove:anObject ifAbsent:nil. - ] ifFalse:[ - sel := nil - ]. - self setSelection:sel withRedraw:true. - self selectionChanged. -! - select:something "change selection to something " @@ -1281,14 +1236,6 @@ ! -selection - "returns selection - " - ^ selection - - -! - selectionChanged "called whenever the selection changed " @@ -1304,18 +1251,6 @@ ! -setSelection:aNewSelection withRedraw:doRedraw - "set a new selection - " - doRedraw ifTrue:[ - self hideSelection. - selection := aNewSelection. - self showSelection - ] ifFalse:[ - selection := aNewSelection - ] -! - showSelection "show the selection - draw handles " @@ -1325,7 +1260,8 @@ ! singleSelection - "returns single selection or nil + "checks whether one element is selected; in this case the element is + returned otherwise nil " |coll| @@ -1338,7 +1274,8 @@ ! singleSelectionDo:aBlock - "perform block with argument a view in case of one selection + "checks whether one element is selected; in this case the block + with argument the selected instance will be processed " |view| @@ -1396,6 +1333,62 @@ ! ! +!UIObjectView methodsFor:'selections basic'! + +addToSelection:anObject + "add an object to the selection + " + (self enabled and:[(self isSelected:anObject) not]) ifTrue:[ + selection isCollection ifFalse:[ + selection isNil ifTrue:[ + selection := anObject + ] ifFalse:[ + selection := OrderedCollection with:selection with:anObject + ] + ] ifTrue:[ + selection add:anObject + ]. + self showSelected:anObject. + self selectionChanged. + ] +! + +removeFromSelection:anObject + "remove an object from the selection + " + (self isSelected:anObject) ifTrue:[ + self showUnselected:anObject. + + selection size > 1 ifTrue:[ + selection remove:anObject ifAbsent:nil. + self showSelection. + ] ifFalse:[ + selection := nil + ]. + self selectionChanged. + ] +! + +selection + "returns the current selection + " + ^ selection + + +! + +setSelection:aNewSelection withRedraw:doRedraw + "set a new selection without change notifications + " + doRedraw ifTrue:[ + self hideSelection. + selection := aNewSelection. + self showSelection + ] ifFalse:[ + selection := aNewSelection + ] +! ! + !UIObjectView methodsFor:'testing'! canMove:something @@ -2247,7 +2240,7 @@ openUndoMenu "open undo menu " - self unselect. + self select:nil. self withSelectionHiddenDo:[ undoHistory openUndoMenu @@ -2264,7 +2257,7 @@ undoLast "undo last action " - self unselect. + self select:nil. self withSelectionHiddenDo:[ undoHistory undoLast:1 @@ -2283,6 +2276,22 @@ ! ! +!UIObjectView::UndoHistory class methodsFor:'documentation'! + +documentation +" + undo history used by the UIPainter-Tool; to each operation, an undo block + and some text is stored. In case of a required undo, the corresponding + undo block will be performed. + + [see also:] + UIObjectView + UIPainterView +" + + +! ! + !UIObjectView::UndoHistory class methodsFor:'instance creation'! new @@ -2471,8 +2480,15 @@ !UIObjectView::UndoHistory::Transaction class methodsFor:'documentation'! -version - ^ '$Header$' +documentation +" + represents one undo record, keeping the associated type and printable text + and the undo action performed on an undo request + + [see also:] + UndoHistory +" + ! ! !UIObjectView::UndoHistory::Transaction class methodsFor:'instance creation'!