# HG changeset patch # User ca # Date 1218197285 -7200 # Node ID 9f9cf71a311c8676f0279ade75f4794acc05b3ae # Parent 664ca922a80adb576230f3045c84092a095eb533 *** empty log message *** diff -r 664ca922a80a -r 9f9cf71a311c UIPainterView.st --- a/UIPainterView.st Fri Aug 08 14:02:20 2008 +0200 +++ b/UIPainterView.st Fri Aug 08 14:08:05 2008 +0200 @@ -375,11 +375,11 @@ self changeSelectionAfterPasteOf:sel. ! -pasteSpecifications:aSpecificationOrList into:aContainerOrNil keepLayout:keepLayout keepPosition:keepPosition at:aPointOrNilOrKeep +pasteSpecifications:aSpecificationOrList into:aContainerOrNil beforeIndex:anIndexOrNil keepLayout:keepLayout keepPosition:keepPosition at:aPointOrNilOrKeep "add the specs to the object view; returns list of pasted widgets" |specsToPaste pasteOffset builder newSel - bounds containerToPasteInto pastePoint| + bounds containerToPasteInto pastePoint beforeIndex| treeView askForSelectionChangeAllowed ifFalse:[^ nil]. @@ -454,13 +454,19 @@ pasteOffset := 0. + (anIndexOrNil notNil and:[anIndexOrNil > 0]) ifTrue:[ + beforeIndex := anIndexOrNil. + ]. specsToPaste do:[:eachSpec| |view newOrigin uiPainterAttributes thisAbsOrigin| uiPainterAttributes := eachSpec otherAttributeAt:#uiPainterAttributes. eachSpec otherAttributeAt:#uiPainterAttributes put:nil. - view := self addSpec:eachSpec builder:builder in:containerToPasteInto. + view := self addSpec:eachSpec builder:builder in:containerToPasteInto beforeIndex:beforeIndex. + beforeIndex notNil ifTrue:[ + beforeIndex := beforeIndex + 1 + ]. (keepPosition and:[ uiPainterAttributes notNil ]) ifTrue:[ aPointOrNilOrKeep == #keep ifTrue:[ @@ -488,9 +494,10 @@ newOrigin notNil ifTrue:[ self moveObject:view to:newOrigin. ]. - view realize. + view realized ifFalse:[ + view realize. + ]. newSel add:view. - ]. self withinTransaction:#paste objects:newSel do:[ @@ -500,7 +507,7 @@ ]. self realizeAllSubViews. - newSel do:[:v| v raise]. + "/ newSel do:[:v| v raise]. self elementChangedSize:containerToPasteInto. newSel size == 1 ifTrue:[newSel := newSel at:1]. @@ -509,6 +516,17 @@ "Modified: / 10.10.2001 / 14:15:12 / cg" ! +pasteSpecifications:aSpecificationOrList into:aContainerOrNil keepLayout:keepLayout keepPosition:keepPosition at:aPointOrNilOrKeep + "add the specs to the object view; returns list of pasted widgets" + + ^ self pasteSpecifications:aSpecificationOrList + into:aContainerOrNil + beforeIndex:nil + keepLayout:keepLayout + keepPosition:keepPosition + at:aPointOrNilOrKeep +! + pasteSpecifications:aSpecificationOrList keepLayout:keepLayout "add the specs to the object view; returns list of pasted widgets" @@ -536,6 +554,7 @@ ^ self pasteSpecifications:aSpecificationOrList into:nil + beforeIndex:nil keepLayout:keepLayout keepPosition:keepPosition at:aPointOrNilOrKeep @@ -570,7 +589,7 @@ replaceSelectionBy:aNewSpec "replace the selected widget by another one." - |oldSelection treeModel widgets oldView container| + |oldSelection treeModel newView oldView container specs| (self singleSelection notNil and:[treeView askForSelectionChangeAllowed]) ifFalse:[ ^ self @@ -579,7 +598,13 @@ oldSelection := treeModel selectedNodes at:1 ifAbsent: nil. oldSelection isNil ifTrue:[^ self]. - oldView := oldSelection contents view. + oldView := oldSelection contents view. + + (oldSelection hasChildren and:[aNewSpec class supportsSubComponents]) ifTrue:[ + specs := oldSelection children collect:[:each| + self fullSpecWithAbsolutePositionFor:(each contents view) + ]. + ]. aNewSpec otherAttributeAt:#uiPainterAttributes @@ -592,17 +617,28 @@ 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 withSelectionHiddenDo:[ + newView := self + pasteSpecifications:(Array with:aNewSpec) + into:container + beforeIndex:1 + keepLayout:true + keepPosition:true + at:#keep. + + self deleteSelectionBuffered:false. + + specs size > 0 ifTrue:[ + self pasteSpecifications:specs + into:newView + keepLayout:(aNewSpec class canResizeSubComponents) + keepPosition:(aNewSpec class isLayoutContainer not) + at:nil. + ]. + self select:newView. + ]. ]. - self select:widgets. - ^ widgets. + ^ newView. ! ! !UIPainterView methodsFor:'drag & drop'! @@ -2326,7 +2362,7 @@ |newProperty copyOfSpec nameOfSpec beforeIndex| (viewPosition notNil and:[aSpecification == aSpec]) ifTrue:[ - subviewToRealize := aFrame. + subviewToRealize := aView. [ (subviewToRealize notNil and:[subviewToRealize superView ~~ aFrame]) ] whileTrue:[ subviewToRealize := subviewToRealize superView.