]> Creatis software - bbtk.git/blob - kernel/src/ThirdParty/wx/treemultictrl/TreeMultiItemBase.h
Feature #1774
[bbtk.git] / kernel / src / ThirdParty / wx / treemultictrl / TreeMultiItemBase.h
1 /*
2  # ---------------------------------------------------------------------
3  #
4  # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5  #                        pour la SantÈ)
6  # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7  # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8  # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9  #
10  #  This software is governed by the CeCILL-B license under French law and
11  #  abiding by the rules of distribution of free software. You can  use,
12  #  modify and/ or redistribute the software under the terms of the CeCILL-B
13  #  license as circulated by CEA, CNRS and INRIA at the following URL
14  #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15  #  or in the file LICENSE.txt.
16  #
17  #  As a counterpart to the access to the source code and  rights to copy,
18  #  modify and redistribute granted by the license, users are provided only
19  #  with a limited warranty  and the software's author,  the holder of the
20  #  economic rights,  and the successive licensors  have only  limited
21  #  liability.
22  #
23  #  The fact that you are presently reading this means that you have had
24  #  knowledge of the CeCILL-B license and that you accept its terms.
25  # ------------------------------------------------------------------------ */
26
27
28 //---------------------------------------------------------------------------
29 // $RCSfile: TreeMultiItemBase.h,v $
30 // $Source: /cvs/creatis/bbtk/kernel/src/ThirdParty/wx/treemultictrl/TreeMultiItemBase.h,v $
31 // $Revision: 1.2 $
32 // $Date: 2012/11/16 08:49:16 $
33 //---------------------------------------------------------------------------
34 // Author:      Jorgen Bodde
35 // Copyright:   (c) Jorgen Bodde
36 // License:     wxWidgets License
37 //---------------------------------------------------------------------------
38
39 #ifndef __TREEMULTIITEMBASE_HPP_
40 #define __TREEMULTIITEMBASE_HPP_
41
42 #ifdef __GNUG__
43     #pragma interface "TreeMultiItemBase.cpp"
44 #endif
45
46 #ifndef WX_PRECOMP
47     #include "wx/wx.h"
48 #endif
49
50 // forward definitions
51 class TreeMultiItemRoot;
52 class TreeMultiItemWindow;
53 class TreeMultiItemNode;
54
55 class TreeMultiItemBase
56 {
57 protected:
58         TreeMultiItemBase(TreeMultiItemNode *parent);
59
60         /** Name property of this item, useful for assigning / coupling
61             external variable reference to this item. It is not mandatory */
62         wxString _name;
63
64         /** Flag to indicate that this node is visible or not. The Node can be 
65             temporarily excluded by flagging it. This has also consequences for all 
66                 the children of this node (if any) */
67         bool _excluded;
68
69         /** Type of instanced class */
70         int _type;
71
72         /** Calculated X, Y position */
73         int _x, _y;
74
75         /** Calculated width, height */
76         int _width, _height;
77         
78 #if(CHECKBOXVIEW)
79         /** Checkbox flag (draw one or not) */
80         bool _checkbox;
81         
82         /** Internal draw state. This is a unintelligent state, and should be
83             updated when this node has some checked and some unchecked children
84                 then this should become a tri-stated item */
85         int _checkboxState;
86 #endif
87
88 public:
89         virtual ~TreeMultiItemBase();
90
91         // type of tree item
92
93     int GetType() const { return _type; };
94         TreeMultiItemNode *GetParent() const { return _parent; };
95
96         /** Get name of this node */
97         wxString GetName() const {
98                 return _name;
99         };
100  /** Set name of the item */
101   void SetName(wxString const& NewName)
102   {
103     this->_name = NewName;
104   }
105
106         /** returns the instance pointer if the current node is
107         a TreeMultiItemRoot, and NULL when it's not.
108         */
109         virtual TreeMultiItemRoot *IsTreeMultiItemRoot() const {
110                 return 0;
111         };
112
113     /** returns the instance pointer if the current node is
114         a TreeMultiItemWindow, and NULL when it's not.
115         */
116         virtual TreeMultiItemWindow *IsTreeMultiItemWindow() const {
117                 return 0;
118         };
119
120     /** returns the instance pointer if the current node is
121         a TreeMultiItemNode, and NULL when it's not.
122         */
123         virtual TreeMultiItemNode *IsTreeMultiItemNode() const {
124                 return 0;
125         };
126
127         /** Sets or resets the excluded flag. When excluded node is not visible */
128         void SetExcluded(bool excluded) {
129                 _excluded = excluded;
130         };
131
132         /** Get / Set routine for X */
133         void SetX(int x) {
134                 _x = x;
135         };
136
137         int GetX() const {
138                 return _x;
139         };
140
141         /** Get / Set routine for Y */
142         void SetY(int y) {
143                 _y = y;
144         };
145
146         int GetY() const {
147                 return _y;
148         };
149
150         /** Get / Set routine for height */
151         void SetHeight(int height) {
152                 _height = height;
153         };
154
155         int GetHeight() const {
156                 return _height;
157         };
158
159         /** Get / Set routine for width */
160         void SetWidth(int width) {
161                 _width = width;
162         };
163
164         int GetWidth() const {
165                 return _width;
166         };
167
168         /** Returns true when this item is drawn somewhere in the
169             tree. Whenever a parent of this node is collapsed, it
170             is not visible and it is not necessary to perform i.e.
171             redraw actions. 
172                 
173                 It also returns false when this node is excluded from the
174                 tree. 
175                 
176                 \sa wxTreeMultiCtrl::Exclude(), wxTreeMultiCtrl::Include())
177         */
178         bool IsVisible();
179
180         /* Returns if this node is excluded from the tree. If this item
181            is a Node, then all kids are excluded as well */
182         bool IsExcluded() const {
183                 return _excluded;
184         };
185         
186  //
187  // item selection status handling
188  
189  /** checks if the item is selected */
190   bool IsSelected(void) const
191   {
192     return this->m_Selected;
193   }
194
195  /** mark the current item as selected */
196   void Select(void)
197   {
198     this->m_Selected = true;
199   }
200   
201  /** toggle the selection status */
202   void ToggleSelection(void)
203   {
204     this->m_Selected = !(this->m_Selected);
205   }
206
207  /** unmark the item */
208   void Unselect(void)
209   {
210     this->m_Selected = false;
211   }
212
213 #if(CHECKBOXVIEW)
214         /** Sets checkbox or not. This does not influence the state of the checkbox */
215         void SetCheckbox(bool value) {
216                 _checkbox = value;
217         };
218
219         /** Returns current state of the checkbox view */
220         bool GetCheckbox() const {
221                 return _checkbox;
222         };
223
224         /** Sets checkbox state. If 0 it's unchecked, 1 = checked and 2 = tristate */
225         virtual void SetCheckboxState(int state) {
226                 wxCHECK2(state < 3 && state >= 0, return);
227                 _checkboxState = state;
228         };
229
230         /** Returns current state of checkbox */
231         int GetCheckboxState() const {
232                 return _checkboxState;
233         };
234 #endif
235
236 private:
237         TreeMultiItemNode *_parent;
238         
239  // flags to indicate the status of the item:
240   bool m_Selected;
241 };
242
243 #endif
244