1 // Copyright (C) 2002-2012 Nikolaus Gebhardt
\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_ENVIRONMENT_H_INCLUDED__
\r
6 #define __I_GUI_ENVIRONMENT_H_INCLUDED__
\r
8 #include "IReferenceCounted.h"
\r
9 #include "IGUISkin.h"
\r
11 #include "EMessageBoxFlags.h"
\r
12 #include "EFocusFlags.h"
\r
13 #include "IEventReceiver.h"
\r
19 class IEventReceiver;
\r
26 } // end namespace io
\r
31 } // end namespace video
\r
38 class IGUISpriteBank;
\r
39 class IGUIScrollBar;
\r
41 class IGUIMeshViewer;
\r
45 class IGUIImageList;
\r
46 class IGUIFileOpenDialog;
\r
47 class IGUIColorSelectDialog;
\r
48 class IGUIInOutFader;
\r
49 class IGUIStaticText;
\r
52 class IGUITabControl;
\r
55 class IGUIContextMenu;
\r
61 class IGUIElementFactory;
\r
63 //! GUI Environment. Used as factory and manager of all other GUI elements.
\r
64 /** \par This element can create the following events of type EGUI_EVENT_TYPE (which are passed on to focused sub-elements):
\r
65 \li EGET_ELEMENT_FOCUS_LOST
\r
66 \li EGET_ELEMENT_FOCUSED
\r
67 \li EGET_ELEMENT_LEFT
\r
68 \li EGET_ELEMENT_HOVERED
\r
70 class IGUIEnvironment : public virtual IReferenceCounted
\r
74 //! Draws all gui elements by traversing the GUI environment starting at the root node.
\r
75 /** \param When true ensure the GuiEnvironment (aka the RootGUIElement) has the same size as the current driver screensize.
\r
76 Can be set to false to control that size yourself, p.E when not the full size should be used for UI. */
\r
77 virtual void drawAll(bool useScreenSize=true) = 0;
\r
79 //! Sets the focus to an element.
\r
80 /** Causes a EGET_ELEMENT_FOCUS_LOST event followed by a
\r
81 EGET_ELEMENT_FOCUSED event. If someone absorbed either of the events,
\r
82 then the focus will not be changed.
\r
83 \param element Pointer to the element which shall get the focus.
\r
84 \return True on success, false on failure */
\r
85 virtual bool setFocus(IGUIElement* element) = 0;
\r
87 //! Returns the element which holds the focus.
\r
88 /** \return Pointer to the element with focus. */
\r
89 virtual IGUIElement* getFocus() const = 0;
\r
91 //! Returns the element which was last under the mouse cursor
\r
92 /** NOTE: This information is updated _after_ the user-eventreceiver
\r
93 received it's mouse-events. To find the hovered element while catching
\r
94 mouse events you have to use instead:
\r
95 IGUIEnvironment::getRootGUIElement()->getElementFromPoint(mousePos);
\r
96 \return Pointer to the element under the mouse. */
\r
97 virtual IGUIElement* getHovered() const = 0;
\r
99 //! Removes the focus from an element.
\r
100 /** Causes a EGET_ELEMENT_FOCUS_LOST event. If the event is absorbed
\r
101 then the focus will not be changed.
\r
102 \param element Pointer to the element which shall lose the focus.
\r
103 \return True on success, false on failure */
\r
104 virtual bool removeFocus(IGUIElement* element) = 0;
\r
106 //! Returns whether the element has focus
\r
107 /** \param element Pointer to the element which is tested.
\r
108 \param checkSubElements When true and focus is on a sub-element of element then it will still count as focused and return true
\r
109 \return True if the element has focus, else false. */
\r
110 virtual bool hasFocus(const IGUIElement* element, bool checkSubElements=false) const = 0;
\r
112 //! Returns the current video driver.
\r
113 /** \return Pointer to the video driver. */
\r
114 virtual video::IVideoDriver* getVideoDriver() const = 0;
\r
116 //! Returns the file system.
\r
117 /** \return Pointer to the file system. */
\r
118 virtual io::IFileSystem* getFileSystem() const = 0;
\r
120 //! returns a pointer to the OS operator
\r
121 /** \return Pointer to the OS operator. */
\r
122 virtual IOSOperator* getOSOperator() const = 0;
\r
124 //! Removes all elements from the environment.
\r
125 virtual void clear() = 0;
\r
127 //! Posts an input event to the environment.
\r
128 /** Usually you do not have to
\r
129 use this method, it is used by the engine internally.
\r
130 \param event The event to post.
\r
131 \return True if succeeded, else false. */
\r
132 virtual bool postEventFromUser(const SEvent& event) = 0;
\r
134 //! This sets a new event receiver for gui events.
\r
135 /** Usually you do not have to
\r
136 use this method, it is used by the engine internally.
\r
137 \param evr Pointer to the new receiver. */
\r
138 virtual void setUserEventReceiver(IEventReceiver* evr) = 0;
\r
140 //! Returns pointer to the current gui skin.
\r
141 /** \return Pointer to the GUI skin. */
\r
142 virtual IGUISkin* getSkin() const = 0;
\r
144 //! Sets a new GUI Skin
\r
145 /** You can use this to change the appearance of the whole GUI
\r
146 Environment. You can set one of the built-in skins or implement your
\r
147 own class derived from IGUISkin and enable it using this method.
\r
148 To set for example the built-in Windows classic skin, use the following
\r
151 gui::IGUISkin* newskin = environment->createSkin(gui::EGST_WINDOWS_CLASSIC);
\r
152 environment->setSkin(newskin);
\r
155 \param skin New skin to use.
\r
157 virtual void setSkin(IGUISkin* skin) = 0;
\r
159 //! Creates a new GUI Skin based on a template.
\r
160 /** Use setSkin() to set the created skin.
\r
161 \param type The type of the new skin.
\r
162 \return Pointer to the created skin.
\r
163 If you no longer need it, you should call IGUISkin::drop().
\r
164 See IReferenceCounted::drop() for more information. */
\r
165 virtual IGUISkin* createSkin(EGUI_SKIN_TYPE type) = 0;
\r
168 //! Creates the image list from the given texture.
\r
169 /** \param texture Texture to split into images
\r
170 \param imageSize Dimension of each image
\r
171 \param useAlphaChannel Flag whether alpha channel of the texture should be honored.
\r
172 \return Pointer to the font. Returns 0 if the font could not be loaded.
\r
173 This pointer should not be dropped. See IReferenceCounted::drop() for
\r
174 more information. */
\r
175 virtual IGUIImageList* createImageList( video::ITexture* texture,
\r
176 core::dimension2d<s32> imageSize,
\r
177 bool useAlphaChannel ) = 0;
\r
179 //! Returns pointer to the font with the specified filename.
\r
180 /** Loads the font if it was not loaded before.
\r
181 \param filename Filename of the Font.
\r
182 \return Pointer to the font. Returns 0 if the font could not be loaded.
\r
183 This pointer should not be dropped. See IReferenceCounted::drop() for
\r
184 more information. */
\r
185 virtual IGUIFont* getFont(const io::path& filename) = 0;
\r
187 //! Adds an externally loaded font to the font list.
\r
188 /** This method allows to attach an already loaded font to the list of
\r
189 existing fonts. The font is grabbed if non-null and adding was successful.
\r
190 \param name Name the font should be stored as.
\r
191 \param font Pointer to font to add.
\r
192 \return Pointer to the font stored. This can differ from given parameter if the name previously existed. */
\r
193 virtual IGUIFont* addFont(const io::path& name, IGUIFont* font) = 0;
\r
195 //! remove loaded font
\r
196 virtual void removeFont(IGUIFont* font) = 0;
\r
198 //! Returns the default built-in font.
\r
199 /** \return Pointer to the default built-in font.
\r
200 This pointer should not be dropped. See IReferenceCounted::drop() for
\r
201 more information. */
\r
202 virtual IGUIFont* getBuiltInFont() const = 0;
\r
204 //! Returns pointer to the sprite bank which was added with addEmptySpriteBank
\r
205 /** TODO: This should load files in the future, but not implemented so far.
\r
206 \param filename Name of a spritebank added with addEmptySpriteBank
\r
207 \return Pointer to the sprite bank. Returns 0 if it could not be loaded.
\r
208 This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
\r
209 virtual IGUISpriteBank* getSpriteBank(const io::path& filename) = 0;
\r
211 //! Adds an empty sprite bank to the manager
\r
212 /** \param name Name of the new sprite bank.
\r
213 \return Pointer to the sprite bank.
\r
214 This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
\r
215 virtual IGUISpriteBank* addEmptySpriteBank(const io::path& name) = 0;
\r
217 //! Returns the root gui element.
\r
218 /** This is the first gui element, the (direct or indirect) parent of all
\r
219 other gui elements. It is a valid IGUIElement, with dimensions the same
\r
220 size as the screen.
\r
221 \return Pointer to the root element of the GUI. The returned pointer
\r
222 should not be dropped. See IReferenceCounted::drop() for more
\r
224 virtual IGUIElement* getRootGUIElement() = 0;
\r
226 //! Adds a button element.
\r
227 /** \param rectangle Rectangle specifying the borders of the button.
\r
228 \param parent Parent gui element of the button.
\r
229 \param id Id with which the gui element can be identified.
\r
230 \param text Text displayed on the button.
\r
231 \param tooltiptext Text displayed in the tooltip.
\r
232 \return Pointer to the created button. Returns 0 if an error occurred.
\r
233 This pointer should not be dropped. See IReferenceCounted::drop() for
\r
234 more information. */
\r
235 virtual IGUIButton* addButton(const core::rect<s32>& rectangle,
\r
236 IGUIElement* parent=0, s32 id=-1, const wchar_t* text=0, const wchar_t* tooltiptext = 0) = 0;
\r
238 //! Adds an empty window element.
\r
239 /** \param rectangle Rectangle specifying the borders of the window.
\r
240 \param modal Defines if the dialog is modal. This means, that all other
\r
241 gui elements which were created before the window cannot be used until
\r
243 \param text Text displayed as the window title.
\r
244 \param parent Parent gui element of the window.
\r
245 \param id Id with which the gui element can be identified.
\r
246 \return Pointer to the created window. Returns 0 if an error occurred.
\r
247 This pointer should not be dropped. See IReferenceCounted::drop() for
\r
248 more information. */
\r
249 virtual IGUIWindow* addWindow(const core::rect<s32>& rectangle, bool modal = false,
\r
250 const wchar_t* text=0, IGUIElement* parent=0, s32 id=-1) = 0;
\r
252 //! Adds a modal screen.
\r
253 /** Input focus stays with children of the modal screen.
\r
254 If you have some window x which should keep the input focus you
\r
255 do something like: addModalScreen()->addChild(x). And x will then get the focus
\r
256 and not lose it anymore.
\r
257 The modal screen removes itself when it no longer has any children.
\r
258 Note that it usually works badly to pass the modal screen already as parent when creating
\r
259 a new element. It's better to add that new element later to the modal screen with addChild.
\r
260 \param parent Parent gui element of the modal.
\r
261 \param blinkMode Bitset of when to blink (can be combined)
\r
264 2 = Left mouse button pressed down
\r
265 \return Pointer to the created modal. Returns 0 if an error occurred.
\r
266 This pointer should not be dropped. See IReferenceCounted::drop() for
\r
267 more information. */
\r
268 virtual IGUIElement* addModalScreen(IGUIElement* parent, int blinkMode = 3) = 0;
\r
270 //! Adds a message box.
\r
271 /** \param caption Text to be displayed the title of the message box.
\r
272 \param text Text to be displayed in the body of the message box.
\r
273 \param modal Defines if the dialog is modal. This means, that all other
\r
274 gui elements which were created before the message box cannot be used
\r
275 until this messagebox is removed.
\r
276 \param flags Flags specifying the layout of the message box using ::EMESSAGE_BOX_FLAG.
\r
277 Create a message box with an OK and CANCEL button for example with (EMBF_OK | EMBF_CANCEL).
\r
278 \param parent Parent gui element of the message box.
\r
279 \param id Id with which the gui element can be identified.
\r
280 \param image Optional texture which will be displayed beside the text as an image
\r
281 \return Pointer to the created message box. Returns 0 if an error
\r
282 occurred. This pointer should not be dropped. See
\r
283 IReferenceCounted::drop() for more information. */
\r
284 virtual IGUIWindow* addMessageBox(const wchar_t* caption, const wchar_t* text=0,
\r
285 bool modal = true, s32 flags = EMBF_OK, IGUIElement* parent=0, s32 id=-1, video::ITexture* image=0) = 0;
\r
287 //! Adds a scrollbar.
\r
288 /** \param horizontal Specifies if the scroll bar is drawn horizontal
\r
290 \param rectangle Rectangle specifying the borders of the scrollbar.
\r
291 \param parent Parent gui element of the scroll bar.
\r
292 \param id Id to identify the gui element.
\r
293 \return Pointer to the created scrollbar. Returns 0 if an error
\r
294 occurred. This pointer should not be dropped. See
\r
295 IReferenceCounted::drop() for more information. */
\r
296 virtual IGUIScrollBar* addScrollBar(bool horizontal, const core::rect<s32>& rectangle,
\r
297 IGUIElement* parent=0, s32 id=-1) = 0;
\r
299 //! Adds an image element.
\r
300 /** \param image Image to be displayed.
\r
301 \param pos Position of the image. The width and height of the image is
\r
302 taken from the image.
\r
303 \param useAlphaChannel Sets if the image should use the alpha channel
\r
304 of the texture to draw itself.
\r
305 \param parent Parent gui element of the image.
\r
306 \param id Id to identify the gui element.
\r
307 \param text Title text of the image (not displayed).
\r
308 \return Pointer to the created image element. Returns 0 if an error
\r
309 occurred. This pointer should not be dropped. See
\r
310 IReferenceCounted::drop() for more information. */
\r
311 virtual IGUIImage* addImage(video::ITexture* image, core::position2d<s32> pos,
\r
312 bool useAlphaChannel=true, IGUIElement* parent=0, s32 id=-1, const wchar_t* text=0) = 0;
\r
314 //! Adds an image element.
\r
315 /** Use IGUIImage::setImage later to set the image to be displayed.
\r
316 \param rectangle Rectangle specifying the borders of the image.
\r
317 \param parent Parent gui element of the image.
\r
318 \param id Id to identify the gui element.
\r
319 \param text Title text of the image (not displayed).
\r
320 \param useAlphaChannel Sets if the image should use the alpha channel
\r
321 of the texture to draw itself.
\r
322 \return Pointer to the created image element. Returns 0 if an error
\r
323 occurred. This pointer should not be dropped. See
\r
324 IReferenceCounted::drop() for more information. */
\r
325 virtual IGUIImage* addImage(const core::rect<s32>& rectangle,
\r
326 IGUIElement* parent=0, s32 id=-1, const wchar_t* text=0, bool useAlphaChannel=true) = 0;
\r
328 //! Adds a checkbox element.
\r
329 /** \param checked Define the initial state of the check box.
\r
330 \param rectangle Rectangle specifying the borders of the check box.
\r
331 \param parent Parent gui element of the check box.
\r
332 \param id Id to identify the gui element.
\r
333 \param text Title text of the check box.
\r
334 \return Pointer to the created check box. Returns 0 if an error
\r
335 occurred. This pointer should not be dropped. See
\r
336 IReferenceCounted::drop() for more information. */
\r
337 virtual IGUICheckBox* addCheckBox(bool checked, const core::rect<s32>& rectangle,
\r
338 IGUIElement* parent=0, s32 id=-1, const wchar_t* text=0) = 0;
\r
340 //! Adds a list box element.
\r
341 /** \param rectangle Rectangle specifying the borders of the list box.
\r
342 \param parent Parent gui element of the list box.
\r
343 \param id Id to identify the gui element.
\r
344 \param drawBackground Flag whether the background should be drawn.
\r
345 \return Pointer to the created list box. Returns 0 if an error occurred.
\r
346 This pointer should not be dropped. See IReferenceCounted::drop() for
\r
347 more information. */
\r
348 virtual IGUIListBox* addListBox(const core::rect<s32>& rectangle,
\r
349 IGUIElement* parent=0, s32 id=-1, bool drawBackground=false) = 0;
\r
351 //! Adds a tree view element.
\r
352 /** \param rectangle Position and dimension of list box.
\r
353 \param parent Parent gui element of the list box.
\r
354 \param id Id to identify the gui element.
\r
355 \param drawBackground Flag whether the background should be drawn.
\r
356 \param scrollBarVertical Flag whether a vertical scrollbar should be used
\r
357 \param scrollBarHorizontal Flag whether a horizontal scrollbar should be used
\r
358 \return Pointer to the created list box. Returns 0 if an error occurred.
\r
359 This pointer should not be dropped. See IReferenceCounted::drop() for
\r
360 more information. */
\r
361 virtual IGUITreeView* addTreeView(const core::rect<s32>& rectangle,
\r
362 IGUIElement* parent=0, s32 id=-1, bool drawBackground=false,
\r
363 bool scrollBarVertical = true, bool scrollBarHorizontal = false) = 0;
\r
365 //! Adds a mesh viewer. Not 100% implemented yet.
\r
366 /** \param rectangle Rectangle specifying the borders of the mesh viewer.
\r
367 \param parent Parent gui element of the mesh viewer.
\r
368 \param id Id to identify the gui element.
\r
369 \param text Title text of the mesh viewer.
\r
370 \return Pointer to the created mesh viewer. Returns 0 if an error
\r
371 occurred. This pointer should not be dropped. See
\r
372 IReferenceCounted::drop() for more information. */
\r
373 virtual IGUIMeshViewer* addMeshViewer(const core::rect<s32>& rectangle,
\r
374 IGUIElement* parent=0, s32 id=-1, const wchar_t* text=0) = 0;
\r
376 //! Adds a file open dialog.
\r
377 /** \param title Text to be displayed as the title of the dialog.
\r
378 \param modal Defines if the dialog is modal. This means, that all other
\r
379 gui elements which were created before the message box cannot be used
\r
380 until this messagebox is removed.
\r
381 \param parent Parent gui element of the dialog.
\r
382 \param id Id to identify the gui element.
\r
383 \param restoreCWD If set to true, the current working directory will be
\r
384 restored after the dialog is closed in some way. Otherwise the working
\r
385 directory will be the one that the file dialog was last showing.
\r
386 \param startDir Optional path for which the file dialog will be opened.
\r
387 \return Pointer to the created file open dialog. Returns 0 if an error
\r
388 occurred. This pointer should not be dropped. See
\r
389 IReferenceCounted::drop() for more information. */
\r
390 virtual IGUIFileOpenDialog* addFileOpenDialog(const wchar_t* title=0,
\r
391 bool modal=true, IGUIElement* parent=0, s32 id=-1,
\r
392 bool restoreCWD=false, io::path::char_type* startDir=0) = 0;
\r
394 //! Adds a color select dialog.
\r
395 /** \param title The title of the dialog.
\r
396 \param modal Defines if the dialog is modal. This means, that all other
\r
397 gui elements which were created before the dialog cannot be used
\r
398 until it is removed.
\r
399 \param parent The parent of the dialog.
\r
400 \param id The ID of the dialog.
\r
401 \return Pointer to the created file open dialog. Returns 0 if an error
\r
402 occurred. This pointer should not be dropped. See
\r
403 IReferenceCounted::drop() for more information. */
\r
404 virtual IGUIColorSelectDialog* addColorSelectDialog(const wchar_t* title = 0,
\r
405 bool modal=true, IGUIElement* parent=0, s32 id=-1) = 0;
\r
407 //! Adds a static text.
\r
408 /** \param text Text to be displayed. Can be altered after creation by SetText().
\r
409 \param rectangle Rectangle specifying the borders of the static text
\r
410 \param border Set to true if the static text should have a 3d border.
\r
411 \param wordWrap Enable if the text should wrap into multiple lines.
\r
412 \param parent Parent item of the element, e.g. a window.
\r
413 \param id The ID of the element.
\r
414 \param fillBackground Enable if the background shall be filled.
\r
416 \return Pointer to the created static text. Returns 0 if an error
\r
417 occurred. This pointer should not be dropped. See
\r
418 IReferenceCounted::drop() for more information. */
\r
419 virtual IGUIStaticText* addStaticText(const wchar_t* text, const core::rect<s32>& rectangle,
\r
420 bool border=false, bool wordWrap=true, IGUIElement* parent=0, s32 id=-1,
\r
421 bool fillBackground = false) = 0;
\r
423 //! Adds an edit box.
\r
424 /** Supports Unicode input from every keyboard around the world,
\r
425 scrolling, copying and pasting (exchanging data with the clipboard
\r
426 directly), maximum character amount, marking, and all shortcuts like
\r
427 ctrl+X, ctrl+V, ctrl+C, shift+Left, shift+Right, Home, End, and so on.
\r
428 \param text Text to be displayed. Can be altered after creation
\r
430 \param rectangle Rectangle specifying the borders of the edit box.
\r
431 \param border Set to true if the edit box should have a 3d border.
\r
432 \param parent Parent item of the element, e.g. a window.
\r
433 Set it to 0 to place the edit box directly in the environment.
\r
434 \param id The ID of the element.
\r
435 \return Pointer to the created edit box. Returns 0 if an error occurred.
\r
436 This pointer should not be dropped. See IReferenceCounted::drop() for
\r
437 more information. */
\r
438 virtual IGUIEditBox* addEditBox(const wchar_t* text, const core::rect<s32>& rectangle,
\r
439 bool border=true, IGUIElement* parent=0, s32 id=-1) = 0;
\r
441 //! Adds a spin box.
\r
442 /** An edit box with up and down buttons
\r
443 \param text Text to be displayed. Can be altered after creation by setText().
\r
444 \param rectangle Rectangle specifying the borders of the spin box.
\r
445 \param border Set to true if the spin box should have a 3d border.
\r
446 \param parent Parent item of the element, e.g. a window.
\r
447 Set it to 0 to place the spin box directly in the environment.
\r
448 \param id The ID of the element.
\r
449 \return Pointer to the created spin box. Returns 0 if an error occurred.
\r
450 This pointer should not be dropped. See IReferenceCounted::drop() for
\r
451 more information. */
\r
452 virtual IGUISpinBox* addSpinBox(const wchar_t* text, const core::rect<s32>& rectangle,
\r
453 bool border=true,IGUIElement* parent=0, s32 id=-1) = 0;
\r
455 //! Adds an element for fading in or out.
\r
456 /** \param rectangle Rectangle specifying the borders of the fader.
\r
457 If the pointer is NULL, the whole screen is used.
\r
458 \param parent Parent item of the element, e.g. a window.
\r
459 \param id An identifier for the fader.
\r
460 \return Pointer to the created in-out-fader. Returns 0 if an error
\r
461 occurred. This pointer should not be dropped. See
\r
462 IReferenceCounted::drop() for more information. */
\r
463 virtual IGUIInOutFader* addInOutFader(const core::rect<s32>* rectangle=0, IGUIElement* parent=0, s32 id=-1) = 0;
\r
465 //! Adds a tab control to the environment.
\r
466 /** \param rectangle Rectangle specifying the borders of the tab control.
\r
467 \param parent Parent item of the element, e.g. a window.
\r
468 Set it to 0 to place the tab control directly in the environment.
\r
469 \param fillbackground Specifies if the background of the tab control
\r
471 \param border Specifies if a flat 3d border should be drawn. This is
\r
472 usually not necessary unless you place the control directly into
\r
473 the environment without a window as parent.
\r
474 \param id An identifier for the tab control.
\r
475 \return Pointer to the created tab control element. Returns 0 if an
\r
476 error occurred. This pointer should not be dropped. See
\r
477 IReferenceCounted::drop() for more information. */
\r
478 virtual IGUITabControl* addTabControl(const core::rect<s32>& rectangle,
\r
479 IGUIElement* parent=0, bool fillbackground=false,
\r
480 bool border=true, s32 id=-1) = 0;
\r
482 //! Adds tab to the environment.
\r
483 /** You can use this element to group other elements. This is not used
\r
484 for creating tabs on tab controls, please use IGUITabControl::addTab()
\r
486 \param rectangle Rectangle specifying the borders of the tab.
\r
487 \param parent Parent item of the element, e.g. a window.
\r
488 Set it to 0 to place the tab directly in the environment.
\r
489 \param id An identifier for the tab.
\r
490 \return Pointer to the created tab. Returns 0 if an
\r
491 error occurred. This pointer should not be dropped. See
\r
492 IReferenceCounted::drop() for more information. */
\r
493 virtual IGUITab* addTab(const core::rect<s32>& rectangle,
\r
494 IGUIElement* parent=0, s32 id=-1) = 0;
\r
496 //! Adds a context menu to the environment.
\r
497 /** \param rectangle Rectangle specifying the borders of the menu.
\r
498 Note that the menu is resizing itself based on what items you add.
\r
499 \param parent Parent item of the element, e.g. a window.
\r
500 Set it to 0 to place the menu directly in the environment.
\r
501 \param id An identifier for the menu.
\r
502 \return Pointer to the created context menu. Returns 0 if an
\r
503 error occurred. This pointer should not be dropped. See
\r
504 IReferenceCounted::drop() for more information. */
\r
505 virtual IGUIContextMenu* addContextMenu(const core::rect<s32>& rectangle,
\r
506 IGUIElement* parent=0, s32 id=-1) = 0;
\r
508 //! Adds a menu to the environment.
\r
509 /** This is like the menu you can find on top of most windows in modern
\r
510 graphical user interfaces.
\r
511 \param parent Parent item of the element, e.g. a window.
\r
512 Set it to 0 to place the menu directly in the environment.
\r
513 \param id An identifier for the menu.
\r
514 \return Pointer to the created menu. Returns 0 if an
\r
515 error occurred. This pointer should not be dropped. See
\r
516 IReferenceCounted::drop() for more information. */
\r
517 virtual IGUIContextMenu* addMenu(IGUIElement* parent=0, s32 id=-1) = 0;
\r
519 //! Adds a toolbar to the environment.
\r
520 /** It is like a menu that is always placed on top of its parent, and
\r
522 \param parent Parent item of the element, e.g. a window.
\r
523 Set it to 0 to place the tool bar directly in the environment.
\r
524 \param id An identifier for the tool bar.
\r
525 \return Pointer to the created tool bar. Returns 0 if an
\r
526 error occurred. This pointer should not be dropped. See
\r
527 IReferenceCounted::drop() for more information. */
\r
528 virtual IGUIToolBar* addToolBar(IGUIElement* parent=0, s32 id=-1) = 0;
\r
530 //! Adds a combo box to the environment.
\r
531 /** \param rectangle Rectangle specifying the borders of the combo box.
\r
532 \param parent Parent item of the element, e.g. a window.
\r
533 Set it to 0 to place the combo box directly in the environment.
\r
534 \param id An identifier for the combo box.
\r
535 \return Pointer to the created combo box. Returns 0 if an
\r
536 error occurred. This pointer should not be dropped. See
\r
537 IReferenceCounted::drop() for more information. */
\r
538 virtual IGUIComboBox* addComboBox(const core::rect<s32>& rectangle,
\r
539 IGUIElement* parent=0, s32 id=-1) = 0;
\r
541 //! Adds a table to the environment
\r
542 /** \param rectangle Rectangle specifying the borders of the table.
\r
543 \param parent Parent item of the element, e.g. a window. Set it to 0
\r
544 to place the element directly in the environment.
\r
545 \param id An identifier for the table.
\r
546 \param drawBackground Flag whether the background should be drawn.
\r
547 \return Pointer to the created table. Returns 0 if an error occurred.
\r
548 This pointer should not be dropped. See IReferenceCounted::drop() for
\r
549 more information. */
\r
550 virtual IGUITable* addTable(const core::rect<s32>& rectangle,
\r
551 IGUIElement* parent=0, s32 id=-1, bool drawBackground=false) =0;
\r
553 //! Adds an element to display the information from the Irrlicht profiler
\r
554 /** \param rectangle Rectangle specifying the borders of the element.
\r
555 \param parent Parent of the element. When 0 the environment itself will
\r
557 \param id An identifier for the element. */
\r
558 virtual IGUIProfiler* addProfilerDisplay(const core::rect<s32>& rectangle,
\r
559 IGUIElement* parent=0, s32 id=-1) = 0;
\r
561 //! Get the default element factory which can create all built-in elements
\r
562 /** \return Pointer to the factory.
\r
563 This pointer should not be dropped. See IReferenceCounted::drop() for
\r
564 more information. */
\r
565 virtual IGUIElementFactory* getDefaultGUIElementFactory() const = 0;
\r
567 //! Adds an element factory to the gui environment.
\r
568 /** Use this to extend the gui environment with new element types which
\r
569 it should be able to create automatically, for example when loading
\r
570 data from xml files.
\r
571 \param factoryToAdd Pointer to new factory. */
\r
572 virtual void registerGUIElementFactory(IGUIElementFactory* factoryToAdd) = 0;
\r
574 //! Get amount of registered gui element factories.
\r
575 /** \return Amount of registered gui element factories. */
\r
576 virtual u32 getRegisteredGUIElementFactoryCount() const = 0;
\r
578 //! Get a gui element factory by index
\r
579 /** \param index Index of the factory.
\r
580 \return Factory at given index, or 0 if no such factory exists. */
\r
581 virtual IGUIElementFactory* getGUIElementFactory(u32 index) const = 0;
\r
583 //! Adds a GUI element by its name
\r
584 /** Each factory is checked if it can create an element of the given
\r
585 name. The first match will be created.
\r
586 \param elementName Name of the element to be created.
\r
587 \param parent Parent of the new element, if not 0.
\r
588 \return New GUI element, or 0 if no such element exists. */
\r
589 virtual IGUIElement* addGUIElement(const c8* elementName, IGUIElement* parent=0) = 0;
\r
591 //! Saves the current gui into a file.
\r
592 /** \param filename Name of the file.
\r
593 \param start The GUIElement to start with. Root if 0.
\r
594 \return True if saving succeeded, else false. */
\r
595 virtual bool saveGUI(const io::path& filename, IGUIElement* start=0) = 0;
\r
597 //! Saves the current gui into a file.
\r
598 /** \param file The file to write to.
\r
599 \param start The GUIElement to start with. Root if 0.
\r
600 \return True if saving succeeded, else false. */
\r
601 virtual bool saveGUI(io::IWriteFile* file, IGUIElement* start=0) = 0;
\r
603 //! Loads the gui. Note that the current gui is not cleared before.
\r
604 /** When a parent is set the elements will be added below the parent, the parent itself does not deserialize.
\r
605 When the file contains skin-settings from the gui-environment those are always serialized into the
\r
606 guienvironment independent of the parent setting.
\r
607 \param filename Name of the file.
\r
608 \param parent Parent for the loaded GUI, root if 0.
\r
609 \return True if loading succeeded, else false. */
\r
610 virtual bool loadGUI(const io::path& filename, IGUIElement* parent=0) = 0;
\r
612 //! Loads the gui. Note that the current gui is not cleared before.
\r
613 /** When a parent is set the elements will be added below the parent, the parent itself does not deserialize.
\r
614 When the file contains skin-settings from the gui-environment those are always serialized into the
\r
615 guienvironment independent of the parent setting.
\r
616 \param file The file to load from.
\r
617 \param parent Parent for the loaded GUI, root if 0.
\r
618 \return True if loading succeeded, else false. */
\r
619 virtual bool loadGUI(io::IReadFile* file, IGUIElement* parent=0) = 0;
\r
621 //! Find the next element which would be selected when pressing the tab-key
\r
622 /** If you set the focus for the result you can manually force focus-changes like they
\r
623 would happen otherwise by the tab-keys.
\r
624 \param reverse When true it will search backward (toward lower TabOrder numbers, like shift+tab)
\r
625 \param group When true it will search for the next tab-group (like ctrl+tab)
\r
627 virtual IGUIElement* getNextElement(bool reverse=false, bool group=false) = 0;
\r
629 //! Set the way the gui will handle automatic focus changes
\r
630 /** The default is (EFF_SET_ON_LMOUSE_DOWN | EFF_SET_ON_TAB).
\r
631 with the left mouse button.
\r
632 This does not affect the setFocus function itself - users can still call that whenever they want on any element.
\r
633 \param flags A bitmask which is a combination of ::EFOCUS_FLAG flags.*/
\r
634 virtual void setFocusBehavior(u32 flags) = 0;
\r
636 //! Get the way the gui does handle focus changes
\r
637 /** \returns A bitmask which is a combination of ::EFOCUS_FLAG flags.*/
\r
638 virtual u32 getFocusBehavior() const = 0;
\r
640 //! Adds a IGUIElement to deletion queue.
\r
641 /** Queued elements will be removed at the end of each drawAll call.
\r
642 Or latest in the destructor of the GUIEnvironment.
\r
643 This can be used to allow an element removing itself safely in a function
\r
644 iterating over gui elements, like an overloaded IGUIElement::draw or
\r
645 IGUIElement::OnPostRender function.
\r
646 Note that in general just calling IGUIElement::remove() is enough.
\r
647 Unless you create your own GUI elements removing themselves you won't need it.
\r
648 \param element: Element to remove */
\r
649 virtual void addToDeletionQueue(IGUIElement* element) = 0;
\r
653 } // end namespace gui
\r
654 } // end namespace irr
\r