CTFScrollPanel::CTFScrollPanel(int x,int y,int wide,int tall) : ScrollPanel(x,y,wide,tall)
{
	ScrollBar *pScrollBar = getVerticalScrollBar();
	pScrollBar->setButton( new CTFScrollButton( ARROW_UP, "", 0,0,16,16 ), 0 );
	pScrollBar->setButton( new CTFScrollButton( ARROW_DOWN, "", 0,0,16,16 ), 1 );
	pScrollBar->setSlider( new CTFSlider(0,wide-1,wide,(tall-(wide*2))+2,true) ); 
	pScrollBar->setPaintBorderEnabled(false);
	pScrollBar->setPaintBackgroundEnabled(false);
	pScrollBar->setPaintEnabled(false);

	pScrollBar = getHorizontalScrollBar();
	pScrollBar->setButton( new CTFScrollButton( ARROW_LEFT, "", 0,0,16,16 ), 0 );
	pScrollBar->setButton( new CTFScrollButton( ARROW_RIGHT, "", 0,0,16,16 ), 1 );
	pScrollBar->setSlider( new CTFSlider(tall,0,wide-(tall*2),tall,false) );
	pScrollBar->setPaintBorderEnabled(false);
	pScrollBar->setPaintBackgroundEnabled(false);
	pScrollBar->setPaintEnabled(false);
}
示例#2
0
bool Viewport::autoScroll (const int mouseX, const int mouseY, const int activeBorderThickness, const int maximumSpeed)
{
    if (contentComp != nullptr)
    {
        int dx = 0, dy = 0;

        if (getHorizontalScrollBar().isVisible() || canScrollHorizontally())
        {
            if (mouseX < activeBorderThickness)
                dx = activeBorderThickness - mouseX;
            else if (mouseX >= contentHolder.getWidth() - activeBorderThickness)
                dx = (contentHolder.getWidth() - activeBorderThickness) - mouseX;

            if (dx < 0)
                dx = jmax (dx, -maximumSpeed, contentHolder.getWidth() - contentComp->getRight());
            else
                dx = jmin (dx, maximumSpeed, -contentComp->getX());
        }

        if (getVerticalScrollBar().isVisible() || canScrollVertically())
        {
            if (mouseY < activeBorderThickness)
                dy = activeBorderThickness - mouseY;
            else if (mouseY >= contentHolder.getHeight() - activeBorderThickness)
                dy = (contentHolder.getHeight() - activeBorderThickness) - mouseY;

            if (dy < 0)
                dy = jmax (dy, -maximumSpeed, contentHolder.getHeight() - contentComp->getBottom());
            else
                dy = jmin (dy, maximumSpeed, -contentComp->getY());
        }

        if (dx != 0 || dy != 0)
        {
            contentComp->setTopLeftPosition (contentComp->getX() + dx,
                                             contentComp->getY() + dy);

            return true;
        }
    }

    return false;
}
示例#3
0
bool Viewport::useMouseWheelMoveIfNeeded (const MouseEvent& e, const MouseWheelDetails& wheel)
{
    if (! (e.mods.isAltDown() || e.mods.isCtrlDown() || e.mods.isCommandDown()))
    {
        const bool canScrollVert = (allowScrollingWithoutScrollbarV || getVerticalScrollBar().isVisible());
        const bool canScrollHorz = (allowScrollingWithoutScrollbarH || getHorizontalScrollBar().isVisible());

        if (canScrollHorz || canScrollVert)
        {
            auto deltaX = rescaleMouseWheelDistance (wheel.deltaX, singleStepX);
            auto deltaY = rescaleMouseWheelDistance (wheel.deltaY, singleStepY);

            auto pos = getViewPosition();

            if (deltaX != 0 && deltaY != 0 && canScrollHorz && canScrollVert)
            {
                pos.x -= deltaX;
                pos.y -= deltaY;
            }
            else if (canScrollHorz && (deltaX != 0 || e.mods.isShiftDown() || ! canScrollVert))
            {
                pos.x -= deltaX != 0 ? deltaX : deltaY;
            }
            else if (canScrollVert && deltaY != 0)
            {
                pos.y -= deltaY;
            }

            if (pos != getViewPosition())
            {
                setViewPosition (pos);
                return true;
            }
        }
    }

    return false;
}
void FileListComponent::scrollToTop()
{
    getVerticalScrollBar()->setCurrentRangeStart (0);
}
示例#5
0
void ScrollBar::changed(ConstFieldMaskArg whichField, 
                            UInt32            origin,
                            BitVector         details)
{
    Inherited::changed(whichField, origin, details);

    if( (whichField & VerticalMinButtonFieldMask) ||
        (whichField & VerticalMaxButtonFieldMask) ||
        (whichField & VerticalScrollBarFieldMask) ||
        (whichField & VerticalScrollFieldFieldMask)||
        (whichField & HorizontalMinButtonFieldMask) ||
        (whichField & HorizontalMaxButtonFieldMask) ||
        (whichField & HorizontalScrollBarFieldMask) ||
        (whichField & HorizontalScrollFieldFieldMask) ||
        (whichField & OrientationFieldMask) )
    {
            clearChildren();
            if(getOrientation() == ScrollBar::VERTICAL_ORIENTATION)
            {
                if(getVerticalScrollField() != NULL) {pushToChildren(getVerticalScrollField());}
                if(getVerticalScrollBar() != NULL) {pushToChildren(getVerticalScrollBar());}
                if(getVerticalMinButton() != NULL) {pushToChildren(getVerticalMinButton());}
                if(getVerticalMaxButton() != NULL) {pushToChildren(getVerticalMaxButton());}
            }
            else
            {
                if(getHorizontalScrollField() != NULL) {pushToChildren(getHorizontalScrollField());}
                if(getHorizontalScrollBar() != NULL) {pushToChildren(getHorizontalScrollBar());}
                if(getHorizontalMinButton() != NULL) {pushToChildren(getHorizontalMinButton());}
                if(getHorizontalMaxButton() != NULL) {pushToChildren(getHorizontalMaxButton());}
            }
    }

    if((whichField & VerticalMinButtonFieldMask) &&
        getVerticalMinButton() != NULL)
    {
        getVerticalMinButton()->addMousePressedActionListener(&_MinButtonActionListener);
    }

    if((whichField & VerticalMaxButtonFieldMask) &&
        getVerticalMaxButton() != NULL)
    {
        getVerticalMaxButton()->addMousePressedActionListener(&_MaxButtonActionListener);
    }
    
    if((whichField & VerticalScrollBarFieldMask) &&
        getVerticalScrollBar() != NULL)
    {
        getVerticalScrollBar()->addMouseListener(&_ScrollBarListener);
    }
    
    if((whichField & VerticalScrollFieldFieldMask) &&
        getVerticalScrollField() != NULL)
    {
        getVerticalScrollField()->addMousePressedActionListener(&_ScrollFieldListener);
    }
    
    if((whichField & HorizontalMinButtonFieldMask) &&
        getHorizontalMinButton() != NULL)
    {
        getHorizontalMinButton()->addMousePressedActionListener(&_MinButtonActionListener);
    }

    if((whichField & HorizontalMaxButtonFieldMask) &&
        getHorizontalMaxButton() != NULL)
    {
        getHorizontalMaxButton()->addMousePressedActionListener(&_MaxButtonActionListener);
    }
    
    if((whichField & HorizontalScrollBarFieldMask) &&
        getHorizontalScrollBar() != NULL)
    {
        getHorizontalScrollBar()->addMouseListener(&_ScrollBarListener);
    }
    
    if((whichField & HorizontalScrollFieldFieldMask) &&
        getHorizontalScrollField() != NULL)
    {
        getHorizontalScrollField()->addMousePressedActionListener(&_ScrollFieldListener);
    }

	if(whichField & EnabledFieldMask)
	{
		if(getVerticalMinButton() != NULL)
		{
				getVerticalMinButton()->setEnabled(getEnabled());
		}
		if(getVerticalMaxButton() != NULL)
		{
				getVerticalMaxButton()->setEnabled(getEnabled());
		}
		if(getVerticalScrollBar() != NULL)
		{
				getVerticalScrollBar()->setEnabled(getEnabled());
		}
		if(getVerticalScrollField() != NULL)
		{
				getVerticalScrollField()->setEnabled(getEnabled());
		}
		if(getHorizontalMinButton() != NULL)
		{
				getHorizontalMinButton()->setEnabled(getEnabled());
		}
		if(getHorizontalMaxButton() != NULL)
		{
				getHorizontalMaxButton()->setEnabled(getEnabled());
		}
		if(getHorizontalScrollBar() != NULL)
		{
				getHorizontalScrollBar()->setEnabled(getEnabled());
		}
		if(getHorizontalScrollField() != NULL)
		{
				getHorizontalScrollField()->setEnabled(getEnabled());
		}
	}
    if(whichField & RangeModelFieldMask)
    {
        if(getRangeModel() != NULL)
        {
            _RangeModelConnection = getRangeModel()->addChangeListener(&_BoundedRangeModelChangeListener);
        }
    }
}
示例#6
0
void ScrollBar::changed(ConstFieldMaskArg whichField, 
                            UInt32            origin,
                            BitVector         details)
{
    Inherited::changed(whichField, origin, details);

    //Do not respond to changes that have a Sync origin
    if(origin & ChangedOrigin::Sync)
    {
        return;
    }

    if( (whichField & VerticalMinButtonFieldMask) ||
        (whichField & VerticalMaxButtonFieldMask) ||
        (whichField & VerticalScrollBarFieldMask) ||
        (whichField & VerticalScrollFieldFieldMask)||
        (whichField & HorizontalMinButtonFieldMask) ||
        (whichField & HorizontalMaxButtonFieldMask) ||
        (whichField & HorizontalScrollBarFieldMask) ||
        (whichField & HorizontalScrollFieldFieldMask) ||
        (whichField & OrientationFieldMask) )
    {
            clearChildren();
            if(getOrientation() == ScrollBar::VERTICAL_ORIENTATION)
            {
                if(getVerticalScrollField() != NULL) {pushToChildren(getVerticalScrollField());}
                if(getVerticalScrollBar() != NULL) {pushToChildren(getVerticalScrollBar());}
                if(getVerticalMinButton() != NULL) {pushToChildren(getVerticalMinButton());}
                if(getVerticalMaxButton() != NULL) {pushToChildren(getVerticalMaxButton());}
            }
            else
            {
                if(getHorizontalScrollField() != NULL) {pushToChildren(getHorizontalScrollField());}
                if(getHorizontalScrollBar() != NULL) {pushToChildren(getHorizontalScrollBar());}
                if(getHorizontalMinButton() != NULL) {pushToChildren(getHorizontalMinButton());}
                if(getHorizontalMaxButton() != NULL) {pushToChildren(getHorizontalMaxButton());}
            }
    }

    if(getOrientation() == ScrollBar::VERTICAL_ORIENTATION)
    {
        if(whichField & VerticalMinButtonFieldMask)
        {
            _MinActionConnection.disconnect();
            if(getVerticalMinButton() != NULL)
            {
                _MinActionConnection = getVerticalMinButton()->connectMousePressedActionPerformed(boost::bind(&ScrollBar::handleMinButtonAction, this, _1));
            }
        }

        if(whichField & VerticalMaxButtonFieldMask)
        {
            _MaxActionConnection.disconnect();
            if(getVerticalMaxButton() != NULL)
            {
                _MaxActionConnection = getVerticalMaxButton()->connectMousePressedActionPerformed(boost::bind(&ScrollBar::handleMaxButtonAction, this, _1));
            }
        }
        
        if(whichField & VerticalScrollBarFieldMask)
        {
            _ScrollBarMousePressedConnection.disconnect();
            if(getVerticalScrollBar() != NULL)
            {
                _ScrollBarMousePressedConnection = getVerticalScrollBar()->connectMousePressed(boost::bind(&ScrollBar::handleScrollBarMousePressed, this, _1));
            }
        }
        
        if(whichField & VerticalScrollFieldFieldMask)
        {
            _ScrollFieldActionConnection.disconnect();
            if(getVerticalScrollField() != NULL)
            {
                _ScrollFieldActionConnection = getVerticalScrollField()->connectActionPerformed(boost::bind(&ScrollBar::handleScrollFieldAction, this, _1));
            }
        }
    }
    else
    {
        if(whichField & HorizontalMinButtonFieldMask)
        {
            _MinActionConnection.disconnect();
            if(getHorizontalMinButton() != NULL)
            {
                _MinActionConnection = getHorizontalMinButton()->connectMousePressedActionPerformed(boost::bind(&ScrollBar::handleMinButtonAction, this, _1));
            }
        }

        if(whichField & HorizontalMaxButtonFieldMask)
        {
            _MaxActionConnection.disconnect();
            if(getHorizontalMaxButton() != NULL)
            {
                _MaxActionConnection = getHorizontalMaxButton()->connectMousePressedActionPerformed(boost::bind(&ScrollBar::handleMaxButtonAction, this, _1));
            }
        }
        
        if(whichField & HorizontalScrollBarFieldMask)
        {
            _ScrollBarMousePressedConnection.disconnect();
            if(getHorizontalScrollBar() != NULL)
            {
                _ScrollBarMousePressedConnection = getHorizontalScrollBar()->connectMousePressed(boost::bind(&ScrollBar::handleScrollBarMousePressed, this, _1));
            }
        }
        
        if(whichField & HorizontalScrollFieldFieldMask)
        {
            _ScrollFieldActionConnection.disconnect();
            if(getHorizontalScrollField() != NULL)
            {
                _ScrollFieldActionConnection = getHorizontalScrollField()->connectActionPerformed(boost::bind(&ScrollBar::handleScrollFieldAction, this, _1));
            }
        }
    }

	if(whichField & EnabledFieldMask)
	{
		if(getVerticalMinButton() != NULL)
		{
				getVerticalMinButton()->setEnabled(getEnabled());
		}
		if(getVerticalMaxButton() != NULL)
		{
				getVerticalMaxButton()->setEnabled(getEnabled());
		}
		if(getVerticalScrollBar() != NULL)
		{
				getVerticalScrollBar()->setEnabled(getEnabled());
		}
		if(getVerticalScrollField() != NULL)
		{
				getVerticalScrollField()->setEnabled(getEnabled());
		}
		if(getHorizontalMinButton() != NULL)
		{
				getHorizontalMinButton()->setEnabled(getEnabled());
		}
		if(getHorizontalMaxButton() != NULL)
		{
				getHorizontalMaxButton()->setEnabled(getEnabled());
		}
		if(getHorizontalScrollBar() != NULL)
		{
				getHorizontalScrollBar()->setEnabled(getEnabled());
		}
		if(getHorizontalScrollField() != NULL)
		{
				getHorizontalScrollField()->setEnabled(getEnabled());
		}
	}
    if(whichField & RangeModelFieldMask)
    {
        _RangeModelConnection.disconnect();
        if(getRangeModel() != NULL)
        {
            _RangeModelConnection = getRangeModel()->connectStateChanged(boost::bind(&ScrollBar::handleRangeModelStateChanged, this, _1));
        }
    }
}