~baltix/+junk/irrlicht-test

« back to all changes in this revision

Viewing changes to include/IGUITreeView.h

  • Committer: Mantas Kriaučiūnas
  • Date: 2011-07-18 13:06:25 UTC
  • Revision ID: mantas@akl.lt-20110718130625-c5pvifp61e7kj1ol
Included whole irrlicht SVN libraries to work around launchpad recipe issue with quilt, see https://answers.launchpad.net/launchpad/+question/165193

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// This file is part of the "Irrlicht Engine".
 
2
// written by Reinhard Ostermeier, reinhard@nospam.r-ostermeier.de
 
3
 
 
4
#ifndef __I_GUI_TREE_VIEW_H_INCLUDED__
 
5
#define __I_GUI_TREE_VIEW_H_INCLUDED__
 
6
 
 
7
#include "IGUIElement.h"
 
8
#include "IGUIImageList.h"
 
9
#include "irrTypes.h"
 
10
 
 
11
namespace irr
 
12
{
 
13
namespace gui
 
14
{
 
15
        class IGUIFont;
 
16
        class IGUITreeView;
 
17
 
 
18
 
 
19
        //! Node for gui tree view
 
20
        class IGUITreeViewNode : public IReferenceCounted
 
21
        {
 
22
        public:
 
23
                //! returns the owner (tree view) of this node
 
24
                virtual IGUITreeView* getOwner() const = 0;
 
25
 
 
26
                //! Returns the parent node of this node.
 
27
                /** For the root node this will return 0. */
 
28
                virtual IGUITreeViewNode* getParent() const = 0;
 
29
 
 
30
                //! returns the text of the node
 
31
                virtual const wchar_t* getText() const = 0;
 
32
 
 
33
                //! sets the text of the node
 
34
                virtual void setText( const wchar_t* text ) = 0;
 
35
 
 
36
                //! returns the icon text of the node
 
37
                virtual const wchar_t* getIcon() const = 0;
 
38
 
 
39
                //! sets the icon text of the node
 
40
                virtual void setIcon( const wchar_t* icon ) = 0;
 
41
 
 
42
                //! returns the image index of the node
 
43
                virtual u32 getImageIndex() const = 0;
 
44
 
 
45
                //! sets the image index of the node
 
46
                virtual void setImageIndex( u32 imageIndex ) = 0;
 
47
 
 
48
                //! returns the image index of the node
 
49
                virtual u32 getSelectedImageIndex() const = 0;
 
50
 
 
51
                //! sets the image index of the node
 
52
                virtual void setSelectedImageIndex( u32 imageIndex ) = 0;
 
53
 
 
54
                //! returns the user data (void*) of this node
 
55
                virtual void* getData() const = 0;
 
56
 
 
57
                //! sets the user data (void*) of this node
 
58
                virtual void setData( void* data ) = 0;
 
59
 
 
60
                //! returns the user data2 (IReferenceCounted) of this node
 
61
                virtual IReferenceCounted* getData2() const = 0;
 
62
 
 
63
                //! sets the user data2 (IReferenceCounted) of this node
 
64
                virtual void setData2( IReferenceCounted* data ) = 0;
 
65
 
 
66
                //! returns the child item count
 
67
                virtual u32 getChildCount() const = 0;
 
68
 
 
69
                //! removes all children (recursive) from this node
 
70
                virtual void clearChildren() = 0;
 
71
 
 
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()
 
76
                {
 
77
                        return clearChildren();
 
78
                }
 
79
 
 
80
                //! returns true if this node has child nodes
 
81
                virtual bool hasChildren() const = 0;
 
82
 
 
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
 
87
                {
 
88
                        return hasChildren();
 
89
                }
 
90
 
 
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
 
98
                \return The new node
 
99
                */
 
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;
 
104
 
 
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
 
112
                \return The new node
 
113
                */
 
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;
 
118
 
 
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
 
129
                */
 
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;
 
135
 
 
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
 
146
                */
 
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;
 
152
 
 
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;
 
156
 
 
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;
 
160
 
 
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.
 
164
                */
 
165
                virtual IGUITreeViewNode* getPrevSibling() const = 0;
 
166
 
 
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.
 
170
                */
 
171
                virtual IGUITreeViewNode* getNextSibling() const = 0;
 
172
 
 
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;
 
177
 
 
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;
 
181
 
 
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;
 
185
 
 
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;
 
189
 
 
190
                //! Returns true if the node is expanded (children are visible).
 
191
                virtual bool getExpanded() const = 0;
 
192
 
 
193
                //! Sets if the node is expanded.
 
194
                virtual void setExpanded( bool expanded ) = 0;
 
195
 
 
196
                //! Returns true if the node is currently selected.
 
197
                virtual bool getSelected() const = 0;
 
198
 
 
199
                //! Sets this node as selected.
 
200
                virtual void setSelected( bool selected ) = 0;
 
201
 
 
202
                //! Returns true if this node is the root node.
 
203
                virtual bool isRoot() const = 0;
 
204
 
 
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;
 
208
 
 
209
                //! Returns true if this node is visible (all parents are expanded).
 
210
                virtual bool isVisible() const = 0;
 
211
        };
 
212
 
 
213
 
 
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
 
219
        {
 
220
        public:
 
221
                //! constructor
 
222
                IGUITreeView(IGUIEnvironment* environment, IGUIElement* parent,
 
223
                                s32 id, core::rect<s32> rectangle)
 
224
                        : IGUIElement( EGUIET_TREE_VIEW, environment, parent, id, rectangle ) {}
 
225
 
 
226
                //! returns the root node (not visible) from the tree.
 
227
                virtual IGUITreeViewNode* getRoot() const = 0;
 
228
 
 
229
                //! returns the selected node of the tree or 0 if none is selected
 
230
                virtual IGUITreeViewNode* getSelected() const = 0;
 
231
 
 
232
                //! returns true if the tree lines are visible
 
233
                virtual bool getLinesVisible() const = 0;
 
234
 
 
235
                //! sets if the tree lines are visible
 
236
                /** \param visible true for visible, false for invisible */
 
237
                virtual void setLinesVisible( bool visible ) = 0;
 
238
 
 
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.
 
245
                */
 
246
                virtual void setIconFont( IGUIFont* font ) = 0;
 
247
 
 
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;
 
251
 
 
252
                //! Returns the image list which is used for the nodes.
 
253
                virtual IGUIImageList* getImageList() const = 0;
 
254
 
 
255
                //! Sets if the image is left of the icon. Default is true.
 
256
                virtual void setImageLeftOfIcon( bool bLeftOf ) = 0;
 
257
 
 
258
                //! Returns if the Image is left of the icon. Default is true.
 
259
                virtual bool getImageLeftOfIcon() const = 0;
 
260
 
 
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;
 
264
        };
 
265
 
 
266
 
 
267
} // end namespace gui
 
268
} // end namespace irr
 
269
 
 
270
#endif
 
271