void InternalWindow::getTitlebarBounds(Pnt2f& TopLeft, Pnt2f& BottomRight) const
{
    if(getDrawDecorations() && getDrawTitlebar() && getDrawnBorder()->getType().isDerivedFrom(WindowBorder::getClassType()))
    {
        dynamic_pointer_cast<WindowBorder>(getDrawnBorder())->getTitlebarBounds(0, 0, getSize().x(), getSize().y(), TopLeft, BottomRight);
    }
    else
    {
        TopLeft.setValues(0,0);
        BottomRight.setValues(0,0);
    }
}
Example #2
0
void InternalWindow::drawInternal(Graphics* const TheGraphics, Real32 Opacity) const
{
    Inherited::drawInternal(TheGraphics, Opacity);

    //If I have an active TitleBar then draw it
    if(getDrawDecorations() && getDrawTitlebar() && getTitlebar() != NULL)
    {
        getTitlebar()->draw(TheGraphics, Opacity*getOpacity());
    }

    //If I have a MenuBar then Draw it
    if(getMenuBar() != NULL)
    {
        getMenuBar()->draw(TheGraphics, Opacity*getOpacity());
    }
}
void InternalWindow::updateLayout(void)
{
    //If I have a MenuBar Update it's layout
    if(getMenuBar() != NULL)
    {
        Pnt2f MenuTopLeft, MenuBottomRight;
        getMenuBar()->updateLayout();
        getMenuBarBounds(MenuTopLeft, MenuBottomRight);
        getMenuBar()->setPosition(MenuTopLeft);
        getMenuBar()->setSize(Vec2f( MenuBottomRight.x() - MenuTopLeft.x(), getMenuBar()->getPreferredSize().y()));
    }

    //If I have a Titlebar then update it's layout
    if(getDrawDecorations() && getDrawTitlebar() && getTitlebar() != NULL)
    {
        Pnt2f TitlebarTopLeft, TitlebarBottomRight;
        getTitlebarBounds(TitlebarTopLeft, TitlebarBottomRight);
        getTitlebar()->setPosition(TitlebarTopLeft);
        getTitlebar()->setSize(Vec2f( TitlebarBottomRight.x() - TitlebarTopLeft.x(), getTitlebar()->getPreferredSize().y()));
    }

    ComponentContainer::updateLayout();
}
Example #4
0
void InternalWindow::changed(ConstFieldMaskArg whichField, 
                             UInt32            origin,
                             BitVector         details)
{
    if( ((whichField & FocusedFieldMask) ||
         (whichField & TitlebarFieldMask))&&
         getTitlebar() != NULL &&
         getDrawTitlebar() &&
         !getTitlebar()->getEnabled())
    {
        getTitlebar()->setEnabled(getFocused());
    }

    if( (whichField & ActiveToolTipFieldMask) &&
        getActiveToolTip() != NULL)
    {
        getActiveToolTip()->updateClipBounds();
    }

    if( (whichField & ActivePopupMenusFieldMask) &&
        getMFActivePopupMenus()->size() > 0)
    {
        _PopupConnections.clear();
        for(UInt32 i(0) ; i<getMFActivePopupMenus()->size() ; ++i)
        {
            getActivePopupMenus(i)->setParentWindow(this);
            _PopupConnections[getActivePopupMenus(i)].push_back(boost::shared_ptr<boost::signals2::scoped_connection>(new boost::signals2::scoped_connection(getParentDrawingSurface()->getEventProducer()->connectMouseClicked(boost::bind(&InternalWindow::popupMenuMousePressed, this, _1)))));
            _PopupConnections[getActivePopupMenus(i)].push_back(boost::shared_ptr<boost::signals2::scoped_connection>(new boost::signals2::scoped_connection(getParentDrawingSurface()->getEventProducer()->connectMousePressed(boost::bind(&InternalWindow::popupMenuMousePressed, this, _1)))));
            _PopupConnections[getActivePopupMenus(i)].push_back(boost::shared_ptr<boost::signals2::scoped_connection>(new boost::signals2::scoped_connection(getParentDrawingSurface()->getEventProducer()->connectMouseReleased(boost::bind(&InternalWindow::popupMenuMouseReleased, this, _1)))));
            _PopupConnections[getActivePopupMenus(i)].push_back(boost::shared_ptr<boost::signals2::scoped_connection>(new boost::signals2::scoped_connection(getParentDrawingSurface()->getEventProducer()->connectKeyPressed(boost::bind(&InternalWindow::popupMenuKeyPressed, this, _1)))));
            _PopupConnections[getActivePopupMenus(i)].push_back(boost::shared_ptr<boost::signals2::scoped_connection>(new boost::signals2::scoped_connection(getParentDrawingSurface()->getEventProducer()->connectMouseMoved(boost::bind(&InternalWindow::popupMenuMouseMoved, this, _1)))));
            _PopupConnections[getActivePopupMenus(i)].push_back(boost::shared_ptr<boost::signals2::scoped_connection>(new boost::signals2::scoped_connection(getParentDrawingSurface()->getEventProducer()->connectMouseDragged(boost::bind(&InternalWindow::popupMenuMouseDragged, this, _1)))));
        }
        setLockInput(true);
    }

    if( (whichField & MenuBarFieldMask) && getMenuBar() != NULL)
    {
        getMenuBar()->setParentWindow(this);
    }

    if( (whichField & MenuBarFieldMask) || (whichField & TitlebarFieldMask))
    {
        updateLayout();
    }

    if( (whichField & TitleFieldMask) && getTitlebar() != NULL)
    {
        getTitlebar()->setTitle(getTitle());
    }

    if( (whichField & TitlebarFieldMask) && getTitlebar() != NULL)
    {
        getTitlebar()->setParentWindow(this);
    }

    if((whichField & TitlebarFieldMask) ||
       (whichField & BorderFieldMask) ||
       (whichField & DisabledBorderFieldMask) ||
       (whichField & FocusedBorderFieldMask) ||
       (whichField & RolloverBorderFieldMask) ||
       (whichField & DrawTitlebarFieldMask))
    {
        TitlebarRefPtr TheTitlebar;
        if(getDrawTitlebar())
        {
            TheTitlebar = getTitlebar();
        }
        else
        {
            TheTitlebar = NULL;
        }

        if(getBorder() != NULL && getBorder()->getType().isDerivedFrom(WindowBorder::getClassType()))
        {
            dynamic_cast<WindowBorder*>(getBorder())->setTitlebar(TheTitlebar);
        }
        if(getDisabledBorder() != NULL && getDisabledBorder()->getType().isDerivedFrom(WindowBorder::getClassType()))
        {
            dynamic_cast<WindowBorder*>(getDisabledBorder())->setTitlebar(TheTitlebar);
        }
        if(getFocusedBorder() != NULL && getFocusedBorder()->getType().isDerivedFrom(WindowBorder::getClassType()))
        {
            dynamic_cast<WindowBorder*>(getFocusedBorder())->setTitlebar(TheTitlebar);
        }
        if(getRolloverBorder() != NULL && getRolloverBorder()->getType().isDerivedFrom(WindowBorder::getClassType()))
        {
            dynamic_cast<WindowBorder*>(getRolloverBorder())->setTitlebar(TheTitlebar);
        }
    }

    if( whichField & ClipBoundsFieldMask)
    {
        if(getTitlebar() != NULL)
        {
            getTitlebar()->updateClipBounds();
        }
    }

    if( (whichField & TitlebarFieldMask) &&
        getTitlebar() != NULL)
    {
        if(getTitlebar()->getTitleLabel() != NULL)
        {
            _TitleBarMousePressedConnection = getTitlebar()->getTitleLabel()->connectMousePressed(boost::bind(&InternalWindow::titlebarMousePressed, this, _1));
        }
        if(getTitlebar()->getCloseButton() != NULL)
        {
            _CloseButtonActionConnection = getTitlebar()->getCloseButton()->connectActionPerformed(boost::bind(&InternalWindow::closeButtonAction, this, _1));
        }
        if(getTitlebar()->getMaximizeButton() != NULL)
        {
            _MaximizeButtonActionConnection = getTitlebar()->getMaximizeButton()->connectActionPerformed(boost::bind(&InternalWindow::maximizeButtonAction, this, _1));
        }
        if(getTitlebar()->getIconifyButton() != NULL)
        {
            _IconifyButtonActionConnection = getTitlebar()->getIconifyButton()->connectActionPerformed(boost::bind(&InternalWindow::iconifyButtonAction, this, _1));
        }
    }

    if( (whichField & IconableFieldMask) &&
        getTitlebar() != NULL)
    {
        getTitlebar()->setDrawIconify(getIconable());
    }
    if( (whichField & MaximizableFieldMask) &&
        getTitlebar() != NULL)
    {
        getTitlebar()->setDrawMaximize(getMaximizable());
    }
    if( (whichField & ClosableFieldMask) &&
        getTitlebar() != NULL)
    {
        getTitlebar()->setDrawClose(getClosable());
    }

    Inherited::changed(whichField, origin, details);
}
Example #5
0
InternalWindow::WindowArea InternalWindow::getCursurArea(const Pnt2f& DrawingSurfaceLocation) const
{
    Pnt2f LocationInWindow(DrawingSurfaceToComponent(DrawingSurfaceLocation, this));
    if(LocationInWindow.x() < 0 ||
       LocationInWindow.x() > getSize().x() ||
       LocationInWindow.y() < 0 ||
       LocationInWindow.y() > getSize().y())
    {
        return WINDOW_OUTSIDE;
    }
    else
    {
        if(getDrawDecorations())
        {
            Pnt2f TitlebarTopLeft, TitlebarBottomRight;
            getTitlebarBounds(TitlebarTopLeft, TitlebarBottomRight);
            //Borders
            if(LocationInWindow.x() < getResizeModifyCursorWidth() || 
               LocationInWindow.y() < getResizeModifyCursorWidth() ||
               LocationInWindow.x() > (getSize().x() - getResizeModifyCursorWidth()) || 
               LocationInWindow.y() > (getSize().y() - getResizeModifyCursorWidth()))
            {
                //Top Left
                if(LocationInWindow.x() >= 0 &&
                   LocationInWindow.x() < getResizeModifyCursorWidth() &&
                   LocationInWindow.y() >= 0 &&
                   LocationInWindow.y() < getResizeModifyCursorWidth())
                {
                    return WINDOW_TOP_LEFT_BORDER;
                }
                //Bottom Right
                else if(LocationInWindow.x() >= getSize().x() - getResizeModifyCursorWidth() &&
                        LocationInWindow.x() < getSize().x() &&
                        LocationInWindow.y() >= getSize().y() - getResizeModifyCursorWidth() &&
                        LocationInWindow.y() < getSize().y())
                {
                    return WINDOW_BOTTOM_RIGHT_BORDER;
                }
                //Top Right
                else if(LocationInWindow.x() >= getSize().x() - getResizeModifyCursorWidth() &&
                        LocationInWindow.x() < getSize().x() &&
                        LocationInWindow.y() >= 0 &&
                        LocationInWindow.y() < getResizeModifyCursorWidth())
                {
                    return WINDOW_TOP_RIGHT_BORDER;
                }
                //Bottom Left
                else if(LocationInWindow.x() >= 0 &&
                        LocationInWindow.x() < getResizeModifyCursorWidth() &&
                        LocationInWindow.y() >= getSize().y() - getResizeModifyCursorWidth() &&
                        LocationInWindow.y() < getSize().y())
                {
                    return WINDOW_BOTTOM_LEFT_BORDER;
                }
                //Left
                else if(LocationInWindow.x() >= 0 &&
                        LocationInWindow.x() < getResizeModifyCursorWidth() &&
                        LocationInWindow.y() >= getResizeModifyCursorWidth() &&
                        LocationInWindow.y() < getSize().y() - getResizeModifyCursorWidth())
                {
                    return WINDOW_LEFT_BORDER;
                }
                //Right
                else if(LocationInWindow.x() >= getSize().x() - getResizeModifyCursorWidth() &&
                        LocationInWindow.x() < getSize().x() &&
                        LocationInWindow.y() >= getResizeModifyCursorWidth() &&
                        LocationInWindow.y() < getSize().y() - getResizeModifyCursorWidth())
                {
                    return WINDOW_RIGHT_BORDER;
                }
                //Top
                else if(LocationInWindow.x() >= getResizeModifyCursorWidth() &&
                        LocationInWindow.x() < getSize().x() - getResizeModifyCursorWidth() &&
                        LocationInWindow.y() >= 0 &&
                        LocationInWindow.y() < getResizeModifyCursorWidth())
                {
                    return WINDOW_TOP_BORDER;
                }
                //Bottom
                else if(
                        (LocationInWindow.x() >= getResizeModifyCursorWidth() &&
                         LocationInWindow.x() < getSize().x() - getResizeModifyCursorWidth() &&
                         LocationInWindow.y() >= getSize().y() - getResizeModifyCursorWidth() &&
                         LocationInWindow.y() < getSize().y()))
                {
                    return WINDOW_BOTTOM_BORDER;
                }
            }
            //Title bar
            else if(getDrawTitlebar() && isContainedBounds(LocationInWindow, TitlebarTopLeft, TitlebarBottomRight))
            {
                return WINDOW_TITLE_BAR;
            }
            //Main Panel
            else
            {
                return WINDOW_MAIN_PANEL;
            }
        }
        else
        {
            return WINDOW_MAIN_PANEL;
        }
    }
}
void InternalWindow::changed(ConstFieldMaskArg whichField, 
                             UInt32            origin,
                             BitVector         details)
{
    if( ((whichField & FocusedFieldMask) ||
         (whichField & TitlebarFieldMask))&&
        getTitlebar() != NULL)
    {
        getTitlebar()->setEnabled(getFocused());
    }

    if( (whichField & ActiveToolTipFieldMask) &&
        getActiveToolTip() != NULL)
    {
        getActiveToolTip()->updateClipBounds();
    }

    if( (whichField & ActivePopupMenusFieldMask) &&
        getMFActivePopupMenus()->size() > 0)
    {
        for(UInt32 i(0) ; i<getMFActivePopupMenus()->size() ; ++i)
        {
            getActivePopupMenus(i)->setParentContainer(this);
            getActivePopupMenus(i)->setParentWindow(this);
        }

        getDrawingSurface()->getEventProducer()->addMouseListener(&_PopupMenuInteractionListener);
        getDrawingSurface()->getEventProducer()->addMouseMotionListener(&_PopupMenuInteractionListener);
        getDrawingSurface()->getEventProducer()->addKeyListener(&_PopupMenuInteractionListener);
        setLockInput(true);
    }

    if( (whichField & MenuBarFieldMask) && getMenuBar() != NULL)
    {
        getMenuBar()->setParentContainer(this);
        getMenuBar()->setParentWindow(this);
    }

    if( (whichField & MenuBarFieldMask) || (whichField & TitlebarFieldMask))
    {
        updateLayout();
    }

    if( (whichField & TitleFieldMask) && getTitlebar() != NULL)
    {
        getTitlebar()->setTitle(getTitle());
    }

    if( (whichField & TitlebarFieldMask) && getTitlebar() != NULL)
    {
        getTitlebar()->setParentContainer(this);
        getTitlebar()->setParentWindow(this);
    }

    if((whichField & TitlebarFieldMask) ||
       (whichField & BorderFieldMask) ||
       (whichField & DisabledBorderFieldMask) ||
       (whichField & FocusedBorderFieldMask) ||
       (whichField & RolloverBorderFieldMask) ||
       (whichField & DrawTitlebarFieldMask))
    {
        TitlebarRefPtr TheTitlebar;
        if(getDrawTitlebar())
        {
            TheTitlebar = getTitlebar();
        }
        else
        {
            TheTitlebar = NULL;
        }

        if(getBorder() != NULL && getBorder()->getType().isDerivedFrom(WindowBorder::getClassType()))
        {
            dynamic_cast<WindowBorder*>(getBorder())->setTitlebar(TheTitlebar);
        }
        if(getDisabledBorder() != NULL && getDisabledBorder()->getType().isDerivedFrom(WindowBorder::getClassType()))
        {
            dynamic_cast<WindowBorder*>(getDisabledBorder())->setTitlebar(TheTitlebar);
        }
        if(getFocusedBorder() != NULL && getFocusedBorder()->getType().isDerivedFrom(WindowBorder::getClassType()))
        {
            dynamic_cast<WindowBorder*>(getFocusedBorder())->setTitlebar(TheTitlebar);
        }
        if(getRolloverBorder() != NULL && getRolloverBorder()->getType().isDerivedFrom(WindowBorder::getClassType()))
        {
            dynamic_cast<WindowBorder*>(getRolloverBorder())->setTitlebar(TheTitlebar);
        }
    }

    if( whichField & ClipBoundsFieldMask)
    {
        if(getTitlebar() != NULL)
        {
            getTitlebar()->updateClipBounds();
        }
    }

    if( (whichField & TitlebarFieldMask) &&
        getTitlebar() != NULL)
    {
        if(getTitlebar()->getTitleLabel() != NULL)
        {
            getTitlebar()->getTitleLabel()->addMouseListener(&_TitlebarStartDragListener);
        }
        if(getTitlebar()->getCloseButton() != NULL)
        {
            getTitlebar()->getCloseButton()->addActionListener(&_CloseButtonListener);
        }
        if(getTitlebar()->getMaximizeButton() != NULL)
        {
            getTitlebar()->getMaximizeButton()->addActionListener(&_MaximizeButtonListener);
        }
        if(getTitlebar()->getIconifyButton() != NULL)
        {
            getTitlebar()->getIconifyButton()->addActionListener(&_IconifyButtonListener);
        }
    }

    if( (whichField & IconableFieldMask) &&
        getTitlebar() != NULL)
    {
        getTitlebar()->setDrawIconify(getIconable());
    }
    if( (whichField & MaximizableFieldMask) &&
        getTitlebar() != NULL)
    {
        getTitlebar()->setDrawMaximize(getMaximizable());
    }
    if( (whichField & ClosableFieldMask) &&
        getTitlebar() != NULL)
    {
        getTitlebar()->setDrawClose(getClosable());
    }

    Inherited::changed(whichField, origin, details);
}