Beispiel #1
0
/*************************************************************************
Layout the widgets
*************************************************************************/
void TabControl::performChildWindowLayout()
{
    Window::performChildWindowLayout();

    if (d_tabButtonPane)
    {
        // Set the size of the tab button area (full width, height from tab height)
        d_tabButtonPane->setSize(Relative, Size(1.0f, d_rel_tabHeight) );
        d_tabButtonPane->setPosition(Relative, Point(0.0f, 0.0f) );
        // Calculate the positions and sizes of the tab buttons
        TabButtonIndexMap::iterator i, iend;
        iend = d_tabButtonIndexMap.end();
        uint x = 0;
        for (i = d_tabButtonIndexMap.begin(); i != iend; ++i, ++x)
        {
            TabButton* btn = i->second;
            calculateTabButtonSizePosition(btn, x);
        }
    }
    if (d_tabContentPane)
    {
        // Set the size of the content area
        d_tabContentPane->setSize(Relative, Size(1.0f, 1.0f - d_rel_tabHeight) );
        d_tabContentPane->setPosition(Relative, Point(0.0f, d_rel_tabHeight) );
    }

}
Beispiel #2
0
/*************************************************************************
Layout the widgets
*************************************************************************/
void TabControl::performChildWindowLayout()
{
    Window* tabButtonPane = getTabButtonPane();
    Window* tabContentPane = getTabPane();

    // Enable top/bottom edges of the tabPane control,
    // if supported by looknfeel
    if (tabContentPane->isPropertyPresent (EnableTop))
        tabContentPane->setProperty (EnableTop, (d_tabPanePos == Top) ? n0 : n1);
    if (tabContentPane->isPropertyPresent (EnableBottom))
        tabContentPane->setProperty (EnableBottom, (d_tabPanePos == Top) ? n1 : n0);
    if (tabButtonPane->isPropertyPresent (EnableTop))
        tabButtonPane->setProperty (EnableTop, (d_tabPanePos == Top) ? n0 : n1);
    if (tabButtonPane->isPropertyPresent (EnableBottom))
        tabButtonPane->setProperty (EnableBottom, (d_tabPanePos == Top) ? n1 : n0);

    Window::performChildWindowLayout();

    // Calculate the size & position of the tab scroll buttons
    Window *scrollLeftBtn = 0, *scrollRightBtn = 0;
    String name = getName() + ButtonScrollLeftSuffix;
    if (WindowManager::getSingleton().isWindowPresent (name))
        scrollLeftBtn = WindowManager::getSingleton().getWindow (name);

    name = getName() + ButtonScrollRightSuffix;
    if (WindowManager::getSingleton().isWindowPresent (name))
        scrollRightBtn = WindowManager::getSingleton().getWindow (name);

    // Calculate the positions and sizes of the tab buttons
    if (d_firstTabOffset > 0)
        d_firstTabOffset = 0;

    for (;;)
    {
        size_t i;
        for (i = 0; i < d_tabButtonVector.size (); ++i)
            calculateTabButtonSizePosition (i);

        if (d_tabButtonVector.empty ())
        {
            if (scrollRightBtn)
                scrollRightBtn->setVisible (false);
            if (scrollLeftBtn)
                scrollLeftBtn->setVisible (false);
            break;
        }

        // Now check if tab pane wasn't scrolled too far
        --i;
        float xmax = d_tabButtonVector [i]->getXPosition ().d_offset +
            d_tabButtonVector [i]->getPixelSize ().d_width;
        float width = tabContentPane->getPixelSize ().d_width;

        // If right button margin exceeds right window margin,
        // or leftmost button is at offset 0, finish
        if ((xmax > (width - 0.5)) || (d_firstTabOffset == 0))
        {
            if (scrollLeftBtn)
                scrollLeftBtn->setVisible (d_firstTabOffset < 0);
            if (scrollRightBtn)
                scrollRightBtn->setVisible (xmax > width);
            break;
        }

        // Scroll the tab pane until the rightmost button
        // touches the right margin
        d_firstTabOffset += width - xmax;
        // If we scrolled it too far, set leftmost button offset to 0
        if (d_firstTabOffset > 0)
            d_firstTabOffset = 0;
    }
}