- undo/redo fixes for moving and cut/paste;
- compatibility check for non-container controls git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@46018 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
a297dec681
commit
4427147544
@ -1265,12 +1265,6 @@ class XML_Tree(wx.TreeCtrl):
|
||||
self.PopupMenu(menu, evt.GetPosition())
|
||||
menu.Destroy()
|
||||
|
||||
# Redefine to force the update of font dimentions on wxGTK
|
||||
if wx.Platform == '__WXGTK__':
|
||||
def SetItemBold(self, item, state=True):
|
||||
wx.TreeCtrl.SetItemBold(self, item, state)
|
||||
self.SetIndent(self.GetIndent())
|
||||
|
||||
# Apply changes
|
||||
def Apply(self, xxx, item):
|
||||
g.panel.Apply()
|
||||
|
@ -167,20 +167,23 @@ class UndoReplace:
|
||||
|
||||
class UndoMove:
|
||||
def __init__(self, oldParent, oldIndex, newParent, newIndex):
|
||||
self.oldParent = oldParent
|
||||
# Store indexes because items can be invalid already
|
||||
self.oldParentIndex = g.tree.ItemFullIndex(oldParent)
|
||||
self.oldIndex = oldIndex
|
||||
self.newParent = newParent
|
||||
self.newParentIndex = g.tree.ItemFullIndex(newParent)
|
||||
self.newIndex = newIndex
|
||||
def destroy(self):
|
||||
pass
|
||||
def undo(self):
|
||||
item = g.tree.GetFirstChild(self.newParent)[0]
|
||||
oldParent = g.tree.ItemAtFullIndex(self.oldParentIndex)
|
||||
newParent = g.tree.ItemAtFullIndex(self.newParentIndex)
|
||||
item = g.tree.GetFirstChild(newParent)[0]
|
||||
for i in range(self.newIndex): item = g.tree.GetNextSibling(item)
|
||||
elem = g.tree.RemoveLeaf(item)
|
||||
nextItem = g.tree.GetFirstChild(self.oldParent)[0]
|
||||
nextItem = g.tree.GetFirstChild(oldParent)[0]
|
||||
for i in range(self.oldIndex): nextItem = g.tree.GetNextSibling(nextItem)
|
||||
|
||||
parent = g.tree.GetPyData(self.oldParent).treeObject()
|
||||
parent = g.tree.GetPyData(oldParent).treeObject()
|
||||
|
||||
# Check parent and child relationships.
|
||||
# If parent is sizer or notebook, child is of wrong class or
|
||||
@ -208,7 +211,7 @@ class UndoMove:
|
||||
pageElem.appendChild(elem)
|
||||
elem = pageElem
|
||||
|
||||
selected = g.tree.InsertNode(self.oldParent, parent, elem, nextItem)
|
||||
selected = g.tree.InsertNode(oldParent, parent, elem, nextItem)
|
||||
g.tree.EnsureVisible(selected)
|
||||
# Highlight is outdated
|
||||
if g.testWin and g.testWin.highLight:
|
||||
@ -216,11 +219,13 @@ class UndoMove:
|
||||
g.tree.needUpdate = True
|
||||
g.tree.SelectItem(selected)
|
||||
def redo(self):
|
||||
item = g.tree.GetFirstChild(self.oldParent)[0]
|
||||
oldParent = g.tree.ItemAtFullIndex(self.oldParentIndex)
|
||||
newParent = g.tree.ItemAtFullIndex(self.newParentIndex)
|
||||
item = g.tree.GetFirstChild(oldParent)[0]
|
||||
for i in range(self.oldIndex): item = g.tree.GetNextSibling(item)
|
||||
elem = g.tree.RemoveLeaf(item)
|
||||
|
||||
parent = g.tree.GetPyData(self.newParent).treeObject()
|
||||
parent = g.tree.GetPyData(newParent).treeObject()
|
||||
|
||||
# Check parent and child relationships.
|
||||
# If parent is sizer or notebook, child is of wrong class or
|
||||
@ -248,9 +253,9 @@ class UndoMove:
|
||||
pageElem.appendChild(elem)
|
||||
elem = pageElem
|
||||
|
||||
nextItem = g.tree.GetFirstChild(self.newParent)[0]
|
||||
nextItem = g.tree.GetFirstChild(newParent)[0]
|
||||
for i in range(self.newIndex): nextItem = g.tree.GetNextSibling(nextItem)
|
||||
selected = g.tree.InsertNode(self.newParent, parent, elem, nextItem)
|
||||
selected = g.tree.InsertNode(newParent, parent, elem, nextItem)
|
||||
g.tree.EnsureVisible(selected)
|
||||
# Highlight is outdated
|
||||
if g.testWin and g.testWin.highLight:
|
||||
|
@ -725,6 +725,8 @@ class Frame(wx.Frame):
|
||||
# Toolbar can be top-level of child of panel or frame
|
||||
if parent.__class__ not in [xxxMainNode, xxxPanel, xxxFrame] and \
|
||||
not parent.isSizer: error = True
|
||||
elif not parent.hasChildren:
|
||||
error = True
|
||||
elif child.__class__ == xxxPanel and parent.__class__ == xxxMainNode:
|
||||
pass
|
||||
elif child.__class__ == xxxSpacer:
|
||||
@ -835,12 +837,16 @@ class Frame(wx.Frame):
|
||||
|
||||
if g.testWin and g.testWin.highLight:
|
||||
g.testWin.highLight.Remove()
|
||||
tree.needUpdate = True
|
||||
tree.needUpdate = True
|
||||
|
||||
# Undo info
|
||||
self.lastOp = 'MOVELEFT'
|
||||
status = 'Made next sibling of parent'
|
||||
|
||||
# Prepare undo data
|
||||
panel.Apply()
|
||||
tree.UnselectAll()
|
||||
|
||||
oldIndex = tree.ItemIndex(selected)
|
||||
elem = tree.RemoveLeaf(selected)
|
||||
nextItem = tree.GetFirstChild(pparent)[0]
|
||||
@ -901,7 +907,11 @@ class Frame(wx.Frame):
|
||||
# Remove highlight, update testWin
|
||||
if g.testWin and g.testWin.highLight:
|
||||
g.testWin.highLight.Remove()
|
||||
tree.needUpdate = True
|
||||
tree.needUpdate = True
|
||||
|
||||
# Prepare undo data
|
||||
panel.Apply()
|
||||
tree.UnselectAll()
|
||||
|
||||
# Undo info
|
||||
self.lastOp = 'MOVERIGHT'
|
||||
@ -939,6 +949,7 @@ class Frame(wx.Frame):
|
||||
selected = tree.InsertNode(newParent, tree.GetPyData(newParent).treeObject(), elem, wx.TreeItemId())
|
||||
|
||||
newIndex = tree.ItemIndex(selected)
|
||||
tree.Expand(selected)
|
||||
tree.SelectItem(selected)
|
||||
|
||||
undoMan.RegisterUndo(UndoMove(oldParent, oldIndex, newParent, newIndex))
|
||||
|
Loading…
Reference in New Issue
Block a user