IGUIElementFactory.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 IRR_I_GUI_ELEMENT_FACTORY_H_INCLUDED
  5. #define IRR_I_GUI_ELEMENT_FACTORY_H_INCLUDED
  6. #include "IReferenceCounted.h"
  7. #include "EGUIElementTypes.h"
  8. namespace irr
  9. {
  10. namespace gui
  11. {
  12. class IGUIElement;
  13. //! Interface making it possible to dynamically create GUI elements
  14. /** To be able to add custom elements to Irrlicht and to make it possible for the
  15. scene manager to save and load them, simply implement this interface and register it
  16. in your gui environment via IGUIEnvironment::registerGUIElementFactory.
  17. Note: When implementing your own element factory, don't call IGUIEnvironment::grab() to
  18. increase the reference counter of the environment. This is not necessary because the
  19. it will grab() the factory anyway, and otherwise cyclic references will be created.
  20. */
  21. class IGUIElementFactory : public virtual IReferenceCounted
  22. {
  23. public:
  24. //! adds an element to the gui environment based on its type id
  25. /** \param type: Type of the element to add.
  26. \param parent: Parent scene node of the new element, can be null to add to the root.
  27. \return Pointer to the new element or null if not successful. */
  28. virtual IGUIElement* addGUIElement(EGUI_ELEMENT_TYPE type, IGUIElement* parent=0) = 0;
  29. //! adds a GUI element to the GUI Environment based on its type name
  30. /** \param typeName: Type name of the element to add.
  31. \param parent: Parent scene node of the new element, can be null to add it to the root.
  32. \return Pointer to the new element or null if not successful. */
  33. virtual IGUIElement* addGUIElement(const c8* typeName, IGUIElement* parent=0) = 0;
  34. //! Get amount of GUI element types this factory is able to create
  35. virtual s32 getCreatableGUIElementTypeCount() const = 0;
  36. //! Get type of a creatable element type
  37. /** \param idx: Index of the element type in this factory. Must be a value between 0 and
  38. getCreatableGUIElementTypeCount() */
  39. virtual EGUI_ELEMENT_TYPE getCreateableGUIElementType(s32 idx) const = 0;
  40. //! Get type name of a creatable GUI element type by index
  41. /** \param idx: Index of the type in this factory. Must be a value between 0 and
  42. getCreatableGUIElementTypeCount() */
  43. virtual const c8* getCreateableGUIElementTypeName(s32 idx) const = 0;
  44. //! returns type name of a creatable GUI element
  45. /** \param type: Type of GUI element.
  46. \return Name of the type if this factory can create the type, otherwise 0. */
  47. virtual const c8* getCreateableGUIElementTypeName(EGUI_ELEMENT_TYPE type) const = 0;
  48. };
  49. } // end namespace gui
  50. } // end namespace irr
  51. #endif // IRR_I_GUI_ELEMENT_FACTORY_H_INCLUDED