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