diff -abBdpuNPr --exclude='*.svn' irrlicht-svn-ss/trunk/include/IGUITabControl.h Irrlicht_starsonata/include/IGUITabControl.h --- irrlicht-svn-ss/trunk/include/IGUITabControl.h 2007-07-26 02:11:22.000000000 +0200 +++ Irrlicht_starsonata/include/IGUITabControl.h 2008-06-13 21:16:34.000000000 +0200 @@ -7,6 +7,7 @@ #include "IGUIElement.h" #include "SColor.h" +#include "IGUISkin.h" namespace irr { @@ -34,6 +35,12 @@ namespace gui //! sets the color of the background, if it should be drawn. virtual void setBackgroundColor(video::SColor c) = 0; + //! sets the color of the text + virtual void setTextColor(video::SColor c) = 0; + + //! gets the color of the text + virtual video::SColor getTextColor() = 0; + //! returns true if the tab is drawing its background, false if not virtual bool isDrawingBackground() const = 0; @@ -66,6 +73,14 @@ namespace gui is corresponding to this tab. */ virtual IGUITab* getTab(s32 idx) = 0; + // Micha, Starsonata + //! remove tab for given index + virtual void removeTab(s32 idx) = 0; + + // Micha, Starsonata + //! remove all tabs + virtual void clearTabs() = 0; + //! Brings a tab to front. /** \param idx: number of the tab. \return Returns true if successful. */ @@ -78,6 +93,27 @@ namespace gui //! Returns which tab is currently active virtual s32 getActiveTab() = 0; + + //! Set the height of the tabs + virtual void setTabHeight( s32 height ) = 0; + + //! Get the height of the tabs + /** return Returns the height of the tabs */ + virtual s32 getTabHeight() = 0; + + //! Set the alignment of the tabs + virtual void setTabVerticalAlignment( gui::EGUI_VERTICAL_ALIGNMENT alignment ) = 0; + + //! Get the alignment of the tabs + /** return Returns the alignment of the tabs */ + virtual gui::EGUI_VERTICAL_ALIGNMENT getTabVerticalAlignment() = 0; + + //! Set the extra width added to tabs on each side of the text + virtual void setTabExtraWidth( s32 extraWidth ) = 0; + + //! Get the extra width added to tabs on each side of the text + /** return Returns the extra width of the tabs */ + virtual s32 getTabExtraWidth() = 0; }; diff -abBdpuNPr --exclude='*.svn' irrlicht-svn-ss/trunk/source/Irrlicht/CGUITabControl.cpp Irrlicht_starsonata/source/Irrlicht/CGUITabControl.cpp --- irrlicht-svn-ss/trunk/source/Irrlicht/CGUITabControl.cpp 2007-07-26 02:11:08.000000000 +0200 +++ Irrlicht_starsonata/source/Irrlicht/CGUITabControl.cpp 2008-06-13 21:15:56.000000000 +0200 @@ -3,6 +3,7 @@ // For conditions of distribution and use, see copyright notice in irrlicht.h #include "CGUITabControl.h" +#include "CGUIButton.h" #include "IGUISkin.h" #include "IGUIEnvironment.h" #include "IGUIFont.h" @@ -29,6 +31,15 @@ CGUITab::CGUITab(s32 number, IGUIEnviron #ifdef _DEBUG setDebugName("CGUITab"); #endif + + if ( Environment ) + { + IGUISkin* skin = Environment->getSkin(); + if ( skin ) + { + TextColor = skin->getColor(EGDC_BUTTON_TEXT); + } + } } @@ -81,6 +97,17 @@ void CGUITab::setBackgroundColor(video:: BackColor = c; } +//! sets the color of the text +void CGUITab::setTextColor(video::SColor c) +{ + TextColor = c; +} + +video::SColor CGUITab::getTextColor() +{ + return TextColor; +} + //! returns true if the tab is drawing its background, false if not bool CGUITab::isDrawingBackground() const { @@ -102,7 +129,7 @@ void CGUITab::serializeAttributes(io::IA out->addInt ("TabNumber", Number); out->addBool ("DrawBackground", DrawBackground); out->addColor ("BackColor", BackColor); - + out->addColor ("TextColor", TextColor); } //! Reads attributes of the element @@ -113,6 +140,7 @@ void CGUITab::deserializeAttributes(io:: setNumber(in->getAttributeAsInt("TabNumber")); setDrawBackground(in->getAttributeAsBool("DrawBackground")); setBackgroundColor(in->getAttributeAsColor("BackColor")); + setTextColor(in->getAttributeAsColor("TextColor")); if (Parent && Parent->getType() == EGUIET_TAB_CONTROL) { @@ -133,11 +161,43 @@ CGUITabControl::CGUITabControl(IGUIEnvir IGUIElement* parent, const core::rect& rectangle, bool fillbackground, bool border, s32 id) : IGUITabControl(environment, parent, id, rectangle), ActiveTab(-1), - Border(border), FillBackground(fillbackground) + Border(border), FillBackground(fillbackground), VerticalAlignment(EGVA_TOP), + UpButton(0), DownButton(0), currentScrollTabIndex(0), ScrollControl(false), TabExtraWidth(20) { #ifdef _DEBUG setDebugName("CGUITabControl"); #endif + + IGUISkin* skin = Environment->getSkin(); + + TabHeight = skin->getSize(gui::EGDS_BUTTON_HEIGHT) + 2; + + + bool NoClip = false; + + s32 h = RelativeRect.getHeight(); + + UpButton = new CGUIButton(Environment, this, -1, core::rect(RelativeRect.getWidth() - (2 * TabHeight) ,2, RelativeRect.getWidth() - TabHeight, TabHeight+2), NoClip); + if (UpButton) + { + UpButton->setSpriteBank(skin->getSpriteBank()); + UpButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_TAB_ARROW_LEFT), skin->getColor(EGDC_ICON)); + UpButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_TAB_ARROW_LEFT_PRESSED), skin->getColor(EGDC_ICON)); + UpButton->setVisible( false ); + UpButton->setOverrideFont(Environment->getBuiltInFont()); + } + + DownButton = new CGUIButton(Environment, this, -1, core::rect(RelativeRect.getWidth() - TabHeight, 2, RelativeRect.getWidth(), TabHeight+2), NoClip); + if (DownButton) + { + DownButton->setSpriteBank(skin->getSpriteBank()); + DownButton->setSprite(EGBS_BUTTON_UP, skin->getIcon(EGDI_TAB_ARROW_RIGHT), skin->getColor(EGDC_ICON)); + DownButton->setSprite(EGBS_BUTTON_DOWN, skin->getIcon(EGDI_TAB_ARROW_RIGHT_PRESSED), skin->getColor(EGDC_ICON)); + DownButton->setVisible( false ); + DownButton->setOverrideFont(Environment->getBuiltInFont()); + } + + TabMaxWidth = 2 * TabHeight; } @@ -145,9 +205,16 @@ CGUITabControl::CGUITabControl(IGUIEnvir //! destructor CGUITabControl::~CGUITabControl() { + clearTabs(); for (s32 i=0; i<(s32)Tabs.size(); ++i) if (Tabs[i]) Tabs[i]->drop(); + + if (UpButton) + UpButton->drop(); + + if (DownButton) + DownButton->drop(); } @@ -158,10 +225,23 @@ IGUITab* CGUITabControl::addTab(const wc if (!skin) return 0; - s32 tabheight = skin->getSize(gui::EGDS_BUTTON_HEIGHT) + 2; - core::rect r(1,tabheight, - AbsoluteRect.getWidth()-1, - AbsoluteRect.getHeight()-1); + core::rect r; + if ( VerticalAlignment == EGVA_TOP ) + { + r.UpperLeftCorner.X = 1; + r.UpperLeftCorner.Y = TabHeight+2; + + r.LowerRightCorner.X = AbsoluteRect.getWidth()-1; + r.LowerRightCorner.Y = AbsoluteRect.getHeight()-1; + } + else + { + r.UpperLeftCorner.X = 1; + r.UpperLeftCorner.Y = 1; + + r.LowerRightCorner.X = AbsoluteRect.getWidth()-1; + r.LowerRightCorner.Y = AbsoluteRect.getHeight()-TabHeight; + } CGUITab* tab = new CGUITab(Tabs.size(), Environment, this, r, id); @@ -173,10 +253,11 @@ IGUITab* CGUITabControl::addTab(const wc if (ActiveTab == -1) { - ActiveTab = 0; - tab->setVisible(true); + setActiveTab(0); } + RecalculateScrollBar(); + return tab; } @@ -233,16 +314,61 @@ IGUITab* CGUITabControl::getTab(s32 idx) return Tabs[idx]; } +void CGUITabControl::clearTabs() +{ + ActiveTab = -1; + for (s32 i=0; i<(s32)Tabs.size(); ++i) + { + if (Tabs[i]) + { + Tabs[i]->drop(); + } + } + Tabs.clear(); + RecalculateScrollBar(); +} + +void CGUITabControl::removeTab(s32 idx) +{ + if ( idx < 0 || idx >= (s32)Tabs.size() ) + return; + Tabs[idx]->drop(); + Tabs.erase(idx); + if ( ActiveTab >= idx ) + { + -- ActiveTab; + setActiveTab(ActiveTab); + } + RecalculateScrollBar(); +} //! called if an event happened. bool CGUITabControl::OnEvent(SEvent event) { if (!IsEnabled) - return Parent ? Parent->OnEvent(event) : false; + return IGUIElement::OnEvent(event); switch(event.EventType) { + case EET_GUI_EVENT: + switch(event.GUIEvent.EventType) + { + case gui::EGET_BUTTON_CLICKED: + if (event.GUIEvent.Caller == UpButton) + { + scrollLeft(); + return true; + } + else if (event.GUIEvent.Caller == DownButton) + { + scrollRight(); + return true; + } + break; + } + break; + case EET_MOUSE_INPUT_EVENT: switch(event.MouseInput.Event) { @@ -257,7 +383,73 @@ bool CGUITabControl::OnEvent(SEvent even break; } - return Parent ? Parent->OnEvent(event) : false; + return IGUIElement::OnEvent(event); +} + +void CGUITabControl::scrollLeft() +{ + if ( currentScrollTabIndex > 0 ) + --currentScrollTabIndex; +} + +void CGUITabControl::scrollRight() +{ + if ( currentScrollTabIndex < ((s32)Tabs.size() - 1) ) + { + if ( NeedScrollControl( currentScrollTabIndex, true ) ) + ++currentScrollTabIndex; + } +} + +bool CGUITabControl::NeedScrollControl( s32 startIndex, bool withScrollControl ) +{ + if ( startIndex >= (s32)Tabs.size() ) + startIndex -= 1; + + if ( startIndex < 0 ) + startIndex = 0; + + IGUISkin* skin = Environment->getSkin(); + if (!skin) + return false; + + IGUIFont* font = skin->getFont(); + video::IVideoDriver* driver = Environment->getVideoDriver(); + + core::rect frameRect(AbsoluteRect); + + if (Tabs.empty()) + return false; + + if (!font) + return false; + + s32 pos = frameRect.UpperLeftCorner.X + 2; + + for (s32 i=startIndex; i<(s32)Tabs.size(); ++i) + { + // get Text + const wchar_t* text = 0; + if (Tabs[i]) + text = Tabs[i]->getText(); + + // get text length + s32 len = font->getDimension(text).Width + TabExtraWidth; + + frameRect.LowerRightCorner.X += len; + + frameRect.UpperLeftCorner.X = pos; + frameRect.LowerRightCorner.X = frameRect.UpperLeftCorner.X + len; + pos += len; + + if ( withScrollControl && pos > AbsoluteRect.LowerRightCorner.X - TabMaxWidth ) + return true; + + if ( !withScrollControl && pos > AbsoluteRect.LowerRightCorner.X ) + return true; + } + + return false; } void CGUITabControl::selectTab(core::position2d p) @@ -267,22 +459,36 @@ void CGUITabControl::selectTab(core::pos core::rect frameRect(AbsoluteRect); - s32 tabheight = skin->getSize(gui::EGDS_BUTTON_HEIGHT); + if ( VerticalAlignment == EGVA_TOP ) + { frameRect.UpperLeftCorner.Y += 2; - frameRect.LowerRightCorner.Y = frameRect.UpperLeftCorner.Y + tabheight; + frameRect.LowerRightCorner.Y = frameRect.UpperLeftCorner.Y + TabHeight; + } + else + { + frameRect.UpperLeftCorner.Y = frameRect.LowerRightCorner.Y - TabHeight; + } + s32 pos = frameRect.UpperLeftCorner.X + 2; + s32 rightCornerTabArea = AbsoluteRect.LowerRightCorner.X - TabMaxWidth; - for (s32 i=0; i<(s32)Tabs.size(); ++i) + for (s32 i=currentScrollTabIndex; i<(s32)Tabs.size(); ++i) { // get Text const wchar_t* text = 0; if (Tabs[i]) text = Tabs[i]->getText(); - // get text length - s32 len = 20; - if (font) - len += font->getDimension(text).Width; + // check if we miss the place to draw at least some minimal button + if ( ScrollControl && pos+2 > rightCornerTabArea ) + return; + + // get text length in units + s32 len = font->getDimension(text).Width + TabExtraWidth; + + // check if we can't draw the whole tab + if ( ScrollControl && pos+len > rightCornerTabArea ) + len = rightCornerTabArea - pos; frameRect.UpperLeftCorner.X = pos; frameRect.LowerRightCorner.X = frameRect.UpperLeftCorner.X + len; @@ -318,26 +524,58 @@ void CGUITabControl::draw() if (!font) return; - s32 tabheight = skin->getSize(gui::EGDS_BUTTON_HEIGHT); + if ( VerticalAlignment == EGVA_TOP ) + { frameRect.UpperLeftCorner.Y += 2; - frameRect.LowerRightCorner.Y = frameRect.UpperLeftCorner.Y + tabheight; + frameRect.LowerRightCorner.Y = frameRect.UpperLeftCorner.Y + TabHeight; + } + else + { + frameRect.UpperLeftCorner.Y = frameRect.LowerRightCorner.Y - TabHeight - 1; + frameRect.LowerRightCorner.Y -= 2; + } + core::rect tr; s32 pos = frameRect.UpperLeftCorner.X + 2; + s32 rightCornerTabArea = AbsoluteRect.LowerRightCorner.X - TabMaxWidth; + + bool needLeftScroll = currentScrollTabIndex > 0; + bool needRightScroll = false; // left and right pos of the active tab s32 left = 0; s32 right = 0; - const wchar_t* activetext = 0; + CGUITab *activeTab = 0; + core::stringw activeText; - for (s32 i=0; i<(s32)Tabs.size(); ++i) + for (s32 i=currentScrollTabIndex; i<(s32)Tabs.size(); ++i) { // get Text - const wchar_t* text = 0; + core::stringw text; if (Tabs[i]) text = Tabs[i]->getText(); - // get text length - s32 len = font->getDimension(text).Width + 20; + // check if we miss the place to draw at least some minimal button + if ( ScrollControl && pos+2 > rightCornerTabArea ) + { + needRightScroll = true; + break; + } + + // get text length in units + s32 len = font->getDimension(text.c_str()).Width + TabExtraWidth; + + // check if we can't draw the whole tab + if ( ScrollControl && pos+len > rightCornerTabArea ) + { + len = rightCornerTabArea - pos; + needRightScroll = true; + + s32 charIdx = font->getCharacterFromPos(text.c_str(), len); + if ( charIdx >= 0 ) + text = text.subString(0, charIdx); + } + frameRect.UpperLeftCorner.X = pos; frameRect.LowerRightCorner.X = frameRect.UpperLeftCorner.X + len; pos += len; @@ -346,32 +584,35 @@ void CGUITabControl::draw() { left = frameRect.UpperLeftCorner.X; right = frameRect.LowerRightCorner.X; - activetext = text; + activeText = text; + activeTab = Tabs[i]; } else { - skin->draw3DTabButton(this, false, frameRect, &AbsoluteClippingRect); + skin->draw3DTabButton(this, false, frameRect, &AbsoluteClippingRect, VerticalAlignment); // draw text - font->draw(text, frameRect, skin->getColor(EGDC_BUTTON_TEXT), + font->draw(text.c_str(), frameRect, Tabs[i]->getTextColor(), true, true, &AbsoluteClippingRect); } } // draw active tab - if (left != 0 && right != 0) + if (left != 0 && right != 0 && activeTab != 0) + { + // draw upper highlight frame + if ( VerticalAlignment == EGVA_TOP ) { frameRect.UpperLeftCorner.X = left-2; frameRect.LowerRightCorner.X = right+2; frameRect.UpperLeftCorner.Y -= 2; - skin->draw3DTabButton(this, true, frameRect, &AbsoluteClippingRect); + skin->draw3DTabButton(this, true, frameRect, &AbsoluteClippingRect, VerticalAlignment); // draw text - font->draw(activetext, frameRect, skin->getColor(EGDC_BUTTON_TEXT), + font->draw(activeText.c_str(), frameRect, activeTab->getTextColor(), true, true, &AbsoluteClippingRect); - // draw upper highlight frame tr.UpperLeftCorner.X = AbsoluteRect.UpperLeftCorner.X; tr.LowerRightCorner.X = left - 1; tr.UpperLeftCorner.Y = frameRect.LowerRightCorner.Y - 1; @@ -382,12 +623,141 @@ void CGUITabControl::draw() tr.LowerRightCorner.X = AbsoluteRect.LowerRightCorner.X; skin->draw2DRectangle(this, skin->getColor(EGDC_3D_HIGH_LIGHT), tr, &AbsoluteClippingRect); } + else + { - skin->draw3DTabBody(this, Border, FillBackground, AbsoluteRect, &AbsoluteClippingRect); + frameRect.UpperLeftCorner.X = left-2; + frameRect.LowerRightCorner.X = right+2; + frameRect.LowerRightCorner.Y += 2; + + skin->draw3DTabButton(this, true, frameRect, &AbsoluteClippingRect, VerticalAlignment); + + // draw text + font->draw(activeText.c_str(), frameRect, activeTab->getTextColor(), + true, true, &AbsoluteClippingRect); + + tr.UpperLeftCorner.X = AbsoluteRect.UpperLeftCorner.X; + tr.LowerRightCorner.X = left - 1; + tr.UpperLeftCorner.Y = frameRect.UpperLeftCorner.Y - 1; + tr.LowerRightCorner.Y = frameRect.UpperLeftCorner.Y; + skin->draw2DRectangle(this, skin->getColor(EGDC_3D_DARK_SHADOW), tr, &AbsoluteClippingRect); + + tr.UpperLeftCorner.X = right; + tr.LowerRightCorner.X = AbsoluteRect.LowerRightCorner.X; + skin->draw2DRectangle(this, skin->getColor(EGDC_3D_DARK_SHADOW), tr, &AbsoluteClippingRect); + } + } + else + { + if ( VerticalAlignment == EGVA_TOP ) + { + tr.UpperLeftCorner.X = AbsoluteRect.UpperLeftCorner.X; + tr.LowerRightCorner.X = AbsoluteRect.LowerRightCorner.X; + tr.UpperLeftCorner.Y = frameRect.LowerRightCorner.Y - 1; + tr.LowerRightCorner.Y = frameRect.LowerRightCorner.Y; + skin->draw2DRectangle(this, skin->getColor(EGDC_3D_HIGH_LIGHT), tr, &AbsoluteClippingRect); + } + else + { + tr.UpperLeftCorner.X = AbsoluteRect.UpperLeftCorner.X; + tr.LowerRightCorner.X = 1000; + tr.UpperLeftCorner.Y = frameRect.UpperLeftCorner.Y - 1; + tr.LowerRightCorner.Y = frameRect.UpperLeftCorner.Y; + skin->draw2DRectangle(this, skin->getColor(EGDC_3D_DARK_SHADOW), tr, &AbsoluteClippingRect); + } + } + + skin->draw3DTabBody(this, Border, FillBackground, AbsoluteRect, &AbsoluteClippingRect, TabHeight, VerticalAlignment); + + + // enable scrollcontrols on need + if ( UpButton ) + UpButton->setEnabled(needLeftScroll); + if ( DownButton ) + DownButton->setEnabled(needRightScroll); IGUIElement::draw(); } +//! Set the height of the tabs +void CGUITabControl::setTabHeight( s32 height ) +{ + if ( height < 0 ) + height = 0; + + TabHeight = height; + + TabMaxWidth = 2 * TabHeight; + + RecalculateScrollBar(); +} + +//! Get the height of the tabs +s32 CGUITabControl::getTabHeight() +{ + return TabHeight; +} + +//! Set the extra width added to tabs on each side of the text +void CGUITabControl::setTabExtraWidth( s32 extraWidth ) +{ + if ( extraWidth < 0 ) + extraWidth = 0; + + TabExtraWidth = extraWidth; + + RecalculateScrollBar(); +} + +//! Get the extra width added to tabs on each side of the text +s32 CGUITabControl::getTabExtraWidth() +{ + return TabExtraWidth; +} + +void CGUITabControl::RecalculateScrollBar() +{ + if ( VerticalAlignment == gui::EGVA_TOP ) + { + UpButton->setRelativePosition( core::rect(RelativeRect.getWidth() - (2 * TabHeight) ,2, RelativeRect.getWidth() - TabHeight, TabHeight+2) ); + DownButton->setRelativePosition( core::rect(RelativeRect.getWidth() - TabHeight, 2, RelativeRect.getWidth(), TabHeight+2) ); + } + else + { + UpButton->setRelativePosition( core::rect(RelativeRect.getWidth() - (2 * TabHeight) ,RelativeRect.getHeight() - TabHeight, RelativeRect.getWidth() - TabHeight, RelativeRect.getHeight()-1) ); + DownButton->setRelativePosition( core::rect(RelativeRect.getWidth() - TabHeight, RelativeRect.getHeight() - TabHeight, RelativeRect.getWidth(), RelativeRect.getHeight()-1) ); + } + + ScrollControl = NeedScrollControl(); + + if ( ScrollControl ) + { + UpButton->setVisible( true ); + DownButton->setVisible( true ); + } + else + { + UpButton->setVisible( false ); + DownButton->setVisible( false ); + } + + this->bringToFront( UpButton ); + this->bringToFront( DownButton ); +} + +//! Set the alignment of the tabs +void CGUITabControl::setTabVerticalAlignment( EGUI_VERTICAL_ALIGNMENT alignment ) +{ + VerticalAlignment = alignment; + + RecalculateScrollBar(); +} + +//! Get the alignment of the tabs +EGUI_VERTICAL_ALIGNMENT CGUITabControl::getTabVerticalAlignment() +{ + return VerticalAlignment; +} //! Returns which tab is currently active s32 CGUITabControl::getActiveTab() @@ -412,18 +782,19 @@ bool CGUITabControl::setActiveTab(s32 id bool changed = (ActiveTab != idx); + if (changed) + { + if ( ActiveTab >= 0 && ActiveTab < (s32)Tabs.size() ) + Tabs[ActiveTab]->setVisible(false); + ActiveTab = idx; - for (s32 i=0; i<(s32)Tabs.size(); ++i) - if (Tabs[i]) - Tabs[i]->setVisible( i == ActiveTab ); + Tabs[ActiveTab]->setVisible(true); - if (changed) - { SEvent event; event.EventType = EET_GUI_EVENT; event.GUIEvent.Caller = this; - event.GUIEvent.Element = 0; + event.GUIEvent.Element = Tabs[ActiveTab]; event.GUIEvent.EventType = EGET_TAB_CHANGED; Parent->OnEvent(event); } @@ -457,6 +828,8 @@ void CGUITabControl::removeChild(IGUIEle // remove real element IGUIElement::removeChild(child); + + RecalculateScrollBar(); } @@ -468,7 +841,7 @@ void CGUITabControl::serializeAttributes out->addInt ("ActiveTab", ActiveTab); out->addBool("Border", Border); out->addBool("FillBackground", FillBackground); - + // TODO: new elements missing } //! Reads attributes of the element @@ -476,6 +849,7 @@ void CGUITabControl::deserializeAttribut { Border = in->getAttributeAsBool("Border"); FillBackground = in->getAttributeAsBool("FillBackground"); + // TODO: new elements missing ActiveTab = -1; diff -abBdpuNPr --exclude='*.svn' irrlicht-svn-ss/trunk/source/Irrlicht/CGUITabControl.h Irrlicht_starsonata/source/Irrlicht/CGUITabControl.h --- irrlicht-svn-ss/trunk/source/Irrlicht/CGUITabControl.h 2007-07-26 02:11:08.000000000 +0200 +++ Irrlicht_starsonata/source/Irrlicht/CGUITabControl.h 2008-06-13 21:16:24.000000000 +0200 @@ -7,11 +7,14 @@ #include "IGUITabControl.h" #include "irrArray.h" +#include "IGUISkin.h" namespace irr { namespace gui { + class IGUIButton; + // A tab, onto which other gui elements could be added. class CGUITab : public IGUITab { @@ -47,18 +53,24 @@ namespace gui //! returns the color of the background virtual video::SColor getBackgroundColor() const; + //! sets the color of the text + virtual void setTextColor(video::SColor c); + + //! gets the color of the text + virtual video::SColor getTextColor(); + //! Writes attributes of the element. virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options); //! Reads attributes of the element virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); - private: s32 Number; bool DrawBackground; video::SColor BackColor; + video::SColor TextColor; }; @@ -88,6 +100,14 @@ namespace gui //! Returns a tab based on zero based index virtual IGUITab* getTab(s32 idx); + // Micha, Starsonata + //! remove tab for given index + virtual void removeTab(s32 idx); + + // Micha, Starsonata + //! remove all tabs + virtual void clearTabs(); + //! Brings a tab to front. virtual bool setActiveTab(s32 idx); @@ -106,6 +126,24 @@ namespace gui //! Removes a child. virtual void removeChild(IGUIElement* child); + //! Set the height of the tabs + virtual void setTabHeight( s32 height ); + + //! Get the height of the tabs + virtual s32 getTabHeight(); + + //! Set the alignment of the tabs + virtual void setTabVerticalAlignment( gui::EGUI_VERTICAL_ALIGNMENT alignment ); + + //! Get the alignment of the tabs + virtual gui::EGUI_VERTICAL_ALIGNMENT getTabVerticalAlignment(); + + //! 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(); + //! Writes attributes of the element. virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options); @@ -115,11 +153,24 @@ namespace gui private: void selectTab(core::position2d p); + void scrollLeft(); + void scrollRight(); + bool NeedScrollControl( s32 startIndex=0, bool withScrollControl=false ); + + void RecalculateScrollBar(); core::array Tabs; s32 ActiveTab; bool Border; bool FillBackground; + bool ScrollControl; + s32 TabHeight; + gui::EGUI_VERTICAL_ALIGNMENT VerticalAlignment; + IGUIButton* UpButton; + IGUIButton* DownButton; + s32 TabMaxWidth; + s32 currentScrollTabIndex; + s32 TabExtraWidth; };