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