Java Code Examples for org.eclipse.swt.widgets.ScrollBar#setIncrement()

The following examples show how to use org.eclipse.swt.widgets.ScrollBar#setIncrement() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ContextDialog.java    From hop with Apache License 2.0 5 votes vote down vote up
private void updateVerticalBar() {
	ScrollBar verticalBar = wCanvas.getVerticalBar();

	int pageRows = Math.floorDiv( wCanvas.getClientArea().height, cellHeight );

	verticalBar.setMinimum( 0 );
	verticalBar.setIncrement( 1 );
	verticalBar.setPageIncrement( pageRows );
	verticalBar.setMaximum( calculateNrRows() );
	verticalBar.setThumb( pageRows );
}
 
Example 2
Source File: Gallery.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Move the scrollbar to reflect the current visible items position.
 * 
 * @param bar
 *            - the scroll bar to move
 * @param clientSize
 *            - Client (visible) area size
 * @param totalSize
 *            - Total Size
 */
private void updateScrollBarProperties(ScrollBar bar, int clientSize,
		int totalSize) {
	if (bar == null)
		return;

	bar.setMinimum(0);
	bar.setPageIncrement(clientSize);
	bar.setMaximum(totalSize);
	bar.setThumb(clientSize);

	// Let the group renderer use a custom increment value.
	if (groupRenderer != null)
		bar.setIncrement(groupRenderer.getScrollBarIncrement());

	if (totalSize > clientSize) {
		if (DEBUG)
			System.out.println("Enabling scrollbar"); //$NON-NLS-1$

		bar.setEnabled(true);
		bar.setVisible(true);
		bar.setSelection(translate);

		// Ensure that translate has a valid value.
		validateTranslation();
	} else {
		if (DEBUG)
			System.out.println("Disabling scrollbar"); //$NON-NLS-1$

		bar.setEnabled(false);
		bar.setVisible(false);
		bar.setSelection(0);
		translate = 0;
	}

}
 
Example 3
Source File: ScrollView.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Setup scroll bar using contents, visible and scroll bar mode properties.
 */
protected void updateScrollBarsValues() {
    /* update vertical scrollbar */
    ScrollBar b = getVerticalBar();
    if (b != null) {
        b.setMinimum(0);
        b.setMaximum(getContentsHeight());
        b.setThumb(getVisibleHeight());
        b.setPageIncrement(getVisibleHeight());
        b.setIncrement(fVertScrollbarIncrement);
        b.setSelection(getContentsY());
    }

    // update "hidden" vertical bar too
    b = fViewControl.getVerticalBar();
    if (b != null) {
        b.setMinimum(0);
        b.setMaximum(getContentsHeight());
        b.setThumb(getVisibleHeight());
        b.setPageIncrement(getVisibleHeight());
        b.setIncrement(fVertScrollbarIncrement);
        b.setSelection(getContentsY());
    }

    /* update horizontal scrollbar */
    b = getHorizontalBar();
    if (b != null) {
        b.setMinimum(0);
        b.setMaximum(getContentsWidth());
        b.setThumb(getVisibleWidth());
        b.setSelection(getContentsX());
        b.setPageIncrement(getVisibleWidth());
        b.setIncrement(fHorScrollbarIncrement);
    }
    // update "hidden" horizontal bar too
    b = fViewControl.getHorizontalBar();
    if (b != null) {
        b.setMinimum(0);
        b.setMaximum(getContentsWidth());
        b.setThumb(getVisibleWidth());
        b.setSelection(getContentsX());
        b.setPageIncrement(getVisibleWidth());
        b.setIncrement(fHorScrollbarIncrement);
    }
}
 
Example 4
Source File: IconCanvas.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * SYNC the scroll-bars with the image.
 */
public void syncScrollBars( )
{
	if ( sourceImage == null )
	{
		redraw( );
		return;
	}

	AffineTransform af = transform;
	double sx = af.getScaleX( ), sy = af.getScaleY( );
	double tx = af.getTranslateX( ), ty = af.getTranslateY( );
	if ( tx > 0 )
		tx = 0;
	if ( ty > 0 )
		ty = 0;

	Rectangle imageBound = sourceImage.getBounds( );
	int cw = getClientArea( ).width, ch = getClientArea( ).height;

	ScrollBar horizontal = getHorizontalBar( );

	if ( horizontal != null )
	{
		horizontal.setIncrement( ( getClientArea( ).width / 100 ) );
		horizontal.setPageIncrement( getClientArea( ).width );

		if ( imageBound.width * sx > cw )
		{
			horizontal.setMaximum( (int) ( imageBound.width * sx ) );
			horizontal.setEnabled( true );
			if ( ( (int) -tx ) > horizontal.getMaximum( ) - cw )
				tx = -horizontal.getMaximum( ) + cw;
		}
		else
		{
			horizontal.setEnabled( false );
			tx = ( cw - imageBound.width * sx ) / 2;
		}
		horizontal.setSelection( (int) ( -tx ) );
		horizontal.setThumb( ( getClientArea( ).width ) );
	}
	ScrollBar vertical = getVerticalBar( );
	if ( vertical != null )
	{
		vertical.setIncrement( ( getClientArea( ).height / 100 ) );
		vertical.setPageIncrement( ( getClientArea( ).height ) );
		if ( imageBound.height * sy > ch )
		{
			vertical.setMaximum( (int) ( imageBound.height * sy ) );
			vertical.setEnabled( true );
			if ( ( (int) -ty ) > vertical.getMaximum( ) - ch )
				ty = -vertical.getMaximum( ) + ch;
		}
		else
		{
			vertical.setEnabled( false );
			ty = ( ch - imageBound.height * sy ) / 2;
		}
		vertical.setSelection( (int) ( -ty ) );
		vertical.setThumb( ( getClientArea( ).height ) );
	}

	af = AffineTransform.getScaleInstance( sx, sy );
	af.preConcatenate( AffineTransform.getTranslateInstance( tx, ty ) );
	transform = af;

	redraw( );
}
 
Example 5
Source File: ImageCanvas.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * SYNC the scroll-bars with the image.
 */
public void syncScrollBars( )
{
	if ( sourceImage == null )
	{
		redraw( );
		return;
	}

	AffineTransform af = transform;
	double sx = af.getScaleX( ), sy = af.getScaleY( );
	double tx = af.getTranslateX( ), ty = af.getTranslateY( );
	if ( tx > 0 )
		tx = 0;
	if ( ty > 0 )
		ty = 0;

	Rectangle imageBound = sourceImage.getBounds( );
	int cw = getClientArea( ).width, ch = getClientArea( ).height;

	ScrollBar horizontal = getHorizontalBar( );

	if ( horizontal != null )
	{
		horizontal.setIncrement( (int) ( getClientArea( ).width / 100 ) );
		horizontal.setPageIncrement( getClientArea( ).width );

		if ( imageBound.width * sx > cw )
		{
			horizontal.setMaximum( (int) ( imageBound.width * sx ) );
			horizontal.setEnabled( true );
			if ( ( (int) -tx ) > horizontal.getMaximum( ) - cw )
				tx = -horizontal.getMaximum( ) + cw;
		}
		else
		{
			horizontal.setEnabled( false );
			tx = ( cw - imageBound.width * sx ) / 2;
		}
		horizontal.setSelection( (int) ( -tx ) );
		horizontal.setThumb( (int) ( getClientArea( ).width ) );
	}
	ScrollBar vertical = getVerticalBar( );
	if ( vertical != null )
	{
		vertical.setIncrement( (int) ( getClientArea( ).height / 100 ) );
		vertical.setPageIncrement( (int) ( getClientArea( ).height ) );
		if ( imageBound.height * sy > ch )
		{
			vertical.setMaximum( (int) ( imageBound.height * sy ) );
			vertical.setEnabled( true );
			if ( ( (int) -ty ) > vertical.getMaximum( ) - ch )
				ty = -vertical.getMaximum( ) + ch;
		}
		else
		{
			vertical.setEnabled( false );
			ty = ( ch - imageBound.height * sy ) / 2;
		}
		vertical.setSelection( (int) ( -ty ) );
		vertical.setThumb( (int) ( getClientArea( ).height ) );
	}

	af = AffineTransform.getScaleInstance( sx, sy );
	af.preConcatenate( AffineTransform.getTranslateInstance( tx, ty ) );
	transform = af;

	redraw( );
}