Java Code Examples for org.eclipse.swt.widgets.ScrollBar#setThumb()
The following examples show how to use
org.eclipse.swt.widgets.ScrollBar#setThumb() .
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 |
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 |
/** * 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: TagCloud.java From gef with Eclipse Public License 2.0 | 5 votes |
private void updateScrollbars() { if (zoomLayerImage == null) { return; } Rectangle rect = zoomLayerImage.getBounds(); Rectangle client = getClientArea(); ScrollBar hBar = getHorizontalBar(); ScrollBar vBar = getVerticalBar(); if (hBar != null) { hBar.setMaximum(rect.width); hBar.setThumb(Math.min(rect.width, client.width)); int hPage = rect.width - client.width; int hSelection = hBar.getSelection(); if (hSelection >= hPage) { if (hPage <= 0) hSelection = 0; origin.x = -hSelection; } } if (vBar != null) { vBar.setMaximum(rect.height); vBar.setThumb(Math.min(rect.height, client.height)); int vPage = rect.height - client.height; int vSelection = vBar.getSelection(); if (vSelection >= vPage) { if (vPage <= 0) vSelection = 0; origin.y = -vSelection; } } }
Example 4
Source File: ScrollView.java From tracecompass with Eclipse Public License 2.0 | 4 votes |
/** * 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 5
Source File: NatTable.java From translationstudio8 with GNU General Public License v2.0 | 4 votes |
private void disableScrollBar(ScrollBar scrollBar) { scrollBar.setMinimum(0); scrollBar.setMaximum(1); scrollBar.setThumb(1); scrollBar.setEnabled(false); }
Example 6
Source File: NatTable.java From tmxeditor8 with GNU General Public License v2.0 | 4 votes |
private void disableScrollBar(ScrollBar scrollBar) { scrollBar.setMinimum(0); scrollBar.setMaximum(1); scrollBar.setThumb(1); scrollBar.setEnabled(false); }
Example 7
Source File: IconCanvas.java From birt with Eclipse Public License 1.0 | 4 votes |
/** * 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 8
Source File: ImageCanvas.java From birt with Eclipse Public License 1.0 | 4 votes |
/** * 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( ); }