- Author
- Jorgen Bodde
This is the wxTreeMultiCtrl documentation guide. For the upcoming CodeShop project I am working on, I've created a new control for wxWidgets (http://www.wxwidgets.com), with similar functionality as the wxTreeCtrl. This control allows you to add multiple wxWindow based components in a tree shaped form, with multiple root entries, which can contain multiple sub nodes, which can contain the visual controls in the tree. The tree behaves very much like a wxTreeCtrl, showing all controls in a more structured way.
wxTreeMultiCtrl is freeware and distributed under the wxWidgets license. wxWidgets is THE toolkit for (cross platform) C++ / Python programming!
How does it work?
The internals of the wxTreeMultiCtrl are built up from a composite pattern. This pattern forms a recursive tree where each end node can consist of a Window or a Node type. The Node type can consist out of multiple Window or Node types, and the Window type is an end node which contains an assigned wxWindow to be displayed on the current level.
The wxTreeMultiCtrl communicates to the developer by using the wxTreeMultiItem class, which is about the same as a wxTreeItemId. The wxTreeMultiItem class can be used in add or delete operations, fold operations, find operations, data get and set methods, and more. It helps the developer build up the tree, and later on, get and set data from it.
What can it do and what not?
What it can do:
- Run-time addition / deletion of nodes, with an unlimited level depth
- Inheriting the control makes it possible to respond to the events of the added wxWindow based components
- Since all structured controls are owned by the wxTreeMultiCtrl, FindWindow will work, and all events can be captured
- Collapsing and expanding of a (or all) sub nodes from a specific location by method or by mouse click
- Typesafe getting or setting boolean, text or selection values by simply passing the window ID
- Run-time adjustment of spacing between controls
- Easy indenting of Window nodes
- Contain complex controls per Window node by putting them on a wxPanel, allowing custom behavior of those controls on the wxPanel
- Automatic deep background color adjustment of every window added, which means that every control on a wxPanel will be automatically set to the proper background. There is also an exception flag for wxButton controls, so that they remain their original color (if desired).
What it cannot do:
- Drag and drop support of individual nodes. Since the purpose was creating a tree shaped / property sheet kind of window, dragging and dropping is not really desired behavior.
- No selection possible. Click on the controls to edit, double click on a container node to collapse and expand.
- Draw a selection border. Since there is no selection possible, no selection will be drawn
- Editing of captions like point and click in wxTreeCtrl. Again this is not desired behavior, because the (sub) items are not really the same as wxTreeCtrl items.
Special thanks to Phil for testing, Julian Smart et al. for making this great toolkit!