void TabbedArea::widgetResized(const gcn::Event &event) { int width = getWidth() - 2 * getFrameSize() - 2 * mWidgetContainer->getFrameSize(); int height = getHeight() - 2 * getFrameSize() - mWidgetContainer->getY() - 2 * mWidgetContainer->getFrameSize(); mWidgetContainer->setSize(width, height); gcn::Widget *w = getCurrentWidget(); if (w) w->setSize(width, height); // Check whether there is room to show more tabs now. int innerWidth = getWidth() - 4 - mArrowButton[0]->getWidth() - mArrowButton[1]->getWidth(); int newWidth = mVisibleTabsWidth; while (mTabScrollIndex && newWidth < innerWidth) { newWidth += mTabs[mTabScrollIndex - 1].first->getWidth(); if (newWidth < innerWidth) --mTabScrollIndex; } // Move the right arrow to fit the windows content. mArrowButton[1]->setPosition(width - mArrowButton[1]->getWidth(), 0); updateArrowEnableState(); adjustTabPositions(); }
void TabbedArea::action(const gcn::ActionEvent& actionEvent) { Widget* source = actionEvent.getSource(); Tab* tab = dynamic_cast<Tab*>(source); if (tab) { setSelectedTab(tab); } else { if (actionEvent.getId() == "shift_left") { if (mTabScrollIndex) --mTabScrollIndex; } else if (actionEvent.getId() == "shift_right") { if (mTabScrollIndex < mTabs.size() - 1) ++mTabScrollIndex; } adjustTabPositions(); updateArrowEnableState(); } }
void TabbedArea::addTab(gcn::Tab* tab, gcn::Widget* widget) { gcn::TabbedArea::addTab(tab, widget); widget->setSize(mWidgetContainer->getWidth(), mWidgetContainer->getHeight()); updateTabsWidth(); updateArrowEnableState(); }
void TabbedArea::addTab(gcn::Tab* tab, gcn::Widget* widget) { gcn::TabbedArea::addTab(tab, widget); int width = getWidth() - 2 * getFrameSize(); int height = getHeight() - 2 * getFrameSize() - mTabContainer->getHeight(); widget->setSize(width, height); updateTabsWidth(); updateArrowEnableState(); }