Fix hide items in HypreTreeList

Hiding items was only partially implemented and very buggy.
This feature does not exist in CustomTreeCtrl but I see no reason why
it couldn't be added in the future. This fix requires the arrow key fixes
in order for arrow keys to work reliably in a tree with hidden items.
Hidden items always report they are disabled and not expanded.

Also updates the demo of HyperTreeList to add hide options to context
menu so the feature can be tested.
This commit is contained in:
cbeytas
2018-11-21 14:43:07 -05:00
parent 46dfbacfed
commit e11848f735
3 changed files with 63 additions and 7 deletions

View File

@@ -2061,6 +2061,9 @@ class HyperTreeList(HTL.HyperTreeList):
item7 = menu.Append(wx.ID_ANY, "Disable Item")
menu.AppendSeparator()
item14 = menu.Append(wx.ID_ANY, "Hide Item")
item15 = menu.Append(wx.ID_ANY, "Unhide All Items")
menu.AppendSeparator()
item8 = menu.Append(wx.ID_ANY, "Change Item Icons")
menu.AppendSeparator()
@@ -2084,6 +2087,8 @@ class HyperTreeList(HTL.HyperTreeList):
self.Bind(wx.EVT_MENU, self.OnItemPrepend, item11)
self.Bind(wx.EVT_MENU, self.OnItemAppend, item12)
self.Bind(wx.EVT_MENU, self.OnItemBackground, item13)
self.Bind(wx.EVT_MENU, self.OnHideItem, item14)
self.Bind(wx.EVT_MENU, self.OnUnhideItems, item15)
self.PopupMenu(menu)
menu.Destroy()
@@ -2145,6 +2150,22 @@ class HyperTreeList(HTL.HyperTreeList):
event.Skip()
def OnHideItem(self, event):
self.HideItem(self.current)
event.Skip()
def OnUnhideItems(self, event):
item = self.GetRootItem()
while item:
if item.IsHidden():
self.HideItem(item, False)
item = self.GetNext(item)
event.Skip()
def OnItemIcons(self, event):
bitmaps = [self.itemdict["normal"], self.itemdict["selected"],