예제 #1
0
void TabbedArea::keyPressed(gcn::KeyEvent& keyEvent)
{
    if (keyEvent.isConsumed() || !isFocused())
        return;

    if (keyEvent.getKey().getValue() == Key::LEFT)
    {
        TabContainer::iterator index = getTabIterator(mSelectedTab);

        if (index != mTabs.begin())
            setSelectedTab((--index)->first);
        else
            setSelectedTab((--mTabs.end())->first);

        keyEvent.consume();
    }
    else if (keyEvent.getKey().getValue() == Key::RIGHT)
    {
        TabContainer::iterator index = getTabIterator(mSelectedTab);

        if (index != (--mTabs.end()))
            setSelectedTab((++index)->first);
        else
            setSelectedTab(mTabs.begin()->first);

        keyEvent.consume();
    }
}
예제 #2
0
void TabbedArea::keyPressed(gcn::KeyEvent& keyEvent)
{
    if (keyEvent.isConsumed() || !isFocused())
        return;

    if (keyEvent.getKey().getValue() == Key::LEFT)
    {
        int index = getSelectedTabIndex();
        index--;

        if (index < 0)
            setSelectedTab(mTabs[mTabs.size() - 1].first);
        else
            setSelectedTab(mTabs[index].first);

        keyEvent.consume();
    }
    else if (keyEvent.getKey().getValue() == Key::RIGHT)
    {
        int index = getSelectedTabIndex();
        index++;

        if (index >= (int) mTabs.size())
            setSelectedTab(mTabs[0].first);
        else
            setSelectedTab(mTabs[index].first);

        keyEvent.consume();
    }
}
예제 #3
0
bool TabViewController::handleEvent(Ion::Events::Event event) {
  if (event == Ion::Events::Back) {
    if (app()->firstResponder() != this) {
      app()->setFirstResponder(this);
      return true;
    }
    return false;
  }
  if (app()->firstResponder() != this) {
    return false;
  }
  if (event == Ion::Events::Left) {
    if (m_dataSource->selectedTab() > 0) {
      setSelectedTab(m_dataSource->selectedTab()-1);
    }
    return true;
  }
  if (event == Ion::Events::Right) {
    if (m_dataSource->selectedTab() < m_numberOfChildren-1) {
      setSelectedTab(m_dataSource->selectedTab()+1);
    }
    return true;
  }
  if (event == Ion::Events::Down) {
    setActiveTab(m_dataSource->activeTab());
    return true;
  }
  if (event == Ion::Events::OK || event == Ion::Events::EXE) {
    setActiveTab(m_dataSource->selectedTab());
    return true;
  }
  return false;
}
예제 #4
0
/*************************************************************************
Remove a tab by ID
*************************************************************************/
void TabControl::removeTab(uint ID)
{
    // do nothing if given window is not attached as a tab.
    if (!d_tabContentPane->isChild(ID))
        return;

    Window* wnd = d_tabContentPane->getChild(ID);
    // Was this selected?
    bool reselect = wnd->isVisible();
    // Tab buttons are the 2nd onward children
    d_tabContentPane->removeChildWindow(ID);

    // remove button too
    removeButtonForTabContent(wnd);

    if (reselect)
    {
        // Select another tab
        if (getTabCount() > 0)
        {
            setSelectedTab(d_tabContentPane->getChildAtIdx(0)->getName());
        }
    }

    performChildWindowLayout();

    requestRedraw();

}
예제 #5
0
    void TabbedArea::mousePressed(MouseEvent& mouseEvent)
    {
        if (mouseEvent.isConsumed())
        {
            return;
        }

        if (mouseEvent.getButton() == MouseEvent::LEFT)
        {
            Widget* widget = mTabContainer->getWidgetAt(mouseEvent.getX(), mouseEvent.getY());
            Tab* tab = dynamic_cast<Tab*>(widget);

            if (tab != NULL)
            {
                setSelectedTab(tab);
            }
        }

        // Request focus only if the source of the event
        // is not focusble. If the source of the event
        // is focused we don't want to steal the focus.
        if (!mouseEvent.getSource()->isFocusable())
        {
            requestFocus();
        }
    }
예제 #6
0
파일: tabbedarea.cpp 프로젝트: B-Rich/mana
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();
    }
}
예제 #7
0
/*************************************************************************
Add a new tab
*************************************************************************/
void TabControl::addTab(Window* wnd)
{
    // abort attempts to add null window pointers, but log it for tracking.
    if (!wnd)
    {
        Logger::getSingleton().logEvent("Attempt to add null window pointer as "
            "tab to TabControl '" + getName() + "'.  Ignoring!", Informative);

        return;
    }

    // Create a new TabButton
    addButtonForTabContent(wnd);
    // Add the window to the content pane
    getTabPane()->addChildWindow(wnd);
    // Auto-select?
    if (getTabCount() == 1)
        setSelectedTab(wnd->getName());
    else
        // initialise invisible content
        wnd->setVisible(false);

	// when adding the 1st page, autosize tab pane height
    if (d_tabHeight.d_scale == 0 && d_tabHeight.d_offset == -1)
        d_tabHeight.d_offset = 8 + getFont()->getFontHeight ();

    // Just request redraw
    performChildWindowLayout();
    invalidate();
    // Subscribe to text changed event so that we can resize as needed
    d_eventConnections[wnd] =
        wnd->subscribeEvent(Window::EventTextChanged,
            Event::Subscriber(&TabControl::handleContentWindowTextChanged,
                              this));
}
예제 #8
0
  void TabbedPane::removeTab( int index )
  {
    if(index < 0 || index >= (int)tabs.size())
    {
      return;
    }

    int newSelectedIndex = getSelectedIndex();

    if(newSelectedIndex > 0 && tabs.size() >= 2)
    {
      newSelectedIndex--;
    }
    else if(newSelectedIndex == 0 && tabs.size() == 1)
    {
      newSelectedIndex = -1;
    }

    tabs[index].first->setTabPane(NULL);

    tabContainer->remove(tabs[index].first);
    tabs.erase(tabs.begin() + index);

    for(std::vector<TabbedPaneListener*>::iterator it = tabListeners.begin();
      it != tabListeners.end(); ++it)
    {
      (*it)->tabRemoved(this,tabs[index].first);
    }

    setSelectedTab(newSelectedIndex);
    
  }
예제 #9
0
  void TabbedPane::addTab( Tab *tab, Widget *content )
  {
    if(!tab || !content)
    {
      return;
    }

    tab->setTabPane(this);
    tabs.push_back(std::pair<Tab*,Widget*>(tab,content));
    
    tabContainer->add(tab);

    if(tabs.size() == 1 && getSelectedTab() == NULL)
    {
      setSelectedTab(tab);
    }

    adjustSize();

    for(std::vector<TabbedPaneListener*>::iterator it = tabListeners.begin();
      it != tabListeners.end(); ++it)
    {
      (*it)->tabAdded(this,tab,content);
    }

  }
예제 #10
0
 void TabbedPane::keyDown( KeyEvent &keyEvent )
 {
   if(keyEvent.getExtendedKey() == EXT_KEY_LEFT)
   {
     if(getSelectedIndex() > 0)
     {
       setSelectedTab(getSelectedIndex() - 1);
       keyEvent.consume();
     }
   }
   else if(keyEvent.getExtendedKey() == EXT_KEY_RIGHT)
   {
     setSelectedTab(getSelectedIndex() + 1);
     keyEvent.consume();
   }
 }
예제 #11
0
void TabHeaderControl::addTab(const TabHeader& tabHeader)
{
	tabHeaders.add(new TabHeader(tabHeader));
	setNumTabs(tabHeaders.size());
	setSelectedTab(tabHeaders.size()-1);
	adjustLabels();
}
예제 #12
0
    void TabbedArea::removeTab(Tab* tab)
    {
        int tabIndexToBeSelected = - 1;

        if (tab == mSelectedTab)
        {
            int index = getSelectedTabIndex();

            if (index == (int)mTabs.size() - 1
                && mTabs.size() >= 2)
            {
                tabIndexToBeSelected = index--;
            }
            else if (index == (int)mTabs.size() - 1
                     && mTabs.size() == 1)
            {
                tabIndexToBeSelected = -1;
            }
            else
            {
                tabIndexToBeSelected = index;
            }
        }

        std::vector<std::pair<Tab*, Widget*> >::iterator iter;
        for (iter = mTabs.begin(); iter != mTabs.end(); iter++)
        {
            if (iter->first == tab)
            {
                mTabContainer->remove(tab);
                mTabs.erase(iter);
                break;
            }
        }

        std::vector<Tab*>::iterator iter2;
        for (iter2 = mTabsToDelete.begin(); iter2 != mTabsToDelete.end(); iter2++)
        {
            if (*iter2 == tab)
            {
                mTabsToDelete.erase(iter2);
                delete tab;
                break;
            }
        }

        if (tabIndexToBeSelected == -1)
        {
            mSelectedTab = NULL;
            mWidgetContainer->clear();
        }
        else
        {
            setSelectedTab(tabIndexToBeSelected);
        }

        adjustSize();
        adjustTabPositions();
    }
예제 #13
0
  void TabbedPane::setSelectedTab( Tab *tab )
  {
    if(tab == NULL)
    {
      setSelectedTab(-1);
      return;
    }

    int foundIndex = getIndex(tab);
    if(foundIndex != -1)
    {
      setSelectedTab(foundIndex);
    }



  }
예제 #14
0
/*************************************************************************
Tab button clicked
*************************************************************************/
bool TabControl::handleTabButtonClicked(const EventArgs& args)
{
    const WindowEventArgs& wargs = static_cast<const WindowEventArgs&>(args);
    TabButton* tabButton = static_cast<TabButton*>(wargs.window);
    setSelectedTab(tabButton->getTargetWindow()->getName());

	return true;
}
예제 #15
0
void TabbedArea::action(const gcn::ActionEvent& actionEvent)
{
    gcn::Widget* source = actionEvent.getSource();
    Tab* tab = dynamic_cast<Tab*>(source);

    if (tab != NULL)
        setSelectedTab(tab);
}
예제 #16
0
void TabbedArea::removeTab(Tab *tab)
{
    // If the tab isn't contained in this tabbed area, ignore the removal
    // request
    if (!contains(tab))
        return;

    // Ensure that we only permanently delete tabs which we created locally
    std::list<Tab*>::iterator itr = mTabsToDelete.begin(),
                              itr_end = mTabsToDelete.end();
    while (itr != itr_end)
    {
        if (*itr == tab)
        {
            mTabContainer->scheduleDelete(tab);
            mTabsToDelete.remove(*itr); // Remove the tab from the to
            // delete list, since the container
            // is taking care of this
            break;
        }

        ++itr;
    }

    // Change the selected tab if the tab to be deleted is currently selected
    TabContainer::iterator tabItr = getTabIterator(tab);
    if (tab == mSelectedTab)
    {
        if (tabItr != mTabs.end())
        {
            setSelectedTab((*(++tabItr)).first);
            --tabItr;
        }
        else if (mTabs.size() > 1)
            setSelectedTab((*(--mTabs.end())).first);
        else
            setSelectedTab(NULL);
    }

    tabItr = mTabs.erase(tabItr);

    setFocusable(mHideWhenOneTab ? mTabs.size() > 1 : !mTabs.empty());

    // Fix tab positioning
    fontChanged();
}
예제 #17
0
    void TabbedArea::setSelectedTab(unsigned int index)
    {
        if (index >= mTabs.size())
        {
            throw GCN_EXCEPTION("No such tab index.");
        }

        setSelectedTab(mTabs[index].first);
    }
예제 #18
0
    void TabbedArea::action(const ActionEvent& actionEvent)
    {
        Widget* source = actionEvent.getSource();
        Tab* tab = dynamic_cast<Tab*>(source);

        if (tab == NULL)
        {
            throw GCN_EXCEPTION("Received an action from a widget that's not a tab!");
        }

        setSelectedTab(tab);
    }
예제 #19
0
    void TabbedArea::keyPressed(KeyEvent& keyEvent)
    {
        if (keyEvent.isConsumed() || !isFocused())
        {
            return;
        }

        if (keyEvent.getKey().getValue() == Key::Left)
        {
            int index = getSelectedTabIndex();
            index--;

            if (index < 0)
            {
                return;
            }
            else
            {
                setSelectedTab(mTabs[index].first);
            }

            keyEvent.consume();
        }
        else if (keyEvent.getKey().getValue() == Key::Right)
        {
            int index = getSelectedTabIndex();
            index++;

            if (index >= (int)mTabs.size())
            {
                return;
            }
            else
            {
                setSelectedTab(mTabs[index].first);
            }

            keyEvent.consume();
        }
    }
예제 #20
0
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)
        setSelectedTab(tab);

    adjustTabPositions();
    adjustSize();
}
예제 #21
0
파일: tabbedarea.cpp 프로젝트: B-Rich/mana
void TabbedArea::mousePressed(gcn::MouseEvent &mouseEvent)
{
    if (mouseEvent.isConsumed())
        return;

    if (mouseEvent.getButton() == gcn::MouseEvent::LEFT)
    {
        gcn::Widget *widget = mTabContainer->getWidgetAt(mouseEvent.getX(),
                                                         mouseEvent.getY());
        gcn::Tab *tab = dynamic_cast<gcn::Tab*>(widget);

        if (tab)
        {
            setSelectedTab(tab);
            requestFocus();
        }
    }
}
예제 #22
0
파일: tabbedarea.cpp 프로젝트: B-Rich/mana
void TabbedArea::removeTab(Tab *tab)
{
    if (tab == mSelectedTab)
    {
        if (getNumberOfTabs() > 1)
            setSelectedTab(std::max(0, getSelectedTabIndex() - 1));
        else
            mSelectedTab = 0;
    }

    TabContainer::iterator iter;
    for (iter = mTabs.begin(); iter != mTabs.end(); iter++)
    {
        if (iter->first == tab)
        {
            mTabContainer->remove(tab);
            mTabs.erase(iter);
            break;
        }
    }

    std::vector<gcn::Tab*>::iterator iter2;
    for (iter2 = mTabsToDelete.begin(); iter2 != mTabsToDelete.end(); iter2++)
    {
        if (*iter2 == tab)
        {
            mTabsToDelete.erase(iter2);
            delete tab;
            break;
        }
    }

    adjustSize();
    updateTabsWidth();
    adjustTabPositions();
}
예제 #23
0
/*************************************************************************
Add a new tab
*************************************************************************/
void TabControl::addTab(Window* wnd)
{
    // Create a new TabButton
    addButtonForTabContent(wnd);
    // Add the window to the content pane
    d_tabContentPane->addChildWindow(wnd);
    // Auto-select?
    if (getTabCount() == 1)
    {
        setSelectedTab(wnd->getName());
    }
    else
    {
        // initialise invisible content
        wnd->setVisible(false);
    }
    // Just request redraw
    performChildWindowLayout();
    requestRedraw();
    // Subscribe to text changed event so that we can resize as needed
    wnd->subscribeEvent(Window::EventTextChanged, 
        Event::Subscriber(&TabControl::handleContentWindowTextChanged, this));

}
예제 #24
0
void TabControl::removeTab_impl(Window* window)
{
    // silently abort if window to be removed is 0.
    if (!window)
        return;

    // delete connection to event we subscribed earlier
    d_eventConnections.erase(window);
    // Was this selected?
    bool reselect = window->isVisible();
    // Tab buttons are the 2nd onward children
    getTabPane()->removeChildWindow(window);

    // remove button too
    removeButtonForTabContent(window);

    if (reselect && (getTabCount() > 0))
        // Select another tab
        setSelectedTab(getTabPane()->getChildAtIdx(0)->getName());

    performChildWindowLayout();

    invalidate();
}
예제 #25
0
void TabViewController::didBecomeFirstResponder() {
  setSelectedTab(m_dataSource->activeTab());
}
예제 #26
0
void TabViewController::willResignFirstResponder() {
  setSelectedTab(-1);
}