2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
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
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.
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
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 # ------------------------------------------------------------------------ */
28 //---------------------------------------------------------------------------
29 // $RCSfile: TreeMultiItemNode.cpp,v $
30 // $Source: /cvs/creatis/bbtk/kernel/src/ThirdParty/wx/treemultictrl/TreeMultiItemNode.cpp,v $
32 // $Date: 2012/11/16 08:49:16 $
33 //---------------------------------------------------------------------------
34 // Author: Jorgen Bodde
35 // Copyright: (c) Jorgen Bodde
36 // License: wxWidgets License
37 //---------------------------------------------------------------------------
40 #pragma implementation "TreeMultiItemNode.cpp"
43 /* for compilers that support precompilation
46 #include "wx/wxprec.h"
52 #include "wx/treemultictrl/TreeMultiItemNode.h"
54 #include "wx/arrimpl.cpp"
55 WX_DEFINE_OBJARRAY(TreeMultiItemBaseArray);
58 * This class is a container holder for multiple TreeMultiItemBase classes.
59 * Since both a TreeMultiItemNode and a TreeMultiItemWindow are a descendant
60 * from a TreeMultiItemBase class, it can hold multiple of these.
61 * In the case of a directory tree structure, it can hold multiple
62 * directories, and leafs (files).
65 // default constructor for container composite
66 TreeMultiItemNode::TreeMultiItemNode(TreeMultiItemNode *parent, const wxString &caption, const wxString &name)
67 : TreeMultiItemBase(parent)
76 //------------------------------------------------------------
78 TreeMultiItemNode::~TreeMultiItemNode()
80 // delete all items on this level
84 //------------------------------------------------------------
86 void TreeMultiItemNode::AddNode(TreeMultiItemBase *node)
92 void TreeMultiItemNode::InsertNode(TreeMultiItemBase* NodePtr, size_t Position)
95 this->_items.Insert(NodePtr,Position);
98 //------------------------------------------------------------
100 void TreeMultiItemNode::DeleteNode(TreeMultiItemBase *node)
102 // this is wrong. The RemoveAt and Remove should delete
106 _items.Detach(Index(node));
112 //------------------------------------------------------------
114 void TreeMultiItemNode::DeleteNode(int index)
116 // this is wrong. The RemoveAt and Remove should delete
118 if(index < (int)_items.Count() && index >= 0)
119 _items.RemoveAt(index);
122 //------------------------------------------------------------
124 int TreeMultiItemNode::GetNodeCount() const
126 return _items.Count();
129 //------------------------------------------------------------
131 TreeMultiItemBase *TreeMultiItemNode::GetNode(int index) const
133 TreeMultiItemBase *value = 0;
135 if(index < (int)_items.Count() && index >= 0)
136 value = &_items.Item(index);
141 //------------------------------------------------------------
143 TreeMultiItemBase *TreeMultiItemNode::RemoveNode(TreeMultiItemBase *node)
146 _items.Detach(_items.Index(*node));
151 //------------------------------------------------------------
153 TreeMultiItemBase * TreeMultiItemNode::RemoveNode(int index)
155 TreeMultiItemBase *value = 0;
157 if(index < (int)_items.Count() && index > 0)
159 value = &_items.Item(index);
160 _items.Detach(index);
166 //------------------------------------------------------------
168 int TreeMultiItemNode::Index(TreeMultiItemBase *node, bool searchFromEnd) const
172 return _items.Index(*node, searchFromEnd);
175 //------------------------------------------------------------
177 void TreeMultiItemNode::Clear()
182 //------------------------------------------------------------
184 TreeMultiItemBase * TreeMultiItemNode::GetNodeNext(int &cookie) const
186 TreeMultiItemBase *value = 0;
188 if(cookie >= 0 && cookie < (int)_items.Count())
190 value = &_items[cookie];
197 //------------------------------------------------------------
199 TreeMultiItemBase* TreeMultiItemNode::First() const
201 if (this->_items.GetCount() > 0)
202 return &(this->_items[0]);
205 } /* TreeMultiItemNode::First() const */
207 TreeMultiItemBase* TreeMultiItemNode::Last() const
209 if(this->_items.GetCount() > 0)
210 return &(this->_items.Last());
213 } /* TreeMultiItemNode::Last() const */