]> git.lizzy.rs Git - irrlicht.git/blob - source/Irrlicht/CGUITabControl.h
Prefer static_cast to reinterpret_cast where possible.
[irrlicht.git] / source / Irrlicht / CGUITabControl.h
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
4 \r
5 #ifndef __C_GUI_TAB_CONTROL_H_INCLUDED__\r
6 #define __C_GUI_TAB_CONTROL_H_INCLUDED__\r
7 \r
8 #include "IrrCompileConfig.h"\r
9 #ifdef _IRR_COMPILE_WITH_GUI_\r
10 \r
11 #include "IGUITabControl.h"\r
12 #include "irrArray.h"\r
13 #include "IGUISkin.h"\r
14 \r
15 namespace irr\r
16 {\r
17 namespace gui\r
18 {\r
19         class CGUITabControl;\r
20         class IGUIButton;\r
21 \r
22         // A tab, onto which other gui elements could be added.\r
23         class CGUITab : public IGUITab\r
24         {\r
25         public:\r
26 \r
27                 //! constructor\r
28                 CGUITab(IGUIEnvironment* environment,\r
29                         IGUIElement* parent, const core::rect<s32>& rectangle,\r
30                         s32 id);\r
31 \r
32                 //! draws the element and its children\r
33                 virtual void draw() _IRR_OVERRIDE_;\r
34 \r
35                 //! sets if the tab should draw its background\r
36                 virtual void setDrawBackground(bool draw=true) _IRR_OVERRIDE_;\r
37 \r
38                 //! sets the color of the background, if it should be drawn.\r
39                 virtual void setBackgroundColor(video::SColor c) _IRR_OVERRIDE_;\r
40 \r
41                 //! sets the color of the text\r
42                 virtual void setTextColor(video::SColor c) _IRR_OVERRIDE_;\r
43 \r
44                 //! returns true if the tab is drawing its background, false if not\r
45                 virtual bool isDrawingBackground() const _IRR_OVERRIDE_;\r
46 \r
47                 //! returns the color of the background\r
48                 virtual video::SColor getBackgroundColor() const _IRR_OVERRIDE_;\r
49 \r
50                 virtual video::SColor getTextColor() const _IRR_OVERRIDE_;\r
51 \r
52         private:\r
53 \r
54                 video::SColor BackColor;\r
55                 bool OverrideTextColorEnabled;\r
56                 video::SColor TextColor;\r
57                 bool DrawBackground;\r
58         };\r
59 \r
60 \r
61         //! A standard tab control\r
62         class CGUITabControl : public IGUITabControl\r
63         {\r
64         public:\r
65 \r
66                 //! destructor\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
70 \r
71                 //! destructor\r
72                 virtual ~CGUITabControl();\r
73 \r
74                 //! Adds a tab\r
75                 virtual IGUITab* addTab(const wchar_t* caption, s32 id=-1) _IRR_OVERRIDE_;\r
76 \r
77                 //! Adds an existing tab\r
78                 virtual s32 addTab(IGUITab* tab) _IRR_OVERRIDE_;\r
79 \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
82 \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
87 \r
88                 //! Removes a tab from the tabcontrol\r
89                 virtual void removeTab(s32 idx) _IRR_OVERRIDE_;\r
90 \r
91                 //! Clears the tabcontrol removing all tabs\r
92                 virtual void clear() _IRR_OVERRIDE_;\r
93 \r
94                 //! Returns amount of tabs in the tabcontrol\r
95                 virtual s32 getTabCount() const _IRR_OVERRIDE_;\r
96 \r
97                 //! Returns a tab based on zero based index\r
98                 virtual IGUITab* getTab(s32 idx) const _IRR_OVERRIDE_;\r
99 \r
100                 //! Brings a tab to front.\r
101                 virtual bool setActiveTab(s32 idx) _IRR_OVERRIDE_;\r
102 \r
103                 //! Brings a tab to front.\r
104                 virtual bool setActiveTab(IGUITab *tab) _IRR_OVERRIDE_;\r
105 \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
108 \r
109                 //! Returns which tab is currently active\r
110                 virtual s32 getActiveTab() const _IRR_OVERRIDE_;\r
111 \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
114 \r
115                 //! called if an event happened.\r
116                 virtual bool OnEvent(const SEvent& event) _IRR_OVERRIDE_;\r
117 \r
118                 //! draws the element and its children\r
119                 virtual void draw() _IRR_OVERRIDE_;\r
120 \r
121                 //! Removes a child.\r
122                 virtual void removeChild(IGUIElement* child) _IRR_OVERRIDE_;\r
123 \r
124                 //! Set the height of the tabs\r
125                 virtual void setTabHeight( s32 height ) _IRR_OVERRIDE_;\r
126 \r
127                 //! Get the height of the tabs\r
128                 virtual s32 getTabHeight() const _IRR_OVERRIDE_;\r
129 \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
132 \r
133                 //! get the maximal width of a tab\r
134                 virtual s32 getTabMaxWidth() const _IRR_OVERRIDE_;\r
135 \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
139 \r
140                 //! Get the alignment of the tabs\r
141                 virtual gui::EGUI_ALIGNMENT getTabVerticalAlignment() const _IRR_OVERRIDE_;\r
142 \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
145 \r
146                 //! Get the extra width added to tabs on each side of the text\r
147                 virtual s32 getTabExtraWidth() const _IRR_OVERRIDE_;\r
148 \r
149                 //! Update the position of the element, decides scroll button status\r
150                 virtual void updateAbsolutePosition() _IRR_OVERRIDE_;\r
151 \r
152         private:\r
153 \r
154                 void scrollLeft();\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
161 \r
162                 void recalculateScrollButtonPlacement();\r
163                 void recalculateScrollBar();\r
164                 void refreshSprites();\r
165 \r
166                 core::array<IGUITab*> Tabs;\r
167                 s32 ActiveTabIndex;\r
168                 bool Border;\r
169                 bool FillBackground;\r
170                 bool ScrollControl;\r
171                 s32 TabHeight;\r
172                 gui::EGUI_ALIGNMENT VerticalAlignment;\r
173                 IGUIButton* UpButton;\r
174                 IGUIButton* DownButton;\r
175                 s32 TabMaxWidth;\r
176                 s32 CurrentScrollTabIndex;\r
177                 s32 TabExtraWidth;\r
178         };\r
179 \r
180 \r
181 } // end namespace gui\r
182 } // end namespace irr\r
183 \r
184 #endif // _IRR_COMPILE_WITH_GUI_\r
185 \r
186 #endif\r
187 \r