#ifndef __C_GUI_TAB_CONTROL_H_INCLUDED__
#define __C_GUI_TAB_CONTROL_H_INCLUDED__
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "IGUITabControl.h"
#include "irrArray.h"
#include "IGUISkin.h"
namespace irr
{
namespace gui
{
class CGUITabControl;
class IGUIButton;
class CGUITab : public IGUITab
{
public:
CGUITab(s32 number, IGUIEnvironment* environment,
IGUIElement* parent, const core::rect<s32>& rectangle,
s32 id);
virtual s32 getNumber() const;
virtual void setNumber(s32 n);
virtual void draw();
virtual void setDrawBackground(bool draw=true);
virtual void setBackgroundColor(video::SColor c);
virtual void setTextColor(video::SColor c);
virtual bool isDrawingBackground() const;
virtual video::SColor getBackgroundColor() const;
virtual video::SColor getTextColor() const;
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const;
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options);
void refreshSkinColors();
private:
s32 Number;
video::SColor BackColor;
bool OverrideTextColorEnabled;
video::SColor TextColor;
bool DrawBackground;
};
class CGUITabControl : public IGUITabControl
{
public:
CGUITabControl(IGUIEnvironment* environment,
IGUIElement* parent, const core::rect<s32>& rectangle,
bool fillbackground=true, bool border=true, s32 id=-1);
virtual ~CGUITabControl();
virtual IGUITab* addTab(const wchar_t* caption, s32 id=-1);
virtual void addTab(CGUITab* tab);
virtual s32 getTabCount() const;
virtual IGUITab* getTab(s32 idx) const;
virtual bool setActiveTab(s32 idx);
virtual bool setActiveTab(IGUITab *tab);
virtual s32 getActiveTab() const;
virtual bool OnEvent(const SEvent& event);
virtual void draw();
virtual void removeChild(IGUIElement* child);
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const;
virtual void setTabHeight( s32 height );
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options);
virtual s32 getTabHeight() const;
virtual void setTabMaxWidth(s32 width );
virtual s32 getTabMaxWidth() const;
virtual void setTabVerticalAlignment( gui::EGUI_ALIGNMENT alignment );
virtual gui::EGUI_ALIGNMENT getTabVerticalAlignment() const;
virtual void setTabExtraWidth( s32 extraWidth );
virtual s32 getTabExtraWidth() const;
virtual void updateAbsolutePosition();
private:
bool selectTab(core::position2d<s32> p);
void scrollLeft();
void scrollRight();
bool needScrollControl( s32 startIndex=0, bool withScrollControl=false );
s32 calcTabWidth(s32 pos, IGUIFont* font, const wchar_t* text, bool withScrollControl );
core::rect<s32> calcTabPos();
void recalculateScrollButtonPlacement();
void recalculateScrollBar();
void refreshSprites();
core::array<CGUITab*> Tabs;
s32 ActiveTab;
bool Border;
bool FillBackground;
bool ScrollControl;
s32 TabHeight;
gui::EGUI_ALIGNMENT VerticalAlignment;
IGUIButton* UpButton;
IGUIButton* DownButton;
s32 TabMaxWidth;
s32 CurrentScrollTabIndex;
s32 TabExtraWidth;
};
}
}
#endif
#endif