diff options
author | David Athay <ko2fan@gmail.com> | 2008-05-15 14:07:19 +0000 |
---|---|---|
committer | David Athay <ko2fan@gmail.com> | 2008-05-15 14:07:19 +0000 |
commit | f4c0d85edfc8c6fb0d4d436f098e841bac72f5f1 (patch) | |
tree | 34a053b8ec7995dab3b54b025764ff511a0b6954 /src/gui/widgets/tabbedarea.cpp | |
parent | 96b79b905b22bfcf4b35c26e6e70065e4ce3222c (diff) | |
download | mana-client-f4c0d85edfc8c6fb0d4d436f098e841bac72f5f1.tar.gz mana-client-f4c0d85edfc8c6fb0d4d436f098e841bac72f5f1.tar.bz2 mana-client-f4c0d85edfc8c6fb0d4d436f098e841bac72f5f1.tar.xz mana-client-f4c0d85edfc8c6fb0d4d436f098e841bac72f5f1.zip |
Added tab with image based on button
Diffstat (limited to 'src/gui/widgets/tabbedarea.cpp')
-rw-r--r-- | src/gui/widgets/tabbedarea.cpp | 41 |
1 files changed, 33 insertions, 8 deletions
diff --git a/src/gui/widgets/tabbedarea.cpp b/src/gui/widgets/tabbedarea.cpp index 7821190b..5c9403c7 100644 --- a/src/gui/widgets/tabbedarea.cpp +++ b/src/gui/widgets/tabbedarea.cpp @@ -22,6 +22,7 @@ */ #include "tabbedarea.h" +#include "tab.h" #include <guichan/widgets/container.hpp> @@ -35,15 +36,14 @@ int TabbedArea::getNumberOfTabs() return mTabs.size(); } -gcn::Tab* TabbedArea::getTab(const std::string &name) +Tab* TabbedArea::getTab(const std::string &name) { - std::vector< std::pair<gcn::Tab*, gcn::Widget*> >::iterator itr = mTabs.begin(), - itr_end = mTabs.end(); + TabContainer::iterator itr = mTabs.begin(), itr_end = mTabs.end(); while (itr != itr_end) { if ((*itr).first->getCaption() == name) { - return (*itr).first; + return static_cast<Tab*>((*itr).first); } ++itr; } @@ -62,8 +62,7 @@ void TabbedArea::draw(gcn::Graphics *graphics) gcn::Widget* TabbedArea::getWidget(const std::string &name) { - std::vector< std::pair<gcn::Tab*, gcn::Widget*> >::iterator itr = mTabs.begin(), - itr_end = mTabs.end(); + TabContainer::iterator itr = mTabs.begin(), itr_end = mTabs.end(); while (itr != itr_end) { if ((*itr).first->getCaption() == name) @@ -76,7 +75,33 @@ gcn::Widget* TabbedArea::getWidget(const std::string &name) return NULL; } -void TabbedArea::removeTab(gcn::Tab *tab) +void TabbedArea::addTab(const std::string &caption, gcn::Widget *widget) +{ + Tab* tab = new Tab(); + tab->setCaption(caption); + mTabsToDelete.push_back(tab); + + addTab(tab, widget); +} + +void TabbedArea::addTab(Tab *tab, gcn::Widget *widget) +{ + tab->setTabbedArea(this); + tab->addActionListener(this); + + mTabContainer->add(tab); + mTabs.push_back(std::pair<Tab*, gcn::Widget*>(tab, widget)); + + if (mSelectedTab == NULL) + { + setSelectedTab(tab); + } + + adjustTabPositions(); + adjustSize(); +} + +void TabbedArea::removeTab(Tab *tab) { int tabIndexToBeSelected = 0; @@ -95,7 +120,7 @@ void TabbedArea::removeTab(gcn::Tab *tab) } } - std::vector<std::pair<gcn::Tab*, gcn::Widget*> >::iterator iter; + TabContainer::iterator iter; for (iter = mTabs.begin(); iter != mTabs.end(); iter++) { if (iter->first == tab) |