1 // written by Reinhard Ostermeier, reinhard@nospam.r-ostermeier.de
\r
2 // This file is part of the "Irrlicht Engine".
\r
3 // For conditions of distribution and use, see copyright notice in irrlicht.h
\r
5 #ifndef __I_GUI_TREE_VIEW_H_INCLUDED__
\r
6 #define __I_GUI_TREE_VIEW_H_INCLUDED__
\r
8 #include "IGUIElement.h"
\r
9 #include "IGUIImageList.h"
\r
10 #include "irrTypes.h"
\r
18 class IGUIScrollBar;
\r
21 //! Node for gui tree view
\r
22 /** \par This element can create the following events of type EGUI_EVENT_TYPE:
\r
23 \li EGET_TREEVIEW_NODE_EXPAND
\r
24 \li EGET_TREEVIEW_NODE_COLLAPS
\r
25 \li EGET_TREEVIEW_NODE_DESELECT
\r
26 \li EGET_TREEVIEW_NODE_SELECT
\r
28 class IGUITreeViewNode : public IReferenceCounted
\r
31 //! returns the owner (tree view) of this node
\r
32 virtual IGUITreeView* getOwner() const = 0;
\r
34 //! Returns the parent node of this node.
\r
35 /** For the root node this will return 0. */
\r
36 virtual IGUITreeViewNode* getParent() const = 0;
\r
38 //! returns the text of the node
\r
39 virtual const wchar_t* getText() const = 0;
\r
41 //! sets the text of the node
\r
42 virtual void setText( const wchar_t* text ) = 0;
\r
44 //! returns the icon text of the node
\r
45 virtual const wchar_t* getIcon() const = 0;
\r
47 //! sets the icon text of the node
\r
48 virtual void setIcon( const wchar_t* icon ) = 0;
\r
50 //! returns the image index of the node
\r
51 virtual u32 getImageIndex() const = 0;
\r
53 //! sets the image index of the node
\r
54 virtual void setImageIndex( u32 imageIndex ) = 0;
\r
56 //! returns the image index of the node
\r
57 virtual u32 getSelectedImageIndex() const = 0;
\r
59 //! sets the image index of the node
\r
60 virtual void setSelectedImageIndex( u32 imageIndex ) = 0;
\r
62 //! returns the user data (void*) of this node
\r
63 virtual void* getData() const = 0;
\r
65 //! sets the user data (void*) of this node
\r
66 virtual void setData( void* data ) = 0;
\r
68 //! returns the user data2 (IReferenceCounted) of this node
\r
69 virtual IReferenceCounted* getData2() const = 0;
\r
71 //! sets the user data2 (IReferenceCounted) of this node
\r
72 virtual void setData2( IReferenceCounted* data ) = 0;
\r
74 //! returns the child item count
\r
75 virtual u32 getChildCount() const = 0;
\r
77 //! removes all children (recursive) from this node
\r
78 virtual void clearChildren() = 0;
\r
80 //! removes all children (recursive) from this node
\r
81 /** \deprecated Deprecated in 1.8, use clearChildren() instead.
\r
82 This method may be removed by Irrlicht 1.9 */
\r
83 _IRR_DEPRECATED_ void clearChilds()
\r
85 return clearChildren();
\r
88 //! returns true if this node has child nodes
\r
89 virtual bool hasChildren() const = 0;
\r
91 //! returns true if this node has child nodes
\r
92 /** \deprecated Deprecated in 1.8, use hasChildren() instead.
\r
93 This method may be removed by Irrlicht 1.9 */
\r
94 _IRR_DEPRECATED_ bool hasChilds() const
\r
96 return hasChildren();
\r
99 //! Adds a new node behind the last child node.
\r
100 /** \param text text of the new node
\r
101 \param icon icon text of the new node
\r
102 \param imageIndex index of the image for the new node (-1 = none)
\r
103 \param selectedImageIndex index of the selected image for the new node (-1 = same as imageIndex)
\r
104 \param data user data (void*) of the new node
\r
105 \param data2 user data2 (IReferenceCounted*) of the new node
\r
106 \return The new node
\r
108 virtual IGUITreeViewNode* addChildBack(
\r
109 const wchar_t* text, const wchar_t* icon = 0,
\r
110 s32 imageIndex=-1, s32 selectedImageIndex=-1,
\r
111 void* data=0, IReferenceCounted* data2=0) =0;
\r
113 //! Adds a new node before the first child node.
\r
114 /** \param text text of the new node
\r
115 \param icon icon text of the new node
\r
116 \param imageIndex index of the image for the new node (-1 = none)
\r
117 \param selectedImageIndex index of the selected image for the new node (-1 = same as imageIndex)
\r
118 \param data user data (void*) of the new node
\r
119 \param data2 user data2 (IReferenceCounted*) of the new node
\r
120 \return The new node
\r
122 virtual IGUITreeViewNode* addChildFront(
\r
123 const wchar_t* text, const wchar_t* icon = 0,
\r
124 s32 imageIndex=-1, s32 selectedImageIndex=-1,
\r
125 void* data=0, IReferenceCounted* data2=0 ) =0;
\r
127 //! Adds a new node behind the other node.
\r
128 /** The other node has also to be a child node from this node.
\r
129 \param other Node to insert after
\r
130 \param text text of the new node
\r
131 \param icon icon text of the new node
\r
132 \param imageIndex index of the image for the new node (-1 = none)
\r
133 \param selectedImageIndex index of the selected image for the new node (-1 = same as imageIndex)
\r
134 \param data user data (void*) of the new node
\r
135 \param data2 user data2 (IReferenceCounted*) of the new node
\r
136 \return The new node or 0 if other is no child node from this
\r
138 virtual IGUITreeViewNode* insertChildAfter(
\r
139 IGUITreeViewNode* other,
\r
140 const wchar_t* text, const wchar_t* icon = 0,
\r
141 s32 imageIndex=-1, s32 selectedImageIndex=-1,
\r
142 void* data=0, IReferenceCounted* data2=0) =0;
\r
144 //! Adds a new node before the other node.
\r
145 /** The other node has also to be a child node from this node.
\r
146 \param other Node to insert before
\r
147 \param text text of the new node
\r
148 \param icon icon text of the new node
\r
149 \param imageIndex index of the image for the new node (-1 = none)
\r
150 \param selectedImageIndex index of the selected image for the new node (-1 = same as imageIndex)
\r
151 \param data user data (void*) of the new node
\r
152 \param data2 user data2 (IReferenceCounted*) of the new node
\r
153 \return The new node or 0 if other is no child node from this
\r
155 virtual IGUITreeViewNode* insertChildBefore(
\r
156 IGUITreeViewNode* other,
\r
157 const wchar_t* text, const wchar_t* icon = 0,
\r
158 s32 imageIndex=-1, s32 selectedImageIndex=-1,
\r
159 void* data=0, IReferenceCounted* data2=0) = 0;
\r
161 //! Return the first child node from this node.
\r
162 /** \return The first child node or 0 if this node has no children. */
\r
163 virtual IGUITreeViewNode* getFirstChild() const = 0;
\r
165 //! Return the last child node from this node.
\r
166 /** \return The last child node or 0 if this node has no children. */
\r
167 virtual IGUITreeViewNode* getLastChild() const = 0;
\r
169 //! Returns the previous sibling node from this node.
\r
170 /** \return The previous sibling node from this node or 0 if this is
\r
171 the first node from the parent node.
\r
173 virtual IGUITreeViewNode* getPrevSibling() const = 0;
\r
175 //! Returns the next sibling node from this node.
\r
176 /** \return The next sibling node from this node or 0 if this is
\r
177 the last node from the parent node.
\r
179 virtual IGUITreeViewNode* getNextSibling() const = 0;
\r
181 //! Returns the next visible (expanded, may be out of scrolling) node from this node.
\r
182 /** \return The next visible node from this node or 0 if this is
\r
183 the last visible node. */
\r
184 virtual IGUITreeViewNode* getNextVisible() const = 0;
\r
186 //! Deletes a child node.
\r
187 /** \return Returns true if the node was found as a child and is deleted. */
\r
188 virtual bool deleteChild( IGUITreeViewNode* child ) = 0;
\r
190 //! Moves a child node one position up.
\r
191 /** \return True if the node was found as a child node and was not already the first child. */
\r
192 virtual bool moveChildUp( IGUITreeViewNode* child ) = 0;
\r
194 //! Moves a child node one position down.
\r
195 /** \return True if the node was found as a child node and was not already the last child. */
\r
196 virtual bool moveChildDown( IGUITreeViewNode* child ) = 0;
\r
198 //! Returns true if the node is expanded (children are visible).
\r
199 virtual bool getExpanded() const = 0;
\r
201 //! Sets if the node is expanded.
\r
202 virtual void setExpanded( bool expanded ) = 0;
\r
204 //! Returns true if the node is currently selected.
\r
205 virtual bool getSelected() const = 0;
\r
207 //! Sets this node as selected.
\r
208 virtual void setSelected( bool selected ) = 0;
\r
210 //! Returns true if this node is the root node.
\r
211 virtual bool isRoot() const = 0;
\r
213 //! Returns the level of this node.
\r
214 /** The root node has level 0. Direct children of the root has level 1 ... */
\r
215 virtual s32 getLevel() const = 0;
\r
217 //! Returns true if this node is visible (all parents are expanded).
\r
218 virtual bool isVisible() const = 0;
\r
222 //! Default tree view GUI element.
\r
223 /** Displays a windows like tree buttons to expand/collapse the child
\r
224 nodes of an node and optional tree lines. Each node consists of an
\r
225 text, an icon text and a void pointer for user data. */
\r
226 class IGUITreeView : public IGUIElement
\r
230 IGUITreeView(IGUIEnvironment* environment, IGUIElement* parent,
\r
231 s32 id, core::rect<s32> rectangle)
\r
232 : IGUIElement( EGUIET_TREE_VIEW, environment, parent, id, rectangle ) {}
\r
234 //! returns the root node (not visible) from the tree.
\r
235 virtual IGUITreeViewNode* getRoot() const = 0;
\r
237 //! returns the selected node of the tree or 0 if none is selected
\r
238 virtual IGUITreeViewNode* getSelected() const = 0;
\r
240 //! returns true if the tree lines are visible
\r
241 virtual bool getLinesVisible() const = 0;
\r
243 //! sets if the tree lines are visible
\r
244 /** \param visible true for visible, false for invisible */
\r
245 virtual void setLinesVisible( bool visible ) = 0;
\r
247 //! Sets the font which should be used as icon font.
\r
248 /** This font is set to the Irrlicht engine built-in-font by
\r
249 default. Icons can be displayed in front of every list item.
\r
250 An icon is a string, displayed with the icon font. When using
\r
251 the build-in-font of the Irrlicht engine as icon font, the icon
\r
252 strings defined in GUIIcons.h can be used.
\r
254 virtual void setIconFont( IGUIFont* font ) = 0;
\r
256 //! Sets a skin independent font.
\r
257 /** \param font: New font to set or 0 to use the skin-font. */
\r
258 virtual void setOverrideFont(IGUIFont* font=0) = 0;
\r
260 //! Gets the override font (if any)
\r
261 /** \return The override font (may be 0) */
\r
262 virtual IGUIFont* getOverrideFont(void) const = 0;
\r
264 //! Get the font which is used for drawing
\r
265 /** This is the override font when one is set and the
\r
266 font of the skin otherwise. */
\r
267 virtual IGUIFont* getActiveFont() const = 0;
\r
269 //! Sets the image list which should be used for the image and selected image of every node.
\r
270 /** The default is 0 (no images). */
\r
271 virtual void setImageList( IGUIImageList* imageList ) = 0;
\r
273 //! Returns the image list which is used for the nodes.
\r
274 virtual IGUIImageList* getImageList() const = 0;
\r
276 //! Sets if the image is left of the icon. Default is true.
\r
277 virtual void setImageLeftOfIcon( bool bLeftOf ) = 0;
\r
279 //! Returns if the Image is left of the icon. Default is true.
\r
280 virtual bool getImageLeftOfIcon() const = 0;
\r
282 //! Returns the node which is associated to the last event.
\r
283 /** This pointer is only valid inside the OnEvent call! */
\r
284 virtual IGUITreeViewNode* getLastEventNode() const = 0;
\r
286 //! Access the vertical scrollbar
\r
287 virtual IGUIScrollBar* getVerticalScrollBar() const = 0;
\r
289 //! Access the horizontal scrollbar
\r
290 virtual IGUIScrollBar* getHorizontalScrollBar() const = 0;
\r
294 } // end namespace gui
\r
295 } // end namespace irr
\r