1 // Copyright (C) 2002-2012 Nikolaus Gebhardt
\r
2 // This file is part of the "Irrlicht Engine".
\r
3 // For conditions of distribution and use, see copyright notice in irrlicht.h
\r
5 #ifndef __C_GUI_TAB_CONTROL_H_INCLUDED__
\r
6 #define __C_GUI_TAB_CONTROL_H_INCLUDED__
\r
8 #include "IrrCompileConfig.h"
\r
9 #ifdef _IRR_COMPILE_WITH_GUI_
\r
11 #include "IGUITabControl.h"
\r
12 #include "irrArray.h"
\r
13 #include "IGUISkin.h"
\r
19 class CGUITabControl;
\r
22 // A tab, onto which other gui elements could be added.
\r
23 class CGUITab : public IGUITab
\r
28 CGUITab(IGUIEnvironment* environment,
\r
29 IGUIElement* parent, const core::rect<s32>& rectangle,
\r
32 //! draws the element and its children
\r
33 virtual void draw() _IRR_OVERRIDE_;
\r
35 //! sets if the tab should draw its background
\r
36 virtual void setDrawBackground(bool draw=true) _IRR_OVERRIDE_;
\r
38 //! sets the color of the background, if it should be drawn.
\r
39 virtual void setBackgroundColor(video::SColor c) _IRR_OVERRIDE_;
\r
41 //! sets the color of the text
\r
42 virtual void setTextColor(video::SColor c) _IRR_OVERRIDE_;
\r
44 //! returns true if the tab is drawing its background, false if not
\r
45 virtual bool isDrawingBackground() const _IRR_OVERRIDE_;
\r
47 //! returns the color of the background
\r
48 virtual video::SColor getBackgroundColor() const _IRR_OVERRIDE_;
\r
50 virtual video::SColor getTextColor() const _IRR_OVERRIDE_;
\r
54 video::SColor BackColor;
\r
55 bool OverrideTextColorEnabled;
\r
56 video::SColor TextColor;
\r
57 bool DrawBackground;
\r
61 //! A standard tab control
\r
62 class CGUITabControl : public IGUITabControl
\r
67 CGUITabControl(IGUIEnvironment* environment,
\r
68 IGUIElement* parent, const core::rect<s32>& rectangle,
\r
69 bool fillbackground=true, bool border=true, s32 id=-1);
\r
72 virtual ~CGUITabControl();
\r
75 virtual IGUITab* addTab(const wchar_t* caption, s32 id=-1) _IRR_OVERRIDE_;
\r
77 //! Adds an existing tab
\r
78 virtual s32 addTab(IGUITab* tab) _IRR_OVERRIDE_;
\r
80 //! Insert the tab at the given index
\r
81 virtual IGUITab* insertTab(s32 idx, const wchar_t* caption, s32 id=-1) _IRR_OVERRIDE_;
\r
83 //! Insert an existing tab
\r
84 /** Note that it will also add the tab as a child of this TabControl.
\r
85 \return Index of added tab (should be same as the one passed) or -1 for failure*/
\r
86 virtual s32 insertTab(s32 idx, IGUITab* tab, bool serializationMode) _IRR_OVERRIDE_;
\r
88 //! Removes a tab from the tabcontrol
\r
89 virtual void removeTab(s32 idx) _IRR_OVERRIDE_;
\r
91 //! Clears the tabcontrol removing all tabs
\r
92 virtual void clear() _IRR_OVERRIDE_;
\r
94 //! Returns amount of tabs in the tabcontrol
\r
95 virtual s32 getTabCount() const _IRR_OVERRIDE_;
\r
97 //! Returns a tab based on zero based index
\r
98 virtual IGUITab* getTab(s32 idx) const _IRR_OVERRIDE_;
\r
100 //! Brings a tab to front.
\r
101 virtual bool setActiveTab(s32 idx) _IRR_OVERRIDE_;
\r
103 //! Brings a tab to front.
\r
104 virtual bool setActiveTab(IGUITab *tab) _IRR_OVERRIDE_;
\r
106 //! For given given tab find it's zero-based index (or -1 for not found)
\r
107 virtual s32 getTabIndex(const IGUIElement *tab) const _IRR_OVERRIDE_;
\r
109 //! Returns which tab is currently active
\r
110 virtual s32 getActiveTab() const _IRR_OVERRIDE_;
\r
112 //! get the the id of the tab at the given absolute coordinates
\r
113 virtual s32 getTabAt(s32 xpos, s32 ypos) const _IRR_OVERRIDE_;
\r
115 //! called if an event happened.
\r
116 virtual bool OnEvent(const SEvent& event) _IRR_OVERRIDE_;
\r
118 //! draws the element and its children
\r
119 virtual void draw() _IRR_OVERRIDE_;
\r
121 //! Removes a child.
\r
122 virtual void removeChild(IGUIElement* child) _IRR_OVERRIDE_;
\r
124 //! Set the height of the tabs
\r
125 virtual void setTabHeight( s32 height ) _IRR_OVERRIDE_;
\r
127 //! Get the height of the tabs
\r
128 virtual s32 getTabHeight() const _IRR_OVERRIDE_;
\r
130 //! set the maximal width of a tab. Per default width is 0 which means "no width restriction".
\r
131 virtual void setTabMaxWidth(s32 width ) _IRR_OVERRIDE_;
\r
133 //! get the maximal width of a tab
\r
134 virtual s32 getTabMaxWidth() const _IRR_OVERRIDE_;
\r
136 //! Set the alignment of the tabs
\r
137 //! note: EGUIA_CENTER is not an option
\r
138 virtual void setTabVerticalAlignment( gui::EGUI_ALIGNMENT alignment ) _IRR_OVERRIDE_;
\r
140 //! Get the alignment of the tabs
\r
141 virtual gui::EGUI_ALIGNMENT getTabVerticalAlignment() const _IRR_OVERRIDE_;
\r
143 //! Set the extra width added to tabs on each side of the text
\r
144 virtual void setTabExtraWidth( s32 extraWidth ) _IRR_OVERRIDE_;
\r
146 //! Get the extra width added to tabs on each side of the text
\r
147 virtual s32 getTabExtraWidth() const _IRR_OVERRIDE_;
\r
149 //! Update the position of the element, decides scroll button status
\r
150 virtual void updateAbsolutePosition() _IRR_OVERRIDE_;
\r
155 void scrollRight();
\r
156 bool needScrollControl( s32 startIndex=0, bool withScrollControl=false );
\r
157 s32 calcTabWidth(s32 pos, IGUIFont* font, const wchar_t* text, bool withScrollControl ) const;
\r
158 core::rect<s32> calcTabPos();
\r
159 void setVisibleTab(s32 idx);
\r
160 void removeTabButNotChild(s32 idx);
\r
162 void recalculateScrollButtonPlacement();
\r
163 void recalculateScrollBar();
\r
164 void refreshSprites();
\r
166 core::array<IGUITab*> Tabs;
\r
167 s32 ActiveTabIndex;
\r
169 bool FillBackground;
\r
170 bool ScrollControl;
\r
172 gui::EGUI_ALIGNMENT VerticalAlignment;
\r
173 IGUIButton* UpButton;
\r
174 IGUIButton* DownButton;
\r
176 s32 CurrentScrollTabIndex;
\r
181 } // end namespace gui
\r
182 } // end namespace irr
\r
184 #endif // _IRR_COMPILE_WITH_GUI_
\r