File: IGUITreeView.h

package info (click to toggle)
irrlicht 1.7.1%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 32,124 kB
  • ctags: 44,051
  • sloc: cpp: 137,592; ansic: 3,232; makefile: 801; sh: 16; sed: 11
file content (255 lines) | stat: -rw-r--r-- 9,694 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
// This file is part of the "Irrlicht Engine".
// written by Reinhard Ostermeier, reinhard@nospam.r-ostermeier.de

#ifndef __I_GUI_TREE_VIEW_H_INCLUDED__
#define __I_GUI_TREE_VIEW_H_INCLUDED__

#include "IGUIElement.h"
#include "IGUIImageList.h"
#include "irrTypes.h"

namespace irr
{
namespace gui
{
	class IGUIFont;
	class IGUITreeView;


	//! Node for gui tree view
	class IGUITreeViewNode : public IReferenceCounted
	{
	public:
		//! returns the owner (tree view) of this node
		virtual IGUITreeView* getOwner() const = 0;
		
		//! Returns the parent node of this node.
		/** For the root node this will return 0. */
		virtual IGUITreeViewNode* getParent() const = 0;
		
		//! returns the text of the node
		virtual const wchar_t* getText() const = 0;

		//! sets the text of the node
		virtual void setText( const wchar_t* text ) = 0;

		//! returns the icon text of the node		
		virtual const wchar_t* getIcon() const = 0;
		
		//! sets the icon text of the node
		virtual void setIcon( const wchar_t* icon ) = 0;
		
		//! returns the image index of the node		
		virtual u32 getImageIndex() const = 0;
		
		//! sets the image index of the node
		virtual void setImageIndex( u32 imageIndex ) = 0;
		
		//! returns the image index of the node		
		virtual u32 getSelectedImageIndex() const = 0;
		
		//! sets the image index of the node
		virtual void setSelectedImageIndex( u32 imageIndex ) = 0;
		
		//! returns the user data (void*) of this node
		virtual void* getData() const = 0;
		
		//! sets the user data (void*) of this node
		virtual void setData( void* data ) = 0;
		
		//! returns the user data2 (IReferenceCounted) of this node
		virtual IReferenceCounted* getData2() const = 0;
		
		//! sets the user data2 (IReferenceCounted) of this node
		virtual void setData2( IReferenceCounted* data ) = 0;
		
		//! returns the child item count
		virtual u32 getChildCount() const = 0;		
		
		//! removes all childs (recursive) from this node
		virtual void clearChilds() = 0;
		
		//! returns true if this node has child nodes
		virtual bool hasChilds() const = 0;
		
		//! Adds a new node behind the last child node.
		/** \param text text of the new node
		\param icon icon text of the new node
		\param imageIndex index of the image for the new node (-1 = none)
		\param selectedImageIndex index of the selected image for the new node (-1 = same as imageIndex)
		\param data user data (void*) of the new node
		\param data2 user data2 (IReferenceCounted*) of the new node
		\return The new node
		*/
		virtual IGUITreeViewNode* addChildBack(
				const wchar_t* text, const wchar_t* icon = 0,
				s32 imageIndex=-1, s32 selectedImageIndex=-1,
				void* data=0, IReferenceCounted* data2=0) =0;

		//! Adds a new node before the first child node.
		/** \param text text of the new node
		\param icon icon text of the new node
		\param imageIndex index of the image for the new node (-1 = none)
		\param selectedImageIndex index of the selected image for the new node (-1 = same as imageIndex)
		\param data user data (void*) of the new node
		\param data2 user data2 (IReferenceCounted*) of the new node
		\return The new node
		*/
		virtual IGUITreeViewNode* addChildFront(
				const wchar_t* text, const wchar_t* icon = 0,
				s32 imageIndex=-1, s32 selectedImageIndex=-1,
				void* data=0, IReferenceCounted* data2=0 ) =0;

		//! Adds a new node behind the other node.
		/** The other node has also te be a child node from this node.
		\param other Node to insert after
		\param text text of the new node
		\param icon icon text of the new node
		\param imageIndex index of the image for the new node (-1 = none)
		\param selectedImageIndex index of the selected image for the new node (-1 = same as imageIndex)
		\param data user data (void*) of the new node
		\param data2 user data2 (IReferenceCounted*) of the new node
		\return The new node or 0 if other is no child node from this
		*/
		virtual IGUITreeViewNode* insertChildAfter(
				IGUITreeViewNode* other,
				const wchar_t* text, const wchar_t* icon = 0,
				s32 imageIndex=-1, s32 selectedImageIndex=-1,
				void* data=0, IReferenceCounted* data2=0) =0;

		//! Adds a new node before the other node.
		/** The other node has also te be a child node from this node.
		\param other Node to insert before
		\param text text of the new node
		\param icon icon text of the new node
		\param imageIndex index of the image for the new node (-1 = none)
		\param selectedImageIndex index of the selected image for the new node (-1 = same as imageIndex)
		\param data user data (void*) of the new node
		\param data2 user data2 (IReferenceCounted*) of the new node
		\return The new node or 0 if other is no child node from this
		*/
		virtual IGUITreeViewNode* insertChildBefore(
				IGUITreeViewNode* other,
				const wchar_t* text, const wchar_t* icon = 0,
				s32 imageIndex=-1, s32 selectedImageIndex=-1,
				void* data=0, IReferenceCounted* data2=0) = 0;
		
		//! Return the first child node from this node.
		/** \return The first child node or 0 if this node has no childs. */
		virtual IGUITreeViewNode* getFirstChild() const = 0;

		//! Return the last child node from this node.
		/** \return The last child node or 0 if this node has no childs. */
		virtual IGUITreeViewNode* getLastChild() const = 0;

		//! Returns the previous sibling node from this node.
		/** \return The previous sibling node from this node or 0 if this is
		the first node from the parent node.
		*/
		virtual IGUITreeViewNode* getPrevSibling() const = 0;

		//! Returns the next sibling node from this node.
		/** \return The next sibling node from this node or 0 if this is
		the last node from the parent node.
		*/
		virtual IGUITreeViewNode* getNextSibling() const = 0;

		//! Returns the next visible (expanded, may be out of scrolling) node from this node.
		/** \return The next visible node from this node or 0 if this is
		the last visible node. */
		virtual IGUITreeViewNode* getNextVisible() const = 0;

		//! Deletes a child node.
		/** \return Returns true if the node was found as a child and is deleted. */
		virtual bool deleteChild( IGUITreeViewNode* child ) = 0;
		
		//! Moves a child node one position up.
		/** \return True if the node was found as achild node and was not already the first child. */
		virtual bool moveChildUp( IGUITreeViewNode* child ) = 0;

		//! Moves a child node one position down.
		/** \return True if the node was found as achild node and was not already the last child. */
		virtual bool moveChildDown( IGUITreeViewNode* child ) = 0;

		//! Returns true if the node is expanded (childs are visible).
		virtual bool getExpanded() const = 0;
		
		//! Sets if the node is expanded.
		virtual void setExpanded( bool expanded ) = 0;
		
		//! Returns true if the node is currently selected.
		virtual bool getSelected() const = 0;
		
		//! Sets this node as selected.
		virtual void setSelected( bool selected ) = 0;
		
		//! Returns true if this node is the root node.
		virtual bool isRoot() const = 0;
		
		//! Returns the level of this node.
		/** The root node has level 0. Direct childs of the root has level 1 ... */
		virtual s32 getLevel() const = 0;
		
		//! Returns true if this node is visible (all parents are expanded).
		virtual bool isVisible() const = 0;
	};
	
	
	//! Default tree view GUI element.
	/** Displays a windows like tree buttons to expand/collaps the child
	nodes of an node and optional tree lines. Each node consits of an
	text, an icon text and a void pointer for user data. */
	class IGUITreeView : public IGUIElement
	{
	public:
		//! constructor
		IGUITreeView(IGUIEnvironment* environment, IGUIElement* parent,
				s32 id, core::rect<s32> rectangle)
			: IGUIElement( EGUIET_TREE_VIEW, environment, parent, id, rectangle ) {}

		//! returns the root node (not visible) from the tree.
		virtual IGUITreeViewNode* getRoot() const = 0;

		//! returns the selected node of the tree or 0 if none is selected
		virtual IGUITreeViewNode* getSelected() const = 0;

		//! returns true if the tree lines are visible
		virtual bool getLinesVisible() const = 0;
		
		//! sets if the tree lines are visible
		/** \param visible true for visible, false for invisible */
		virtual void setLinesVisible( bool visible ) = 0;

		//! Sets the font which should be used as icon font.
		/** This font is set to the Irrlicht engine built-in-font by
		default. Icons can be displayed in front of every list item.
		An icon is a string, displayed with the icon font. When using
		the build-in-font of the Irrlicht engine as icon font, the icon
		strings defined in GUIIcons.h can be used.
		*/
		virtual void setIconFont( IGUIFont* font ) = 0;
		
		//! Sets the image list which should be used for the image and selected image of every node.
		/** The default is 0 (no images). */
		virtual void setImageList( IGUIImageList* imageList ) = 0;
		
		//! Returns the image list which is used for the nodes.
		virtual IGUIImageList* getImageList() const = 0;
		
		//! Sets if the image is left of the icon. Default is true.
		virtual void setImageLeftOfIcon( bool bLeftOf ) = 0;
		
		//! Returns if the Image is left of the icon. Default is true.
		virtual bool getImageLeftOfIcon() const = 0;
		
		//! Returns the node which is associated to the last event.
		/** This pointer is only valid inside the OnEvent call! */
		virtual IGUITreeViewNode* getLastEventNode() const = 0;
	};


} // end namespace gui
} // end namespace irr

#endif