/** * Sets the 'selection', which is the receiver's * value, to the argument which must be greater than or equal * to zero. * * @param value 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 value) { checkWidget(); updateBar(value, minimum, maximum, thumb); }
this.increment = increment; this.pageIncrement = pageIncrement; updateBar(selection, minimum, maximum, thumb);
/** * Sets the minimum value. If this value is negative or greater * than or equal to the maximum, the value is ignored. If necessary, * first the thumb and then the selection are adjusted to fit within * the new range. * * @param value the new minimum * * @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 setMinimum (int value) { checkWidget(); if (value < 0) return; if (value >= maximum) return; if (maximum - value < thumb) { thumb = maximum - value; } int selection = Math.min(maximum - thumb, Math.max (getSelection (), value)); this.minimum = value; updateBar(selection, value, maximum, thumb); }
/** * Sets the maximum. If this value is negative or less than or * equal to the minimum, the value is ignored. If necessary, first * the thumb and then the selection are adjusted to fit within the * new range. * * @param value the new maximum, which must be greater than the current minimum * * @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 setMaximum (int value) { checkWidget(); if (value < 0) return; if (value <= minimum) return; if (value - minimum < thumb) { thumb = value - minimum; } int selection = Math.max(minimum, Math.min (getSelection (), value - thumb)); this.maximum = value; updateBar(selection, minimum, value, thumb); }
/** * Sets the thumb value. The thumb value should be used to represent * the size of the visual portion of the current range. This value is * usually the same as the page increment value. * <p> * This new value will be ignored if it is less than one, and will be * clamped if it exceeds the receiver's current range. * </p> * * @param value the new thumb value, which must be at least one and not * larger than the size of the current range * * @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 setThumb (int value) { checkWidget(); if (value < 1) return; value = Math.min (value, maximum - minimum); updateBar(getSelection(), minimum, maximum, value); this.thumb = value; }
void createHandle () { NSScroller widget = (NSScroller)new SWTScroller().alloc(); NSRect rect = new NSRect(); if ((style & SWT.HORIZONTAL) != 0) { rect.width = 1; } else { rect.height = 1; } widget.initWithFrame(rect); widget.setEnabled(true); widget.setTarget(widget); widget.setAction(OS.sel_sendSelection); view = widget; updateBar(0, minimum, maximum, thumb); }