aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/irrlicht-1.8/source/Irrlicht/CGUITabControl.h
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/irrlicht-1.8/source/Irrlicht/CGUITabControl.h')
-rw-r--r--libraries/irrlicht-1.8/source/Irrlicht/CGUITabControl.h202
1 files changed, 202 insertions, 0 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/CGUITabControl.h b/libraries/irrlicht-1.8/source/Irrlicht/CGUITabControl.h
new file mode 100644
index 0000000..dd6c5ae
--- /dev/null
+++ b/libraries/irrlicht-1.8/source/Irrlicht/CGUITabControl.h
@@ -0,0 +1,202 @@
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
5#ifndef __C_GUI_TAB_CONTROL_H_INCLUDED__
6#define __C_GUI_TAB_CONTROL_H_INCLUDED__
7
8#include "IrrCompileConfig.h"
9#ifdef _IRR_COMPILE_WITH_GUI_
10
11#include "IGUITabControl.h"
12#include "irrArray.h"
13#include "IGUISkin.h"
14
15namespace irr
16{
17namespace gui
18{
19 class CGUITabControl;
20 class IGUIButton;
21
22 // A tab, onto which other gui elements could be added.
23 class CGUITab : public IGUITab
24 {
25 public:
26
27 //! constructor
28 CGUITab(s32 number, IGUIEnvironment* environment,
29 IGUIElement* parent, const core::rect<s32>& rectangle,
30 s32 id);
31
32 //! destructor
33 //virtual ~CGUITab();
34
35 //! Returns number of this tab in tabcontrol. Can be accessed
36 //! later IGUITabControl::getTab() by this number.
37 virtual s32 getNumber() const;
38
39 //! Sets the number
40 virtual void setNumber(s32 n);
41
42 //! draws the element and its children
43 virtual void draw();
44
45 //! sets if the tab should draw its background
46 virtual void setDrawBackground(bool draw=true);
47
48 //! sets the color of the background, if it should be drawn.
49 virtual void setBackgroundColor(video::SColor c);
50
51 //! sets the color of the text
52 virtual void setTextColor(video::SColor c);
53
54 //! returns true if the tab is drawing its background, false if not
55 virtual bool isDrawingBackground() const;
56
57 //! returns the color of the background
58 virtual video::SColor getBackgroundColor() const;
59
60 virtual video::SColor getTextColor() const;
61
62 //! Writes attributes of the element.
63 virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const;
64
65 //! Reads attributes of the element
66 virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options);
67
68 //! only for internal use by CGUITabControl
69 void refreshSkinColors();
70
71 private:
72
73 s32 Number;
74 video::SColor BackColor;
75 bool OverrideTextColorEnabled;
76 video::SColor TextColor;
77 bool DrawBackground;
78 };
79
80
81 //! A standard tab control
82 class CGUITabControl : public IGUITabControl
83 {
84 public:
85
86 //! destructor
87 CGUITabControl(IGUIEnvironment* environment,
88 IGUIElement* parent, const core::rect<s32>& rectangle,
89 bool fillbackground=true, bool border=true, s32 id=-1);
90
91 //! destructor
92 virtual ~CGUITabControl();
93
94 //! Adds a tab
95 virtual IGUITab* addTab(const wchar_t* caption, s32 id=-1);
96
97 //! Adds a tab that has already been created
98 virtual void addTab(CGUITab* tab);
99
100 //! Insert the tab at the given index
101 virtual IGUITab* insertTab(s32 idx, const wchar_t* caption, s32 id=-1);
102
103 //! Removes a tab from the tabcontrol
104 virtual void removeTab(s32 idx);
105
106 //! Clears the tabcontrol removing all tabs
107 virtual void clear();
108
109 //! Returns amount of tabs in the tabcontrol
110 virtual s32 getTabCount() const;
111
112 //! Returns a tab based on zero based index
113 virtual IGUITab* getTab(s32 idx) const;
114
115 //! Brings a tab to front.
116 virtual bool setActiveTab(s32 idx);
117
118 //! Brings a tab to front.
119 virtual bool setActiveTab(IGUITab *tab);
120
121 //! Returns which tab is currently active
122 virtual s32 getActiveTab() const;
123
124 //! get the the id of the tab at the given absolute coordinates
125 virtual s32 getTabAt(s32 xpos, s32 ypos) const;
126
127 //! called if an event happened.
128 virtual bool OnEvent(const SEvent& event);
129
130 //! draws the element and its children
131 virtual void draw();
132
133 //! Removes a child.
134 virtual void removeChild(IGUIElement* child);
135
136 //! Writes attributes of the element.
137 virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const;
138 //! Set the height of the tabs
139 virtual void setTabHeight( s32 height );
140
141 //! Reads attributes of the element
142 virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options);
143
144 //! Get the height of the tabs
145 virtual s32 getTabHeight() const;
146
147 //! set the maximal width of a tab. Per default width is 0 which means "no width restriction".
148 virtual void setTabMaxWidth(s32 width );
149
150 //! get the maximal width of a tab
151 virtual s32 getTabMaxWidth() const;
152
153 //! Set the alignment of the tabs
154 //! note: EGUIA_CENTER is not an option
155 virtual void setTabVerticalAlignment( gui::EGUI_ALIGNMENT alignment );
156
157 //! Get the alignment of the tabs
158 virtual gui::EGUI_ALIGNMENT getTabVerticalAlignment() const;
159
160 //! Set the extra width added to tabs on each side of the text
161 virtual void setTabExtraWidth( s32 extraWidth );
162
163 //! Get the extra width added to tabs on each side of the text
164 virtual s32 getTabExtraWidth() const;
165
166 //! Update the position of the element, decides scroll button status
167 virtual void updateAbsolutePosition();
168
169 private:
170
171 void scrollLeft();
172 void scrollRight();
173 bool needScrollControl( s32 startIndex=0, bool withScrollControl=false );
174 s32 calcTabWidth(s32 pos, IGUIFont* font, const wchar_t* text, bool withScrollControl ) const;
175 core::rect<s32> calcTabPos();
176
177 void recalculateScrollButtonPlacement();
178 void recalculateScrollBar();
179 void refreshSprites();
180
181 core::array<CGUITab*> Tabs; // CGUITab* because we need setNumber (which is certainly not nice)
182 s32 ActiveTab;
183 bool Border;
184 bool FillBackground;
185 bool ScrollControl;
186 s32 TabHeight;
187 gui::EGUI_ALIGNMENT VerticalAlignment;
188 IGUIButton* UpButton;
189 IGUIButton* DownButton;
190 s32 TabMaxWidth;
191 s32 CurrentScrollTabIndex;
192 s32 TabExtraWidth;
193 };
194
195
196} // end namespace gui
197} // end namespace irr
198
199#endif // _IRR_COMPILE_WITH_GUI_
200
201#endif
202