wx.lib.customtreectrl patches from Andrea:
1. ExpandAll has been renamed as ExpandAllChildren, and the new ExpandAll now takes no input arguments (consistent with wx.TreeCtrl) 2. ctstyle keyword is now defaulted to 0: every style related to CustomTreeCtrl and the underlying wx.PyScrolledWindow should be declared using the keyword "style" only. For backward compatibility, ctstyle continues to work as I merged ctstyle and style in the __init__ method. 3. GetClassDefaultAttributes is now a classmethod. 4. UnselectAll bug fixed. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@44601 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -764,7 +764,8 @@ class CustomTreeCtrlDemo(wx.Panel):
|
|||||||
splitter = wx.SplitterWindow(self, -1, style=wx.CLIP_CHILDREN | wx.SP_LIVE_UPDATE | wx.SP_3D)
|
splitter = wx.SplitterWindow(self, -1, style=wx.CLIP_CHILDREN | wx.SP_LIVE_UPDATE | wx.SP_3D)
|
||||||
|
|
||||||
# Create the CustomTreeCtrl, using a derived class defined below
|
# Create the CustomTreeCtrl, using a derived class defined below
|
||||||
self.tree = CustomTreeCtrl(splitter, -1, log=self.log, style=wx.SUNKEN_BORDER)
|
self.tree = CustomTreeCtrl(splitter, -1, log=self.log,
|
||||||
|
style= wx.SUNKEN_BORDER| CT.TR_HAS_BUTTONS | CT.TR_HAS_VARIABLE_ROW_HEIGHT)
|
||||||
|
|
||||||
self.leftpanel = wx.ScrolledWindow(splitter, -1, style=wx.SUNKEN_BORDER)
|
self.leftpanel = wx.ScrolledWindow(splitter, -1, style=wx.SUNKEN_BORDER)
|
||||||
self.leftpanel.SetScrollRate(20,20)
|
self.leftpanel.SetScrollRate(20,20)
|
||||||
@@ -1239,11 +1240,10 @@ class CustomTreeCtrl(CT.CustomTreeCtrl):
|
|||||||
|
|
||||||
def __init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition,
|
def __init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition,
|
||||||
size=wx.DefaultSize,
|
size=wx.DefaultSize,
|
||||||
style=wx.SUNKEN_BORDER,
|
style=wx.SUNKEN_BORDER | CT.TR_HAS_BUTTONS | CT.TR_HAS_VARIABLE_ROW_HEIGHT,
|
||||||
ctstyle=CT.TR_HAS_BUTTONS | CT.TR_HAS_VARIABLE_ROW_HEIGHT,
|
|
||||||
log=None):
|
log=None):
|
||||||
|
|
||||||
CT.CustomTreeCtrl.__init__(self, parent, id, pos, size, style, ctstyle)
|
CT.CustomTreeCtrl.__init__(self, parent, id, pos, size, style)
|
||||||
|
|
||||||
alldata = dir(CT)
|
alldata = dir(CT)
|
||||||
|
|
||||||
|
@@ -40,6 +40,23 @@ have been done. This includes implementations for GetTextExtent,
|
|||||||
Clip, DrawBitmap, fixing the drawing position of text to be at the
|
Clip, DrawBitmap, fixing the drawing position of text to be at the
|
||||||
upper left corner instead of the baseline, etc.
|
upper left corner instead of the baseline, etc.
|
||||||
|
|
||||||
|
wx.lib.customtreectrl patches from Andrea:
|
||||||
|
|
||||||
|
1. ExpandAll has been renamed as ExpandAllChildren, and the new
|
||||||
|
ExpandAll now takes no input arguments (consistent with
|
||||||
|
wx.TreeCtrl)
|
||||||
|
|
||||||
|
2. ctstyle keyword is now defaulted to 0: every style related to
|
||||||
|
CustomTreeCtrl and the underlying wx.PyScrolledWindow should be
|
||||||
|
declared using the keyword "style" only. For backward
|
||||||
|
compatibility, ctstyle continues to work as I merged ctstyle and
|
||||||
|
style in the __init__ method.
|
||||||
|
|
||||||
|
3. GetClassDefaultAttributes is now a classmethod.
|
||||||
|
|
||||||
|
4. UnselectAll bug fixed.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -3,7 +3,7 @@
|
|||||||
# Inspired By And Heavily Based On wxGenericTreeCtrl.
|
# Inspired By And Heavily Based On wxGenericTreeCtrl.
|
||||||
#
|
#
|
||||||
# Andrea Gavana, @ 17 May 2006
|
# Andrea Gavana, @ 17 May 2006
|
||||||
# Latest Revision: 26 May 2006, 22.30 CET
|
# Latest Revision: 02 Mar 2007, 22.30 CET
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# TODO List
|
# TODO List
|
||||||
@@ -134,8 +134,8 @@ CustomTreeCtrl has been tested on the following platforms:
|
|||||||
* Mac OS (Thanks to John Jackson).
|
* Mac OS (Thanks to John Jackson).
|
||||||
|
|
||||||
|
|
||||||
Latest Revision: Andrea Gavana @ 26 May 2006, 22.30 CET
|
Latest Revision: Andrea Gavana @ 02 Mar 2007, 22.30 CET
|
||||||
Version 0.8
|
Version 0.9
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -1736,7 +1736,7 @@ def EventFlagsToSelType(style, shiftDown=False, ctrlDown=False):
|
|||||||
class CustomTreeCtrl(wx.PyScrolledWindow):
|
class CustomTreeCtrl(wx.PyScrolledWindow):
|
||||||
|
|
||||||
def __init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize,
|
def __init__(self, parent, id=wx.ID_ANY, pos=wx.DefaultPosition, size=wx.DefaultSize,
|
||||||
style=0, ctstyle=TR_DEFAULT_STYLE, validator=wx.DefaultValidator,
|
style=TR_DEFAULT_STYLE, ctstyle=0, validator=wx.DefaultValidator,
|
||||||
name="CustomTreeCtrl"):
|
name="CustomTreeCtrl"):
|
||||||
"""
|
"""
|
||||||
Default class constructor.
|
Default class constructor.
|
||||||
@@ -1749,9 +1749,8 @@ class CustomTreeCtrl(wx.PyScrolledWindow):
|
|||||||
|
|
||||||
size: window size. If the default size (-1, -1) is specified then the window is sized appropriately.
|
size: window size. If the default size (-1, -1) is specified then the window is sized appropriately.
|
||||||
|
|
||||||
style: the underlying wx.ScrolledWindow style
|
style: the underlying wx.ScrolledWindow style + CustomTreeCtrl window style. This can be one of:
|
||||||
|
|
||||||
ctstyle: CustomTreeCtrl window style. This can be one of:
|
|
||||||
TR_NO_BUTTONS
|
TR_NO_BUTTONS
|
||||||
TR_HAS_BUTTONS # draw collapsed/expanded btns
|
TR_HAS_BUTTONS # draw collapsed/expanded btns
|
||||||
TR_NO_LINES # don't draw lines at all
|
TR_NO_LINES # don't draw lines at all
|
||||||
@@ -1769,10 +1768,14 @@ class CustomTreeCtrl(wx.PyScrolledWindow):
|
|||||||
TR_AUTO_CHECK_PARENT # only meaningful for checkboxes
|
TR_AUTO_CHECK_PARENT # only meaningful for checkboxes
|
||||||
TR_AUTO_TOGGLE_CHILD # only meaningful for checkboxes
|
TR_AUTO_TOGGLE_CHILD # only meaningful for checkboxes
|
||||||
|
|
||||||
|
ctstyle: kept for backward compatibility.
|
||||||
|
|
||||||
validator: window validator.
|
validator: window validator.
|
||||||
|
|
||||||
name: window name.
|
name: window name.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
style = style | ctstyle
|
||||||
|
|
||||||
self._current = self._key_current = self._anchor = self._select_me = None
|
self._current = self._key_current = self._anchor = self._select_me = None
|
||||||
self._hasFocus = False
|
self._hasFocus = False
|
||||||
@@ -1873,14 +1876,14 @@ class CustomTreeCtrl(wx.PyScrolledWindow):
|
|||||||
self._itemWithWindow = []
|
self._itemWithWindow = []
|
||||||
|
|
||||||
if wx.Platform == "__WXMAC__":
|
if wx.Platform == "__WXMAC__":
|
||||||
ctstyle &= ~TR_LINES_AT_ROOT
|
style &= ~TR_LINES_AT_ROOT
|
||||||
ctstyle |= TR_NO_LINES
|
style |= TR_NO_LINES
|
||||||
|
|
||||||
platform, major, minor = wx.GetOsVersion()
|
platform, major, minor = wx.GetOsVersion()
|
||||||
if major < 10:
|
if major < 10:
|
||||||
ctstyle |= TR_ROW_LINES
|
style |= TR_ROW_LINES
|
||||||
|
|
||||||
self._windowStyle = ctstyle
|
self._windowStyle = style
|
||||||
|
|
||||||
# Create the default check image list
|
# Create the default check image list
|
||||||
self.SetImageListCheck(13, 13)
|
self.SetImageListCheck(13, 13)
|
||||||
@@ -3467,8 +3470,8 @@ class CustomTreeCtrl(wx.PyScrolledWindow):
|
|||||||
self.ProcessEvent(event)
|
self.ProcessEvent(event)
|
||||||
|
|
||||||
|
|
||||||
def ExpandAll(self, item):
|
def ExpandAllChildren(self, item):
|
||||||
"""Expands all the items."""
|
"""Expands all the items children of the input item."""
|
||||||
|
|
||||||
if not item:
|
if not item:
|
||||||
raise Exception("\nERROR: Invalid Tree Item. ")
|
raise Exception("\nERROR: Invalid Tree Item. ")
|
||||||
@@ -3481,10 +3484,17 @@ class CustomTreeCtrl(wx.PyScrolledWindow):
|
|||||||
child, cookie = self.GetFirstChild(item)
|
child, cookie = self.GetFirstChild(item)
|
||||||
|
|
||||||
while child:
|
while child:
|
||||||
self.ExpandAll(child)
|
self.ExpandAllChildren(child)
|
||||||
child, cookie = self.GetNextChild(item, cookie)
|
child, cookie = self.GetNextChild(item, cookie)
|
||||||
|
|
||||||
|
|
||||||
|
def ExpandAll(self):
|
||||||
|
"""Expands all CustomTreeCtrl items."""
|
||||||
|
|
||||||
|
if self._anchor:
|
||||||
|
self.ExpandAllChildren(self._anchor)
|
||||||
|
|
||||||
|
|
||||||
def Collapse(self, item):
|
def Collapse(self, item):
|
||||||
"""
|
"""
|
||||||
Collapse an item, sending a EVT_TREE_ITEM_COLLAPSING and
|
Collapse an item, sending a EVT_TREE_ITEM_COLLAPSING and
|
||||||
@@ -3578,7 +3588,8 @@ class CustomTreeCtrl(wx.PyScrolledWindow):
|
|||||||
# the tree might not have the root item at all
|
# the tree might not have the root item at all
|
||||||
if rootItem:
|
if rootItem:
|
||||||
self.UnselectAllChildren(rootItem)
|
self.UnselectAllChildren(rootItem)
|
||||||
|
|
||||||
|
self.Unselect()
|
||||||
|
|
||||||
# Recursive function !
|
# Recursive function !
|
||||||
# To stop we must have crt_item<last_item
|
# To stop we must have crt_item<last_item
|
||||||
@@ -5734,4 +5745,6 @@ class CustomTreeCtrl(wx.PyScrolledWindow):
|
|||||||
attr.font = wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
|
attr.font = wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
|
||||||
return attr
|
return attr
|
||||||
|
|
||||||
|
GetClassDefaultAttributes = classmethod(GetClassDefaultAttributes)
|
||||||
|
|
||||||
|
|
Reference in New Issue
Block a user