bool Component::isContained(const Pnt2f& p, bool TestAgainstClipBounds) const
{
    if(!getVisible())
    {
        return false;
    }

    Pnt2f PointInCompSpace(DrawingSurfaceToComponent(p,this));
    Border* DrawnBorder(getDrawnBorder());
    Pnt2f TopLeft, BottomRight;
    if(TestAgainstClipBounds && getClipping())
    {
        TopLeft = getClipTopLeft();
        BottomRight = getClipBottomRight();
    }
    else
    {
        TopLeft.setValues(0,0);
        BottomRight = Pnt2f(getSize());
    }

    if(DrawnBorder == NULL)
    {
        return isContainedBounds(PointInCompSpace, TopLeft, BottomRight);
    }
    else
    {
        return isContainedBounds(PointInCompSpace, TopLeft, BottomRight) && 
            DrawnBorder->isContained(PointInCompSpace,0,0,getSize().x(),getSize().y());
    }
}
Beispiel #2
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;
        }
    }
}