]> Creatis software - bbtk.git/blob - kernel/src/ThirdParty/wx/treemultictrl/TreeMultiItemBase.h
Started the devel of a wx package browser
[bbtk.git] / kernel / src / ThirdParty / wx / treemultictrl / TreeMultiItemBase.h
1 //---------------------------------------------------------------------------
2 // $RCSfile: TreeMultiItemBase.h,v $\r
3 // $Source: /cvs/creatis/bbtk/kernel/src/ThirdParty/wx/treemultictrl/TreeMultiItemBase.h,v $\r
4 // $Revision: 1.1 $\r
5 // $Date: 2008/03/28 13:42:18 $\r
6 //---------------------------------------------------------------------------
7 // Author:      Jorgen Bodde
8 // Copyright:   (c) Jorgen Bodde
9 // License:     wxWidgets License
10 //---------------------------------------------------------------------------
11
12 #ifndef __TREEMULTIITEMBASE_HPP_
13 #define __TREEMULTIITEMBASE_HPP_
14
15 #ifdef __GNUG__
16     #pragma interface "TreeMultiItemBase.cpp"
17 #endif
18
19 #ifndef WX_PRECOMP
20     #include "wx/wx.h"
21 #endif
22
23 // forward definitions
24 class TreeMultiItemRoot;
25 class TreeMultiItemWindow;
26 class TreeMultiItemNode;
27
28 class TreeMultiItemBase
29 {
30 protected:
31         TreeMultiItemBase(TreeMultiItemNode *parent);
32
33         /** Name property of this item, useful for assigning / coupling
34             external variable reference to this item. It is not mandatory */
35         wxString _name;
36
37         /** Flag to indicate that this node is visible or not. The Node can be 
38             temporarily excluded by flagging it. This has also consequences for all 
39                 the children of this node (if any) */
40         bool _excluded;
41
42         /** Type of instanced class */
43         int _type;
44
45         /** Calculated X, Y position */
46         int _x, _y;
47
48         /** Calculated width, height */
49         int _width, _height;
50         
51 #if(CHECKBOXVIEW)
52         /** Checkbox flag (draw one or not) */
53         bool _checkbox;
54         
55         /** Internal draw state. This is a unintelligent state, and should be
56             updated when this node has some checked and some unchecked children
57                 then this should become a tri-stated item */
58         int _checkboxState;
59 #endif
60
61 public:
62         virtual ~TreeMultiItemBase();
63
64         // type of tree item
65
66     int GetType() const { return _type; };
67         TreeMultiItemNode *GetParent() const { return _parent; };
68
69         /** Get name of this node */
70         wxString GetName() const {
71                 return _name;
72         };
73  /** Set name of the item */
74   void SetName(wxString const& NewName)
75   {
76     this->_name = NewName;
77   }
78
79         /** returns the instance pointer if the current node is
80         a TreeMultiItemRoot, and NULL when it's not.
81         */
82         virtual TreeMultiItemRoot *IsTreeMultiItemRoot() const {
83                 return 0;
84         };
85
86     /** returns the instance pointer if the current node is
87         a TreeMultiItemWindow, and NULL when it's not.
88         */
89         virtual TreeMultiItemWindow *IsTreeMultiItemWindow() const {
90                 return 0;
91         };
92
93     /** returns the instance pointer if the current node is
94         a TreeMultiItemNode, and NULL when it's not.
95         */
96         virtual TreeMultiItemNode *IsTreeMultiItemNode() const {
97                 return 0;
98         };
99
100         /** Sets or resets the excluded flag. When excluded node is not visible */
101         void SetExcluded(bool excluded) {
102                 _excluded = excluded;
103         };
104
105         /** Get / Set routine for X */
106         void SetX(int x) {
107                 _x = x;
108         };
109
110         int GetX() const {
111                 return _x;
112         };
113
114         /** Get / Set routine for Y */
115         void SetY(int y) {
116                 _y = y;
117         };
118
119         int GetY() const {
120                 return _y;
121         };
122
123         /** Get / Set routine for height */
124         void SetHeight(int height) {
125                 _height = height;
126         };
127
128         int GetHeight() const {
129                 return _height;
130         };
131
132         /** Get / Set routine for width */
133         void SetWidth(int width) {
134                 _width = width;
135         };
136
137         int GetWidth() const {
138                 return _width;
139         };
140
141         /** Returns true when this item is drawn somewhere in the
142             tree. Whenever a parent of this node is collapsed, it
143             is not visible and it is not necessary to perform i.e.
144             redraw actions. 
145                 
146                 It also returns false when this node is excluded from the
147                 tree. 
148                 
149                 \sa wxTreeMultiCtrl::Exclude(), wxTreeMultiCtrl::Include())
150         */
151         bool IsVisible();
152
153         /* Returns if this node is excluded from the tree. If this item
154            is a Node, then all kids are excluded as well */
155         bool IsExcluded() const {
156                 return _excluded;
157         };
158         
159  //
160  // item selection status handling
161  
162  /** checks if the item is selected */
163   bool IsSelected(void) const
164   {
165     return this->m_Selected;
166   }
167
168  /** mark the current item as selected */
169   void Select(void)
170   {
171     this->m_Selected = true;
172   }
173   
174  /** toggle the selection status */
175   void ToggleSelection(void)
176   {
177     this->m_Selected = !(this->m_Selected);
178   }
179
180  /** unmark the item */
181   void Unselect(void)
182   {
183     this->m_Selected = false;
184   }
185
186 #if(CHECKBOXVIEW)
187         /** Sets checkbox or not. This does not influence the state of the checkbox */
188         void SetCheckbox(bool value) {
189                 _checkbox = value;
190         };
191
192         /** Returns current state of the checkbox view */
193         bool GetCheckbox() const {
194                 return _checkbox;
195         };
196
197         /** Sets checkbox state. If 0 it's unchecked, 1 = checked and 2 = tristate */
198         virtual void SetCheckboxState(int state) {
199                 wxCHECK2(state < 3 && state >= 0, return);
200                 _checkboxState = state;
201         };
202
203         /** Returns current state of checkbox */
204         int GetCheckboxState() const {
205                 return _checkboxState;
206         };
207 #endif
208
209 private:
210         TreeMultiItemNode *_parent;
211         
212  // flags to indicate the status of the item:
213   bool m_Selected;
214 };
215
216 #endif
217