Version 1.8-0

New feature added from a patch submitted on sourceforge by botg:
moving of tree items.

Bugs fixed:
- ChecklistBox content editing;
- Window styles more in sync with the docs;
- Replacing items;
- Reference property page created correctly (every property is
  optional).


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44381 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Roman Rolinsky
2007-02-06 15:40:32 +00:00
parent 750040fabb
commit 75aa19469b
14 changed files with 581 additions and 110 deletions

View File

@@ -6,6 +6,7 @@
from globals import *
from xxx import MakeXXXFromDOM
from tree import *
#from panel import *
# Undo/redo classes
@@ -123,9 +124,10 @@ class UndoPasteCreate:
class UndoReplace:
def __init__(self, item):
self.itemIndex = g.tree.ItemFullIndex(item)
self.xxx = g.tree.GetPyData(item)
#self.xxx = g.tree.GetPyData(item)
self.elem = None
def destroy(self):
if self.xxx: self.xxx.element.unlink()
if self.elem: self.elem.unlink()
def undo(self):
print 'Sorry, UndoReplace is not yet implemented.'
return
@@ -163,6 +165,91 @@ class UndoReplace:
def redo(self):
return
class UndoMove:
def __init__(self, oldParent, oldIndex, newParent, newIndex):
self.oldParent = oldParent
self.oldIndex = oldIndex
self.newParent = newParent
self.newIndex = newIndex
def destroy(self):
pass
def undo(self):
item = g.tree.GetFirstChild(self.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]
for i in range(self.oldIndex): nextItem = g.tree.GetNextSibling(nextItem)
parent = g.tree.GetPyData(self.oldParent).treeObject()
# Check parent and child relationships.
# If parent is sizer or notebook, child is of wrong class or
# parent is normal window, child is child container then detach child.
xxx = MakeXXXFromDOM(parent, elem)
isChildContainer = isinstance(xxx, xxxChildContainer)
if isChildContainer and \
((parent.isSizer and not isinstance(xxx, xxxSizerItem)) or \
(isinstance(parent, xxxNotebook) and not isinstance(xxx, xxxNotebookPage)) or \
not (parent.isSizer or isinstance(parent, xxxNotebook))):
elem.removeChild(xxx.child.element) # detach child
elem.unlink() # delete child container
elem = xxx.child.element # replace
# This may help garbage collection
xxx.child.parent = None
isChildContainer = False
# Parent is sizer or notebook, child is not child container
if parent.isSizer and not isChildContainer and not isinstance(xxx, xxxSpacer):
# Create sizer item element
sizerItemElem = MakeEmptyDOM('sizeritem')
sizerItemElem.appendChild(elem)
elem = sizerItemElem
elif isinstance(parent, xxxNotebook) and not isChildContainer:
pageElem = MakeEmptyDOM('notebookpage')
pageElem.appendChild(elem)
elem = pageElem
selected = g.tree.InsertNode(self.oldParent, parent, elem, nextItem)
g.tree.EnsureVisible(selected)
g.tree.SelectItem(selected)
def redo(self):
item = g.tree.GetFirstChild(self.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()
# Check parent and child relationships.
# If parent is sizer or notebook, child is of wrong class or
# parent is normal window, child is child container then detach child.
xxx = MakeXXXFromDOM(parent, elem)
isChildContainer = isinstance(xxx, xxxChildContainer)
if isChildContainer and \
((parent.isSizer and not isinstance(xxx, xxxSizerItem)) or \
(isinstance(parent, xxxNotebook) and not isinstance(xxx, xxxNotebookPage)) or \
not (parent.isSizer or isinstance(parent, xxxNotebook))):
elem.removeChild(xxx.child.element) # detach child
elem.unlink() # delete child container
elem = xxx.child.element # replace
# This may help garbage collection
xxx.child.parent = None
isChildContainer = False
# Parent is sizer or notebook, child is not child container
if parent.isSizer and not isChildContainer and not isinstance(xxx, xxxSpacer):
# Create sizer item element
sizerItemElem = MakeEmptyDOM('sizeritem')
sizerItemElem.appendChild(elem)
elem = sizerItemElem
elif isinstance(parent, xxxNotebook) and not isChildContainer:
pageElem = MakeEmptyDOM('notebookpage')
pageElem.appendChild(elem)
elem = pageElem
nextItem = g.tree.GetFirstChild(self.newParent)[0]
for i in range(self.newIndex): nextItem = g.tree.GetNextSibling(nextItem)
selected = g.tree.InsertNode(self.newParent, parent, elem, nextItem)
g.tree.EnsureVisible(selected)
g.tree.SelectItem(selected)
class UndoEdit:
def __init__(self):
self.pages = map(ParamPage.GetState, g.panel.pages)