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

The following examples show how to use org.eclipse.swt.widgets.ScrollBar#getMaximum() . 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: ScrollingSmoother.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
public void handleEvent(Event event) {
	// Remove standard behavior
	event.doit = false;

	// Get scrollbar on which the event occurred.
	ScrollBar currentScrollBar = getScrollbar(event);

	int start = currentScrollBar.getSelection();
	int end = start;

	// If an effect is currently running, get the current and target
	// values.
	if (me != null) {
		start = me.getCurrent();
		end = me.getEnd();
	}

	end -= event.count * currentScrollBar.getIncrement();

	if (end > currentScrollBar.getMaximum()
			- currentScrollBar.getThumb()) {
		end = currentScrollBar.getMaximum()
				- currentScrollBar.getThumb();
	}

	if (end < currentScrollBar.getMinimum()) {
		end = currentScrollBar.getMinimum();
	}

	startEffect(new MoveScrollBar(currentScrollBar, start, end,
			2000, movement, null, null));

}
 
Example 2
Source File: CustomPreviewTable.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private void scrollTable( ScrollBar widget, KeyEvent event )
{
	int newSelectionValue = widget.getSelection( );
	if ( event.keyCode == SWT.ARROW_LEFT )
	{
		newSelectionValue -= TableCanvas.SCROLL_HORIZONTAL_STEP;
	}
	else if ( event.keyCode == SWT.ARROW_RIGHT )
	{
		newSelectionValue += TableCanvas.SCROLL_HORIZONTAL_STEP;
	}
	else if ( event.keyCode == SWT.PAGE_UP 
			|| event.keyCode == SWT.ARROW_UP )
	{
		newSelectionValue -= 1;
	}
	else if ( event.keyCode == SWT.PAGE_DOWN
			|| event.keyCode == SWT.ARROW_DOWN )
	{
		newSelectionValue += 1;
	}

	if ( newSelectionValue < widget.getMinimum( ) )
	{
		newSelectionValue = widget.getMinimum( );
	}
	else if ( newSelectionValue > widget.getMaximum( ) )
	{
		newSelectionValue = widget.getMaximum( );
	}

	widget.setSelection( newSelectionValue );
	Event newEvent = new Event( );
	newEvent.widget = widget;
	newEvent.type = SWT.Selection;
	newEvent.data = event.data;
	widget.notifyListeners( SWT.Selection, newEvent );
}
 
Example 3
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 4
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( );
}