2009-01-27 05:23:36 -08:00
|
|
|
// Copyright (C) 2002-2009 Nikolaus Gebhardt
|
2007-05-20 11:03:49 -07:00
|
|
|
// This file is part of the "Irrlicht Engine".
|
|
|
|
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
|
|
|
|
|
|
|
#ifndef __C_GUI_TAB_CONTROL_H_INCLUDED__
|
|
|
|
#define __C_GUI_TAB_CONTROL_H_INCLUDED__
|
|
|
|
|
2007-07-25 22:30:19 -07:00
|
|
|
#include "IrrCompileConfig.h"
|
|
|
|
#ifdef _IRR_COMPILE_WITH_GUI_
|
|
|
|
|
2007-05-20 11:03:49 -07:00
|
|
|
#include "IGUITabControl.h"
|
|
|
|
#include "irrArray.h"
|
2007-12-21 23:49:29 -08:00
|
|
|
#include "IGUISkin.h"
|
2007-05-20 11:03:49 -07:00
|
|
|
|
|
|
|
namespace irr
|
|
|
|
{
|
|
|
|
namespace gui
|
|
|
|
{
|
2007-12-21 23:49:29 -08:00
|
|
|
class CGUITabControl;
|
|
|
|
class IGUIButton;
|
|
|
|
|
2007-05-20 11:03:49 -07:00
|
|
|
// A tab, onto which other gui elements could be added.
|
|
|
|
class CGUITab : public IGUITab
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
//! constructor
|
|
|
|
CGUITab(s32 number, IGUIEnvironment* environment,
|
|
|
|
IGUIElement* parent, const core::rect<s32>& rectangle,
|
|
|
|
s32 id);
|
|
|
|
|
2007-12-21 23:49:29 -08:00
|
|
|
//! destructor
|
|
|
|
//virtual ~CGUITab();
|
|
|
|
|
2007-05-20 11:03:49 -07:00
|
|
|
//! Returns number of this tab in tabcontrol. Can be accessed
|
|
|
|
//! later IGUITabControl::getTab() by this number.
|
2007-09-15 17:18:13 -07:00
|
|
|
virtual s32 getNumber() const;
|
2007-05-20 11:03:49 -07:00
|
|
|
|
|
|
|
//! Sets the number
|
|
|
|
virtual void setNumber(s32 n);
|
|
|
|
|
|
|
|
//! draws the element and its children
|
|
|
|
virtual void draw();
|
|
|
|
|
|
|
|
//! sets if the tab should draw its background
|
|
|
|
virtual void setDrawBackground(bool draw=true);
|
|
|
|
|
|
|
|
//! sets the color of the background, if it should be drawn.
|
|
|
|
virtual void setBackgroundColor(video::SColor c);
|
2009-01-27 05:23:36 -08:00
|
|
|
|
2007-12-21 23:49:29 -08:00
|
|
|
//! sets the color of the text
|
|
|
|
virtual void setTextColor(video::SColor c);
|
2007-05-20 11:03:49 -07:00
|
|
|
|
2007-05-26 13:44:25 -07:00
|
|
|
//! returns true if the tab is drawing its background, false if not
|
|
|
|
virtual bool isDrawingBackground() const;
|
|
|
|
|
|
|
|
//! returns the color of the background
|
|
|
|
virtual video::SColor getBackgroundColor() const;
|
|
|
|
|
2007-12-21 23:49:29 -08:00
|
|
|
virtual video::SColor getTextColor() const;
|
|
|
|
|
2007-05-20 11:03:49 -07:00
|
|
|
//! Writes attributes of the element.
|
2007-09-14 15:25:59 -07:00
|
|
|
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const;
|
2007-05-20 11:03:49 -07:00
|
|
|
|
|
|
|
//! Reads attributes of the element
|
|
|
|
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options);
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
s32 Number;
|
|
|
|
video::SColor BackColor;
|
2007-12-21 23:49:29 -08:00
|
|
|
video::SColor TextColor;
|
2009-01-27 05:23:36 -08:00
|
|
|
bool DrawBackground;
|
2007-05-20 11:03:49 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//! A standard tab control
|
|
|
|
class CGUITabControl : public IGUITabControl
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
//! destructor
|
|
|
|
CGUITabControl(IGUIEnvironment* environment,
|
|
|
|
IGUIElement* parent, const core::rect<s32>& rectangle,
|
|
|
|
bool fillbackground=true, bool border=true, s32 id=-1);
|
|
|
|
|
|
|
|
//! destructor
|
|
|
|
virtual ~CGUITabControl();
|
|
|
|
|
|
|
|
//! Adds a tab
|
|
|
|
virtual IGUITab* addTab(const wchar_t* caption, s32 id=-1);
|
|
|
|
|
|
|
|
//! Adds a tab that has already been created
|
|
|
|
virtual void addTab(CGUITab* tab);
|
|
|
|
|
|
|
|
//! Returns amount of tabs in the tabcontrol
|
2007-09-15 17:18:13 -07:00
|
|
|
virtual s32 getTabCount() const;
|
2007-05-20 11:03:49 -07:00
|
|
|
|
|
|
|
//! Returns a tab based on zero based index
|
2007-09-15 17:18:13 -07:00
|
|
|
virtual IGUITab* getTab(s32 idx) const;
|
2007-05-20 11:03:49 -07:00
|
|
|
|
|
|
|
//! Brings a tab to front.
|
|
|
|
virtual bool setActiveTab(s32 idx);
|
|
|
|
|
|
|
|
//! Brings a tab to front.
|
|
|
|
virtual bool setActiveTab(IGUIElement *tab);
|
|
|
|
|
|
|
|
//! Returns which tab is currently active
|
2007-09-15 17:18:13 -07:00
|
|
|
virtual s32 getActiveTab() const;
|
2007-05-20 11:03:49 -07:00
|
|
|
|
|
|
|
//! called if an event happened.
|
2007-09-16 16:41:55 -07:00
|
|
|
virtual bool OnEvent(const SEvent& event);
|
2007-05-20 11:03:49 -07:00
|
|
|
|
|
|
|
//! draws the element and its children
|
|
|
|
virtual void draw();
|
|
|
|
|
|
|
|
//! Removes a child.
|
|
|
|
virtual void removeChild(IGUIElement* child);
|
|
|
|
|
|
|
|
//! Writes attributes of the element.
|
2007-09-14 15:25:59 -07:00
|
|
|
virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const;
|
2007-12-21 23:49:29 -08:00
|
|
|
//! Set the height of the tabs
|
|
|
|
virtual void setTabHeight( s32 height );
|
2007-05-20 11:03:49 -07:00
|
|
|
|
|
|
|
//! Reads attributes of the element
|
|
|
|
virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options);
|
2009-09-16 05:48:19 -07:00
|
|
|
|
2007-12-21 23:49:29 -08:00
|
|
|
//! Get the height of the tabs
|
|
|
|
virtual s32 getTabHeight() const;
|
|
|
|
|
2009-09-16 05:48:19 -07:00
|
|
|
//! set the maximal width of a tab. Per default width is 0 which means "no width restriction".
|
|
|
|
virtual void setTabMaxWidth(s32 width );
|
|
|
|
|
|
|
|
//! get the maximal width of a tab
|
|
|
|
virtual s32 getTabMaxWidth() const;
|
|
|
|
|
2007-12-21 23:49:29 -08:00
|
|
|
//! Set the alignment of the tabs
|
|
|
|
//! note: EGUIA_CENTER is not an option
|
|
|
|
virtual void setTabVerticalAlignment( gui::EGUI_ALIGNMENT alignment );
|
|
|
|
|
|
|
|
//! Get the alignment of the tabs
|
|
|
|
virtual gui::EGUI_ALIGNMENT getTabVerticalAlignment() const;
|
|
|
|
|
|
|
|
//! Set the extra width added to tabs on each side of the text
|
|
|
|
virtual void setTabExtraWidth( s32 extraWidth );
|
|
|
|
|
|
|
|
//! Get the extra width added to tabs on each side of the text
|
|
|
|
virtual s32 getTabExtraWidth() const;
|
|
|
|
|
|
|
|
//! Update the position of the element, decides scroll button status
|
|
|
|
virtual void updateAbsolutePosition();
|
2007-05-20 11:03:49 -07:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
2007-12-21 23:49:29 -08:00
|
|
|
bool selectTab(core::position2d<s32> p);
|
|
|
|
void scrollLeft();
|
|
|
|
void scrollRight();
|
|
|
|
bool needScrollControl( s32 startIndex=0, bool withScrollControl=false );
|
2009-09-16 05:48:19 -07:00
|
|
|
s32 calcTabWidth(s32 pos, IGUIFont* font, const wchar_t* text, bool withScrollControl );
|
2007-12-21 23:49:29 -08:00
|
|
|
|
2010-01-23 12:13:43 -08:00
|
|
|
void recalculateScrollButtonPlacement();
|
2007-12-21 23:49:29 -08:00
|
|
|
void recalculateScrollBar();
|
2007-05-20 11:03:49 -07:00
|
|
|
|
|
|
|
core::array<CGUITab*> Tabs;
|
|
|
|
s32 ActiveTab;
|
|
|
|
bool Border;
|
|
|
|
bool FillBackground;
|
2007-12-21 23:49:29 -08:00
|
|
|
bool ScrollControl;
|
|
|
|
s32 TabHeight;
|
|
|
|
gui::EGUI_ALIGNMENT VerticalAlignment;
|
|
|
|
IGUIButton* UpButton;
|
|
|
|
IGUIButton* DownButton;
|
|
|
|
s32 TabMaxWidth;
|
|
|
|
s32 CurrentScrollTabIndex;
|
|
|
|
s32 TabExtraWidth;
|
2007-05-20 11:03:49 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} // end namespace gui
|
|
|
|
} // end namespace irr
|
|
|
|
|
2007-07-25 22:30:19 -07:00
|
|
|
#endif // _IRR_COMPILE_WITH_GUI_
|
|
|
|
|
2007-05-20 11:03:49 -07:00
|
|
|
#endif
|
|
|
|
|