]> git.lizzy.rs Git - irrlicht.git/blob - source/Irrlicht/CGUITabControl.h
Reduce IrrCompileConfig usage to files that actually need it
[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 "IGUITabControl.h"\r
9 #include "irrArray.h"\r
10 #include "IGUISkin.h"\r
11 \r
12 namespace irr\r
13 {\r
14 namespace gui\r
15 {\r
16         class CGUITabControl;\r
17         class IGUIButton;\r
18 \r
19         // A tab, onto which other gui elements could be added.\r
20         class CGUITab : public IGUITab\r
21         {\r
22         public:\r
23 \r
24                 //! constructor\r
25                 CGUITab(IGUIEnvironment* environment,\r
26                         IGUIElement* parent, const core::rect<s32>& rectangle,\r
27                         s32 id);\r
28 \r
29                 //! draws the element and its children\r
30                 void draw() override;\r
31 \r
32                 //! sets if the tab should draw its background\r
33                 void setDrawBackground(bool draw=true) override;\r
34 \r
35                 //! sets the color of the background, if it should be drawn.\r
36                 void setBackgroundColor(video::SColor c) override;\r
37 \r
38                 //! sets the color of the text\r
39                 void setTextColor(video::SColor c) override;\r
40 \r
41                 //! returns true if the tab is drawing its background, false if not\r
42                 bool isDrawingBackground() const override;\r
43 \r
44                 //! returns the color of the background\r
45                 video::SColor getBackgroundColor() const override;\r
46 \r
47                 video::SColor getTextColor() const override;\r
48 \r
49         private:\r
50 \r
51                 video::SColor BackColor;\r
52                 bool OverrideTextColorEnabled;\r
53                 video::SColor TextColor;\r
54                 bool DrawBackground;\r
55         };\r
56 \r
57 \r
58         //! A standard tab control\r
59         class CGUITabControl : public IGUITabControl\r
60         {\r
61         public:\r
62 \r
63                 //! destructor\r
64                 CGUITabControl(IGUIEnvironment* environment,\r
65                         IGUIElement* parent, const core::rect<s32>& rectangle,\r
66                         bool fillbackground=true, bool border=true, s32 id=-1);\r
67 \r
68                 //! destructor\r
69                 virtual ~CGUITabControl();\r
70 \r
71                 //! Adds a tab\r
72                 IGUITab* addTab(const wchar_t* caption, s32 id=-1) override;\r
73 \r
74                 //! Adds an existing tab\r
75                 s32 addTab(IGUITab* tab) override;\r
76 \r
77                 //! Insert the tab at the given index\r
78                 IGUITab* insertTab(s32 idx, const wchar_t* caption, s32 id=-1) override;\r
79 \r
80                 //! Insert an existing tab\r
81                 /** Note that it will also add the tab as a child of this TabControl.\r
82                 \return Index of added tab (should be same as the one passed) or -1 for failure*/\r
83                 s32 insertTab(s32 idx, IGUITab* tab, bool serializationMode) override;\r
84 \r
85                 //! Removes a tab from the tabcontrol\r
86                 void removeTab(s32 idx) override;\r
87 \r
88                 //! Clears the tabcontrol removing all tabs\r
89                 void clear() override;\r
90 \r
91                 //! Returns amount of tabs in the tabcontrol\r
92                 s32 getTabCount() const override;\r
93 \r
94                 //! Returns a tab based on zero based index\r
95                 IGUITab* getTab(s32 idx) const override;\r
96 \r
97                 //! Brings a tab to front.\r
98                 bool setActiveTab(s32 idx) override;\r
99 \r
100                 //! Brings a tab to front.\r
101                 bool setActiveTab(IGUITab *tab) override;\r
102 \r
103                 //! For given given tab find it's zero-based index (or -1 for not found)\r
104                 s32 getTabIndex(const IGUIElement *tab) const override;\r
105 \r
106                 //! Returns which tab is currently active\r
107                 s32 getActiveTab() const override;\r
108 \r
109                 //! get the the id of the tab at the given absolute coordinates\r
110                 s32 getTabAt(s32 xpos, s32 ypos) const override;\r
111 \r
112                 //! called if an event happened.\r
113                 bool OnEvent(const SEvent& event) override;\r
114 \r
115                 //! draws the element and its children\r
116                 void draw() override;\r
117 \r
118                 //! Removes a child.\r
119                 void removeChild(IGUIElement* child) override;\r
120 \r
121                 //! Set the height of the tabs\r
122                 void setTabHeight( s32 height ) override;\r
123 \r
124                 //! Get the height of the tabs\r
125                 s32 getTabHeight() const override;\r
126 \r
127                 //! set the maximal width of a tab. Per default width is 0 which means "no width restriction".\r
128                 void setTabMaxWidth(s32 width ) override;\r
129 \r
130                 //! get the maximal width of a tab\r
131                 s32 getTabMaxWidth() const override;\r
132 \r
133                 //! Set the alignment of the tabs\r
134                 //! note: EGUIA_CENTER is not an option\r
135                 void setTabVerticalAlignment( gui::EGUI_ALIGNMENT alignment ) override;\r
136 \r
137                 //! Get the alignment of the tabs\r
138                 gui::EGUI_ALIGNMENT getTabVerticalAlignment() const override;\r
139 \r
140                 //! Set the extra width added to tabs on each side of the text\r
141                 void setTabExtraWidth( s32 extraWidth ) override;\r
142 \r
143                 //! Get the extra width added to tabs on each side of the text\r
144                 s32 getTabExtraWidth() const override;\r
145 \r
146                 //! Update the position of the element, decides scroll button status\r
147                 void updateAbsolutePosition() override;\r
148 \r
149         private:\r
150 \r
151                 void scrollLeft();\r
152                 void scrollRight();\r
153                 //! Indicates whether the tabs overflow in X direction\r
154                 bool needScrollControl( s32 startIndex=0, bool withScrollControl=false, s32 *pos_rightmost=nullptr );\r
155                 //! Left index calculation based on the selected tab\r
156                 s32 calculateScrollIndexFromActive();\r
157                 s32 calcTabWidth(IGUIFont* font, const wchar_t* text) 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\r