/************************************************************************* Remove tab button *************************************************************************/ void TabControl::removeButtonForTabContent(Window* wnd) { // get TabButton* tb = static_cast<TabButton*>( d_tabButtonPane->getChild(makeButtonName(wnd))); // remove d_tabButtonIndexMap.erase(tb->getTabIndex()); d_tabButtonPane->removeChildWindow(tb); // destroy WindowManager::getSingleton().destroyWindow(tb); }
/************************************************************************* Add tab button *************************************************************************/ void TabControl::addButtonForTabContent(Window* wnd) { // Create the button TabButton* tb = createTabButton(makeButtonName(wnd)); // Copy font tb->setFont(getFont()); // Set target window tb->setTargetWindow(wnd); // Set index tb->setTabIndex(d_nextTabIndex++); // Instert into map d_tabButtonIndexMap.insert( TabButtonIndexMap::value_type(tb->getTabIndex(), tb)); // add the button d_tabButtonPane->addChildWindow(tb); // Subscribe to clicked event so that we can change tab tb->subscribeEvent(TabButton::EventClicked, Event::Subscriber(&TabControl::handleTabButtonClicked, this)); }