--- a/UIPainterView.st Tue Feb 08 22:28:19 2000 +0100
+++ b/UIPainterView.st Wed Feb 09 13:45:04 2000 +0100
@@ -311,6 +311,24 @@
!
+pasteKeepingPosition
+ "add the objects in the paste-buffer to the object view;
+ translate the layout as appropriate, to position the component
+ at the same absolute position (relative to topView) as before
+ "
+ |sel|
+
+ sel := self
+ pasteSpecifications:(self getSelection)
+ keepLayout:true
+ keepPosition:true
+ at:nil.
+
+ sel notNil ifTrue:[
+ self select:sel.
+ ].
+!
+
pasteSpecifications:aSpecificationOrList keepLayout:keepLayout
"add the specs to the object view; returns list of pasted components
"
@@ -326,6 +344,17 @@
pasteSpecifications:aSpecificationOrList keepLayout:keepLayout at:aPointOrNil
"add the specs to the object view; returns list of pasted components
"
+ self
+ pasteSpecifications:aSpecificationOrList
+ keepLayout:keepLayout
+ keepPosition:false
+ at:aPointOrNil
+
+!
+
+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|
(self canPaste:aSpecificationOrList) ifFalse:[
@@ -340,6 +369,7 @@
(frame := self singleSelection) isNil ifTrue:[
frame := self
].
+
self selection:nil.
newSel := OrderedCollection new.
@@ -349,36 +379,46 @@
builder applicationClass:(self resolveName:className)
].
- keepLayout ifFalse:[
+ (keepLayout not or:[keepPosition]) ifTrue:[
pasteOffset := 0@0.
- aPointOrNil isNil ifTrue:[
- pasteOrigin := self sensor mousePoint.
- pasteOrigin := device translatePoint:pasteOrigin
- from:device rootView id
- to:frame id.
- ] ifFalse:[
- pasteOrigin := device translatePoint:aPointOrNil
+ keepPosition ifTrue:[
+ pasteOrigin := device translatePoint:0@0
from:self id
to:frame id.
- ]
- ].
- keepLayout ifFalse:[
+ ] ifFalse:[
+ aPointOrNil isNil ifTrue:[
+ pasteOrigin := self sensor mousePoint.
+ pasteOrigin := device translatePoint:pasteOrigin
+ from:device rootView id
+ to:frame id.
+ ] ifFalse:[
+ pasteOrigin := device translatePoint:aPointOrNil
+ from:self id
+ to:frame id.
+ ]
+ ].
+
bounds := Rectangle origin:0@0 extent:(frame bounds extent)
].
paste do:[:aSpec|
- |view|
+ |view newOrigin|
view := self addSpec:aSpec builder:builder in:frame.
- keepLayout ifFalse:[
- (bounds containsPoint:pasteOrigin) ifFalse:[
- self moveObject:view to:pasteOffset.
- ] ifTrue:[
- self moveObject:view to:pasteOrigin + pasteOffset.
+ keepPosition ifTrue:[
+ self moveObject:view to:(view origin + pasteOrigin).
+ ] ifFalse:[
+ keepLayout ifFalse:[
+ (bounds containsPoint:pasteOrigin) ifFalse:[
+ newOrigin := pasteOffset.
+ ] ifTrue:[
+ newOrigin := pasteOrigin + pasteOffset.
+ ].
+ self moveObject:view to:newOrigin.
+ pasteOffset := pasteOffset + 4
].
- pasteOffset := pasteOffset + 4
].
view realize.
newSel add:view.