示例#1
0
    Rectangle ScrollArea::getVerticalMarkerDimension()
    {
        if (!mVBarVisible)
        {
            return Rectangle(0, 0, 0, 0);
        }

        int length, pos;
        Rectangle barDim = getVerticalBarDimension();

        if (getContent() && getContent()->getHeight() != 0)
        {
            length = (barDim.height * getChildrenArea().height)
                / getContent()->getHeight();
        }
        else
        {
            length = barDim.height;
        }

        if (length < mScrollbarWidth)
        {
            length = mScrollbarWidth;
        }

        if (length > barDim.height)
        {
            length = barDim.height;
        }

        if (getVerticalMaxScroll() != 0)
        {
            pos = ((barDim.height - length) * getVerticalScrollAmount())
                / getVerticalMaxScroll();
        }
        else
        {
            pos = 0;
        }

        return Rectangle(barDim.x, barDim.y + pos, mScrollbarWidth, length);
    }
void FFScrollArea::draw(gcn::Graphics *graphics)
{
    graphics->pushClipArea(getContent()->getDimension());
    getContent()->draw(graphics);
    graphics->popClipArea();

    if (getVerticalMaxScroll() != 0)
    {
        int y = ((getHeight() - 32) * getVerticalScrollAmount()) /
            getVerticalMaxScroll();

        graphics->setColor(0x000000);
        graphics->drawRectangle(gcn::Rectangle(getWidth()-11, y, 8, 32));
        graphics->drawRectangle(gcn::Rectangle(getWidth()-10, y+1, 8, 32));

        graphics->setColor(0xffffff);

        graphics->fillRectangle(gcn::Rectangle(getWidth()-10, y+1, 6, 30));
    }
}
示例#3
0
    void ScrollArea::setVerticalScrollAmount(int vScroll)
    {
        int max = getVerticalMaxScroll();

        mVScroll = vScroll;

        if (vScroll > max)
        {
            mVScroll = max;
        }

        if (vScroll < 0)
        {
            mVScroll = 0;
        }
    }
示例#4
0
    void ScrollArea::mouseDragged(MouseEvent& mouseEvent)
    {
        if (mIsVerticalMarkerDragged)
        {
            int pos = mouseEvent.getY() - getVerticalBarDimension().y  - mVerticalMarkerDragOffset;
            int length = getVerticalMarkerDimension().height;

            Rectangle barDim = getVerticalBarDimension();

            if ((barDim.height - length) > 0)
            {
                setVerticalScrollAmount((getVerticalMaxScroll() * pos)
                                         / (barDim.height - length));
            }
            else
            {
                setVerticalScrollAmount(0);
            }
        }

        if (mIsHorizontalMarkerDragged)
        {
            int pos = mouseEvent.getX() - getHorizontalBarDimension().x  - mHorizontalMarkerDragOffset;
            int length = getHorizontalMarkerDimension().width;

            Rectangle barDim = getHorizontalBarDimension();

            if ((barDim.width - length) > 0)
            {
                setHorizontalScrollAmount((getHorizontalMaxScroll() * pos)
                                          / (barDim.width - length));
            }
            else
            {
                setHorizontalScrollAmount(0);
            }
        }

        mouseEvent.consume();
    }
示例#5
0
    void ScrollArea::mouseMotion(int x, int y)
    {
        if (mVerticalMarkerPressed)
        {
            int pos = y - getVerticalBarDimension().y  - mVerticalMarkerMousePosition;
            int length = getVerticalMarkerDimension().height;

            Rectangle barDim = getVerticalBarDimension();
      
            if ((barDim.height - length) > 0)
            {
                setVerticalScrollAmount((getVerticalMaxScroll() * pos)
                                        / (barDim.height - length));
            }
            else
            {
                setVerticalScrollAmount(0);
            }     
        }
        if (mHorizontalMarkerPressed)
        {
            int pos = x - getHorizontalBarDimension().x  - mHorizontalMarkerMousePosition;
            int length = getHorizontalMarkerDimension().width;

            Rectangle barDim = getHorizontalBarDimension();
      
            if ((barDim.width - length) > 0)
            {
                setHorizontalScrollAmount((getHorizontalMaxScroll() * pos)
                                          / (barDim.width - length));
            }
            else
            {
                setHorizontalScrollAmount(0);
            }     
        }
    }