Search code examples
hidewxwidgetsdrawtreenode

Is it possible to hide wxTreeItems in a wxTreeCtrl?


I can associate a wxTreeItem with wxTreeItemData that can be obtained with GetItemData. Suppose in there is a struct with a bit field or boolean 'isVisible'. Now I only want to show the tree node when it is marked as visible, so isVisible==true (and within the client rect of the entire wxTreeCtrl).

If a node is visible, then all parent nodes up to the root are visible. If a node is not marked as visible, I don't want it to be drawn at all. That is, it should be completely 'invisible' (NOT just collapsed = not expanded).

Questions: Is it possible at all to hide items (nodes) in a tree derived from wxTreeCtrl? Would I need to completely draw the entire tree myself?

The questions are mostly for Gtk (version 3), so it is not necessary that the solution works with native controls on Windows or Mac.


Solution

  • No, you can't have invisible items in wxTreeCtrl, you will have to remove them from the tree if they shouldn't be shown.