IGUITabControl.h 5.4 KB

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