]> Creatis software - bbtk.git/blob - kernel/src/ThirdParty/wx/treemultictrl/wxTreeMultiCtrl.h
Started the devel of a wx package browser
[bbtk.git] / kernel / src / ThirdParty / wx / treemultictrl / wxTreeMultiCtrl.h
1 //---------------------------------------------------------------------------\r
2 // $RCSfile: wxTreeMultiCtrl.h,v $\r
3 // $Source: /cvs/creatis/bbtk/kernel/src/ThirdParty/wx/treemultictrl/wxTreeMultiCtrl.h,v $\r
4 // $Revision: 1.1 $\r
5 // $Date: 2008/03/28 13:42:19 $\r
6 //---------------------------------------------------------------------------\r
7 // Author:      Jorgen Bodde\r
8 // Copyright:   (c) Jorgen Bodde\r
9 // License:     wxWidgets License
10 //---------------------------------------------------------------------------
11
12 #ifndef __WXTREEMULTICTRL_H__
13 #define __WXTREEMULTICTRL_H__
14
15 /** \author Jorgen Bodde
16     \mainpage
17
18     This is the wxTreeMultiCtrl documentation guide. For the upcoming CodeShop project I am working on, I've
19     created a new control for wxWidgets (http://www.wxwidgets.com), with similar functionality as
20     the wxTreeCtrl. This control allows you to add multiple wxWindow based components in a tree shaped form,
21     with multiple root entries, which can contain multiple sub nodes, which can contain the visual controls
22     in the tree. The tree behaves very much like a wxTreeCtrl, showing all controls in a more structured way.
23
24     wxTreeMultiCtrl is freeware and distributed under the wxWidgets license. wxWidgets is THE toolkit for
25     (cross platform) C++ / Python programming!
26
27     \section how_work How does it work?
28
29     The internals of the wxTreeMultiCtrl are built up from a composite pattern. This pattern forms a recursive
30     tree where each end node can consist of a Window or a Node type. The Node type can consist out of multiple
31     Window or Node types, and the  Window type is an end node which contains an assigned wxWindow to be displayed
32     on the current level.
33
34     The wxTreeMultiCtrl communicates to the developer by using the wxTreeMultiItem class, which is about the same
35     as a wxTreeItemId. The wxTreeMultiItem class can be used in add or delete operations, fold operations, find
36     operations, data get and set methods, and more. It helps the developer build up the tree, and later on,
37     get and set data from it.
38
39     \section what_dp What can it do and what not?
40
41     What it can do:
42
43     - Run-time addition / deletion of nodes, with an unlimited level depth
44     - Inheriting the control makes it possible to respond to the events of the added wxWindow based components
45     - Since all structured controls are owned by the wxTreeMultiCtrl, FindWindow will work, and all events can be captured
46     - Collapsing and expanding of a (or all) sub nodes from a specific location by method or by mouse click
47     - Typesafe getting or setting boolean, text or selection values by simply passing the window ID
48     - Run-time adjustment of spacing between controls
49     - Easy indenting of Window nodes
50     - Contain complex controls per Window node by putting them on a wxPanel, allowing custom behavior of those controls on the wxPanel
51     - Automatic deep background color adjustment of every window added, which means that every control on a wxPanel will be
52       automatically set to the proper background. There is also an exception flag for wxButton controls, so that they remain
53       their original color (if desired).
54
55     What it cannot do:
56
57     - Drag and drop support of individual nodes. Since the purpose was creating a tree shaped / property sheet kind of window,
58       dragging and dropping is not really desired behavior.
59     - No selection possible. Click on the controls to edit, double click on a container node to collapse and expand.
60     - Draw a selection border. Since there is no selection possible, no selection will be drawn
61     - Editing of captions like point and click in wxTreeCtrl. Again this is not desired behavior, because the (sub)
62       items are not really the same as wxTreeCtrl items.
63
64     Special thanks to Phil for testing, Julian Smart et al. for making this great toolkit!
65 */
66
67 #ifdef __GNUG__
68     #pragma interface "wxTreeMultiCtrl.cpp"
69 #endif
70
71 #ifndef WX_PRECOMP
72     #include "wx/wx.h"
73 #endif
74
75 #include <wx/dynarray.h>
76
77
78 // classes for internal tree structure
79 #include "TreeMultiItemRoot.h"
80
81 // Flags for wxTreeMultCtrl use
82 #define wxTMC_DEFAULT_STYLE wxSIMPLE_BORDER
83
84 /** @defgroup wndflags wxTreeMultiWindowItem flags
85     These flags can be used in wxTreeMultiCtrl::AppendWindow as enforced flags, or in wxTreeMultiWindowInfo to set the flags
86     for repetetive adding of Window nodes with the same (or near same) properties.
87     @{
88 */
89 /** When set, this flag will change the background of all the panels
90     and subwindows added to the wxTreeMultiCtrl. */
91 #define wxTMC_BG_ADJUST_CNT   0x000000001
92 /** When set, the background of the wxButton windows will also be changed.
93     This needs wxTMC_ADJUST_BACKGROUND to be set as well. */
94 #define wxTMC_BG_ADJUST_BTN   0x000000002
95 /** When set, all backgrounds from windows and buttons will be adjusted
96     to match the control background */
97 #define wxTMC_BG_ADJUST_ALL   (wxTMC_BG_ADJUST_CNT | wxTMC_BG_ADJUST_BTN)
98 /** When set, the control added is resized horizontally over the complete
99     length. When the user resizes the window, the control is resized as well */
100 #define wxTMC_SPAN_WIDTH      0x000000004
101 /** @}
102 */
103
104
105 #define wxTreeMultiCtrlNameStr wxT("wxTreeMultiCtrl")
106
107 #define WXTMC_GUTTER_DEFAULT 6      // gutter before and after image of [+] or [-]
108 #define WXTMC_YSPACING_DEFAULT 10   // per item 10 pixels spacing extra for every item
109 #define WXTMC_PIXELS_PER_UNIT 10
110
111 /** \defgroup hitflags wxTreeMultiCtrl HitTest flags
112     @{
113 */
114
115 enum
116 {
117     /// wxCoord was found in the gutter of the node (in front of the [+])
118     wxTMC_HITTEST_GUTTER = 1,
119     /// wxCoord was found inside a window, or behind it, on a Window node
120     wxTMC_HITTEST_WINDOW,
121     /// wxCoord was found on a caption of a Node or Root item
122     wxTMC_HITTEST_CAPTION,
123     /// wxCoord was found on a checkbox (only when item really has a checkbox)
124     wxTMC_HITTEST_CHECKBOX
125 };
126
127 /** @}
128 */
129
130 /** @defgroup classes wxTreeMultiCtrl Classes
131     These classes are all the available classes in the wxTreeMultiCtrl you should know about.
132     @{
133
134     @}
135 */
136
137 /** \class wxTreeMultiItem
138     \ingroup classes
139     \brief An intermediate class which is used to return as 'item' value for the wxTreeMultiCtrl. This class
140     is comparable with wxTreeItemId.
141
142     The wxTreeMultiItem is used to pass information to the user about the tree node in question. It can also be used point out where the
143     subnodes should be added.
144
145     For example:
146     \code
147
148         wxTreeMultiItem item = MyMultiTreeCtrl->AddRoot("This is the first root");
149
150         // now add a node to the root
151         if(item.IsOk())
152             MyMultiTreeCtrl->AppendWindow(item, new wxStaticText(MyMultiTreeCtrl, -1, "This is a static text");
153
154
155     \endcode
156
157     The wxTreeMultiItem comes in three internal types which are used in the wxTreeMultiCtrl. For functions such as
158     wxTreeMultiCtrl::AddRoot, a Root item is returned. For functions such as wxTreeMultiCtrl::AppendWindow, a
159     Window node is returned. For functions such as wxTreeMultiCtrl::AppendNode, a Node item is returned.
160
161     \li A Root item represents a top level item. Special operations on this item is adding multiple nodes to it from a
162     top level.
163
164     \li A Node item represents a container item which has multiple sub items which can both be Window items, or Node items.
165     A root item is a special type of Node item, so all operations which are only for Node items, are also for Root items.
166
167     \li A Window node represents an end node, which points to a wxWindow which represents the visual contents of this node.
168     This type of node can hold any wxWindow derived class.
169
170 */
171
172 class wxTreeMultiItem
173 {
174 private:
175     TreeMultiItemBase *_item;
176 public:
177     /** Default declaration constructor, and should be used when declaring an item which gets assigned a new
178         value by e.g. wxTreeMultiCtrl::AppendNode. */
179     wxTreeMultiItem() {
180         _item = 0;
181     };
182
183 #ifndef _NO_DOXYGEN_
184
185     wxTreeMultiItem(TreeMultiItemBase *ptr) {
186         _item = ptr;
187     };\r
188 \r
189     // Returns the TreeMultiItemBase class. This shoult *NOT* be\r
190     // used if you don't know what you are doing! This means never use it. */\r
191     TreeMultiItemBase *GetItem() const {\r
192         return _item;\r
193     };\r
194
195 #endif // _NO_DOXYGEN_
196
197     /** The copy operator. Used in assigning one wxTreeMultiItem to another, usually in returning wxTreeMultiItem
198         classes from the wxTreeMultiCtrl.
199     */
200     void operator=(const wxTreeMultiItem &item) {
201         _item = item._item;\r
202     };\r
203 \r
204    /** Equality operator. It returns true if the items are identical or if both items are invalid. */\r
205     bool operator==(wxTreeMultiItem const& item) const {return (this->GetItem() == item.GetItem());}\r
206 \r
207    /** Inequality operator. It returns true if the items are different or one of them is invalid. */\r
208     bool operator!=(wxTreeMultiItem const& item) const {return (this->GetItem() != item.GetItem());}\r
209 \r
210         /** Returns the parent of the current wxTreeMultiItem. This means the wxTreeMultiNode is returned. It can\r
211             be useful to check or clear the checkbox at this level. */\r
212         wxTreeMultiItem GetParent() const{\r
213                 wxCHECK(IsOk(), wxTreeMultiItem(0));\r
214                 return wxTreeMultiItem(_item->GetParent());\r
215         };\r
216
217     /** Validates if the wxTreeMultiItem is a valid instance to use in the wxTreeMultiCtrl. Returns TRUE when there
218         is a member value is associated with it, or FALSE when not. This value can also be checked when this class is returned from a wxTreeMultiCtrl operation. For example:
219
220         \code
221
222             wxTreeMultiItem item = MyTreeMultiCtrl->FindNode("NAME");
223             if(item.IsOk())
224             {
225                 // Found the node, now do something with it
226             }
227             else
228             {
229                 // Sorry, not found
230             }
231
232         \endcode
233
234     */
235     bool IsOk() const {
236         return _item != 0;
237     };
238
239     /** Returns TRUE when the wxTreeMultiItem is a Window item. This means the item is both valid, and points to a
240         window node. This means it can be used in functions that expect a Window node. If the item is invalid or a Window
241         item, FALSE is returned
242         \sa wxTreeMultiCtrl::AppendWindow
243     */
244     bool IsWindowItem() const {
245         if(_item && _item->IsTreeMultiItemWindow())
246             return true;
247         return false;
248     };
249
250     /** Returns TRUE when the wxTreeMultiItem is a Node item. This means the item is both valid, and points to a
251         node element (i.e. setting the caption, counting node children, etc). If the item is invalid or not a Node
252         item, FALSE is returned.
253         When the item is actually a root item (specialised node type), this also returns TRUE.
254         \sa wxTreeMultiCtrl::AppendNode wxTreeMultiCtrl::AddRoot
255     */
256     bool IsNodeItem() const {
257         if(_item && (_item->IsTreeMultiItemNode() || _item->IsTreeMultiItemRoot()))
258             return true;
259         return false;
260     };
261
262     /** Returns True when the wxTreeMultiItem is a Root (top node) item. This means the item is both valid,
263         and points to a root element (this item is always shown as first node in the tree). A root node is
264         always visible, but can contain other collapsed children. If the item is invalid or not a Root node,
265         FALSE is returned.
266     */
267     bool IsRootItem() const {
268         if(_item && _item->IsTreeMultiItemRoot())
269             return true;
270         return false;
271     };
272
273     /** Returns TRUE if the node is expanded, else FALSE if it is collapsed. If the item is not a Root or Node
274         item, an assertion failure is generated (in debug mode) or FALSE is returned (in release mode).
275
276         \sa wxTreeMultiCtrl::Expand, wxTreeMultiCtrl::Collapse, wxTreeMultiCtrl::CollapseAndReset
277     */
278     bool IsExpanded() const {
279         wxCHECK(_item, false);
280         TreeMultiItemNode *n = _item->IsTreeMultiItemNode();
281         wxCHECK(n, false);
282
283         return n->IsExpanded();
284     };
285
286     /** Returns true if this node is excluded from drawing. Please note that when this node is not visible
287         due to a higher excluded parent node but not literally excluded itself, it will return false (not excluded).
288         Use wxTreeMultiCtrl::GetExcludedParent() to get the node that hides this one. */
289     bool IsExcluded() {
290         wxCHECK(_item, false);
291         return _item->IsExcluded();\r
292     }\r
293 \r
294    /** Returns true if the item is selected.\r
295        Please note that currently only nodes can be selected.\r
296    */\r
297     bool IsSelected(void) const\r
298     {\r
299       wxCHECK(this->GetItem(),false);\r
300       return this->GetItem()->IsSelected();\r
301     }\r
302     /** Returns true if this node is visible. Please note that when this node is a child node of a collapsed\r
303         node, it is not visible. Also if this node is a child node of an excluded node, it is also not visible.\r
304         It does <b>NOT</b> return false when it's drawn somewhere outside of the visible area. */\r
305     bool IsVisible() {
306         wxCHECK(_item, false);
307         return _item->IsVisible();
308     }
309 \r
310 };\r
311 \r
312 WX_DECLARE_OBJARRAY(wxTreeMultiItem,wxArrayTreeMultiItem);\r
313 \r
314 /** \class wxTreeMultiWindowInfo\r
315     \ingroup classes\r
316     \brief This class contains information for every Window node to be added.\r
317
318     This class can be used to modify the behaviour of the Window node to be added, and can be reused to pass along
319     upon every wxTreeMultiCtrl::AppendWindow call. For example:
320
321     \code
322
323         wxTreeMultiWindowInfo wndinfo;
324
325         MyTreeMultiCtrl->AppendWindow(item, new wxStaticText(MyTreeMultiCtrl,
326                                       -1, "Press this button"), "", wndinfo));
327
328         // now adjust the spacing of our next window to add, by indenting
329         // 4 times the indent size
330
331         wndinfo.Indent(4);
332         MyTreeMultiCtrl->AppendWindow(item, new wxButton(MyTreeMultiCtrl,
333                                       -1, "Apply"), "", wndinfo);
334
335     \endcode
336
337     The class is created to prevent long parameter lists in the functions. Other ways to manipulate a newly added
338     Window node are;
339
340     \li Change top spacing of the Window node to be added
341     \li Change front spacing (indent) of the Window node
342     \li Set extra flags for this Window node
343 */
344
345 //-------------------------------------------------------------------------------------------------------------------
346
347 class wxTreeMultiWindowInfo
348 {
349 private:
350     /** Flag that indicates that every window background in the assigned wxWindow needs te be overriden with the
351         current colour of the TreeMultiCtrl. This is a deep adjustment and will do every subwindow until none are
352         left. If 'false' no adjustment is done. For AppendWindow only */
353     int _flags;
354     /** Extra indent for every item that is added. This will add front spacing to the item's x calculation.
355         For AppendNode and AppendWindow. Spacing is added behind the collapse image not in front. */
356     int _frontSpacing,
357         _frontSpacingOrg;
358
359     /** Extra top spacing for every item that is added. This will add top spacing to the item's y calculation */
360     int _topSpacing;
361
362 #if(CHECKBOXVIEW)
363     /** Checkstate for checkboxed property sheets */
364     bool _checkState;
365 #endif\r
366 \r
367 public:\r
368 #if(CHECKBOXVIEW)\r
369     wxTreeMultiWindowInfo(int flags, int frontSpacing, int topSpacing, bool checkState = false)\r
370         : _flags(flags)\r
371         , _frontSpacing(frontSpacing)\r
372         , _frontSpacingOrg(frontSpacing)\r
373         , _topSpacing(topSpacing)\r
374         , _checkState(checkState)\r
375 #else\r
376     wxTreeMultiWindowInfo(int flags, int frontSpacing, int topSpacing)\r
377         : _flags(flags)\r
378         , _frontSpacing(frontSpacing)\r
379         , _frontSpacingOrg(frontSpacing)\r
380         , _topSpacing(topSpacing)\r
381 #endif\r
382     {\r
383         // constructor\r
384     }
385     /** Adds indent to original front spacing and increments it with that value (quick extra indent).
386         The original value of FrontSpacing (see SetFrontSpacing() gets indented by multiplying
387         the 'num' factor (default = 1) times the indent value. So if the FrontSpacing was set to 10,
388         and Indent(2) is called, the new indent will be 30. (10 + 2 * 10). The original FrontSpacing
389         value is remembered, so calling Outdent(2) will bring it back to 10 (30 - (2*10). Calling
390         SetFrontSpacing with a new value, deletes the old indent.
391
392         \sa Outdent, SetFrontSpacing
393     */
394     int Indent(int num = 1) {
395         if(num > 0)
396             _frontSpacing += (_frontSpacingOrg * num);
397         return _frontSpacing;
398     };
399     /** Reduces indent a number of times, by subtracting 'num' times the original FrontSpacing value from
400         the current FrontSpacing value (quick extra indent). Thus if the original FrontSpacing was set to
401         10, and the current indent value is 40, Outdent(2) will do 40 - (2 * 10) = 20
402
403         \sa Indent, SetFrontSpacing
404     */
405     int Outdent(int num = 1) {
406         _frontSpacing -= (_frontSpacingOrg * num);
407         if(_frontSpacing < 0)
408             _frontSpacing = 0;
409         return _frontSpacing;
410     };
411
412     /** Sets FrontSpacing value. This also resets the current indent level.  */
413     void SetFrontSpacing(int frontSpacing) {
414         _frontSpacing = frontSpacing;
415         _frontSpacingOrg = frontSpacing;
416     };
417     /** Gets front spacing. This will return the current indent level set. If Indent or Outdent is used,
418         this level represents the current Indent level.*/
419     int GetFrontSpacing() const {
420         return _frontSpacing;
421     };
422
423     /** Sets top spacing. This means the number of pixels spacing between the last node and the next one to
424         be added.
425     */
426     void SetTopSpacing(int topSpacing) {
427         _topSpacing = topSpacing;
428         if(_topSpacing < 0)
429             _topSpacing = 0;
430     };
431
432     /* Gets top spacing currently set. */
433     int GetTopSpacing() const {
434         return _topSpacing;
435     };
436
437     /** Sets the current flags set, and returns previous flags state.
438         \sa @link wndflags wxTreeMultiWindowInfo flags@endlink
439     */
440     int SetFlags(int flags) {
441         int tmp = _flags;
442         _flags = flags;
443         return tmp;
444     };
445
446     /** Gets the current flags set.
447         \sa @link wndflags wxTreeMultiWindowInfo flags@endlink
448     */
449     int GetFlags() const {
450         return _flags;
451     };
452
453     /** Or's the given flag with the current flagset, and adds it. The
454         old flag set is returned before the OR is applied.
455         \sa @link wndflags wxTreeMultiWindowInfo flags@endlink
456     */
457     int AddFlag(int flag_mask) {
458         int tmp = _flags;
459         _flags |= flag_mask;
460         return tmp;
461     };
462
463     /** And's the given flag in a negated manner and removes this flag set from
464         the current flags.  The old flag set is returned.
465         \sa @link wndflags wxTreeMultiWindowInfo flags@endlink
466     */
467     int RemoveFlag(int flag_mask) {
468         int tmp = _flags;
469         _flags &= ~(flag_mask);
470         return tmp;
471     };
472
473 #if(CHECKBOXVIEW)
474     /** Sets the default checkstate if checkboxes if SetCheckboxView is chosen. For all the
475         items to be added (even captions) this checkstate is chosen. The default checkstate
476         is false. <b>This needs USE_CHECKBOXVIEW set to YES, or CHECKBOXVIEW=1 during compile</b> */
477     void SetDefaultCheckState(bool checkState = true) {
478         _checkState = checkState;
479     };
480
481     /** Gets the default checkstate of the item. <b>This needs USE_CHECKBOXVIEW set to YES, or CHECKBOXVIEW=1 during compile</b>
482         \sa SetDefaultCheckState */
483     bool GetDefaultCheckState() const {
484         return _checkState;
485     };
486 #endif
487 };
488
489 // Default info string
490 #ifndef LINUX
491   #define wxTreeMultiWindowInfoDefault wxTreeMultiWindowInfo(wxTMC_BG_ADJUST_CNT, 8, 0)
492 #else
493   #define wxTreeMultiWindowInfoDefault wxTreeMultiWindowInfo(wxTMC_BG_ADJUST_ALL, 8, 0)
494 #endif
495
496 /** \class wxTreeMultiCtrl
497     \ingroup classes
498     \brief This is the visual control, which will contain all the logic for the tree mechanism.
499
500     The wxTreeMultiCtrl is the container class which can be filled in to get the tree shaped structure in
501     which the controls are displayed. The user can add / delete new nodes at runtime, expand or collapse
502     nodes, perform get or set actions on the controls inside, and iterate over the items.
503
504     A typical usage of the wxTreeCtrl is;
505
506     \code
507     wxTreeMultiCtrl *tmc = new wxTreeMultiCtrl(this, -1);
508
509     // add root
510     wxTreeMultiItem item = tmc->AddRoot("This is the first root");
511
512     // create a wxTreeMultiWindowInfo object for indenting etc
513     wxTreeMultiWindowInfo wndinfo;
514
515     // add subitem to root
516     tmc->AppendWindow(item, new wxButton(tmc, -1, "Press this"), "", wndinfo);
517
518     // indent a few
519     wndinfo.Indent(4);
520
521     // add a new one
522     tmc->AddWindow(item, new wxCheckBox(tmc, ID_MYCHECK, "Check this!"), "", wndinfo);
523
524     // now check the value of the checkbox
525     tmc->SetBooleanValue(ID_MYCHECK, true);
526
527     \endcode
528
529     <b>IMPORTANT:</b> Every control added to the wxTreeMultiCtrl has to be child of the wxTreeMultiCtrl.
530
531 */
532 class wxTreeMultiCtrl: public wxScrolledWindow
533 {
534     DECLARE_DYNAMIC_CLASS(wxTreeMultiCtrl)
535
536     /** \todo When tab is pressed, the focus can get out of sight. This should be resolved by
537        catching the TAB, see what window is focussed, and scroll the window so it's visible */
538 private:
539     TreeMultiItemRoot _root;
540
541     long _style;
542     wxBitmap *_expandBmp, *_collBmp;
543
544     /** Delta Y for bitmap, to center it on the caption */
545     int _iconDeltaY, _checkDeltaY;
546
547     /* Caption height. This is the height of the font of this window */
548     int _captionHeight;
549
550     /** The gutter spacing in front and back of the image. This determines the amount of spacing in front
551         of each item */
552     int _gutterWidth;
553
554     /** The image width of the [+] / [-] icon. This is also calculated in the gutter */
555     int _iconWidth;
556
557     /** The image height of the [+] / [-] icon. This is calculated as minimal size and to allign */
558     int _iconHeight;
559
560     /** Max height. This is either the [+] bitmap or the checkbox */
561     int _maxHeight;
562
563
564     /** Extra Y spacing between the items. */
565     int _spacingY;
566
567     /** Two step create prevention. Something with GetWindowSize freaks out when not actually created */
568     bool _create_called;
569
570 #if(CHECKBOXVIEW)
571     wxBitmap *_checkBmp, *_uncheckBmp, *_tristateBmp;
572
573     /** Toggles checkbox view. If true, every item created (caption or node) will be created with checkbox */
574     bool _checkboxView;
575
576     /** Height and weight for checkbox */
577     int _checkHeight, _checkWidth;\r
578 #endif\r
579 \r
580     /** brush for highlighting nodes */\r
581      wxBrush* m_HilightBrush;\r
582 \r
583     /** This captionFont is made equal to the font of the wxScrolledWindow. As extra the bold face\r
584         is set on it when this is wanted by the user (see flags) */\r
585     wxFont _captionFont;\r
586 \r
587    /** list of selected items */\r
588     wxArrayTreeMultiItem m_SelectedItems;\r
589 \r
590     /** Does the actual collapsing / expanding. So that Expand and Collapse aren't using the same code twice */\r
591     void DoFold(TreeMultiItemBase *item, bool expand, bool recursive);\r
592 \r
593     /** Redraws and recalculates the nodes from the current node. It will also clear all 'dirty' flags when
594         they are recalculated */
595     void RedrawFromNode(TreeMultiItemNode *n);
596
597     /** Redraws from parent node of this node */
598     void RedrawFromParentNode(TreeMultiItemBase *b);
599
600     /** Draws checkbox belonging to this node, in the given state */
601     void DrawCheckbox(TreeMultiItemBase *b, wxDC &dc, bool convertScrolled = false);
602
603     /** Recalculate the space needed based on every node. It goes as follows.
604         - A foldable node (TreeMultiItemNode) is as high as the 'Jg' y-size. This type only has a caption plus a
605           picture which explains the state ([+] or [-]), the width will be the caption length
606         - A window node will be as high as the y size of the window. The X size is the total length of the
607           window.
608         - For every child node an indent will be added to the x size.
609
610         Only visible nodes will be recalculated. Non visible (collapsed) children will be skipped  */
611     void RecalculateNodePositions();
612
613     /** Recurses into the whole tree and provides every node with the proper x and y values. All non visible items
614         are skipped (so when it encounters a collapsed node, it's children are not calculated). Returns the last Y */
615     int CalculateNodeDimensions(TreeMultiItemBase *b, int currentY, int level);
616
617     void DrawNode(TreeMultiItemBase *b, wxDC &dc);
618
619     /** Sets background colour of all the windows and subwindows in this wxWindow. This is very handy
620         for wxPanel derived classes which need to be made equal to the background colour of the wxTreeMultiCtrl */
621     void SetWindowBackgroundColour(wxWindow *wnd, const wxColour &col, int flags);
622
623     /** Shows or hides the assigned window (if there is any) */
624     void ShowTreeMultiWindow(TreeMultiItemWindow *window, bool show = true);
625
626     /** Goes down the tree, and if a window is not visible (thus all it's children aren't too) it will hide
627         the window so it is not shown on the control */
628     void UpdateAllWindowVisibility();
629
630     /** Hides tree multi window. It this is a TreeMultiItemNode, hide all subwindows as well. */
631     void UpdateTreeMultiWindowVisibility(TreeMultiItemBase *b, bool show);
632
633     /** Recalculates totally needed virtual size of the wxTreeMultiCtrl. It will scan for
634         the largest window, with the biggest size, and report that back */
635     void RecalculateVirtualSize();\r
636 \r
637     /** Adjusts scrollbars in window, usually done after virtual size (x,y) is recalculated */\r
638     using wxScrolledWindow::AdjustScrollbars;\r
639     virtual void AdjustScrollbars(int x, int y);\r
640 \r
641     /** Recalculates and accumulates largest x and y */\r
642     void RecalculateVirtualSizeFromNode(const TreeMultiItemNode *node, int &x, int &y);
643 \r
644     /** Scans for TreeMultiItemBase node that contains x,y and in area returns a hittest constant to\r
645         indicate what matched */\r
646     TreeMultiItemBase *FindNodeByPoint(TreeMultiItemBase *b, wxPoint const& pt, int &area);\r
647 \r
648     /** Scans for TreeMultiItemWindow that holds the wxWindow pointer. Does not scan in panels or does\r
649         a deep search. Reason, this function is used to advance to next TreeMultiItemWindow for focus\r
650         on this wxScrolledWindow. If a sub window is found, it will skip other windows on that same level */
651     wxTreeMultiItem FindWindowNode(wxWindow *wnd, TreeMultiItemNode *n = 0);
652
653     /** Finds next visible window item in chain. If not found use FindFirstVisibleItem to start from the
654         beginning */\r
655     TreeMultiItemWindow *FindNextVisibleWindowItem(TreeMultiItemBase *b, int index = -1);\r
656 \r
657     /** Adjust the centering of the bitmap icons (collapse / expand) when the caption font changes. They need to\r
658         be centered in the middle of the font, so a bit of deltaY adjustment is needed */\r
659     void AdjustIconsDeltaY();\r
660
661         /** Calculate the spanning of the individual nodes */
662         void CalculateNodeSpanning(TreeMultiItemBase *b);
663
664 #if(CHECKBOXVIEW)
665     /** Recurse to all the children and set the checkbox state (even when there is no checkbox) */
666     void SetRecursiveCheckState(TreeMultiItemNode *n, bool check);
667
668     /** From current checked node, all children will be scanned and the parent node of this node
669         will get tristate if the checked items are scattered (some are some aren't). If all nodes in this
670         node are checked, the parent node gets checked all the way up to the last one that matches
671         criteria. If all are cleared, parent node gets cleared */
672     void ScanTristateCheckstates(TreeMultiItemBase *b);\r
673 #endif\r
674 \r
675    /** \name Private add and delete methods\r
676        @{\r
677    */\r
678 \r
679    /** Inserts a node into the parent's node at the specified position.\r
680        As this is a private method error checking is limited. Therefore, it has to be guaranteed that this method\r
681        is only called with a valid parent node pointer.\r
682        The position is zero based. In case the position is equal or larger than the current number of\r
683        parent's elements the new node is appended.\r
684        The newly inserted node is being returned.\r
685    */\r
686     wxTreeMultiItem InsertNode(TreeMultiItemNode* ParentPtr, size_t Position, wxString const& Caption, wxString const& Name);\r
687 \r
688    /** Inserts a window into the parent's node at the specified position.\r
689        As this is a private method error checking is limited. Therefore, it has to be guaranteed that this method\r
690        is only called with a valid parent node and window pointer.\r
691        The position is zero based. In case the position is equal or larger than the current number of\r
692        parent's elements the new node is appended.\r
693        The newly inserted window is being returned.\r
694    */\r
695     wxTreeMultiItem InsertWindow(TreeMultiItemNode* ParentPtr, size_t Position, wxWindow* WindowPtr, wxString const& Name,\r
696                                  wxTreeMultiWindowInfo const& Info, int Flags);\r
697 \r
698    /** @}\r
699    */\r
700 private:\r
701     void Init();\r
702 \r
703     // handlers
704     //---------
705
706     //virtual void OnDraw(wxDC& dc);\r
707     void OnPaint(wxPaintEvent &event);\r
708     void OnMouseClick     (wxMouseEvent& event);\r
709     void OnRightMouseClick(wxMouseEvent& Event);\r
710     void OnKey(wxKeyEvent &event);\r
711         void OnSize(wxSizeEvent &event);\r
712 \r
713         /** Recalculates the spanning controls */
714         void RecalculateSpanSizes();
715
716 public:
717     /** Two step constructor. Call Create when this constructor is called to build up the
718         wxTreeMultiCtrl
719     */
720     wxTreeMultiCtrl()
721         : _create_called(false)
722     {
723
724         Init();
725     }
726
727     /** The default constructor. The style wxTAB_TRAVERSAL is enforced to make sure that the
728         focus handling is being done correctly. The styles to be used are styles valid for
729         the wxWindow and wxScrolledWindow
730     */
731     wxTreeMultiCtrl(wxWindow *parent, wxWindowID id = -1,
732                         const wxPoint& pos = wxDefaultPosition,
733                         const wxSize& size = wxDefaultSize,
734                         long style = wxTMC_DEFAULT_STYLE,
735                         const wxValidator &validator = wxDefaultValidator,
736                         const wxString& name = wxTreeMultiCtrlNameStr)
737         : _style(style | wxTAB_TRAVERSAL)
738         , _create_called(false)
739     {
740         Create(parent, id, pos, size, style, validator, name);
741     }
742
743     /** Destructor */
744     virtual ~wxTreeMultiCtrl();
745
746     /** Two step creation. Whenever the control is created without any parameters, use Create to actually
747         create it. Don't access the control's public methods before this is called
748
749         \sa wxTreeMultiCtrl()
750     */
751     bool Create(wxWindow *parent, wxWindowID id = -1,
752                 const wxPoint& pos = wxDefaultPosition,
753                 const wxSize& size = wxDefaultSize,
754                 long style = wxTMC_DEFAULT_STYLE,
755                 const wxValidator &validator = wxDefaultValidator,
756                 const wxString& name = wxTreeMultiCtrlNameStr);
757
758     // accessors
759     //----------
760
761     /** @name Add and delete methods
762         To add and delete node items like a Root item, Window item or Node item. This allows the user to
763         manipulate the tree, and build it up.
764         @{
765     */
766
767     /** Adds a root node to the wxTreeMultiItem. There can be many root nodes. Use this wxTreeMultiNode pointer to add
768         more subnodes to it. */\r
769     wxTreeMultiItem AddRoot(const wxString &caption, const wxString &name = wxEmptyString);\r
770 \r
771     /** Adds a window to the tree control. Use this wxTreeMultiItem method to add a window class to the\r
772         current wxTreeMultiItem. The wxTreeMultiItem must point to a Node class. If this is not the case\r
773         an empty wxTreeMultiItem is returned. The mask is used to override the mask settings of the\r
774         wxTreeMultiWindowInfo class. This can be handy to set or clear extra flags only needed for certain\r
775         situations */\r
776     wxTreeMultiItem AppendWindow(const wxTreeMultiItem &ParentItem, wxWindow *window = NULL, const wxString &name = wxEmptyString,\r
777                                  wxTreeMultiWindowInfo const& info = wxTreeMultiWindowInfoDefault, int flags = 0);\r
778 \r
779    /** Adds a window to the tree control. Use this method to add a window class at the specified position\r
780        of the parent's wxTreeMultiItem. In case the position is smaller than the current number of children all elements\r
781        are shifted upwards, otherwise the new window is appended to the parent's wxTreeMultiItem.\r
782        The parent wxTreeMultiItem must point to a Node class. If this is not the case an\r
783        empty wxTreeMultiItem is returned.\r
784    */\r
785     wxTreeMultiItem InsertWindow(wxTreeMultiItem const& ParentItem, size_t Position, wxWindow *window = NULL, wxString const& Name = wxEmptyString,\r
786                                  wxTreeMultiWindowInfo const& info = wxTreeMultiWindowInfoDefault, int flags = 0);\r
787 \r
788    /** Adds a window to the tree control. Use this method to add a window class as the first element\r
789        of the parent's wxTreeMultiItem. The parent wxTreeMultiItem must point to a Node class. If this is not the case an\r
790        empty wxTreeMultiItem is returned.\r
791    */\r
792     wxTreeMultiItem PrependWindow(wxTreeMultiItem const& ParentItem, wxWindow *window = NULL, const wxString &name = wxEmptyString,\r
793                                   wxTreeMultiWindowInfo const& info = wxTreeMultiWindowInfoDefault, int flags = 0);\r
794 \r
795     /** Adds a node to the tree control. Use this wxTreeMultiItem method to add a recursive subnode class as the last element\r
796         of the parent's wxTreeMultiItem. The parent wxTreeMultiItem must point to a Node class. If this is not the case\r
797         an empty wxTreeMultiItem is returned. A node can contain multiple nodes or window classes */\r
798     wxTreeMultiItem AppendNode(wxTreeMultiItem const& ParentItem, const wxString &caption = wxEmptyString,\r
799                                const wxString &name = wxEmptyString);\r
800 \r
801    /** Adds a node to the tree control. Use this method to add a recursive subnode class at the specified position\r
802        of the parent's wxTreeMultiItem. In case the position is smaller than the current number of nodes all elements\r
803        are shifted upwards, otherwise the new node is appended to the parent's wxTreeMultiItem.\r
804        The parent wxTreeMultiItem must point to a Node class. If this is not the case an\r
805        empty wxTreeMultiItem is returned. A node can contain multiple nodes or window classes.\r
806    */\r
807     wxTreeMultiItem InsertNode(wxTreeMultiItem const& ParentItem, size_t Position, wxString const& caption, wxString const& name);\r
808 \r
809    /** Adds a node to the tree control. Use this method to add a recursive subnode class as the first element\r
810        of the parent's wxTreeMultiItem. The parent wxTreeMultiItem must point to a Node class. If this is not the case an\r
811        empty wxTreeMultiItem is returned. A node can contain multiple nodes or window classes.\r
812    */\r
813     wxTreeMultiItem PrependNode(wxTreeMultiItem const& ParentItem, wxString const& caption = wxEmptyString,\r
814                                 wxString const& name = wxEmptyString);\r
815 \r
816     /** Delete item from the tree control. Whenever it is present, delete it. If not, return false. After\r
817         deletion the wxTreeMultiItem is 0, thus IsOk will return false */\r
818     bool Delete(wxTreeMultiItem &item);\r
819 \r
820     /** Deletes all the items from the wxTreeMultiCtrl. */\r
821     void DeleteAllItems(void)\r
822     {\r
823       this->_root.Clear();\r
824       this->m_SelectedItems.Clear();\r
825       Refresh();\r
826     };\r
827 \r
828     /** Deletes all children of the current node. The wxTreeMultiItem needs to be of type Node to
829         do this. Call GetParentNode to get the parent wxTreeMultiItem which is always a node. */
830     void DeleteChildren(const wxTreeMultiItem &item);
831
832     /** @}
833     */
834
835     /** @name Expand and collapse methods
836          These methods are all for items of type Node.
837         @{
838     */
839
840     /** Expand all nodes and subnodes. Recursive = true means all subnodes are also expanded. */
841     void ExpandNodes(bool recursive = false);
842
843     /** Collapses all nodes and subnodes. Recursive = true means all subnodes are also expanded. */
844     void CollapseNodes(bool recursive = false);
845
846     /** Expands given node, and with recursive, also the subnodes */
847     void Expand(const wxTreeMultiItem &item, bool recursive);
848
849     /** Collapses given node, and with recursive, also the subnodes. If this item is not a node, but a window.
850         the parent is resolved and that node is collapsed */
851     void Collapse(const wxTreeMultiItem &item, bool recursive);
852
853     /** Collapses this node and removes all children from it. This is only applicable on
854         wxTreeMultiItems which are of type Node / Root. */
855     void CollapseAndReset(const wxTreeMultiItem &item);
856
857     /** Folds the given node. The same as Expand and Collapse, but the state can be
858         given through a parameter */
859     void Fold(const wxTreeMultiItem &item, bool expand = true) {
860         if(expand)
861             Expand(item, false);
862         else
863             Collapse(item, false);
864     };
865
866     /** @}\r
867     */\r
868 \r
869     /** @name Selection manipulation\r
870          These methods allow you to select, unselect or test wxTreeMultiItems on selection.\r
871          Currently only items of type Node can be manipulated.\r
872         @{\r
873     */\r
874 \r
875    /** Returns the number of selected items. */\r
876     size_t GetSelectedItemCount(void) const {return this->m_SelectedItems.GetCount();}\r
877 \r
878    /** Returns the first selected item.\r
879        If there is no selected item an invalid tree multi item is returned.\r
880    */\r
881     wxTreeMultiItem GetFirstSelectedItem(void) const;\r
882 \r
883    /** Returns the last selected item.\r
884        If there is no selected item an invalid tree multi item is returned.\r
885    */\r
886     wxTreeMultiItem GetLastSelectedItem(void) const;\r
887 \r
888    /** Returns a selected item with the specified index.\r
889        If there is no selected item with the passed index an invalide tree multi item is returned.\r
890    */\r
891     wxTreeMultiItem GetSelectedItem(size_t Index) const;\r
892 \r
893    /** Returns the index of the selected item.\r
894        In case the item is not selected "GetSelectedItemCount()" - which is an invalid index - is returned.\r
895    */\r
896     size_t GetSelectedItemIndex(wxTreeMultiItem const& Item) const;\r
897 \r
898    /** Selects the specified item AND in case\r
899         - UnselectOthers is set all other selected items are going to be unselected;\r
900         - ExpandSelection is set all items between the last selected item and the passed item\r
901           are selected, too (in case there this is the first selection all items between the first root\r
902           and the passed item are selected).\r
903        If the passed item is already selected the other parameters are ignored.\r
904        Please not that currently only nodes can be selected, therefore, if any other item is passed nothing will happen.\r
905    */\r
906     void SelectItem(wxTreeMultiItem const& Item, bool UnselectOthers=true, bool ExpandSelection=false);\r
907 \r
908    /** Unselect all selected items. */\r
909     void UnselectAll(void);\r
910 \r
911    /** Unselect specified item */\r
912     void Unselect(wxTreeMultiItem const& Item);\r
913 \r
914     /** @}\r
915     */\r
916 \r
917 \r
918     /** \name Visibility manipulation\r
919         These methods allow you to manipulate a certain wxTreeMultiItem to temporarily exclude or to include\r
920         the node from drawing. Whenever it is excluded, all operations can still be performed, however\r
921         the node may not be visible.
922         @{
923     */
924
925     /** Excludes this node from drawing. When excluded, the node will dissapear from the control but is still
926         physically present in the tree itself. If this node is a composite node with children, they will all be
927         hidden from the control. */
928     void Exclude(const wxTreeMultiItem &item);
929
930     /** Includes an excluded node. If the node was already present on the drawing, nothing happens. If the
931         node is included after exclusion it will become visible. If the parent node is still excluded or
932         collapsed (not visible) this will not show, until the parent node shows */
933     void Include(const wxTreeMultiItem &item);
934
935     /** Returns the parent that is responsible for excluding this node. If there is no excluded node as parent,
936         the wxTreeMultiItem is zero. */
937     wxTreeMultiItem GetExcludedParent(const wxTreeMultiItem &item);
938
939     /** @}
940     */
941
942     /** Checks if the point is under one of the given areas. The returned areas can be
943         \li wxTMC_HITTEST_GUTTER If the front part of the item is clicked (where the node is)
944         \li wxTMC_HITTEST_WINDOW If located in the window area
945         \li wxTMC_HITTEST_CAPTION If located on the caption of the MultiTreeItemNode
946 \r
947         Returned is the item which is located under the mouse, or none (IsOk = false) if\r
948         no item under the mouse */\r
949     wxTreeMultiItem HitTest(wxPoint const& pt, int &flags);\r
950 \r
951     /** @name Find methods\r
952          These methods are used for finding a node in the wxTreeMultiCtrl.\r
953         @{
954     */
955
956     /** Searches for the given name from the given level and lower. It will return a wxTreeMultiItem which needs
957         to be checked with IsOk() to see if it is a correct item. IsRootItem, IsNodeItem and IsWindowItem can be
958         used to determine the type of item. If the search returned an item which doesn't satisfy the query, you can
959         restart the search from here, with skip = true to skip the passed item. */
960     wxTreeMultiItem FindItem(const wxTreeMultiItem &item, const wxString &name, bool ignoreCase = false,
961                              bool skipFirst = false);
962
963     /** Searches all nodes for the given name and returns the one found. This is a specialised method for FindItem */
964     wxTreeMultiItem FindItem(const wxString &name, bool ignoreCase = false) {
965         return FindItem(wxTreeMultiItem(&_root), name, ignoreCase, false);
966     };
967
968     /** @}
969     */
970
971     /** Returns the number of children in this node. If this node is not of type Node, count returns -1. */
972     int GetChildrenCount(const wxTreeMultiItem &item) {
973         if(item.IsNodeItem())
974         {
975             TreeMultiItemNode *n = (TreeMultiItemNode *)item.GetItem();
976             return n->GetNodeCount();
977         }
978
979         return -1;
980     };
981
982     /** This method finds the current focused window, and returns the wxTreeMultiItem that has this window as pointer.
983         If the wxTreeMultiItem is not ok, the focused window is on a sub-panel, or not on this control. If the focus is
984         on a sub-panel, this panel will handle the focusing. If you are still interested in this window, try
985         wxWindow::FindFocus which will always return with a pointer if a wxWindow has focus */
986     wxTreeMultiItem GetFocus();
987
988     /** @name Smart window Get/Set methods
989          These methods are used for quickly getting or setting primitive values, like boolean, string, or selections into
990          primitive wxWindow controls like a wxRadioButton, wxCheckBox, wxTextCtrl, etc.
991          The methods allow you to quickly set e.g. a boolean value by using the wxWindow ID of the control. A type
992          check is performed before the value is actually set with the appropiate method for it. If it fails, an assertion
993          will follow in debug mode. If you want to get values back similar get methods are present to return values.
994          This allows the user to quickly retrieve or set values by ID, without the fuss of remembering the pointer or
995          node ID of the wxTreeMultiCtrl.
996         @{
997     */
998
999     /** This function calls FindWindow on the wxTreeMultiCtrl to find the window with the given ID (which is added with
1000         AppendWindow). When it is found, it is type casted towards a <b>wxCheckBox</b> and <b>wxRadioButton</b>. Whenever
1001         it finds a proper type it will return true or false. Whenever no proper type is found, it will return with false.
1002         In debug mode it will cause an assertion failure as well, to notify the developer something is wrong.
1003
1004         \sa SetBooleanValue
1005     */
1006     bool GetBooleanValue(int wndId);
1007
1008     /** This function calls FindWindow on the wxTreeMultiCtrl to find the window with the given ID (which is added with
1009         AppendWindow). When it is found, it is type casted towards a <b>wxTextCtrl</b>, <b>wxChoice</b> and <b>wxComboBox</b>.
1010         Whenever it finds a proper type it will return the (selected) text in the control. Whenever no proper type is found,
1011         it will return with an empty string. In debug mode it will cause an exception error as well if the cast fails, to notify
1012         the developer something is wrong.
1013
1014         \sa SetTextValue
1015     */
1016     wxString GetTextValue(int wndId);
1017
1018     /** This function calls FindWindow on the wxTreeMultiCtrl to find the window with the given ID (which is added with
1019         AppendWindow). When it is found, it is type casted towards a <b>wxCheckBox</b> and <b>wxRadioButton</b>. Whenever
1020         it finds a proper type it set the control's value to the given boolean parameter. Nothing happens when no proper type
1021         is found, however debug mode it will cause an assertion failure.
1022
1023         \sa GetBooleanValue
1024     */
1025     void SetBooleanValue(int wndId, bool value = true);
1026
1027     /** This function calls FindWindow on the wxTreeMultiCtrl to find the window with the given ID (which is added with
1028         AppendWindow). When it is found, it is type casted towards a <b>wxTextCtrl</b>. If the control is not found or
1029         of the wrong type, an asserion failure (in debug mode) follows. <br><i><b>NOTE: </b></i> this method
1030         does not typecast to wxChoice or wxComboBox and the likes. If a selection in one of those needs to be set, use the
1031         SetSelectionValue / GetSelectionValue combination.
1032         \sa GetTextValue, GetSelectionValue, SetSelectionValue
1033     */
1034     void SetTextValue(int wndId, const wxString &value = wxEmptyString);
1035
1036     /** Retrieves the wxWindow * associated with the wxTreeMultiItem. This only works for Window typed wxTreeMultiItem
1037         classes. If this type does not match or no window is associated, 0 is returned. */
1038     wxWindow *GetWindow(const wxTreeMultiItem &item) {
1039         if(item.IsWindowItem())
1040             return ((TreeMultiItemWindow *)item.GetItem())->GetWindow();
1041         return 0;
1042     };
1043
1044     /** This function calls FindWindow on the wxTreeMultiCtrl to find the window with the given ID (which is added with
1045         AppendWindow). When it is found, it is type casted towards a <b>wxListBox, wxChoice, wxComboBox</b>.
1046         If the control is not found or of the wrong type, an asserion failure (in debug mode) follows. If it is found
1047         the selection is set in the control.
1048     */
1049     void SetSelectionValue(int wndId, int sel);
1050
1051     /** This function calls FindWindow on the wxTreeMultiCtrl to find the window with the given ID (which is added with
1052         AppendWindow). When it is found, it is type casted towards a <b>wxListBox, wxChoice, wxComboBox</b>.
1053         If the control is not found or of the wrong type, an asserion failure (in debug mode) follows. In release mode -1 is
1054         returned. If it is found the selection index is returned.
1055     */
1056     int GetSelectionValue(int wndId);
1057
1058     /** This function calls FindWindow on the wxTreeMultiCtrl to find the window with the given ID (which is added with
1059         AppendWindow). When it is found, it is type casted towards a <b>wxListBox</b>. If the control is not found or
1060         of the wrong type, an asserion failure (in debug mode) follows. In release mode an empty wxArrayInt is returned.
1061         If it is found the selections are stored in the wxArrayInt. This is only valid for wxListBox classes with multiple
1062         selection flag set.
1063     */
1064     void GetSelectionValues(int wndId, wxArrayInt &sels);
1065
1066 #if(CHECKBOXVIEW)
1067     /** Gets the checkbox state of the wxTreeMultiItem pointed out by "item". If the item does not have a checkbox
1068         associated (or the item is not ok), it will return -1. If the checkbox is checked it will return 1,\r
1069         unchecked is 0, and tri-state (usually only for caption nodes) it will return 2. <b>This needs USE_CHECKBOXVIEW\r
1070         set to YES, or CHECKBOXVIEW=1 during compile</b>*/\r
1071     int GetCheckboxState(const wxTreeMultiItem &item, bool WXUNUSED(recursive)) {\r
1072         wxCHECK(item.IsOk(), -1);\r
1073 \r
1074         // return the checkbox state\r
1075         TreeMultiItemBase *b = item.GetItem();
1076         if(b->GetCheckbox())
1077             return b->GetCheckboxState();
1078
1079         return -1;
1080     };
1081
1082     /** Sets the checkbox state of the wxTreeMultiItem pointed out by "item". If the item does not have a checkbox
1083         associated (or the item is not ok), it will simply ignore this. <b>This needs USE_CHECKBOXVIEW
1084         set to YES, or CHECKBOXVIEW=1 during compile</b>. Contributed by Thomas Enickl.*/
1085         void SetCheckboxState( const wxTreeMultiItem &item, int state ) {
1086                 wxCHECK2( item.IsOk(), return );
1087                 TreeMultiItemBase *b = item.GetItem();
1088                 if( b->GetCheckbox() )
1089                         b->SetCheckboxState( state );
1090                 RedrawFromNode( item.GetItem()->GetParent() );
1091         };
1092 #endif
1093
1094     /** @}
1095     */
1096
1097     /** @name Extended visibility and manipulation methods
1098         These methods alter the wxTreeMultiCtrl appearance, or add more functionality like checkboxes before each node.
1099         @{
1100     */
1101
1102     /** Sets the Y spacing of the wxTreeMultiCtrl to a new size. This can be used to give the controls some more
1103         spacing in between */
1104
1105     void SetSpacingY(int spacingY) {
1106         if(spacingY >= 0)
1107         {
1108             _spacingY = spacingY;
1109             RedrawFromNode(0);
1110         }
1111     };
1112
1113     /** Gets the Y spacing of the wxTreeMultiCtrl. */
1114
1115     int GetSpacingY() const {
1116         return _spacingY;
1117     };
1118
1119 #if(CHECKBOXVIEW)
1120     /** This method toggles the checkbox view mode. Whenever set to true, the next window item, or caption node item
1121         will get a checkbox. <b>This needs USE_CHECKBOXVIEW set to YES, or CHECKBOXVIEW=1 during compile</b>
1122         \sa GetCheckboxView, wxTreeMultiWindowInfo::SetDefaultCheckState
1123     */
1124     void SetCheckboxView(bool value) {
1125         _checkboxView = value;
1126     };
1127
1128     /** This method returns the checkbox state currently used. <b>This needs USE_CHECKBOXVIEW set to YES, or
1129         CHECKBOXVIEW=1 during compile</b>
1130         \sa SetCheckboxView, wxTreeMultiWindowInfo::SetDefaultCheckState, wxTreeMultiWindowInfo::GetDefaultCheckState
1131     */
1132     bool GetCheckboxView() const {
1133         return _checkboxView;
1134     };
1135 #endif
1136
1137     /** @}
1138     */\r
1139 \r
1140     /** @name Iteration methods\r
1141         Allows the user to iterate through a wxTreeMultiCtrl node, and get all the children or siblings.\r
1142         To start an iteration from the lowest level the functions GetFirstRoot and GetLastRoot are provided.\r
1143         @{\r
1144     */\r
1145 \r
1146    /** Returns the first root. */\r
1147     wxTreeMultiItem GetFirstRoot(void) const {return wxTreeMultiItem(this->_root.First());}\r
1148 \r
1149    /** Returns the last root. */\r
1150     wxTreeMultiItem GetLastRoot(void) const {return wxTreeMultiItem(this->_root.Last());}\r
1151 \r
1152    /** Returns the items parent. */\r
1153     wxTreeMultiItem GetParent(wxTreeMultiItem const& item) const;\r
1154 \r
1155     /** Returns the first child of this node. The type of wxTreeMultiItem needs to be of Node. Whenever not succesful,\r
1156         the item returned is not ok (IsOk = false). Upon success, a valid child is returned. The cookie variable doesn't\r
1157         need to be initialized */\r
1158     wxTreeMultiItem GetFirstChild(const wxTreeMultiItem &item, int &cookie) const;
1159
1160     /** Returns the next child in the iteration on the level of 'item'. Make sure you called GetFirstChild first
1161         before calling this one */
1162     wxTreeMultiItem GetNextChild(const wxTreeMultiItem &item, int &cookie) const;
1163
1164     /** Returns the last child of this node. The type of 'item' needs to be of Node. Whenever not succesful,
1165         the item returned is not ok (IsOk = false). Upon success, a valid last child is returned. */\r
1166     wxTreeMultiItem GetLastChild(const wxTreeMultiItem &item) const;\r
1167 \r
1168    /** Returns the next sibling of the passed item. */\r
1169     wxTreeMultiItem GetNextSibling(wxTreeMultiItem const& item) const;\r
1170 \r
1171    /** Returns the previous sibling of the passed item. */\r
1172     wxTreeMultiItem GetPrevSibling(wxTreeMultiItem const& item) const;\r
1173 \r
1174    /** Returns the next item. "Next" is defined by the following order:\r
1175         - in case the current item has a child it is the first child of the current item;\r
1176         - in case the current item has a next sibling as the next sibling;\r
1177         - as the parent's (or one of its ancestor's) next sibling.\r
1178    */\r
1179     wxTreeMultiItem GetNext(wxTreeMultiItem const& item) const;\r
1180 \r
1181    /** Returns the previous item. "Previous" is defined by the following order:\r
1182         - in case the current item has a child it is the last child of the current item;\r
1183         - in case the current item has a previous sibling it is the previous sibling;\r
1184         - as the parent's (or one of its ancestor's) previous sibling.\r
1185    */\r
1186     wxTreeMultiItem GetPrevious(wxTreeMultiItem const& item) const;\r
1187 \r
1188 \r
1189     /** @}\r
1190     */\r
1191 \r
1192     /** @name Get and set methods
1193         These methods allow you to set or get certain properties of the wxTreeMultiCtrl.
1194         @{
1195     */
1196
1197     /** Get the currently used font for the caption headers in the wxTreeMultiCtrl. If you want to alter this
1198         font, simply obtain it and copy it to a local font. After that, set this font back using SetCaptionFont()
1199     */
1200     const wxFont &GetCaptionFont() const {
1201         return _captionFont;
1202     };
1203
1204     /** Sets the font to be used for the text caption headers. This triggers a complete redraw because x,y sizes can
1205         differ, and ofcourse all nodes need to be updated. You can call this method at any time not only at the
1206         beginning. */
1207     void SetCaptionFont(const wxFont &font);
1208
1209     /** @}\r
1210     */\r
1211 \r
1212   void OnDraw(wxDC& dc);\r
1213 \r
1214 private:\r
1215     DECLARE_EVENT_TABLE()\r
1216 };\r
1217
1218 #endif