Exemplo n.º 1
0
 void ScrollArea::mousePress(int x, int y, int button)
 {
     if (getUpButtonDimension().isPointInRect(x, y))
     {
         setVerticalScrollAmount(getVerticalScrollAmount() - 10);
         mUpButtonPressed = true;
     }
     else if (getDownButtonDimension().isPointInRect(x, y))
     {
         setVerticalScrollAmount(getVerticalScrollAmount() + 10);
         mDownButtonPressed = true;
     }
     else if (getLeftButtonDimension().isPointInRect(x, y))
     {
         setHorizontalScrollAmount(getHorizontalScrollAmount() - 10);
         mLeftButtonPressed = true;
     }
     else if (getRightButtonDimension().isPointInRect(x, y))
     {
         setHorizontalScrollAmount(getHorizontalScrollAmount() + 10);
         mRightButtonPressed = true;
     }        
     else if (getVerticalMarkerDimension().isPointInRect(x, y))
     {
         mVerticalMarkerPressed = true;
         mVerticalMarkerMousePosition = y - getVerticalMarkerDimension().y;
     }
     else if (getHorizontalMarkerDimension().isPointInRect(x, y))
     {
         mHorizontalMarkerPressed = true;
         mHorizontalMarkerMousePosition = x - getHorizontalMarkerDimension().x;
     } 
 }
Exemplo n.º 2
0
    void ScrollArea::scrollToRectangle(const Rectangle& rectangle)
    {
        Rectangle contentDim = getContentDimension();
    
        if (rectangle.x + rectangle.width
            > getHorizontalScrollAmount() + contentDim.width)
        {
            setHorizontalScrollAmount(rectangle.x + rectangle.width - contentDim.width);
        }
    
        if (rectangle.y + rectangle.height
            > getVerticalScrollAmount() + contentDim.height)
        {
            setVerticalScrollAmount(rectangle.y + rectangle.height - contentDim.height);
        }

        if (rectangle.x < getHorizontalScrollAmount())
        {
            setHorizontalScrollAmount(rectangle.x);
        }
    
        if (rectangle.y < getVerticalScrollAmount())
        {
            setVerticalScrollAmount(rectangle.y);
        }
    }
Exemplo n.º 3
0
void FFScrollArea::keyPressed(gcn::KeyEvent &keyEvent)
{
    if (keyEvent.isConsumed())
    {
        return;
    }
    
    if (keyEvent.getKey().getValue() == gcn::Key::Down)
    {
        setVerticalScrollAmount(getVerticalScrollAmount() + 16);
    }
    else if (keyEvent.getKey().getValue() == gcn::Key::Up)
    {
        setVerticalScrollAmount(getVerticalScrollAmount() - 16);
    }
}
Exemplo n.º 4
0
 void ScrollArea::mouseWheelDown(int x, int y)
 {    
     if (hasMouse())
     {
         setVerticalScrollAmount(getVerticalScrollAmount() + getContentDimension().height / 8);
     }    
 }
Exemplo n.º 5
0
void ScrollArea::logic()
{
    if (!isVisible())
        return;

    gcn::ScrollArea::logic();
    gcn::Widget *content = getContent();

    // When no scrollbar in a certain direction, adapt content size to match
    // the content dimension exactly.
    if (content)
    {
        if (getHorizontalScrollPolicy() == gcn::ScrollArea::SHOW_NEVER)
        {
            content->setWidth(getChildrenArea().width -
                    2 * content->getFrameSize());
        }
        if (getVerticalScrollPolicy() == gcn::ScrollArea::SHOW_NEVER)
        {
            content->setHeight(getChildrenArea().height -
                    2 * content->getFrameSize());
        }
    }

    if (mUpButtonPressed)
    {
        setVerticalScrollAmount(getVerticalScrollAmount() -
                                mUpButtonScrollAmount);
    }
    else if (mDownButtonPressed)
    {
        setVerticalScrollAmount(getVerticalScrollAmount() +
                                mDownButtonScrollAmount);
    }
    else if (mLeftButtonPressed)
    {
        setHorizontalScrollAmount(getHorizontalScrollAmount() -
                                  mLeftButtonScrollAmount);
    }
    else if (mRightButtonPressed)
    {
        setHorizontalScrollAmount(getHorizontalScrollAmount() +
                                  mRightButtonScrollAmount);
    }
}
Exemplo n.º 6
0
    void ScrollArea::mouseWheelMovedDown(MouseEvent& mouseEvent)
    {
        if (mouseEvent.isConsumed())
        {
            return;
        }

        setVerticalScrollAmount(getVerticalScrollAmount() + getChildrenArea().height / 8);

        mouseEvent.consume();
    }
Exemplo n.º 7
0
    void ScrollArea::logic()
    {
        checkPolicies();

        setVerticalScrollAmount(getVerticalScrollAmount());
        setHorizontalScrollAmount(getHorizontalScrollAmount());

        if (getContent() != NULL)
        {
            getContent()->setPosition(-mHScroll + getContent()->getFrameSize(),
                                      -mVScroll + getContent()->getFrameSize());
            getContent()->logic();
        }
    }
Exemplo n.º 8
0
    void ScrollArea::logic()
    {
        checkPolicies();

        setVerticalScrollAmount(getVerticalScrollAmount());
        setHorizontalScrollAmount(getHorizontalScrollAmount());
        
        if (mContent != NULL)
        {
            mContent->setPosition(-mHScroll + getContentDimension().x + mContent->getBorderSize(),
                                  -mVScroll + getContentDimension().y + mContent->getBorderSize());

            mContent->logic();
        }    
    }
Exemplo n.º 9
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);
    }
Exemplo n.º 10
0
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));
    }
}
Exemplo n.º 11
0
    void ScrollArea::mousePressed(MouseEvent& mouseEvent)
    {
        int x = mouseEvent.getX();
        int y = mouseEvent.getY();

        if (getUpButtonDimension().isPointInRect(x, y))
        {
            setVerticalScrollAmount(getVerticalScrollAmount()
                                    - mUpButtonScrollAmount);
            mUpButtonPressed = true;
        }
        else if (getDownButtonDimension().isPointInRect(x, y))
        {
            setVerticalScrollAmount(getVerticalScrollAmount()
                                    + mDownButtonScrollAmount);
            mDownButtonPressed = true;
        }
        else if (getLeftButtonDimension().isPointInRect(x, y))
        {
            setHorizontalScrollAmount(getHorizontalScrollAmount()
                                      - mLeftButtonScrollAmount);
            mLeftButtonPressed = true;
        }
        else if (getRightButtonDimension().isPointInRect(x, y))
        {
            setHorizontalScrollAmount(getHorizontalScrollAmount()
                                      + mRightButtonScrollAmount);
            mRightButtonPressed = true;
        }
        else if (getVerticalMarkerDimension().isPointInRect(x, y))
        {
            mIsHorizontalMarkerDragged = false;
            mIsVerticalMarkerDragged = true;

            mVerticalMarkerDragOffset = y - getVerticalMarkerDimension().y;
        }
        else if (getVerticalBarDimension().isPointInRect(x,y))
        {
            if (y < getVerticalMarkerDimension().y)
            {
                setVerticalScrollAmount(getVerticalScrollAmount()
                                        - (int)(getChildrenArea().height * 0.95));
            }
            else
            {
                setVerticalScrollAmount(getVerticalScrollAmount()
                                        + (int)(getChildrenArea().height * 0.95));
            }
        }
        else if (getHorizontalMarkerDimension().isPointInRect(x, y))
        {
            mIsHorizontalMarkerDragged = true;
            mIsVerticalMarkerDragged = false;

            mHorizontalMarkerDragOffset = x - getHorizontalMarkerDimension().x;
        }
        else if (getHorizontalBarDimension().isPointInRect(x,y))
        {
            if (x < getHorizontalMarkerDimension().x)
            {
                setHorizontalScrollAmount(getHorizontalScrollAmount()
                                          - (int)(getChildrenArea().width * 0.95));
            }
            else
            {
                setHorizontalScrollAmount(getHorizontalScrollAmount()
                                          + (int)(getChildrenArea().width * 0.95));
            }
        }
        
        // Eat the mouse
        mouseEvent.consume();
    }