--- a/UIPainterView.st Thu Aug 07 17:04:18 2008 +0200
+++ b/UIPainterView.st Thu Aug 07 17:07:14 2008 +0200
@@ -2284,7 +2284,14 @@
"build view and subviews from aSpecification into a frame. The top view
is returned. The contained components of a spec are set to nil
"
- |cls|
+ ^ self addSpec:aSpecification builder:aBuilder in:aFrame beforeIndex:nil.
+!
+
+addSpec:aSpecification builder:aBuilder in:aFrame beforeIndex:anIndexOrNil
+ "build view and subviews from aSpecification into a frame. The top view
+ is returned. The contained components of a spec are set to nil
+ "
+ |cls newView viewPosition subviewToRealize|
cls := self resolveName:className.
@@ -2292,9 +2299,27 @@
aBuilder applicationClass:cls.
].
+ ( anIndexOrNil notNil
+ and:[anIndexOrNil between:1 and:(aFrame subViews size)]
+ ) ifTrue:[
+ viewPosition := anIndexOrNil.
+ ].
+
"/ remember view<->spec associations to tree
aBuilder componentCreationHook:[:aView :aSpec :builder|
- |newProperty copyOfSpec nameOfSpec|
+ |newProperty copyOfSpec nameOfSpec beforeIndex|
+
+ (viewPosition notNil and:[aSpecification == aSpec]) ifTrue:[
+ subviewToRealize := aFrame.
+
+ [ (subviewToRealize notNil and:[subviewToRealize superView ~~ aFrame]) ] whileTrue:[
+ subviewToRealize := subviewToRealize superView.
+ ].
+ subviewToRealize notNil ifTrue:[
+ beforeIndex := viewPosition.
+ aFrame changeSequenceOrderFor:subviewToRealize to:viewPosition.
+ ].
+ ].
newProperty := ViewProperty new.
copyOfSpec := aSpec copy.
@@ -2312,9 +2337,18 @@
(nameOfSpec isNil or:[(self propertyOfName:nameOfSpec) notNil]) ifTrue:[
copyOfSpec name:(self uniqueNameFor:copyOfSpec)
].
- treeView addProperty:newProperty.
+ treeView addProperty:newProperty beforeIndex:beforeIndex.
].
- ^ aSpecification buildViewWithLayoutFor:aBuilder in:aFrame.
+ newView := aSpecification buildViewWithLayoutFor:aBuilder in:aFrame.
+
+ subviewToRealize notNil ifTrue:[
+ subviewToRealize realize.
+
+ aFrame subViews from:(viewPosition + 1 ) do:[:v|
+ v shown ifTrue:[v raise]
+ ].
+ ].
+ ^ newView
"Modified: 4.7.1997 / 23:48:55 / cg"
!
@@ -2613,19 +2647,25 @@
createUndoRemove:aView
"create undo method before deleting views
"
- |prop pid|
-
- (prop := self propertyOfView:aView) notNil ifTrue:[
- (pid := self propertyOfParentForView:aView) notNil ifTrue:[
- pid := pid identifier
- ].
-
- undoHistory addUndoSelector:#undoRemove:
- withArgs:(Array with:(self fullSpecFor:aView)
- with:(prop identifier)
- with:pid).
- self undoHistoryChanged.
- ]
+ |item itemParent prop args|
+
+ item := treeView detectItemCorespondingToView:aView.
+ item isNil ifTrue:[^ self ].
+
+ itemParent := item parent.
+ itemParent isNil ifTrue:[^ self ].
+
+ prop := item contents.
+
+ args := Array
+ with:(self fullSpecFor:aView)
+ with:(prop identifier)
+ with:(itemParent contents identifier)
+ with:(itemParent indexOfChild:item).
+
+
+ undoHistory addUndoSelector:#'undoRemove:' withArgs:args.
+ self undoHistoryChanged.
!
createUndoSpecModify:aProp
@@ -2664,17 +2704,23 @@
undoRemove:args
"undo method when removing an object; see 'createUndoRemove:'
"
- |frame prop view|
-
- (args at:3) notNil ifTrue:[
- frame := self findViewWithId:(args at:3).
+ |frame prop view position parentId|
+
+ position := args at:4 ifAbsent:nil.
+ parentId := args at:3 ifAbsent:nil.
+
+ parentId notNil ifTrue:[
+ frame := self findViewWithId:parentId.
].
- frame isNil ifTrue:[
- frame := self
- ].
- view := self addSpec:(args at:1) builder:(UIBuilder new isEditing:true) in:frame.
+
+ frame isNil ifTrue:[ frame := self. ].
+
+ view := self addSpec:(args at:1)
+ builder:(UIBuilder new isEditing:true)
+ in:frame
+ beforeIndex:position.
+
view realize.
-
prop := self propertyOfView:view.
prop identifier:(args at:2).
!