]> Creatis software - bbtk.git/blob - kernel/src/ThirdParty/wx/treemultictrl/TreeMultiItemNode.h
Feature #1774
[bbtk.git] / kernel / src / ThirdParty / wx / treemultictrl / TreeMultiItemNode.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: TreeMultiItemNode.h,v $
30 // $Source: /cvs/creatis/bbtk/kernel/src/ThirdParty/wx/treemultictrl/TreeMultiItemNode.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 __TREEMULTIITEMNODE_HPP_
40 #define __TREEMULTIITEMNODE_HPP_
41
42 #ifdef __GNUG__
43     #pragma interface "TreeMultiItemNode.cpp"
44 #endif
45
46 #ifndef WX_PRECOMP
47     #include "wx/wx.h"
48 #endif
49 #include "wx/treebase.h"
50
51
52 #include <wx/dynarray.h>
53 #include "TreeMultiItemBase.h"
54 #include "TreeMultiItemWindow.h"
55
56 /** TreeMultiItemNode
57   * This class is the element class for WX_OBJ_ARRAY and it
58   * should be filled with the member variables and methods to
59   * manipulate each object inside the object array.
60   *
61   * See wxArray for all base methods manipulating the array
62   * Clear() can be used to safely delete all objects.
63   */
64
65 // declare the array class here
66
67 WX_DECLARE_OBJARRAY(TreeMultiItemBase, TreeMultiItemBaseArray);
68
69 class TreeMultiItemNode : public TreeMultiItemBase
70 {
71 private:
72         TreeMultiItemBaseArray _items;
73
74         /** Caption of this node. */
75         wxString _caption;
76
77         /** Indicates if this node is expanded (true) or collapsed (false) */
78         bool _nodeExpanded;
79
80  /** visual attributes of the node */
81   wxTreeItemAttr m_Attributes;
82
83 public:
84         TreeMultiItemNode(TreeMultiItemNode *parent, const wxString &caption = wxEmptyString, const wxString &name = wxEmptyString);
85         virtual ~TreeMultiItemNode();
86
87         // isClass method
88         virtual TreeMultiItemNode *IsTreeMultiItemNode() const {
89                 return (TreeMultiItemNode *)this;
90         };
91         
92         // add methods
93         void AddNode(TreeMultiItemBase *node);
94         void InsertNode(TreeMultiItemBase* NodePtr, size_t Position);
95
96         // delete methods
97         void Clear();
98         void DeleteNode(TreeMultiItemBase *node);
99         void DeleteNode(int index);
100         TreeMultiItemBase *RemoveNode(TreeMultiItemBase *node);
101         TreeMultiItemBase *RemoveNode(int index);
102
103         // get methods
104         int GetNodeCount() const;
105         TreeMultiItemBase *GetNode(int index) const;
106         int Index(TreeMultiItemBase *node,  bool searchFromEnd = false) const;
107         TreeMultiItemBase *GetNodeNext(int &cookie) const;
108         
109         TreeMultiItemBase* First() const;
110         TreeMultiItemBase* Last() const;
111
112         /** Fold function sets or clears the expanded flag. Note when excluded from drawing, this
113             will have no effect on redraw */
114         void Fold(bool expand) {
115                 if(_nodeExpanded != expand)
116                         _nodeExpanded = expand;
117         };
118
119         /** Return caption */
120         const wxString &GetCaption() const {
121                 return _caption;
122         };
123
124         /** Returns true if the node is expanded. Subnodes can still be collapsed though */
125         bool IsExpanded() const {
126                 return _nodeExpanded;
127         };
128
129
130 };
131
132 #endif
133