IGUITabControl.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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_TAB_CONTROL_H_INCLUDED
  5. #define IRR_I_GUI_TAB_CONTROL_H_INCLUDED
  6. #include "IGUIElement.h"
  7. #include "SColor.h"
  8. #include "IGUISkin.h"
  9. namespace irr
  10. {
  11. namespace gui
  12. {
  13. class IGUITab;
  14. //! A standard tab control
  15. /** \par This element can create the following events of type EGUI_EVENT_TYPE:
  16. \li EGET_TAB_CHANGED
  17. */
  18. class IGUITabControl : public IGUIElement
  19. {
  20. public:
  21. //! constructor
  22. IGUITabControl(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle)
  23. : IGUIElement(EGUIET_TAB_CONTROL, environment, parent, id, rectangle) {}
  24. //! Adds a tab
  25. virtual IGUITab* addTab(const wchar_t* caption, s32 id=-1) = 0;
  26. //! Adds an existing tab
  27. /** Note that it will also add the tab as a child of this TabControl.
  28. \return Index of added tab or -1 for failure*/
  29. virtual s32 addTab(IGUITab* tab) = 0;
  30. //! Insert the tab at the given index
  31. /** \return The tab on success or NULL on failure. */
  32. virtual IGUITab* insertTab(s32 idx, const wchar_t* caption, s32 id=-1) = 0;
  33. //! Insert an existing tab
  34. /** Note that it will also add the tab as a child of this TabControl.
  35. \param idx Index at which tab will be inserted. Later tabs will be moved.
  36. Previous active tab will stay active unless this is the first
  37. element to be inserted in which case it becomes active.
  38. \param tab New tab to insert.
  39. \param serializationMode Internally used for serialization. You should not need this.
  40. When true it reserves space for the index, doesn't move but replaces tabs
  41. and it doesn't change the active tab.
  42. \return Index of added tab (should be same as the one passed) or -1 for failure*/
  43. virtual s32 insertTab(s32 idx, IGUITab* tab, bool serializationMode=false) = 0;
  44. //! Removes a tab from the tabcontrol
  45. virtual void removeTab(s32 idx) = 0;
  46. //! Clears the tabcontrol removing all tabs
  47. virtual void clear() = 0;
  48. //! Returns amount of tabs in the tabcontrol
  49. virtual s32 getTabCount() const = 0;
  50. //! Returns a tab based on zero based index
  51. /** \param idx: zero based index of tab. Is a value between 0 and getTabcount()-1;
  52. \return Returns pointer to the Tab. Returns 0 if no tab
  53. is corresponding to this tab. */
  54. virtual IGUITab* getTab(s32 idx) const = 0;
  55. //! For given element find if it's a tab and return it's zero-based index (or -1 for not found)
  56. /** \param tab Tab for which we are looking (usually you will look for an IGUITab* type as only
  57. those can be tabs, but we allow looking for any kind of IGUIElement* as there are some
  58. use-cases for that even if it just returns 0. For example this way you can check for
  59. all children of this gui-element if they are tabs or some non-tab children.*/
  60. virtual s32 getTabIndex(const IGUIElement *tab) const = 0;
  61. //! Brings a tab to front.
  62. /** \param idx: number of the tab.
  63. \return Returns true if successful. */
  64. virtual bool setActiveTab(s32 idx) = 0;
  65. //! Brings a tab to front.
  66. /** \param tab: pointer to the tab.
  67. \return Returns true if successful. */
  68. virtual bool setActiveTab(IGUITab *tab) = 0;
  69. //! Returns which tab is currently active
  70. virtual s32 getActiveTab() const = 0;
  71. //! get the the id of the tab at the given absolute coordinates
  72. /** \return The id of the tab or -1 when no tab is at those coordinates*/
  73. virtual s32 getTabAt(s32 xpos, s32 ypos) const = 0;
  74. //! Set the height of the tabs
  75. virtual void setTabHeight( s32 height ) = 0;
  76. //! Get the height of the tabs
  77. /** return Returns the height of the tabs */
  78. virtual s32 getTabHeight() const = 0;
  79. //! set the maximal width of a tab. Per default width is 0 which means "no width restriction".
  80. virtual void setTabMaxWidth(s32 width ) = 0;
  81. //! get the maximal width of a tab
  82. virtual s32 getTabMaxWidth() const = 0;
  83. //! Set the alignment of the tabs
  84. /** Use EGUIA_UPPERLEFT or EGUIA_LOWERRIGHT */
  85. virtual void setTabVerticalAlignment( gui::EGUI_ALIGNMENT alignment ) = 0;
  86. //! Get the alignment of the tabs
  87. /** return Returns the alignment of the tabs */
  88. virtual gui::EGUI_ALIGNMENT getTabVerticalAlignment() const = 0;
  89. //! Set the extra width added to tabs on each side of the text
  90. virtual void setTabExtraWidth( s32 extraWidth ) = 0;
  91. //! Get the extra width added to tabs on each side of the text
  92. /** return Returns the extra width of the tabs */
  93. virtual s32 getTabExtraWidth() const = 0;
  94. };
  95. //! A tab-page, onto which other gui elements could be added.
  96. /** IGUITab refers mostly to the page itself, but also carries some data about the tab in the tabbar of an IGUITabControl. */
  97. class IGUITab : public IGUIElement
  98. {
  99. public:
  100. //! constructor
  101. IGUITab(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle)
  102. : IGUIElement(EGUIET_TAB, environment, parent, id, rectangle) {}
  103. //! Returns zero based index of tab if in tabcontrol.
  104. /** \deprecated Deprecated in 1.9, use IGUITabControl::getTabIndex instead*/
  105. IRR_DEPRECATED virtual s32 getNumber() const
  106. {
  107. if (Parent && Parent->getType() == EGUIET_TAB_CONTROL)
  108. return static_cast<IGUITabControl*>(Parent)->getTabIndex(this);
  109. return -1;
  110. }
  111. //! sets if the tab should draw its background
  112. virtual void setDrawBackground(bool draw=true) = 0;
  113. //! sets the color of the background, if it should be drawn.
  114. virtual void setBackgroundColor(video::SColor c) = 0;
  115. //! returns true if the tab is drawing its background, false if not
  116. virtual bool isDrawingBackground() const = 0;
  117. //! returns the color of the background
  118. virtual video::SColor getBackgroundColor() const = 0;
  119. //! sets the color of it's text in the tab-bar
  120. virtual void setTextColor(video::SColor c) = 0;
  121. //! gets the color of the text
  122. virtual video::SColor getTextColor() const = 0;
  123. };
  124. } // end namespace gui
  125. } // end namespace irr
  126. #endif