--- a/UIPainterView.st Fri Sep 26 09:56:09 2003 +0200
+++ b/UIPainterView.st Thu Oct 02 19:42:26 2003 +0200
@@ -208,6 +208,19 @@
!UIPainterView methodsFor:'copy & cut & paste'!
+commonContainerOf:someComponents
+ |container|
+
+ container := someComponents first container.
+ [container notNil
+ and:[ (someComponents conform:[:eachComponent | eachComponent isComponentOf:container]) not]]
+ whileTrue:[
+ container := container container.
+ ].
+self halt.
+ ^ container
+!
+
copySelection
"copy the selection into the cut&paste-buffer
"
@@ -353,17 +366,27 @@
pasteSpecifications:aSpecificationOrList keepLayout:keepLayout keepPosition:keepPosition at:aPointOrNil
"add the specs to the object view; returns list of pasted components
"
- |paste frame pasteOrigin pasteOffset builder newSel bounds container|
+ |paste pasteOrigin pasteOffset builder newSel bounds containerToPasteInto|
treeView askForSelectionChangeAllowed ifFalse:[^ nil].
- (self canPasteInto:(self singleSelection)) ifFalse:[
- (container := self singleSelection) notNil ifTrue:[
+ containerToPasteInto := self singleSelection.
+ containerToPasteInto isNil ifTrue:[
+ self selection size > 0 ifTrue:[
+ containerToPasteInto := self commonContainerOf:self selection
+ ] ifFalse:[
+ containerToPasteInto := self
+ ].
+ self selection:containerToPasteInto.
+ ].
+
+ (self canPasteInto:containerToPasteInto) ifFalse:[
+ containerToPasteInto notNil ifTrue:[
"/ search up parent list for something we can paste into
- [container notNil and:[(self canPasteInto:container) not]] whileTrue:[
- container := container container.
+ [containerToPasteInto notNil and:[(self canPasteInto:containerToPasteInto) not]] whileTrue:[
+ containerToPasteInto := containerToPasteInto container.
].
- self selection:container.
+ self selection:containerToPasteInto.
].
].
@@ -377,9 +400,6 @@
] ifFalse:[
paste := Array with:aSpecificationOrList
].
- (frame := self singleSelection) isNil ifTrue:[
- frame := self
- ].
self setSelection:nil.
newSel := OrderedCollection new.
@@ -395,27 +415,27 @@
keepPosition ifTrue:[
pasteOrigin := device translatePoint:0@0
fromView:self
- toView:frame.
+ toView:containerToPasteInto.
] ifFalse:[
aPointOrNil isNil ifTrue:[
pasteOrigin := self sensor mousePoint.
pasteOrigin := device translatePoint:pasteOrigin
fromView:nil
- toView:frame.
+ toView:containerToPasteInto.
] ifFalse:[
pasteOrigin := device translatePoint:aPointOrNil
fromView:self
- toView:frame.
+ toView:containerToPasteInto.
]
].
- bounds := Rectangle origin:0@0 extent:(frame bounds extent)
+ bounds := Rectangle origin:0@0 extent:(containerToPasteInto bounds extent)
].
paste do:[:aSpec|
|view newOrigin|
- view := self addSpec:aSpec builder:builder in:frame.
+ view := self addSpec:aSpec builder:builder in:containerToPasteInto.
keepPosition ifTrue:[
self moveObject:view to:(view origin + pasteOrigin).
@@ -441,7 +461,7 @@
self realizeAllSubViews.
newSel do:[:v| v raise].
- self elementChangedSize:frame.
+ self elementChangedSize:containerToPasteInto.
newSel size == 1 ifTrue:[newSel := newSel at:1].
^ newSel
@@ -1930,14 +1950,10 @@
"
|prop spec|
- (prop := self propertyOfView:anObject) notNil ifTrue:[
- spec := prop spec copy.
- spec layoutFromView:anObject
- ].
+ (prop := self propertyOfView:anObject) isNil ifTrue:[^ nil].
+ spec := prop spec copy.
+ spec layoutFromView:anObject.
^ spec
-
-
-
!
specForSelection