1 // Copyright (C) 2002-2012 Nikolaus Gebhardt
2 // This file is part of the "Irrlicht Engine".
3 // For conditions of distribution and use, see copyright notice in irrlicht.h
4 
5 #ifndef __I_GUI_ENVIRONMENT_H_INCLUDED__
6 #define __I_GUI_ENVIRONMENT_H_INCLUDED__
7 
8 #include "IReferenceCounted.h"
9 #include "IGUISkin.h"
10 #include "rect.h"
11 #include "EMessageBoxFlags.h"
12 #include "IEventReceiver.h"
13 #include "IXMLReader.h"
14 #include "path.h"
15 
16 namespace irr
17 {
18 	class IOSOperator;
19 	class IEventReceiver;
20 
21 	namespace io
22 	{
23 		class IXMLWriter;
24 		class IReadFile;
25 		class IWriteFile;
26 		class IFileSystem;
27 	} // end namespace io
28 	namespace video
29 	{
30 		class IVideoDriver;
31 		class ITexture;
32 	} // end namespace video
33 
34 namespace gui
35 {
36 
37 class IGUIElement;
38 class IGUIFont;
39 class IGUISpriteBank;
40 class IGUIScrollBar;
41 class IGUIImage;
42 class IGUIMeshViewer;
43 class IGUICheckBox;
44 class IGUIListBox;
45 class IGUITreeView;
46 class IGUIImageList;
47 class IGUIFileOpenDialog;
48 class IGUIColorSelectDialog;
49 class IGUIInOutFader;
50 class IGUIStaticText;
51 class IGUIEditBox;
52 class IGUISpinBox;
53 class IGUITabControl;
54 class IGUITab;
55 class IGUITable;
56 class IGUIContextMenu;
57 class IGUIComboBox;
58 class IGUIToolBar;
59 class IGUIButton;
60 class IGUIWindow;
61 class IGUIElementFactory;
62 
63 //! GUI Environment. Used as factory and manager of all other GUI elements.
64 /** \par This element can create the following events of type EGUI_EVENT_TYPE (which are passed on to focused sub-elements):
65 \li EGET_ELEMENT_FOCUS_LOST
66 \li EGET_ELEMENT_FOCUSED
67 \li EGET_ELEMENT_LEFT
68 \li EGET_ELEMENT_HOVERED
69 */
70 class IGUIEnvironment : public virtual IReferenceCounted
71 {
72 public:
73 
74 	//! Draws all gui elements by traversing the GUI environment starting at the root node.
75 	virtual void drawAll() = 0;
76 
77 	//! Sets the focus to an element.
78 	/** Causes a EGET_ELEMENT_FOCUS_LOST event followed by a
79 	EGET_ELEMENT_FOCUSED event. If someone absorbed either of the events,
80 	then the focus will not be changed.
81 	\param element Pointer to the element which shall get the focus.
82 	\return True on success, false on failure */
83 	virtual bool setFocus(IGUIElement* element) = 0;
84 
85 	//! Returns the element which holds the focus.
86 	/** \return Pointer to the element with focus. */
87 	virtual IGUIElement* getFocus() const = 0;
88 
89 	//! Returns the element which was last under the mouse cursor
90 	/** NOTE: This information is updated _after_ the user-eventreceiver
91 	received it's mouse-events. To find the hovered element while catching
92 	mouse events you have to use instead:
93 	IGUIEnvironment::getRootGUIElement()->getElementFromPoint(mousePos);
94 	\return Pointer to the element under the mouse. */
95 	virtual IGUIElement* getHovered() const = 0;
96 
97 	//! Removes the focus from an element.
98 	/** Causes a EGET_ELEMENT_FOCUS_LOST event. If the event is absorbed
99 	then the focus will not be changed.
100 	\param element Pointer to the element which shall lose the focus.
101 	\return True on success, false on failure */
102 	virtual bool removeFocus(IGUIElement* element) = 0;
103 
104 	//! Returns whether the element has focus
105 	/** \param element Pointer to the element which is tested.
106 	\return True if the element has focus, else false. */
107 	virtual bool hasFocus(IGUIElement* element) const = 0;
108 
109 	//! Returns the current video driver.
110 	/** \return Pointer to the video driver. */
111 	virtual video::IVideoDriver* getVideoDriver() const = 0;
112 
113 	//! Returns the file system.
114 	/** \return Pointer to the file system. */
115 	virtual io::IFileSystem* getFileSystem() const = 0;
116 
117 	//! returns a pointer to the OS operator
118 	/** \return Pointer to the OS operator. */
119 	virtual IOSOperator* getOSOperator() const = 0;
120 
121 	//! Removes all elements from the environment.
122 	virtual void clear() = 0;
123 
124 	//! Posts an input event to the environment.
125 	/** Usually you do not have to
126 	use this method, it is used by the engine internally.
127 	\param event The event to post.
128 	\return True if succeeded, else false. */
129 	virtual bool postEventFromUser(const SEvent& event) = 0;
130 
131 	//! This sets a new event receiver for gui events.
132 	/** Usually you do not have to
133 	use this method, it is used by the engine internally.
134 	\param evr Pointer to the new receiver. */
135 	virtual void setUserEventReceiver(IEventReceiver* evr) = 0;
136 
137 	//! Returns pointer to the current gui skin.
138 	/** \return Pointer to the GUI skin. */
139 	virtual IGUISkin* getSkin() const = 0;
140 
141 	//! Sets a new GUI Skin
142 	/** You can use this to change the appearance of the whole GUI
143 	Environment. You can set one of the built-in skins or implement your
144 	own class derived from IGUISkin and enable it using this method.
145 	To set for example the built-in Windows classic skin, use the following
146 	code:
147 	\code
148 	gui::IGUISkin* newskin = environment->createSkin(gui::EGST_WINDOWS_CLASSIC);
149 	environment->setSkin(newskin);
150 	newskin->drop();
151 	\endcode
152 	\param skin New skin to use.
153 	*/
154 	virtual void setSkin(IGUISkin* skin) = 0;
155 
156 	//! Creates a new GUI Skin based on a template.
157 	/** Use setSkin() to set the created skin.
158 	\param type The type of the new skin.
159 	\return Pointer to the created skin.
160 	If you no longer need it, you should call IGUISkin::drop().
161 	See IReferenceCounted::drop() for more information. */
162 	virtual IGUISkin* createSkin(EGUI_SKIN_TYPE type) = 0;
163 
164 
165 	//! Creates the image list from the given texture.
166 	/** \param texture Texture to split into images
167 	\param imageSize Dimension of each image
168 	\param useAlphaChannel Flag whether alpha channel of the texture should be honored.
169 	\return Pointer to the font. Returns 0 if the font could not be loaded.
170 	This pointer should not be dropped. See IReferenceCounted::drop() for
171 	more information. */
172 	virtual IGUIImageList* createImageList( video::ITexture* texture,
173 					core::dimension2d<s32> imageSize,
174 					bool useAlphaChannel ) = 0;
175 
176 	//! Returns pointer to the font with the specified filename.
177 	/** Loads the font if it was not loaded before.
178 	\param filename Filename of the Font.
179 	\return Pointer to the font. Returns 0 if the font could not be loaded.
180 	This pointer should not be dropped. See IReferenceCounted::drop() for
181 	more information. */
182 	virtual IGUIFont* getFont(const io::path& filename) = 0;
183 
184 	//! Adds an externally loaded font to the font list.
185 	/** This method allows to attach an already loaded font to the list of
186 	existing fonts. The font is grabbed if non-null and adding was successful.
187 	\param name Name the font should be stored as.
188 	\param font Pointer to font to add.
189 	\return Pointer to the font stored. This can differ from given parameter if the name previously existed. */
190 	virtual IGUIFont* addFont(const io::path& name, IGUIFont* font) = 0;
191 
192 	//! remove loaded font
193 	virtual void removeFont(IGUIFont* font) = 0;
194 
195 	//! Returns the default built-in font.
196 	/** \return Pointer to the default built-in font.
197 	This pointer should not be dropped. See IReferenceCounted::drop() for
198 	more information. */
199 	virtual IGUIFont* getBuiltInFont() const = 0;
200 
201 	//! Returns pointer to the sprite bank with the specified file name.
202 	/** Loads the bank if it was not loaded before.
203 	\param filename Filename of the sprite bank's origin.
204 	\return Pointer to the sprite bank. Returns 0 if it could not be loaded.
205 	This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
206 	virtual IGUISpriteBank* getSpriteBank(const io::path& filename) = 0;
207 
208 	//! Adds an empty sprite bank to the manager
209 	/** \param name Name of the new sprite bank.
210 	\return Pointer to the sprite bank.
211 	This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
212 	virtual IGUISpriteBank* addEmptySpriteBank(const io::path& name) = 0;
213 
214 	//! Returns the root gui element.
215 	/** This is the first gui element, the (direct or indirect) parent of all
216 	other gui elements. It is a valid IGUIElement, with dimensions the same
217 	size as the screen.
218 	\return Pointer to the root element of the GUI. The returned pointer
219 	should not be dropped. See IReferenceCounted::drop() for more
220 	information. */
221 	virtual IGUIElement* getRootGUIElement() = 0;
222 
223 	//! Adds a button element.
224 	/** \param rectangle Rectangle specifying the borders of the button.
225 	\param parent Parent gui element of the button.
226 	\param id Id with which the gui element can be identified.
227 	\param text Text displayed on the button.
228 	\param tooltiptext Text displayed in the tooltip.
229 	\return Pointer to the created button. Returns 0 if an error occurred.
230 	This pointer should not be dropped. See IReferenceCounted::drop() for
231 	more information. */
232 	virtual IGUIButton* addButton(const core::rect<s32>& rectangle,
233 		IGUIElement* parent=0, s32 id=-1, const wchar_t* text=0, const wchar_t* tooltiptext = 0) = 0;
234 
235 	//! Adds an empty window element.
236 	/** \param rectangle Rectangle specifying the borders of the window.
237 	\param modal Defines if the dialog is modal. This means, that all other
238 	gui elements which were created before the window cannot be used until
239 	it is removed.
240 	\param text Text displayed as the window title.
241 	\param parent Parent gui element of the window.
242 	\param id Id with which the gui element can be identified.
243 	\return Pointer to the created window. Returns 0 if an error occurred.
244 	This pointer should not be dropped. See IReferenceCounted::drop() for
245 	more information. */
246 	virtual IGUIWindow* addWindow(const core::rect<s32>& rectangle, bool modal = false,
247 		const wchar_t* text=0, IGUIElement* parent=0, s32 id=-1) = 0;
248 
249 	//! Adds a modal screen.
250 	/** This control stops its parent's members from being able to receive
251 	input until its last child is removed, it then deletes itself.
252 	\param parent Parent gui element of the modal.
253 	\return Pointer to the created modal. Returns 0 if an error occurred.
254 	This pointer should not be dropped. See IReferenceCounted::drop() for
255 	more information. */
256 	virtual IGUIElement* addModalScreen(IGUIElement* parent) = 0;
257 
258 	//! Adds a message box.
259 	/** \param caption Text to be displayed the title of the message box.
260 	\param text Text to be displayed in the body of the message box.
261 	\param modal Defines if the dialog is modal. This means, that all other
262 	gui elements which were created before the message box cannot be used
263 	until this messagebox is removed.
264 	\param flags Flags specifying the layout of the message box. For example
265 	to create a message box with an OK and a CANCEL button on it, set this
266 	to (EMBF_OK | EMBF_CANCEL).
267 	\param parent Parent gui element of the message box.
268 	\param id Id with which the gui element can be identified.
269 	\param image Optional texture which will be displayed beside the text as an image
270 	\return Pointer to the created message box. Returns 0 if an error
271 	occurred. This pointer should not be dropped. See
272 	IReferenceCounted::drop() for more information. */
273 	virtual IGUIWindow* addMessageBox(const wchar_t* caption, const wchar_t* text=0,
274 		bool modal = true, s32 flags = EMBF_OK, IGUIElement* parent=0, s32 id=-1, video::ITexture* image=0) = 0;
275 
276 	//! Adds a scrollbar.
277 	/** \param horizontal Specifies if the scroll bar is drawn horizontal
278 	or vertical.
279 	\param rectangle Rectangle specifying the borders of the scrollbar.
280 	\param parent Parent gui element of the scroll bar.
281 	\param id Id to identify the gui element.
282 	\return Pointer to the created scrollbar. Returns 0 if an error
283 	occurred. This pointer should not be dropped. See
284 	IReferenceCounted::drop() for more information. */
285 	virtual IGUIScrollBar* addScrollBar(bool horizontal, const core::rect<s32>& rectangle,
286 		IGUIElement* parent=0, s32 id=-1) = 0;
287 
288 	//! Adds an image element.
289 	/** \param image Image to be displayed.
290 	\param pos Position of the image. The width and height of the image is
291 	taken from the image.
292 	\param useAlphaChannel Sets if the image should use the alpha channel
293 	of the texture to draw itself.
294 	\param parent Parent gui element of the image.
295 	\param id Id to identify the gui element.
296 	\param text Title text of the image.
297 	\return Pointer to the created image element. Returns 0 if an error
298 	occurred. This pointer should not be dropped. See
299 	IReferenceCounted::drop() for more information. */
300 	virtual IGUIImage* addImage(video::ITexture* image, core::position2d<s32> pos,
301 		bool useAlphaChannel=true, IGUIElement* parent=0, s32 id=-1, const wchar_t* text=0) = 0;
302 
303 	//! Adds an image element.
304 	/** Use IGUIImage::setImage later to set the image to be displayed.
305 	\param rectangle Rectangle specifying the borders of the image.
306 	\param parent Parent gui element of the image.
307 	\param id Id to identify the gui element.
308 	\param text Title text of the image.
309 	\param useAlphaChannel Sets if the image should use the alpha channel
310 	of the texture to draw itself.
311 	\return Pointer to the created image element. Returns 0 if an error
312 	occurred. This pointer should not be dropped. See
313 	IReferenceCounted::drop() for more information. */
314 	virtual IGUIImage* addImage(const core::rect<s32>& rectangle,
315 		IGUIElement* parent=0, s32 id=-1, const wchar_t* text=0, bool useAlphaChannel=true) = 0;
316 
317 	//! Adds a checkbox element.
318 	/** \param checked Define the initial state of the check box.
319 	\param rectangle Rectangle specifying the borders of the check box.
320 	\param parent Parent gui element of the check box.
321 	\param id Id to identify the gui element.
322 	\param text Title text of the check box.
323 	\return Pointer to the created check box. Returns 0 if an error
324 	occurred. This pointer should not be dropped. See
325 	IReferenceCounted::drop() for more information. */
326 	virtual IGUICheckBox* addCheckBox(bool checked, const core::rect<s32>& rectangle,
327 		IGUIElement* parent=0, s32 id=-1, const wchar_t* text=0) = 0;
328 
329 	//! Adds a list box element.
330 	/** \param rectangle Rectangle specifying the borders of the list box.
331 	\param parent Parent gui element of the list box.
332 	\param id Id to identify the gui element.
333 	\param drawBackground Flag whether the background should be drawn.
334 	\return Pointer to the created list box. Returns 0 if an error occurred.
335 	This pointer should not be dropped. See IReferenceCounted::drop() for
336 	more information. */
337 	virtual IGUIListBox* addListBox(const core::rect<s32>& rectangle,
338 		IGUIElement* parent=0, s32 id=-1, bool drawBackground=false) = 0;
339 
340 	//! Adds a tree view element.
341 	/** \param rectangle Position and dimension of list box.
342 	\param parent Parent gui element of the list box.
343 	\param id Id to identify the gui element.
344 	\param drawBackground Flag whether the background should be drawn.
345 	\param scrollBarVertical Flag whether a vertical scrollbar should be used
346 	\param scrollBarHorizontal Flag whether a horizontal scrollbar should be used
347 	\return Pointer to the created list box. Returns 0 if an error occurred.
348 	This pointer should not be dropped. See IReferenceCounted::drop() for
349 	more information. */
350 	virtual IGUITreeView* addTreeView(const core::rect<s32>& rectangle,
351 		IGUIElement* parent=0, s32 id=-1, bool drawBackground=false,
352 		bool scrollBarVertical = true, bool scrollBarHorizontal = false) = 0;
353 
354 	//! Adds a mesh viewer. Not 100% implemented yet.
355 	/** \param rectangle Rectangle specifying the borders of the mesh viewer.
356 	\param parent Parent gui element of the mesh viewer.
357 	\param id Id to identify the gui element.
358 	\param text Title text of the mesh viewer.
359 	\return Pointer to the created mesh viewer. Returns 0 if an error
360 	occurred. This pointer should not be dropped. See
361 	IReferenceCounted::drop() for more information. */
362 	virtual IGUIMeshViewer* addMeshViewer(const core::rect<s32>& rectangle,
363 			IGUIElement* parent=0, s32 id=-1, const wchar_t* text=0) = 0;
364 
365 	//! Adds a file open dialog.
366 	/** \param title Text to be displayed as the title of the dialog.
367 	\param modal Defines if the dialog is modal. This means, that all other
368 	gui elements which were created before the message box cannot be used
369 	until this messagebox is removed.
370 	\param parent Parent gui element of the dialog.
371 	\param id Id to identify the gui element.
372 	\param restoreCWD If set to true, the current workingn directory will be
373 	restored after the dialog is closed in some way. Otherwise the working
374 	directory will be the one that the file dialog was last showing.
375 	\param startDir Optional path for which the file dialog will be opened.
376 	\return Pointer to the created file open dialog. Returns 0 if an error
377 	occurred. This pointer should not be dropped. See
378 	IReferenceCounted::drop() for more information. */
379 	virtual IGUIFileOpenDialog* addFileOpenDialog(const wchar_t* title=0,
380 		bool modal=true, IGUIElement* parent=0, s32 id=-1,
381 		bool restoreCWD=false, io::path::char_type* startDir=0) = 0;
382 
383 	//! Adds a color select dialog.
384 	/** \param title The title of the dialog.
385 	\param modal Defines if the dialog is modal. This means, that all other
386 	gui elements which were created before the dialog cannot be used
387 	until it is removed.
388 	\param parent The parent of the dialog.
389 	\param id The ID of the dialog.
390 	\return Pointer to the created file open dialog. Returns 0 if an error
391 	occurred. This pointer should not be dropped. See
392 	IReferenceCounted::drop() for more information. */
393 	virtual IGUIColorSelectDialog* addColorSelectDialog(const wchar_t* title = 0,
394 		bool modal=true, IGUIElement* parent=0, s32 id=-1) = 0;
395 
396 	//! Adds a static text.
397 	/** \param text Text to be displayed. Can be altered after creation by SetText().
398 	\param rectangle Rectangle specifying the borders of the static text
399 	\param border Set to true if the static text should have a 3d border.
400 	\param wordWrap Enable if the text should wrap into multiple lines.
401 	\param parent Parent item of the element, e.g. a window.
402 	\param id The ID of the element.
403 	\param fillBackground Enable if the background shall be filled.
404 	Defaults to false.
405 	\return Pointer to the created static text. Returns 0 if an error
406 	occurred. This pointer should not be dropped. See
407 	IReferenceCounted::drop() for more information. */
408 	virtual IGUIStaticText* addStaticText(const wchar_t* text, const core::rect<s32>& rectangle,
409 		bool border=false, bool wordWrap=true, IGUIElement* parent=0, s32 id=-1,
410 		bool fillBackground = false) = 0;
411 
412 	//! Adds an edit box.
413 	/** Supports unicode input from every keyboard around the world,
414 	scrolling, copying and pasting (exchanging data with the clipboard
415 	directly), maximum character amount, marking, and all shortcuts like
416 	ctrl+X, ctrl+V, ctrl+C, shift+Left, shift+Right, Home, End, and so on.
417 	\param text Text to be displayed. Can be altered after creation
418 	by setText().
419 	\param rectangle Rectangle specifying the borders of the edit box.
420 	\param border Set to true if the edit box should have a 3d border.
421 	\param parent Parent item of the element, e.g. a window.
422 	Set it to 0 to place the edit box directly in the environment.
423 	\param id The ID of the element.
424 	\return Pointer to the created edit box. Returns 0 if an error occurred.
425 	This pointer should not be dropped. See IReferenceCounted::drop() for
426 	more information. */
427 	virtual IGUIEditBox* addEditBox(const wchar_t* text, const core::rect<s32>& rectangle,
428 		bool border=true, IGUIElement* parent=0, s32 id=-1) = 0;
429 
430 	//! Adds a spin box.
431 	/** An edit box with up and down buttons
432 	\param text Text to be displayed. Can be altered after creation by setText().
433 	\param rectangle Rectangle specifying the borders of the spin box.
434 	\param border Set to true if the spin box should have a 3d border.
435 	\param parent Parent item of the element, e.g. a window.
436 	Set it to 0 to place the spin box directly in the environment.
437 	\param id The ID of the element.
438 	\return Pointer to the created spin box. Returns 0 if an error occurred.
439 	This pointer should not be dropped. See IReferenceCounted::drop() for
440 	more information. */
441 	virtual IGUISpinBox* addSpinBox(const wchar_t* text, const core::rect<s32>& rectangle,
442 		bool border=true,IGUIElement* parent=0, s32 id=-1) = 0;
443 
444 	//! Adds an element for fading in or out.
445 	/** \param rectangle Rectangle specifying the borders of the fader.
446 	If the pointer is NULL, the whole screen is used.
447 	\param parent Parent item of the element, e.g. a window.
448 	\param id An identifier for the fader.
449 	\return Pointer to the created in-out-fader. Returns 0 if an error
450 	occurred. This pointer should not be dropped. See
451 	IReferenceCounted::drop() for more information. */
452 	virtual IGUIInOutFader* addInOutFader(const core::rect<s32>* rectangle=0, IGUIElement* parent=0, s32 id=-1) = 0;
453 
454 	//! Adds a tab control to the environment.
455 	/** \param rectangle Rectangle specifying the borders of the tab control.
456 	\param parent Parent item of the element, e.g. a window.
457 	Set it to 0 to place the tab control directly in the environment.
458 	\param fillbackground Specifies if the background of the tab control
459 	should be drawn.
460 	\param border Specifies if a flat 3d border should be drawn. This is
461 	usually not necessary unless you place the control directly into
462 	the environment without a window as parent.
463 	\param id An identifier for the tab control.
464 	\return Pointer to the created tab control element. Returns 0 if an
465 	error occurred. This pointer should not be dropped. See
466 	IReferenceCounted::drop() for more information. */
467 	virtual IGUITabControl* addTabControl(const core::rect<s32>& rectangle,
468 		IGUIElement* parent=0, bool fillbackground=false,
469 		bool border=true, s32 id=-1) = 0;
470 
471 	//! Adds tab to the environment.
472 	/** You can use this element to group other elements. This is not used
473 	for creating tabs on tab controls, please use IGUITabControl::addTab()
474 	for this instead.
475 	\param rectangle Rectangle specifying the borders of the tab.
476 	\param parent Parent item of the element, e.g. a window.
477 	Set it to 0 to place the tab directly in the environment.
478 	\param id An identifier for the tab.
479 	\return Pointer to the created tab. Returns 0 if an
480 	error occurred. This pointer should not be dropped. See
481 	IReferenceCounted::drop() for more information. */
482 	virtual IGUITab* addTab(const core::rect<s32>& rectangle,
483 		IGUIElement* parent=0, s32 id=-1) = 0;
484 
485 	//! Adds a context menu to the environment.
486 	/** \param rectangle Rectangle specifying the borders of the menu.
487 	Note that the menu is resizing itself based on what items you add.
488 	\param parent Parent item of the element, e.g. a window.
489 	Set it to 0 to place the menu directly in the environment.
490 	\param id An identifier for the menu.
491 	\return Pointer to the created context menu. Returns 0 if an
492 	error occurred. This pointer should not be dropped. See
493 	IReferenceCounted::drop() for more information. */
494 	virtual IGUIContextMenu* addContextMenu(const core::rect<s32>& rectangle,
495 		IGUIElement* parent=0, s32 id=-1) = 0;
496 
497 	//! Adds a menu to the environment.
498 	/** This is like the menu you can find on top of most windows in modern
499 	graphical user interfaces.
500 	\param parent Parent item of the element, e.g. a window.
501 	Set it to 0 to place the menu directly in the environment.
502 	\param id An identifier for the menu.
503 	\return Pointer to the created menu. Returns 0 if an
504 	error occurred. This pointer should not be dropped. See
505 	IReferenceCounted::drop() for more information. */
506 	virtual IGUIContextMenu* addMenu(IGUIElement* parent=0, s32 id=-1) = 0;
507 
508 	//! Adds a toolbar to the environment.
509 	/** It is like a menu that is always placed on top of its parent, and
510 	contains buttons.
511 	\param parent Parent item of the element, e.g. a window.
512 	Set it to 0 to place the tool bar directly in the environment.
513 	\param id An identifier for the tool bar.
514 	\return Pointer to the created tool bar. Returns 0 if an
515 	error occurred. This pointer should not be dropped. See
516 	IReferenceCounted::drop() for more information. */
517 	virtual IGUIToolBar* addToolBar(IGUIElement* parent=0, s32 id=-1) = 0;
518 
519 	//! Adds a combo box to the environment.
520 	/** \param rectangle Rectangle specifying the borders of the combo box.
521 	\param parent Parent item of the element, e.g. a window.
522 	Set it to 0 to place the combo box directly in the environment.
523 	\param id An identifier for the combo box.
524 	\return Pointer to the created combo box. Returns 0 if an
525 	error occurred. This pointer should not be dropped. See
526 	IReferenceCounted::drop() for more information. */
527 	virtual IGUIComboBox* addComboBox(const core::rect<s32>& rectangle,
528 		IGUIElement* parent=0, s32 id=-1) = 0;
529 
530 	//! Adds a table to the environment
531 	/** \param rectangle Rectangle specifying the borders of the table.
532 	\param parent Parent item of the element, e.g. a window. Set it to 0
533 	to place the element directly in the environment.
534 	\param id An identifier for the table.
535 	\param drawBackground Flag whether the background should be drawn.
536 	\return Pointer to the created table. Returns 0 if an error occurred.
537 	This pointer should not be dropped. See IReferenceCounted::drop() for
538 	more information. */
539 	virtual IGUITable* addTable(const core::rect<s32>& rectangle,
540 		IGUIElement* parent=0, s32 id=-1, bool drawBackground=false) =0;
541 
542 	//! Get the default element factory which can create all built-in elements
543 	/** \return Pointer to the factory.
544 	This pointer should not be dropped. See IReferenceCounted::drop() for
545 	more information. */
546 	virtual IGUIElementFactory* getDefaultGUIElementFactory() const = 0;
547 
548 	//! Adds an element factory to the gui environment.
549 	/** Use this to extend the gui environment with new element types which
550 	it should be able to create automatically, for example when loading
551 	data from xml files.
552 	\param factoryToAdd Pointer to new factory. */
553 	virtual void registerGUIElementFactory(IGUIElementFactory* factoryToAdd) = 0;
554 
555 	//! Get amount of registered gui element factories.
556 	/** \return Amount of registered gui element factories. */
557 	virtual u32 getRegisteredGUIElementFactoryCount() const = 0;
558 
559 	//! Get a gui element factory by index
560 	/** \param index Index of the factory.
561 	\return Factory at given index, or 0 if no such factory exists. */
562 	virtual IGUIElementFactory* getGUIElementFactory(u32 index) const = 0;
563 
564 	//! Adds a GUI element by its name
565 	/** Each factory is checked if it can create an element of the given
566 	name. The first match will be created.
567 	\param elementName Name of the element to be created.
568 	\param parent Parent of the new element, if not 0.
569 	\return New GUI element, or 0 if no such element exists. */
570 	virtual IGUIElement* addGUIElement(const c8* elementName, IGUIElement* parent=0) = 0;
571 
572 	//! Saves the current gui into a file.
573 	/** \param filename Name of the file.
574 	\param start The GUIElement to start with. Root if 0.
575 	\return True if saving succeeded, else false. */
576 	virtual bool saveGUI(const io::path& filename, IGUIElement* start=0) = 0;
577 
578 	//! Saves the current gui into a file.
579 	/** \param file The file to write to.
580 	\param start The GUIElement to start with. Root if 0.
581 	\return True if saving succeeded, else false. */
582 	virtual bool saveGUI(io::IWriteFile* file, IGUIElement* start=0) = 0;
583 
584 	//! Loads the gui. Note that the current gui is not cleared before.
585 	/** When a parent is set the elements will be added below the parent, the parent itself does not deserialize.
586 	When the file contains skin-settings from the gui-environment those are always serialized into the
587 	guienvironment independent	of the parent setting.
588 	\param filename Name of the file.
589 	\param parent Parent for the loaded GUI, root if 0.
590 	\return True if loading succeeded, else false. */
591 	virtual bool loadGUI(const io::path& filename, IGUIElement* parent=0) = 0;
592 
593 	//! Loads the gui. Note that the current gui is not cleared before.
594 	/** When a parent is set the elements will be added below the parent, the parent itself does not deserialize.
595 	When the file contains skin-settings from the gui-environment those are always serialized into the
596 	guienvironment independent	of the parent setting.
597 	\param file The file to load from.
598 	\param parent Parent for the loaded GUI, root if 0.
599 	\return True if loading succeeded, else false. */
600 	virtual bool loadGUI(io::IReadFile* file, IGUIElement* parent=0) = 0;
601 
602 	//! Writes attributes of the gui environment
603 	virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0) const =0;
604 
605 	//! Reads attributes of the gui environment
606 	virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0)=0;
607 
608 	//! writes an element
609 	virtual void writeGUIElement(io::IXMLWriter* writer, IGUIElement* node) =0;
610 
611 	//! reads an element
612 	virtual void readGUIElement(io::IXMLReader* reader, IGUIElement* node) =0;
613 };
614 
615 
616 } // end namespace gui
617 } // end namespace irr
618 
619 #endif
620 
621