/** * {@inheritDoc} */ public int getMaximum() { return scrollBar.getMaximum(); }
private void checkNeedUpdate() { if(fScrollBar != null){ if (fLastMax != fScrollBar.getMaximum() || fLastSelection != fScrollBar.getSelection()) { this.fAbstractThemedScrollBarAdapter.fPainter.redrawScrollBars(); } } }
public void scrollToEnd() { SWTAsync.assertGUI(); ScrollBar sb = consoleText.getVerticalBar(); if (sb != null) { sb.setSelection(sb.getMaximum()); } }
@Override public void runSupport() { if (isDisposed()) { return; } int pos = vBar.getSelection(); if ( distance > 0 ){ pos += distance; pos = Math.min( pos,vBar.getMaximum()); vBar.setSelection( pos ); }else{ pos += distance; pos = Math.max( pos,vBar.getMinimum()); vBar.setSelection( pos ); } swt_vBarChanged(); }}); }
/** * Sets the single <em>selection</em> that is the receiver's * value to the argument which must be greater than or equal * to zero. * * @param selection the new selection (must be zero or greater) * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public void setSelection (int selection) { checkWidget (); selection = Math.min (selection, getMaximum() - getThumb()); OS.g_signal_handlers_block_matched (adjustmentHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, VALUE_CHANGED); OS.gtk_adjustment_set_value (adjustmentHandle, selection); OS.g_signal_handlers_unblock_matched (adjustmentHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, VALUE_CHANGED); }
/** * Sets the single <em>selection</em> that is the receiver's * value to the argument which must be greater than or equal * to zero. * * @param selection the new selection (must be zero or greater) * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public void setSelection (int selection) { checkWidget (); selection = Math.min (selection, getMaximum() - getThumb()); OS.g_signal_handlers_block_matched (adjustmentHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, VALUE_CHANGED); OS.gtk_adjustment_set_value (adjustmentHandle, selection); OS.g_signal_handlers_unblock_matched (adjustmentHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, VALUE_CHANGED); }
/** * Sets the single <em>selection</em> that is the receiver's * value to the argument which must be greater than or equal * to zero. * * @param selection the new selection (must be zero or greater) * * @exception SWTException <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> * </ul> */ public void setSelection (int selection) { checkWidget (); selection = Math.min (selection, getMaximum() - getThumb()); OS.g_signal_handlers_block_matched (adjustmentHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, VALUE_CHANGED); OS.gtk_adjustment_set_value (adjustmentHandle, selection); OS.g_signal_handlers_unblock_matched (adjustmentHandle, OS.G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, VALUE_CHANGED); }
@Override public void install(AbstractThemedScrollBarAdapter abstractThemedScrollBarAdapter) { super.install(abstractThemedScrollBarAdapter); fStyledText.addModifyListener(this); this.fAbstractThemedScrollBarAdapter = abstractThemedScrollBarAdapter; fTextContent = fStyledText.getContent(); fTextContent.addTextChangeListener(this); if(fScrollBar != null){ fLastMax = fScrollBar.getMaximum(); fLastSelection = fScrollBar.getSelection(); } }
@Override public boolean computePositions(Rectangle currClientArea, Scrollable scrollable) { fHandleDrawnRect = null; if (this.fScrollBar == null || this.fScrollBar.getMaximum() - this.fScrollBar.getMinimum() <= 1 || !getVisible() || !this.fScrollBarSettings.getScrollBarThemed()) { return false; } StyledText styledText = (StyledText) scrollable; int lineWidth = getCurrentScrollBarWidth(); int w = currClientArea.width; int h = currClientArea.height - (styledText.getTopMargin() + styledText.getBottomMargin()); this.fScrollBarPositions = new ScrollBarPositions.ScrollBarPositionsVertical(this.fScrollBar.getMinimum(), this.fScrollBar.getMaximum(), styledText.getTopPixel(), h, w); fHandleDrawnRect = fScrollBarPositions.getHandleDrawRect(lineWidth); if (fHandleDrawnRect == null || h <= fHandleDrawnRect.height) { return false; } return true; }
@Override public boolean computePositions(Rectangle currClientArea, Scrollable scrollable) { fHandleDrawnRect = null; if (this.fScrollBar == null || this.fScrollBar.getMaximum() - this.fScrollBar.getMinimum() <= 1 || !getVisible() || !this.fScrollBarSettings.getScrollBarThemed()) { return false; } StyledText styledText = (StyledText) scrollable; int lineWidth = getCurrentScrollBarWidth(); int w = currClientArea.width - (styledText.getLeftMargin() + styledText.getRightMargin()); int h = currClientArea.height; fScrollBarPositions = new ScrollBarPositions.ScrollBarPositionsHorizontal(this.fScrollBar.getMinimum(), this.fScrollBar.getMaximum(), styledText.getHorizontalPixel(), h, w); fHandleDrawnRect = fScrollBarPositions.getHandleDrawRect(lineWidth); if (fHandleDrawnRect == null || w <= fHandleDrawnRect.width) { return false; } return true; }
/** * {@inheritDoc} */ public void setSelection(int selection) { // RAP [if]: ScrollBar#setSelection() does not limit the value // scrollBar.setSelection(selection); int minimum = scrollBar.getMinimum(); int maximum = scrollBar.getMaximum(); int thumb = scrollBar.getThumb(); if( selection < minimum ) { scrollBar.setSelection( minimum ); } else if ( selection > maximum - thumb ) { scrollBar.setSelection( maximum - thumb ); } else { scrollBar.setSelection( selection ); } }
@Override public void paintControl(GC gc, Rectangle currClientArea, Scrollable scrollable) { // At each paint, check if the content changed and keep the last // max/selection (unfortunately, it doesn't provide a reliable way // to listen such changes, so, we must poll it). if(fScrollBar != null){ fLastMax = fScrollBar.getMaximum(); fLastSelection = fScrollBar.getSelection(); } if (fTextContent != null && fStyledText.getContent() != fTextContent) { fTextContent.removeTextChangeListener(this); fTextContent = fStyledText.getContent(); fTextContent.addTextChangeListener(this); } super.paintControl(gc, currClientArea, scrollable); } }
void updateHorizontalBar (int newRightX, int rightXchange) { if (drawCount > 0) return; ScrollBar hBar = getHorizontalBar (); if (hBar == null) return; newRightX += horizontalOffset; int barMaximum = hBar.getMaximum (); if (newRightX > barMaximum) { /* item has extended beyond previous maximum */ hBar.setMaximum (newRightX); int clientAreaWidth = clientArea.width; int thumb = Math.min (newRightX, clientAreaWidth); hBar.setThumb (thumb); hBar.setPageIncrement (thumb); hBar.setVisible (clientAreaWidth <= newRightX); return; } int previousRightX = newRightX - rightXchange; if (previousRightX != barMaximum) { /* this was not the rightmost item, so just check for client width change */ int clientAreaWidth = clientArea.width; int thumb = Math.min (barMaximum, clientAreaWidth); hBar.setThumb (thumb); hBar.setPageIncrement (thumb); hBar.setVisible (clientAreaWidth <= barMaximum); return; } updateHorizontalBar (); /* must search for the new rightmost item */ } void updateVerticalBar () {
void setScrollBar(ScrollBar bar, int clientArea, int maximum, int margin) { int inactive = 1; if (clientArea < maximum) { bar.setMaximum(maximum - margin); bar.setThumb(clientArea - margin); bar.setPageIncrement(clientArea - margin); if (!alwaysShowScroll) bar.setVisible(true); } else if (bar.getThumb() != inactive || bar.getMaximum() != inactive) { bar.setValues(bar.getSelection(), bar.getMinimum(), inactive, inactive, bar.getIncrement(), inactive); } } /**
void setScrollBar(ScrollBar bar, int clientArea, int maximum, int margin) { int inactive = 1; if (clientArea < maximum) { bar.setMaximum(maximum - margin); bar.setThumb(clientArea - margin); bar.setPageIncrement(clientArea - margin); if (!alwaysShowScroll) bar.setVisible(true); } else if (bar.getThumb() != inactive || bar.getMaximum() != inactive) { bar.setValues(bar.getSelection(), bar.getMinimum(), inactive, inactive, bar.getIncrement(), inactive); } } /**
void setScrollBar(ScrollBar bar, int clientArea, int maximum, int margin) { int inactive = 1; if (clientArea < maximum) { bar.setMaximum(maximum - margin); bar.setThumb(clientArea - margin); bar.setPageIncrement(clientArea - margin); if (!alwaysShowScroll) bar.setVisible(true); } else if (bar.getThumb() != inactive || bar.getMaximum() != inactive) { bar.setValues(bar.getSelection(), bar.getMinimum(), inactive, inactive, bar.getIncrement(), inactive); } } /**
void setScrollBar(ScrollBar bar, int clientArea, int maximum, int margin) { int inactive = 1; if (clientArea < maximum) { bar.setMaximum(maximum - margin); bar.setThumb(clientArea - margin); bar.setPageIncrement(clientArea - margin); if (!alwaysShowScroll) bar.setVisible(true); } else if (bar.getThumb() != inactive || bar.getMaximum() != inactive) { bar.setValues(bar.getSelection(), bar.getMinimum(), inactive, inactive, bar.getIncrement(), inactive); } } /**
void setScrollBar(ScrollBar bar, int clientArea, int maximum, int margin) { int inactive = 1; if (clientArea < maximum) { bar.setMaximum(maximum - margin); bar.setThumb(clientArea - margin); bar.setPageIncrement(clientArea - margin); if (!alwaysShowScroll) bar.setVisible(true); } else if (bar.getThumb() != inactive || bar.getMaximum() != inactive) { bar.setValues(bar.getSelection(), bar.getMinimum(), inactive, inactive, bar.getIncrement(), inactive); } } /**
if (maximum != vBar.getMaximum ()) { vBar.setMaximum (maximum);
void onArrowRight (int stateMask) { ScrollBar hBar = getHorizontalBar (); if (hBar == null) return; int maximum = hBar.getMaximum (); int clientWidth = clientArea.width; if ((horizontalOffset + clientArea.width) == maximum) return; if (maximum <= clientWidth) return; int newSelection = Math.min (horizontalOffset + SIZE_HORIZONTALSCROLL, maximum - clientWidth); update (); GC gc = new GC (this); gc.copyArea ( 0, 0, clientArea.width, clientArea.height, horizontalOffset - newSelection, 0); gc.dispose (); if (header.getVisible ()) { Rectangle headerClientArea = header.getClientArea (); header.update (); gc = new GC (header); gc.copyArea ( 0, 0, headerClientArea.width, headerClientArea.height, horizontalOffset - newSelection, 0); gc.dispose(); } horizontalOffset = newSelection; hBar.setSelection (horizontalOffset); } void onArrowUp (int stateMask) {