diff options
author | Philipp Sehmisch <tmw@crushnet.org> | 2007-02-27 16:31:34 +0000 |
---|---|---|
committer | Philipp Sehmisch <tmw@crushnet.org> | 2007-02-27 16:31:34 +0000 |
commit | 88a86283083800443c4f5e934fface5988c42fe8 (patch) | |
tree | fa6a26c56836d8b1f148d362eb0b6b0e0ed3ce9b /src/gui/tabbedcontainer.cpp | |
parent | a064b260e2950b5a153e51c13f579095c53a9a7a (diff) | |
download | mana-client-88a86283083800443c4f5e934fface5988c42fe8.tar.gz mana-client-88a86283083800443c4f5e934fface5988c42fe8.tar.bz2 mana-client-88a86283083800443c4f5e934fface5988c42fe8.tar.xz mana-client-88a86283083800443c4f5e934fface5988c42fe8.zip |
Tabbed containers now display the button of the active tab pressed all the time.
Diffstat (limited to 'src/gui/tabbedcontainer.cpp')
-rw-r--r-- | src/gui/tabbedcontainer.cpp | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/src/gui/tabbedcontainer.cpp b/src/gui/tabbedcontainer.cpp index 75f9f3cf..5d6d21d1 100644 --- a/src/gui/tabbedcontainer.cpp +++ b/src/gui/tabbedcontainer.cpp @@ -26,6 +26,7 @@ #include "button.h" #include "../utils/tostring.h" +#include "../utils/dtor.h" #define TABWIDTH 60 #define TABHEIGHT 20 @@ -37,10 +38,7 @@ TabbedContainer::TabbedContainer(): TabbedContainer::~TabbedContainer() { - for (WidgetIterator i = mTabs.begin(); i != mTabs.end(); i++) { - remove(*i); - delete (*i); - } + for_each(mTabs.begin(), mTabs.end(), make_dtor(mTabs)); mTabs.clear(); mContents.clear(); @@ -55,7 +53,7 @@ void TabbedContainer::addTab(gcn::Widget *widget, const std::string &caption) tab->setSize(TABWIDTH, TABHEIGHT); add(tab, TABWIDTH * tabNumber, 0); - mTabs.push_back(tab); + mTabs[caption] = tab; mContents.push_back(widget); widget->setPosition(0, TABHEIGHT); @@ -64,7 +62,18 @@ void TabbedContainer::addTab(gcn::Widget *widget, const std::string &caption) if (!mActiveContent) { mActiveContent = widget; add(mActiveContent); + tab->setLogged(true); } + + mWidgets[widget] = caption; +} + +void TabbedContainer::removeTab(const std::string &caption) +{ + gcn::ActionEvent actionEvent(this, "0"); + action(actionEvent); + remove(mTabs[caption]); + mTabs.erase(caption); } void TabbedContainer::logic() @@ -80,16 +89,21 @@ void TabbedContainer::logic() void TabbedContainer::action(const gcn::ActionEvent &event) { - std::stringstream ss(event.getId()); int tabNo; + std::stringstream ss(event.getId()); ss >> tabNo; gcn::Widget *newContent = mContents[tabNo]; + if (newContent) { if (mActiveContent) { + // Unhighlight old tab + ((Button*)mTabs[mWidgets[mActiveContent]])->setLogged(false); remove(mActiveContent); } mActiveContent = newContent; + // Highlight new tab + ((Button*)mTabs[mWidgets[mActiveContent]])->setLogged(true); add(newContent); } } @@ -98,3 +112,13 @@ void TabbedContainer::setOpaque(bool opaque) { Container::setOpaque(opaque); } + +short TabbedContainer::getNumberOfTabs() +{ + return mTabs.size(); +} + +std::string TabbedContainer::getActiveWidget() +{ + return mWidgets[mActiveContent]; +} |