1
// Copyright (C) 2002-2011 Nikolaus Gebhardt
2
// This file is part of the "Irrlicht Engine".
3
// For conditions of distribution and use, see copyright notice in irrlicht.h
5
#ifndef __C_GUI_TAB_CONTROL_H_INCLUDED__
6
#define __C_GUI_TAB_CONTROL_H_INCLUDED__
8
#include "IrrCompileConfig.h"
9
#ifdef _IRR_COMPILE_WITH_GUI_
11
#include "IGUITabControl.h"
22
// A tab, onto which other gui elements could be added.
23
class CGUITab : public IGUITab
28
CGUITab(s32 number, IGUIEnvironment* environment,
29
IGUIElement* parent, const core::rect<s32>& rectangle,
35
//! Returns number of this tab in tabcontrol. Can be accessed
36
//! later IGUITabControl::getTab() by this number.
37
virtual s32 getNumber() const;
40
virtual void setNumber(s32 n);
42
//! draws the element and its children
45
//! sets if the tab should draw its background
46
virtual void setDrawBackground(bool draw=true);
48
//! sets the color of the background, if it should be drawn.
49
virtual void setBackgroundColor(video::SColor c);
51
//! sets the color of the text
52
virtual void setTextColor(video::SColor c);
54
//! returns true if the tab is drawing its background, false if not
55
virtual bool isDrawingBackground() const;
57
//! returns the color of the background
58
virtual video::SColor getBackgroundColor() const;
60
virtual video::SColor getTextColor() const;
62
//! Writes attributes of the element.
63
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const;
65
//! Reads attributes of the element
66
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options);
68
//! only for internal use by CGUITabControl
69
void refreshSkinColors();
74
video::SColor BackColor;
75
bool OverrideTextColorEnabled;
76
video::SColor TextColor;
81
//! A standard tab control
82
class CGUITabControl : public IGUITabControl
87
CGUITabControl(IGUIEnvironment* environment,
88
IGUIElement* parent, const core::rect<s32>& rectangle,
89
bool fillbackground=true, bool border=true, s32 id=-1);
92
virtual ~CGUITabControl();
95
virtual IGUITab* addTab(const wchar_t* caption, s32 id=-1);
97
//! Adds a tab that has already been created
98
virtual void addTab(CGUITab* tab);
100
//! Insert the tab at the given index
101
virtual IGUITab* insertTab(s32 idx, const wchar_t* caption, s32 id=-1);
103
//! Removes a tab from the tabcontrol
104
virtual void removeTab(s32 idx);
106
//! Clears the tabcontrol removing all tabs
107
virtual void clear();
109
//! Returns amount of tabs in the tabcontrol
110
virtual s32 getTabCount() const;
112
//! Returns a tab based on zero based index
113
virtual IGUITab* getTab(s32 idx) const;
115
//! Brings a tab to front.
116
virtual bool setActiveTab(s32 idx);
118
//! Brings a tab to front.
119
virtual bool setActiveTab(IGUITab *tab);
121
//! Returns which tab is currently active
122
virtual s32 getActiveTab() const;
124
//! get the the id of the tab at the given absolute coordinates
125
virtual s32 getTabAt(s32 xpos, s32 ypos) const;
127
//! called if an event happened.
128
virtual bool OnEvent(const SEvent& event);
130
//! draws the element and its children
134
virtual void removeChild(IGUIElement* child);
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 );
141
//! Reads attributes of the element
142
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options);
144
//! Get the height of the tabs
145
virtual s32 getTabHeight() const;
147
//! set the maximal width of a tab. Per default width is 0 which means "no width restriction".
148
virtual void setTabMaxWidth(s32 width );
150
//! get the maximal width of a tab
151
virtual s32 getTabMaxWidth() const;
153
//! Set the alignment of the tabs
154
//! note: EGUIA_CENTER is not an option
155
virtual void setTabVerticalAlignment( gui::EGUI_ALIGNMENT alignment );
157
//! Get the alignment of the tabs
158
virtual gui::EGUI_ALIGNMENT getTabVerticalAlignment() const;
160
//! Set the extra width added to tabs on each side of the text
161
virtual void setTabExtraWidth( s32 extraWidth );
163
//! Get the extra width added to tabs on each side of the text
164
virtual s32 getTabExtraWidth() const;
166
//! Update the position of the element, decides scroll button status
167
virtual void updateAbsolutePosition();
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();
177
void recalculateScrollButtonPlacement();
178
void recalculateScrollBar();
179
void refreshSprites();
181
core::array<CGUITab*> Tabs; // CGUITab* because we need setNumber (which is certainly not nice)
187
gui::EGUI_ALIGNMENT VerticalAlignment;
188
IGUIButton* UpButton;
189
IGUIButton* DownButton;
191
s32 CurrentScrollTabIndex;
196
} // end namespace gui
197
} // end namespace irr
199
#endif // _IRR_COMPILE_WITH_GUI_