/************************************************************************* 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); }
/************************************************************************* Text changed on a content window *************************************************************************/ bool TabControl::handleContentWindowTextChanged(const EventArgs& args) { // update text const WindowEventArgs& wargs = static_cast<const WindowEventArgs&>(args); Window* tabButton = getTabButtonPane()->getChild( makeButtonName(wargs.window)); tabButton->setText(wargs.window->getText()); // sort out the layout performChildWindowLayout(); invalidate(); return true; }
/************************************************************************* Remove tab button *************************************************************************/ void TabControl::removeButtonForTabContent(Window* wnd) { // get TabButton* tb = static_cast<TabButton*>( getTabButtonPane()->getChild(makeButtonName(wnd))); // remove TabButtonVector::iterator i; for (i = d_tabButtonVector.begin (); i < d_tabButtonVector.end (); ++i) if (*i == tb) { d_tabButtonVector.erase (i); break; } getTabButtonPane()->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); // Instert into map d_tabButtonVector.push_back(tb); // add the button getTabButtonPane()->addChildWindow(tb); // Subscribe to clicked event so that we can change tab tb->subscribeEvent(TabButton::EventClicked, Event::Subscriber(&TabControl::handleTabButtonClicked, this)); tb->subscribeEvent(TabButton::EventDragged, Event::Subscriber(&TabControl::handleDraggedPane, this)); tb->subscribeEvent(TabButton::EventScrolled, Event::Subscriber(&TabControl::handleWheeledPane, this)); }
/************************************************************************* 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)); }