diff -r 85ef247db6b1 -r 0e8573b4329a UIPainterView.st --- a/UIPainterView.st Fri Feb 28 10:20:51 1997 +0100 +++ b/UIPainterView.st Fri Feb 28 10:22:30 1997 +0100 @@ -10,8 +10,6 @@ hereby transferred. " -'From Smalltalk/X, Version:3.1.4 on 25-feb-1997 at 2:17:29 pm' ! - UIObjectView subclass:#UIPainterView instanceVariableNames:'fontPanel viewProperties superclassName className methodName categoryName' @@ -212,21 +210,24 @@ ! deleteSelection - "delete the selection; not into the paste buffer (undo) + "delete the selection; copy the selection into the cut&paste-buffer + and open a transaction " - |text| + |text specs| self numberOfSelections ~~ 0 ifTrue:[ - text := self transactionTextFor:selection. + specs := self generateSpecFor:selection. + text := self transactionTextFor:selection. undoHistory transaction:#cut text:text do:[ super deleteSelection ]. + self setSelection:specs ] ! pasteBuffer - "add the objects in the paste-buffer + "add the objects in the paste-buffer to the object view " |paste builder frame pasteOrigin pasteOffset| @@ -237,7 +238,7 @@ frame := self singleSelection. - (self supportsSubComponents:frame) ifFalse:[ + (self canPasteInto:frame) ifFalse:[ frame := self ]. self unselect. @@ -277,6 +278,7 @@ self showSelection. self realizeAllSubViews. inputView raise. + self elementChangedSize:frame. self changed:#tree ! ! @@ -296,7 +298,7 @@ viewProperties add:props. name := props name. - aView specClass basicNew supportsLabel ifTrue:[ + aView specClass supportsLabel ifTrue:[ aView label:name ]. aView name:name. @@ -304,6 +306,8 @@ ! propertiesForNewView:aView + "generate property for a view and return properties + " |cls props index| cls := aView class. @@ -348,6 +352,8 @@ !UIPainterView methodsFor:'event handling'! keyPress:key x:x y:y + "any key pressed + " key == #Copy ifTrue:[ @@ -405,7 +411,7 @@ code := ''. viewProperties do:[:aProp | - |modelSelector protoSpec thisCode| + |modelSelector menuSelector protoSpec thisCode| (modelSelector := aProp aspectSelector) notNil ifTrue:[ (cls implements:modelSelector asSymbol) ifFalse:[ @@ -417,6 +423,15 @@ thisCode := (self generateAspectMethodFor:modelSelector spec:protoSpec inClass:cls). ]. code := code , thisCode + ]. + ]. + + (menuSelector := aProp menuSelector) notNil ifTrue:[ + (cls implements:menuSelector asSymbol) ifFalse:[ + protoSpec := aProp view specClass basicNew. + "/ kludge .. + thisCode := (self generateAspectMethodFor:menuSelector spec:protoSpec inClass:cls). + code := code , thisCode ] ] ]. @@ -833,7 +848,7 @@ (labelSelector := props labelSelector) notNil ifTrue:[ newSpec label:labelSelector ]. - (tabable := props tabable) notNil ifTrue:[ + (tabable := props tabable) == true ifTrue:[ newSpec tabable:tabable ]. (defaultable := props defaultable) notNil ifTrue:[ @@ -889,7 +904,7 @@ ^ self ] ]. - self selectionHiddenDo:[ + self withSelectionHiddenDo:[ group := EnterFieldGroup new. props := GroupProperties new. @@ -922,7 +937,7 @@ ^ self ] ]. - self selectionHiddenDo:[ + self withSelectionHiddenDo:[ group := RadioButtonGroup new. props := GroupProperties new. @@ -950,6 +965,8 @@ !UIPainterView methodsFor:'initialization'! initialize + "setup attributes + " super initialize. superclassName := 'ApplicationModel'. @@ -1113,6 +1130,8 @@ !UIPainterView methodsFor:'menus'! menu + "returns middle-button menu dependent on the selection + " |menu canPaste| testMode ifTrue:[^ nil ]. @@ -1158,7 +1177,7 @@ ) receiver:self. - (canPaste and:[self supportsSubComponents:selection]) ifFalse:[ + (canPaste and:[self canPasteInto:selection]) ifFalse:[ menu disable:#pasteBuffer ]. @@ -1167,6 +1186,8 @@ menu subMenuAt:#align put:(self subMenuAlign). ^ menu + + ! subMenuAlign @@ -1186,6 +1207,7 @@ '-' 'spread horizontal' 'spread vertical' + '-' 'center horizontal in frame' 'center vertical in frame' ) @@ -1202,6 +1224,7 @@ nil spreadSelectionHor spreadSelectionVer + nil centerSelectionHor centerSelectionVer ) @@ -1306,12 +1329,13 @@ size:size. f notNil ifTrue:[ - self selectionHiddenDo:[ + self withSelectionHiddenDo:[ self selectionDo:[:aView | aView font:f. - self elementChanged:aView. + self elementChangedSize:aView. ] - ] + ]. + self changed:#any. ] "Modified: 5.9.1995 / 12:13:27 / claus" @@ -1327,7 +1351,7 @@ ]. ((aView respondsTo:#label:) and:[aView label = prop name]) ifTrue:[ - self selectionHiddenDo:[ + self withSelectionHiddenDo:[ |layout| layout := aView geometryLayout copy. aView label:newName. @@ -1391,9 +1415,10 @@ ! removeAll - "remove the argument, anObject" - + "remove all objects and properties + " self unselect. + viewProperties := OrderedCollection new. subViews notNil ifTrue:[ subViews copy do:[:sub | @@ -1402,7 +1427,6 @@ ] ] ]. - viewProperties := OrderedCollection new. undoHistory reinitialize. self changed:#tree ! @@ -1422,7 +1446,7 @@ ! removeTreeFrom:anObject - "remove the argument, anObject and all of its children + "remove the argument, anObject and all of its subviews " |props| @@ -1461,7 +1485,7 @@ ! findViewWithId:aViewId - "finds view assigned to id and returns the view or nil + "finds view assigned to identifier and returns the view or nil " |prop| @@ -1474,7 +1498,8 @@ !UIPainterView methodsFor:'seraching property'! propertyOf:something - + "returns property assigned to group or view + " ^ viewProperties detect:[:p| (p view == something or:[p group == something])] ifNone:nil @@ -1485,12 +1510,14 @@ ! propertyOfGroup:aGroup - + "returns property assigned to group + " ^ viewProperties detect:[:p| p group == aGroup] ifNone:nil ! propertyOfIdentifier:anId - + "returns property assigned to unique identifier + " anId notNil ifTrue:[ ^ viewProperties detect:[:p| p identifier == anId] ifNone:nil. ]. @@ -1498,7 +1525,8 @@ ! propertyOfName:aString - + "returns property assigned to name + " aString = 'self' ifFalse:[ ^ viewProperties detect:[:p| p name = aString] ifNone:nil ]. @@ -1506,7 +1534,8 @@ ! propertyOfView:aView - + "returns property assigned to view + " (aView isNil or:[aView == self]) ifFalse:[ ^ viewProperties detect:[:p| p view == aView] ifNone:nil ]. @@ -1516,7 +1545,8 @@ !UIPainterView methodsFor:'testing'! isHorizontalResizable:aComponent - + "returns true if instance is horizontal resizeable + " (aComponent isKindOf:ScrollBar) ifTrue:[ ^ aComponent orientation == #horizontal ]. @@ -1532,7 +1562,8 @@ ! isVerticalResizable:aComponent - + "returns true if instance is vertical resizeable + " (aComponent isKindOf:EditField) ifTrue:[ ^ false ]. @@ -1600,6 +1631,8 @@ !UIPainterView methodsFor:'undo actions'! undoCreate:aViewId + "undo method when creating or pasting an object + " |view| undoHistory addUndoBlock:[ @@ -1611,30 +1644,22 @@ ! undoLayout:aViewId - "undo method layout + "undo method when changing the layout (position or dimension) " - |view layout| + |view layout extent| (view := self findViewWithId:aViewId) notNil ifTrue:[ - layout := view geometryLayout copy. - view := nil. - - layout notNil ifTrue:[ - undoHistory addUndoBlock:[ - (view := self findViewWithId:aViewId) notNil ifTrue:[ - view geometryLayout:layout - ] - ] - ] ifFalse:[ - layout := view pixelOrigin. - - undoHistory addUndoBlock:[ - (view := self findViewWithId:aViewId) notNil ifTrue:[ - view pixelOrigin:layout - ] + (layout := view geometryLayout copy) isNil ifTrue:[ + extent := view extent copy + ]. + undoHistory addUndoBlock:[ + (view := self findViewWithId:aViewId) notNil ifTrue:[ + layout notNil ifTrue:[view geometryLayout:layout] + ifFalse:[view extent:extent] ] ] - ] + ]. + view := nil ! undoLayoutView:aView @@ -1651,7 +1676,7 @@ ! undoRemove:aViewId - "prepare undo method + "undo method when removing an object " |view prop spec parentId| @@ -1659,10 +1684,8 @@ spec := (self generateSpecFor:view) first. view := view superView. - (self supportsSubComponents:view) ifTrue:[ - prop := self propertyOfView:view. - - prop notNil ifTrue:[ + (self canPasteInto:view) ifTrue:[ + (prop := self propertyOfView:view) notNil ifTrue:[ parentId := prop identifier ] ]. @@ -1691,7 +1714,7 @@ ! undoSpecModify:aViewId - "undo for updateFromSpec + "undo method when changing the specification for an object " |builder view spec| @@ -1703,7 +1726,7 @@ (view := self findViewWithId:aViewId) notNil ifTrue:[ builder := UIBuilder new. spec setAttributesIn:view with:builder. - view superView sizeChanged:nil + self elementChangedSize:view. ] ] ]. @@ -1720,7 +1743,7 @@ |props name builder| self singleSelection notNil ifTrue:[ - self selectionHiddenDo:[ + self withSelectionHiddenDo:[ self transaction:#specification selectionDo:[:aView| builder := UIBuilder new. props := self propertyOfView:aView. @@ -1742,7 +1765,7 @@ ]. aSpec setAttributesIn:aView with:builder. - aView superView sizeChanged:nil. + self elementChangedSize:aView. props tabable:aSpec tabable. props defaultable:aSpec defaultable. @@ -1751,9 +1774,9 @@ props changeSelector:aSpec changeSelector. props labelSelector:aSpec labelSelector. props menuSelector:aSpec menuSelector. - ]. - self changed:#tree - ] + ] + ]. + self changed:#tree ]. ! !