diff -r 4471bede7939 -r 050c6d4d427d UIPainterView.st --- a/UIPainterView.st Wed Aug 06 17:23:05 2008 +0200 +++ b/UIPainterView.st Thu Aug 07 12:33:13 2008 +0200 @@ -375,29 +375,7 @@ self changeSelectionAfterPasteOf:sel. ! -pasteSpecifications:aSpecificationOrList keepLayout:keepLayout - "add the specs to the object view; returns list of pasted widgets" - - ^ self - pasteSpecifications:aSpecificationOrList - keepLayout:keepLayout - keepPosition:true - at:nil - - "Modified: 11.8.1997 / 01:00:35 / cg" -! - -pasteSpecifications:aSpecificationOrList keepLayout:keepLayout at:aPointOrNil - "add the specs to the object view; returns list of pasted widgets" - - ^ self - pasteSpecifications:aSpecificationOrList - keepLayout:keepLayout - keepPosition:true - at:aPointOrNil -! - -pasteSpecifications:aSpecificationOrList keepLayout:keepLayout keepPosition:keepPosition at:aPointOrNilOrKeep +pasteSpecifications:aSpecificationOrList into:aContainerOrNil keepLayout:keepLayout keepPosition:keepPosition at:aPointOrNilOrKeep "add the specs to the object view; returns list of pasted widgets" |specsToPaste pasteOffset builder newSel @@ -405,11 +383,15 @@ treeView askForSelectionChangeAllowed ifFalse:[^ nil]. + containerToPasteInto := aContainerOrNil. + (aPointOrNilOrKeep == #keep or:[ self window sensor shiftDown or:[ self window sensor ctrlDown ]]) ifTrue:[ "/ paste into the selection - containerToPasteInto := self singleSelection. + containerToPasteInto isNil ifTrue:[ + containerToPasteInto := self singleSelection. + ]. ] ifFalse:[ "/ ignore the selection and paste where we drop!! pastePoint := aPointOrNilOrKeep. @@ -419,7 +401,9 @@ fromView:nil toView:self. ]. - containerToPasteInto := self findObjectAt:pastePoint + containerToPasteInto isNil ifTrue:[ + containerToPasteInto := self findObjectAt:pastePoint. + ]. ]. containerToPasteInto isNil ifTrue:[ @@ -474,7 +458,7 @@ |view newOrigin uiPainterAttributes thisAbsOrigin| uiPainterAttributes := eachSpec otherAttributeAt:#uiPainterAttributes. - "/ eachSpec otherAttributeAt:#uiPainterAttributes put:nil. +"/ eachSpec otherAttributeAt:#uiPainterAttributes put:nil. view := self addSpec:eachSpec builder:builder in:containerToPasteInto. @@ -525,6 +509,38 @@ "Modified: / 10.10.2001 / 14:15:12 / cg" ! +pasteSpecifications:aSpecificationOrList keepLayout:keepLayout + "add the specs to the object view; returns list of pasted widgets" + + ^ self + pasteSpecifications:aSpecificationOrList + keepLayout:keepLayout + keepPosition:true + at:nil + + "Modified: 11.8.1997 / 01:00:35 / cg" +! + +pasteSpecifications:aSpecificationOrList keepLayout:keepLayout at:aPointOrNil + "add the specs to the object view; returns list of pasted widgets" + + ^ self + pasteSpecifications:aSpecificationOrList + keepLayout:keepLayout + keepPosition:true + at:aPointOrNil +! + +pasteSpecifications:aSpecificationOrList keepLayout:keepLayout keepPosition:keepPosition at:aPointOrNilOrKeep + "add the specs to the object view; returns list of pasted widgets" + + ^ self pasteSpecifications:aSpecificationOrList + into:nil + keepLayout:keepLayout + keepPosition:keepPosition + at:aPointOrNilOrKeep +! + pasteWithLayout "add the objects in the paste-buffer to the object view - keep the old layout" @@ -554,66 +570,39 @@ replaceSelectionBy:aNewSpec "replace the selected widget by another one." - |specs coll index oldSelection newSelection treeModel children size node - container widgets builder newView property| - - treeView askForSelectionChangeAllowed ifFalse:[^ self]. - self assert:(self selection size == 1). - - treeModel := treeView model. + |oldSelection treeModel widgets oldView container| + + (self singleSelection notNil and:[treeView askForSelectionChangeAllowed]) ifFalse:[ + ^ self + ]. + treeModel := treeView model. oldSelection := treeModel selectedNodes at:1 ifAbsent: nil. - property := oldSelection contents. - property spec:aNewSpec. - - self rebuildView:(property view) fromSpec:aNewSpec withBuilder:nil forceNewView:true. - -"/ p := self propertyOfView:aView) -"/ -"/ builder := UIBuilder new isEditing:true. -"/ newView := aNewSpec buildViewWithLayoutFor:builder in:(container contents view). -self halt. -"/ ^self. - self deleteSelectionBuffered:false. - widgets := self pasteSpecifications:(Array with:aNewSpec) keepLayout:false. + oldSelection isNil ifTrue:[^ self]. + + oldView := oldSelection contents view. + + aNewSpec + otherAttributeAt:#uiPainterAttributes + put:(Dictionary new + at:#origin put:oldView origin; + at:#extent put:oldView extent; + at:#absOrigin put:(oldView originRelativeTo:self); + yourself). + + container := self singleSelection container. + + self withinTransaction:#replaceBy objects:(Array with:oldView) do:[ + self deleteSelectionBuffered:false. + + widgets := self + pasteSpecifications:(Array with:aNewSpec) + into:container + keepLayout:true + keepPosition:true + at:#keep. + ]. self select:widgets. ^ widgets. - - treeView canvasEventsDisabledDo:[ - treeModel := treeView model. - oldSelection := treeModel selectedNodes at:1 ifAbsent: nil. - - oldSelection notNil ifTrue:[ - children := oldSelection parent children. - (size := children size) > 1 ifTrue:[ - index := children identityIndexOf:oldSelection. - size == index ifTrue:[ - index := index - 1 - ]. - newSelection := children at:index ifAbsent:1. - ] ifFalse:[ - newSelection := oldSelection parent - ]. - newSelection := treeModel indexOf:newSelection. - ] ifFalse:[ - newSelection := 1 - ]. - - self hideSelection. - selection := nil. - specs := coll collect:[:aView| self fullSpecFor:aView ]. - - self withinTransaction:#cut objects:coll do:[ - coll reverseDo:[:aView| - self createUndoRemove:aView. - self remove:aView. - ] - ]. - treeView selection:nil. - treeView selection:(Array with: newSelection). - (node := treeView selectedNode) notNil ifTrue:[ - self setSelection:node contents view withRedraw:true. - ] - ] ! ! !UIPainterView methodsFor:'drag & drop'!