1
// This file is part of the "Irrlicht Engine".
2
// written by Reinhard Ostermeier, reinhard@nospam.r-ostermeier.de
4
#ifndef __I_GUI_TREE_VIEW_H_INCLUDED__
5
#define __I_GUI_TREE_VIEW_H_INCLUDED__
7
#include "IGUIElement.h"
8
#include "IGUIImageList.h"
19
//! Node for gui tree view
20
class IGUITreeViewNode : public IReferenceCounted
23
//! returns the owner (tree view) of this node
24
virtual IGUITreeView* getOwner() const = 0;
26
//! Returns the parent node of this node.
27
/** For the root node this will return 0. */
28
virtual IGUITreeViewNode* getParent() const = 0;
30
//! returns the text of the node
31
virtual const wchar_t* getText() const = 0;
33
//! sets the text of the node
34
virtual void setText( const wchar_t* text ) = 0;
36
//! returns the icon text of the node
37
virtual const wchar_t* getIcon() const = 0;
39
//! sets the icon text of the node
40
virtual void setIcon( const wchar_t* icon ) = 0;
42
//! returns the image index of the node
43
virtual u32 getImageIndex() const = 0;
45
//! sets the image index of the node
46
virtual void setImageIndex( u32 imageIndex ) = 0;
48
//! returns the image index of the node
49
virtual u32 getSelectedImageIndex() const = 0;
51
//! sets the image index of the node
52
virtual void setSelectedImageIndex( u32 imageIndex ) = 0;
54
//! returns the user data (void*) of this node
55
virtual void* getData() const = 0;
57
//! sets the user data (void*) of this node
58
virtual void setData( void* data ) = 0;
60
//! returns the user data2 (IReferenceCounted) of this node
61
virtual IReferenceCounted* getData2() const = 0;
63
//! sets the user data2 (IReferenceCounted) of this node
64
virtual void setData2( IReferenceCounted* data ) = 0;
66
//! returns the child item count
67
virtual u32 getChildCount() const = 0;
69
//! removes all children (recursive) from this node
70
virtual void clearChildren() = 0;
72
//! removes all children (recursive) from this node
73
/** \deprecated Deprecated in 1.8, use clearChildren() instead.
74
This method may be removed by Irrlicht 1.9 */
75
_IRR_DEPRECATED_ void clearChilds()
77
return clearChildren();
80
//! returns true if this node has child nodes
81
virtual bool hasChildren() const = 0;
83
//! returns true if this node has child nodes
84
/** \deprecated Deprecated in 1.8, use hasChildren() instead.
85
This method may be removed by Irrlicht 1.9 */
86
_IRR_DEPRECATED_ bool hasChilds() const
91
//! Adds a new node behind the last child node.
92
/** \param text text of the new node
93
\param icon icon text of the new node
94
\param imageIndex index of the image for the new node (-1 = none)
95
\param selectedImageIndex index of the selected image for the new node (-1 = same as imageIndex)
96
\param data user data (void*) of the new node
97
\param data2 user data2 (IReferenceCounted*) of the new node
100
virtual IGUITreeViewNode* addChildBack(
101
const wchar_t* text, const wchar_t* icon = 0,
102
s32 imageIndex=-1, s32 selectedImageIndex=-1,
103
void* data=0, IReferenceCounted* data2=0) =0;
105
//! Adds a new node before the first child node.
106
/** \param text text of the new node
107
\param icon icon text of the new node
108
\param imageIndex index of the image for the new node (-1 = none)
109
\param selectedImageIndex index of the selected image for the new node (-1 = same as imageIndex)
110
\param data user data (void*) of the new node
111
\param data2 user data2 (IReferenceCounted*) of the new node
114
virtual IGUITreeViewNode* addChildFront(
115
const wchar_t* text, const wchar_t* icon = 0,
116
s32 imageIndex=-1, s32 selectedImageIndex=-1,
117
void* data=0, IReferenceCounted* data2=0 ) =0;
119
//! Adds a new node behind the other node.
120
/** The other node has also te be a child node from this node.
121
\param other Node to insert after
122
\param text text of the new node
123
\param icon icon text of the new node
124
\param imageIndex index of the image for the new node (-1 = none)
125
\param selectedImageIndex index of the selected image for the new node (-1 = same as imageIndex)
126
\param data user data (void*) of the new node
127
\param data2 user data2 (IReferenceCounted*) of the new node
128
\return The new node or 0 if other is no child node from this
130
virtual IGUITreeViewNode* insertChildAfter(
131
IGUITreeViewNode* other,
132
const wchar_t* text, const wchar_t* icon = 0,
133
s32 imageIndex=-1, s32 selectedImageIndex=-1,
134
void* data=0, IReferenceCounted* data2=0) =0;
136
//! Adds a new node before the other node.
137
/** The other node has also te be a child node from this node.
138
\param other Node to insert before
139
\param text text of the new node
140
\param icon icon text of the new node
141
\param imageIndex index of the image for the new node (-1 = none)
142
\param selectedImageIndex index of the selected image for the new node (-1 = same as imageIndex)
143
\param data user data (void*) of the new node
144
\param data2 user data2 (IReferenceCounted*) of the new node
145
\return The new node or 0 if other is no child node from this
147
virtual IGUITreeViewNode* insertChildBefore(
148
IGUITreeViewNode* other,
149
const wchar_t* text, const wchar_t* icon = 0,
150
s32 imageIndex=-1, s32 selectedImageIndex=-1,
151
void* data=0, IReferenceCounted* data2=0) = 0;
153
//! Return the first child node from this node.
154
/** \return The first child node or 0 if this node has no children. */
155
virtual IGUITreeViewNode* getFirstChild() const = 0;
157
//! Return the last child node from this node.
158
/** \return The last child node or 0 if this node has no children. */
159
virtual IGUITreeViewNode* getLastChild() const = 0;
161
//! Returns the previous sibling node from this node.
162
/** \return The previous sibling node from this node or 0 if this is
163
the first node from the parent node.
165
virtual IGUITreeViewNode* getPrevSibling() const = 0;
167
//! Returns the next sibling node from this node.
168
/** \return The next sibling node from this node or 0 if this is
169
the last node from the parent node.
171
virtual IGUITreeViewNode* getNextSibling() const = 0;
173
//! Returns the next visible (expanded, may be out of scrolling) node from this node.
174
/** \return The next visible node from this node or 0 if this is
175
the last visible node. */
176
virtual IGUITreeViewNode* getNextVisible() const = 0;
178
//! Deletes a child node.
179
/** \return Returns true if the node was found as a child and is deleted. */
180
virtual bool deleteChild( IGUITreeViewNode* child ) = 0;
182
//! Moves a child node one position up.
183
/** \return True if the node was found as achild node and was not already the first child. */
184
virtual bool moveChildUp( IGUITreeViewNode* child ) = 0;
186
//! Moves a child node one position down.
187
/** \return True if the node was found as achild node and was not already the last child. */
188
virtual bool moveChildDown( IGUITreeViewNode* child ) = 0;
190
//! Returns true if the node is expanded (children are visible).
191
virtual bool getExpanded() const = 0;
193
//! Sets if the node is expanded.
194
virtual void setExpanded( bool expanded ) = 0;
196
//! Returns true if the node is currently selected.
197
virtual bool getSelected() const = 0;
199
//! Sets this node as selected.
200
virtual void setSelected( bool selected ) = 0;
202
//! Returns true if this node is the root node.
203
virtual bool isRoot() const = 0;
205
//! Returns the level of this node.
206
/** The root node has level 0. Direct children of the root has level 1 ... */
207
virtual s32 getLevel() const = 0;
209
//! Returns true if this node is visible (all parents are expanded).
210
virtual bool isVisible() const = 0;
214
//! Default tree view GUI element.
215
/** Displays a windows like tree buttons to expand/collaps the child
216
nodes of an node and optional tree lines. Each node consits of an
217
text, an icon text and a void pointer for user data. */
218
class IGUITreeView : public IGUIElement
222
IGUITreeView(IGUIEnvironment* environment, IGUIElement* parent,
223
s32 id, core::rect<s32> rectangle)
224
: IGUIElement( EGUIET_TREE_VIEW, environment, parent, id, rectangle ) {}
226
//! returns the root node (not visible) from the tree.
227
virtual IGUITreeViewNode* getRoot() const = 0;
229
//! returns the selected node of the tree or 0 if none is selected
230
virtual IGUITreeViewNode* getSelected() const = 0;
232
//! returns true if the tree lines are visible
233
virtual bool getLinesVisible() const = 0;
235
//! sets if the tree lines are visible
236
/** \param visible true for visible, false for invisible */
237
virtual void setLinesVisible( bool visible ) = 0;
239
//! Sets the font which should be used as icon font.
240
/** This font is set to the Irrlicht engine built-in-font by
241
default. Icons can be displayed in front of every list item.
242
An icon is a string, displayed with the icon font. When using
243
the build-in-font of the Irrlicht engine as icon font, the icon
244
strings defined in GUIIcons.h can be used.
246
virtual void setIconFont( IGUIFont* font ) = 0;
248
//! Sets the image list which should be used for the image and selected image of every node.
249
/** The default is 0 (no images). */
250
virtual void setImageList( IGUIImageList* imageList ) = 0;
252
//! Returns the image list which is used for the nodes.
253
virtual IGUIImageList* getImageList() const = 0;
255
//! Sets if the image is left of the icon. Default is true.
256
virtual void setImageLeftOfIcon( bool bLeftOf ) = 0;
258
//! Returns if the Image is left of the icon. Default is true.
259
virtual bool getImageLeftOfIcon() const = 0;
261
//! Returns the node which is associated to the last event.
262
/** This pointer is only valid inside the OnEvent call! */
263
virtual IGUITreeViewNode* getLastEventNode() const = 0;
267
} // end namespace gui
268
} // end namespace irr