CDefaultGUIElementFactory.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. #ifndef __C_DEFAULT_GUI_ELEMENT_FACTORY_H_INCLUDED__
  5. #define __C_DEFAULT_GUI_ELEMENT_FACTORY_H_INCLUDED__
  6. #include "IrrCompileConfig.h"
  7. #ifdef _IRR_COMPILE_WITH_GUI_
  8. #include "IGUIElementFactory.h"
  9. namespace irr
  10. {
  11. namespace gui
  12. {
  13. class IGUIElement;
  14. class IGUIEnvironment;
  15. //! This interface makes it possible to dynamically create gui elements.
  16. class CDefaultGUIElementFactory : public IGUIElementFactory
  17. {
  18. public:
  19. CDefaultGUIElementFactory(IGUIEnvironment* env);
  20. //! Adds an element to the gui environment based on its type id.
  21. /** \param type: Type of the element to add.
  22. \param parent: Parent scene node of the new element. A value of 0 adds it to the root.
  23. \return Returns pointer to the new element or 0 if unsuccessful. */
  24. virtual IGUIElement* addGUIElement(EGUI_ELEMENT_TYPE type, IGUIElement* parent=0);
  25. //! Adds a GUI element to the GUI Environment based on its type name.
  26. /** \param typeName: Type name of the element to add. Taken from the GUIElementTypeNames c8* array.
  27. \param parent: Parent scene node of the new element. A value of 0 adds it to the root.
  28. \return Returns pointer to the new element or 0 if unsuccessful. */
  29. virtual IGUIElement* addGUIElement(const c8* typeName, IGUIElement* parent=0);
  30. //! Returns the amount of GUI element types this factory is able to create.
  31. virtual s32 getCreatableGUIElementTypeCount() const;
  32. //! Returns the type of a createable GUI element type based on the index.
  33. /** \param idx: Index of the element type in this factory. The value must be equal or greater than 0
  34. and lower than getCreatableGUIElementTypeCount(). */
  35. virtual EGUI_ELEMENT_TYPE getCreateableGUIElementType(s32 idx) const;
  36. //! Returns the type name of a createable GUI element type based on the index.
  37. /** \param idx: Index of the element type in this factory. The value must be equal or greater than 0
  38. and lower than getCreatableGUIElementTypeCount(). */
  39. virtual const c8* getCreateableGUIElementTypeName(s32 idx) const;
  40. //! Returns the type name of a createable GUI element based on its type.
  41. /** \param type: Type of the GUI element.
  42. \return: Returns the name of the type if this factory can create it, otherwise it returns 0. */
  43. virtual const c8* getCreateableGUIElementTypeName(EGUI_ELEMENT_TYPE type) const;
  44. private:
  45. EGUI_ELEMENT_TYPE getTypeFromName(const c8* name) const;
  46. IGUIEnvironment* Environment;
  47. };
  48. } // end namespace gui
  49. } // end namespace irr
  50. #endif // _IRR_COMPILE_WITH_GUI_
  51. #endif // __C_DEFAULT_GUI_ELEMENT_FACTORY_H_INCLUDED__