A bit of cleanup, use a lighter shade of grey for the default pen, use
the base class HasFlag, etc. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@45894 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1870,12 +1870,13 @@ class CustomTreeCtrl(wx.PyScrolledWindow):
|
|||||||
self._vistaselection = False
|
self._vistaselection = False
|
||||||
|
|
||||||
# Connection lines style
|
# Connection lines style
|
||||||
|
grey = (160,160,160)
|
||||||
if wx.Platform != "__WXMAC__":
|
if wx.Platform != "__WXMAC__":
|
||||||
self._dottedPen = wx.Pen("grey", 1, wx.USER_DASH)
|
self._dottedPen = wx.Pen(grey, 1, wx.USER_DASH)
|
||||||
self._dottedPen.SetDashes([1,1])
|
self._dottedPen.SetDashes([1,1])
|
||||||
self._dottedPen.SetCap(wx.CAP_BUTT)
|
self._dottedPen.SetCap(wx.CAP_BUTT)
|
||||||
else:
|
else:
|
||||||
self._dottedPen = wx.Pen("grey", 1)
|
self._dottedPen = wx.Pen(grey, 1)
|
||||||
|
|
||||||
# Pen Used To Draw The Border Around Selected Items
|
# Pen Used To Draw The Border Around Selected Items
|
||||||
self._borderPen = wx.BLACK_PEN
|
self._borderPen = wx.BLACK_PEN
|
||||||
@@ -1893,8 +1894,6 @@ class CustomTreeCtrl(wx.PyScrolledWindow):
|
|||||||
if major < 10:
|
if major < 10:
|
||||||
style |= TR_ROW_LINES
|
style |= TR_ROW_LINES
|
||||||
|
|
||||||
self._windowStyle = style
|
|
||||||
|
|
||||||
# Create the default check image list
|
# Create the default check image list
|
||||||
self.SetImageListCheck(13, 13)
|
self.SetImageListCheck(13, 13)
|
||||||
|
|
||||||
@@ -2169,13 +2168,13 @@ class CustomTreeCtrl(wx.PyScrolledWindow):
|
|||||||
dc = wx.ClientDC(self)
|
dc = wx.ClientDC(self)
|
||||||
self.RefreshLine(item)
|
self.RefreshLine(item)
|
||||||
|
|
||||||
if self._windowStyle & TR_AUTO_CHECK_CHILD:
|
if self.HasFlag(TR_AUTO_CHECK_CHILD):
|
||||||
ischeck = self.IsItemChecked(item)
|
ischeck = self.IsItemChecked(item)
|
||||||
self.AutoCheckChild(item, ischeck)
|
self.AutoCheckChild(item, ischeck)
|
||||||
if self._windowStyle & TR_AUTO_CHECK_PARENT:
|
if self.HasFlag(TR_AUTO_CHECK_PARENT):
|
||||||
ischeck = self.IsItemChecked(item)
|
ischeck = self.IsItemChecked(item)
|
||||||
self.AutoCheckParent(item, ischeck)
|
self.AutoCheckParent(item, ischeck)
|
||||||
elif self._windowStyle & TR_AUTO_TOGGLE_CHILD:
|
elif self.HasFlag(TR_AUTO_TOGGLE_CHILD):
|
||||||
self.AutoToggleChild(item)
|
self.AutoToggleChild(item)
|
||||||
|
|
||||||
e = TreeEvent(wxEVT_TREE_ITEM_CHECKED, self.GetId())
|
e = TreeEvent(wxEVT_TREE_ITEM_CHECKED, self.GetId())
|
||||||
@@ -2310,12 +2309,6 @@ class CustomTreeCtrl(wx.PyScrolledWindow):
|
|||||||
self._dirty = True
|
self._dirty = True
|
||||||
|
|
||||||
|
|
||||||
def HasFlag(self, flag):
|
|
||||||
"""Returns whether CustomTreeCtrl has a flag."""
|
|
||||||
|
|
||||||
return self._windowStyle & flag
|
|
||||||
|
|
||||||
|
|
||||||
def HasChildren(self, item):
|
def HasChildren(self, item):
|
||||||
"""Returns whether an item has children or not."""
|
"""Returns whether an item has children or not."""
|
||||||
|
|
||||||
@@ -2349,19 +2342,19 @@ class CustomTreeCtrl(wx.PyScrolledWindow):
|
|||||||
# want to update the inherited styles, but right now
|
# want to update the inherited styles, but right now
|
||||||
# none of the parents has updatable styles
|
# none of the parents has updatable styles
|
||||||
|
|
||||||
if self._windowStyle & TR_MULTIPLE and not (styles & TR_MULTIPLE):
|
if self.HasFlag(TR_MULTIPLE) and not (styles & TR_MULTIPLE):
|
||||||
selections = self.GetSelections()
|
selections = self.GetSelections()
|
||||||
for select in selections[0:-1]:
|
for select in selections[0:-1]:
|
||||||
self.SelectItem(select, False)
|
self.SelectItem(select, False)
|
||||||
|
|
||||||
self._windowStyle = styles
|
self.SetWindowStyle(styles)
|
||||||
self._dirty = True
|
self._dirty = True
|
||||||
|
|
||||||
|
|
||||||
def GetTreeStyle(self):
|
def GetTreeStyle(self):
|
||||||
"""Returns the CustomTreeCtrl style."""
|
"""Returns the CustomTreeCtrl style."""
|
||||||
|
|
||||||
return self._windowStyle
|
return self.GetWindowStyle()
|
||||||
|
|
||||||
|
|
||||||
def HasButtons(self):
|
def HasButtons(self):
|
||||||
@@ -3155,10 +3148,10 @@ class CustomTreeCtrl(wx.PyScrolledWindow):
|
|||||||
def DoInsertItem(self, parentId, previous, text, ct_type=0, wnd=None, image=-1, selImage=-1, data=None):
|
def DoInsertItem(self, parentId, previous, text, ct_type=0, wnd=None, image=-1, selImage=-1, data=None):
|
||||||
"""Actually inserts an item in the tree."""
|
"""Actually inserts an item in the tree."""
|
||||||
|
|
||||||
if wnd is not None and not (self._windowStyle & TR_HAS_VARIABLE_ROW_HEIGHT):
|
if wnd is not None and not self.HasFlag(TR_HAS_VARIABLE_ROW_HEIGHT):
|
||||||
raise Exception("\nERROR: In Order To Append/Insert Controls You Have To Use The Style TR_HAS_VARIABLE_ROW_HEIGHT")
|
raise Exception("\nERROR: In Order To Append/Insert Controls You Have To Use The Style TR_HAS_VARIABLE_ROW_HEIGHT")
|
||||||
|
|
||||||
if text.find("\n") >= 0 and not (self._windowStyle & TR_HAS_VARIABLE_ROW_HEIGHT):
|
if text.find("\n") >= 0 and not self.HasFlag(TR_HAS_VARIABLE_ROW_HEIGHT):
|
||||||
raise Exception("\nERROR: In Order To Append/Insert A MultiLine Text You Have To Use The Style TR_HAS_VARIABLE_ROW_HEIGHT")
|
raise Exception("\nERROR: In Order To Append/Insert A MultiLine Text You Have To Use The Style TR_HAS_VARIABLE_ROW_HEIGHT")
|
||||||
|
|
||||||
if ct_type < 0 or ct_type > 2:
|
if ct_type < 0 or ct_type > 2:
|
||||||
@@ -3190,10 +3183,10 @@ class CustomTreeCtrl(wx.PyScrolledWindow):
|
|||||||
if self._anchor:
|
if self._anchor:
|
||||||
raise Exception("\nERROR: Tree Can Have Only One Root")
|
raise Exception("\nERROR: Tree Can Have Only One Root")
|
||||||
|
|
||||||
if wnd is not None and not (self._windowStyle & TR_HAS_VARIABLE_ROW_HEIGHT):
|
if wnd is not None and not self.HasFlag(TR_HAS_VARIABLE_ROW_HEIGHT):
|
||||||
raise Exception("\nERROR: In Order To Append/Insert Controls You Have To Use The Style TR_HAS_VARIABLE_ROW_HEIGHT")
|
raise Exception("\nERROR: In Order To Append/Insert Controls You Have To Use The Style TR_HAS_VARIABLE_ROW_HEIGHT")
|
||||||
|
|
||||||
if text.find("\n") >= 0 and not (self._windowStyle & TR_HAS_VARIABLE_ROW_HEIGHT):
|
if text.find("\n") >= 0 and not self.HasFlag(TR_HAS_VARIABLE_ROW_HEIGHT):
|
||||||
raise Exception("\nERROR: In Order To Append/Insert A MultiLine Text You Have To Use The Style TR_HAS_VARIABLE_ROW_HEIGHT")
|
raise Exception("\nERROR: In Order To Append/Insert A MultiLine Text You Have To Use The Style TR_HAS_VARIABLE_ROW_HEIGHT")
|
||||||
|
|
||||||
if ct_type < 0 or ct_type > 2:
|
if ct_type < 0 or ct_type > 2:
|
||||||
@@ -3226,10 +3219,10 @@ class CustomTreeCtrl(wx.PyScrolledWindow):
|
|||||||
def PrependItem(self, parent, text, ct_type=0, wnd=None, image=-1, selImage=-1, data=None):
|
def PrependItem(self, parent, text, ct_type=0, wnd=None, image=-1, selImage=-1, data=None):
|
||||||
"""Appends an item as a first child of parent."""
|
"""Appends an item as a first child of parent."""
|
||||||
|
|
||||||
if wnd is not None and not (self._windowStyle & TR_HAS_VARIABLE_ROW_HEIGHT):
|
if wnd is not None and not self.HasFlag(TR_HAS_VARIABLE_ROW_HEIGHT):
|
||||||
raise Exception("\nERROR: In Order To Append/Insert Controls You Have To Use The Style TR_HAS_VARIABLE_ROW_HEIGHT")
|
raise Exception("\nERROR: In Order To Append/Insert Controls You Have To Use The Style TR_HAS_VARIABLE_ROW_HEIGHT")
|
||||||
|
|
||||||
if text.find("\n") >= 0 and not (self._windowStyle & TR_HAS_VARIABLE_ROW_HEIGHT):
|
if text.find("\n") >= 0 and not self.HasFlag(TR_HAS_VARIABLE_ROW_HEIGHT):
|
||||||
raise Exception("\nERROR: In Order To Append/Insert A MultiLine Text You Have To Use The Style TR_HAS_VARIABLE_ROW_HEIGHT")
|
raise Exception("\nERROR: In Order To Append/Insert A MultiLine Text You Have To Use The Style TR_HAS_VARIABLE_ROW_HEIGHT")
|
||||||
|
|
||||||
return self.DoInsertItem(parent, 0, text, ct_type, wnd, image, selImage, data)
|
return self.DoInsertItem(parent, 0, text, ct_type, wnd, image, selImage, data)
|
||||||
@@ -3238,10 +3231,10 @@ class CustomTreeCtrl(wx.PyScrolledWindow):
|
|||||||
def InsertItemByItem(self, parentId, idPrevious, text, ct_type=0, wnd=None, image=-1, selImage=-1, data=None):
|
def InsertItemByItem(self, parentId, idPrevious, text, ct_type=0, wnd=None, image=-1, selImage=-1, data=None):
|
||||||
"""Auxiliary function to cope with the C++ hideous multifunction."""
|
"""Auxiliary function to cope with the C++ hideous multifunction."""
|
||||||
|
|
||||||
if wnd is not None and not (self._windowStyle & TR_HAS_VARIABLE_ROW_HEIGHT):
|
if wnd is not None and not self.HasFlag(TR_HAS_VARIABLE_ROW_HEIGHT):
|
||||||
raise Exception("\nERROR: In Order To Append/Insert Controls You Have To Use The Style TR_HAS_VARIABLE_ROW_HEIGHT")
|
raise Exception("\nERROR: In Order To Append/Insert Controls You Have To Use The Style TR_HAS_VARIABLE_ROW_HEIGHT")
|
||||||
|
|
||||||
if text.find("\n") >= 0 and not (self._windowStyle & TR_HAS_VARIABLE_ROW_HEIGHT):
|
if text.find("\n") >= 0 and not self.HasFlag(TR_HAS_VARIABLE_ROW_HEIGHT):
|
||||||
raise Exception("\nERROR: In Order To Append/Insert A MultiLine Text You Have To Use The Style TR_HAS_VARIABLE_ROW_HEIGHT")
|
raise Exception("\nERROR: In Order To Append/Insert A MultiLine Text You Have To Use The Style TR_HAS_VARIABLE_ROW_HEIGHT")
|
||||||
|
|
||||||
parent = parentId
|
parent = parentId
|
||||||
@@ -3264,10 +3257,10 @@ class CustomTreeCtrl(wx.PyScrolledWindow):
|
|||||||
def InsertItemByIndex(self, parentId, before, text, ct_type=0, wnd=None, image=-1, selImage=-1, data=None):
|
def InsertItemByIndex(self, parentId, before, text, ct_type=0, wnd=None, image=-1, selImage=-1, data=None):
|
||||||
"""Auxiliary function to cope with the C++ hideous multifunction."""
|
"""Auxiliary function to cope with the C++ hideous multifunction."""
|
||||||
|
|
||||||
if wnd is not None and not (self._windowStyle & TR_HAS_VARIABLE_ROW_HEIGHT):
|
if wnd is not None and not self.HasFlag(TR_HAS_VARIABLE_ROW_HEIGHT):
|
||||||
raise Exception("\nERROR: In Order To Append/Insert Controls You Have To Use The Style TR_HAS_VARIABLE_ROW_HEIGHT")
|
raise Exception("\nERROR: In Order To Append/Insert Controls You Have To Use The Style TR_HAS_VARIABLE_ROW_HEIGHT")
|
||||||
|
|
||||||
if text.find("\n") >= 0 and not (self._windowStyle & TR_HAS_VARIABLE_ROW_HEIGHT):
|
if text.find("\n") >= 0 and not self.HasFlag(TR_HAS_VARIABLE_ROW_HEIGHT):
|
||||||
raise Exception("\nERROR: In Order To Append/Insert A MultiLine Text You Have To Use The Style TR_HAS_VARIABLE_ROW_HEIGHT")
|
raise Exception("\nERROR: In Order To Append/Insert A MultiLine Text You Have To Use The Style TR_HAS_VARIABLE_ROW_HEIGHT")
|
||||||
|
|
||||||
parent = parentId
|
parent = parentId
|
||||||
@@ -3282,10 +3275,10 @@ class CustomTreeCtrl(wx.PyScrolledWindow):
|
|||||||
def InsertItem(self, parentId, input, text, ct_type=0, wnd=None, image=-1, selImage=-1, data=None):
|
def InsertItem(self, parentId, input, text, ct_type=0, wnd=None, image=-1, selImage=-1, data=None):
|
||||||
"""Inserts an item after the given previous."""
|
"""Inserts an item after the given previous."""
|
||||||
|
|
||||||
if wnd is not None and not (self._windowStyle & TR_HAS_VARIABLE_ROW_HEIGHT):
|
if wnd is not None and not self.HasFlag(TR_HAS_VARIABLE_ROW_HEIGHT):
|
||||||
raise Exception("\nERROR: In Order To Append/Insert Controls You Have To Use The Style TR_HAS_VARIABLE_ROW_HEIGHT")
|
raise Exception("\nERROR: In Order To Append/Insert Controls You Have To Use The Style TR_HAS_VARIABLE_ROW_HEIGHT")
|
||||||
|
|
||||||
if text.find("\n") >= 0 and not (self._windowStyle & TR_HAS_VARIABLE_ROW_HEIGHT):
|
if text.find("\n") >= 0 and not self.HasFlag(TR_HAS_VARIABLE_ROW_HEIGHT):
|
||||||
raise Exception("\nERROR: In Order To Append/Insert A MultiLine Text You Have To Use The Style TR_HAS_VARIABLE_ROW_HEIGHT")
|
raise Exception("\nERROR: In Order To Append/Insert A MultiLine Text You Have To Use The Style TR_HAS_VARIABLE_ROW_HEIGHT")
|
||||||
|
|
||||||
if type(input) == type(1):
|
if type(input) == type(1):
|
||||||
@@ -3297,10 +3290,10 @@ class CustomTreeCtrl(wx.PyScrolledWindow):
|
|||||||
def AppendItem(self, parentId, text, ct_type=0, wnd=None, image=-1, selImage=-1, data=None):
|
def AppendItem(self, parentId, text, ct_type=0, wnd=None, image=-1, selImage=-1, data=None):
|
||||||
"""Appends an item as a last child of its parent."""
|
"""Appends an item as a last child of its parent."""
|
||||||
|
|
||||||
if wnd is not None and not (self._windowStyle & TR_HAS_VARIABLE_ROW_HEIGHT):
|
if wnd is not None and not self.HasFlag(TR_HAS_VARIABLE_ROW_HEIGHT):
|
||||||
raise Exception("\nERROR: In Order To Append/Insert Controls You Have To Use The Style TR_HAS_VARIABLE_ROW_HEIGHT")
|
raise Exception("\nERROR: In Order To Append/Insert Controls You Have To Use The Style TR_HAS_VARIABLE_ROW_HEIGHT")
|
||||||
|
|
||||||
if text.find("\n") >= 0 and not (self._windowStyle & TR_HAS_VARIABLE_ROW_HEIGHT):
|
if text.find("\n") >= 0 and not self.HasFlag(TR_HAS_VARIABLE_ROW_HEIGHT):
|
||||||
raise Exception("\nERROR: In Order To Append/Insert A MultiLine Text You Have To Use The Style TR_HAS_VARIABLE_ROW_HEIGHT")
|
raise Exception("\nERROR: In Order To Append/Insert A MultiLine Text You Have To Use The Style TR_HAS_VARIABLE_ROW_HEIGHT")
|
||||||
|
|
||||||
parent = parentId
|
parent = parentId
|
||||||
@@ -4566,7 +4559,7 @@ class CustomTreeCtrl(wx.PyScrolledWindow):
|
|||||||
|
|
||||||
else: # no custom buttons
|
else: # no custom buttons
|
||||||
|
|
||||||
if self._windowStyle & TR_TWIST_BUTTONS:
|
if self.HasFlag(TR_TWIST_BUTTONS):
|
||||||
# We draw something like the Mac twist buttons
|
# We draw something like the Mac twist buttons
|
||||||
|
|
||||||
dc.SetPen(wx.BLACK_PEN)
|
dc.SetPen(wx.BLACK_PEN)
|
||||||
|
Reference in New Issue
Block a user