ScrollBar

Instances of this class are selectable user interface objects that represent a range of positive, numeric values. <p> At any given moment, a given scroll bar will have a single 'selection' that is considered to be its value, which is constrained to be within the range of values the scroll bar represents (that is, between its <em>minimum</em> and <em>maximum</em> values). </p><p> Typically, scroll bars will be made up of five areas: <ol> <li>an arrow button for decrementing the value</li> <li>a page decrement area for decrementing the value by a larger amount</li> <li>a <em>thumb</em> for modifying the value by mouse dragging</li> <li>a page increment area for incrementing the value by a larger amount</li> <li>an arrow button for incrementing the value</li> </ol> Based on their style, scroll bars are either <code>HORIZONTAL</code> (which have a left facing button for decrementing the value and a right facing button for incrementing it) or <code>VERTICAL</code> (which have an upward facing button for decrementing the value and a downward facing buttons for incrementing it). </p><p> On some platforms, the size of the scroll bar's thumb can be varied relative to the magnitude of the range of values it represents (that is, relative to the difference between its maximum and minimum values). Typically, this is used to indicate some proportional value such as the ratio of the visible area of a document to the total amount of space that it would take to display it. SWT supports setting the thumb size even if the underlying platform does not, but in this case the appearance of the scroll bar will not change. </p><p> Scroll bars are created by specifying either <code>H_SCROLL</code>, <code>V_SCROLL</code> or both when creating a <code>Scrollable</code>. They are accessed from the <code>Scrollable</code> using <code>getHorizontalBar</code> and <code>getVerticalBar</code>. </p><p> Note: Scroll bars are not Controls. On some platforms, scroll bars that appear as part of some standard controls such as a text or list have no operating system resources and are not children of the control. For this reason, scroll bars are treated specially. To create a control that looks like a scroll bar but has operating system resources, use <code>Slider</code>. </p> <dl> <dt><b>Styles:</b></dt> <dd>HORIZONTAL, VERTICAL</dd> <dt><b>Events:</b></dt> <dd>Selection</dd> </dl> <p> Note: Only one of the styles HORIZONTAL and VERTICAL may be specified. </p><p> IMPORTANT: This class is <em>not</em> intended to be subclassed. </p>

@see Slider @see Scrollable @see Scrollable#getHorizontalBar @see Scrollable#getVerticalBar @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: ControlExample</a> @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>

Constructors

this
this(Scrollable parent, int style)

Creates a new instance of the widget.

Members

Functions

addSelectionListener
void addSelectionListener(SelectionListener listener)

Adds the listener to the collection of listeners who will be notified when the user changes the receiver's value, by sending it one of the messages defined in the <code>SelectionListener</code> interface. <p> When <code>widgetSelected</code> is called, the event object detail field contains one of the following values: <code>SWT.NONE</code> - for the end of a drag. <code>SWT.DRAG</code>. <code>SWT.HOME</code>. <code>SWT.END</code>. <code>SWT.ARROW_DOWN</code>. <code>SWT.ARROW_UP</code>. <code>SWT.PAGE_DOWN</code>. <code>SWT.PAGE_UP</code>. <code>widgetDefaultSelected</code> is not called. </p>

getEnabled
bool getEnabled()

Returns <code>true</code> if the receiver is enabled, and <code>false</code> otherwise. A disabled control is typically not selectable from the user interface and draws with an inactive or "grayed" look.

getIncrement
int getIncrement()

Returns the amount that the receiver's value will be modified by when the up/down (or right/left) arrows are pressed.

getMaximum
int getMaximum()

Returns the maximum value which the receiver will allow.

getMinimum
int getMinimum()

Returns the minimum value which the receiver will allow.

getPageIncrement
int getPageIncrement()

Returns the amount that the receiver's value will be modified by when the page increment/decrement areas are selected.

getParent
Scrollable getParent()

Returns the receiver's parent, which must be a Scrollable.

getSelection
int getSelection()

Returns the single 'selection' that is the receiver's value.

getSize
Point getSize()

Returns a point describing the receiver's size. The x coordinate of the result is the width of the receiver. The y coordinate of the result is the height of the receiver.

getThumb
int getThumb()

Returns the size of the receiver's thumb relative to the difference between its maximum and minimum values.

getVisible
bool getVisible()

Returns <code>true</code> if the receiver is visible, and <code>false</code> otherwise. <p> If one of the receiver's ancestors is not visible or some other condition makes the receiver not visible, this method may still indicate that it is considered visible even though it may not actually be showing. </p>

isEnabled
bool isEnabled()

Returns <code>true</code> if the receiver is enabled and all of the receiver's ancestors are enabled, and <code>false</code> otherwise. A disabled control is typically not selectable from the user interface and draws with an inactive or "grayed" look.

isVisible
bool isVisible()

Returns <code>true</code> if the receiver is visible and all of the receiver's ancestors are visible and <code>false</code> otherwise.

removeSelectionListener
void removeSelectionListener(SelectionListener listener)

Removes the listener from the collection of listeners who will be notified when the user changes the receiver's value.

setEnabled
void setEnabled(bool enabled)

Enables the receiver if the argument is <code>true</code>, and disables it otherwise. A disabled control is typically not selectable from the user interface and draws with an inactive or "grayed" look.

setIncrement
void setIncrement(int value)

Sets the amount that the receiver's value will be modified by when the up/down (or right/left) arrows are pressed to the argument, which must be at least one.

setMaximum
void setMaximum(int value)

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.

setMinimum
void setMinimum(int value)

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.

setPageIncrement
void setPageIncrement(int value)

Sets the amount that the receiver's value will be modified by when the page increment/decrement areas are selected to the argument, which must be at least one.

setSelection
void setSelection(int value)

Sets the single <em>selection</em> that is the receiver's value to the argument which must be greater than or equal to zero.

setThumb
void setThumb(int value)

Sets the size of the receiver's thumb relative to the difference between its maximum and minimum values. This new value will be ignored if it is less than one, and will be clamped if it exceeds the receiver's current range.

setValues
void setValues(int selection, int minimum, int maximum, int thumb, int increment, int pageIncrement)

Sets the receiver's selection, minimum value, maximum value, thumb, increment and page increment all at once. <p> Note: This is similar to setting the values individually using the appropriate methods, but may be implemented in a more efficient fashion on some platforms. </p>

setVisible
void setVisible(bool visible)

Marks the receiver as visible if the argument is <code>true</code>, and marks it invisible otherwise. <p> If one of the receiver's ancestors is not visible or some other condition makes the receiver not visible, marking it visible may not actually cause it to be displayed. </p>

Inherited Members

From Widget

handle
GtkWidget* handle;

the handle to the OS resource (Warning: This field is platform dependent) <p> <b>IMPORTANT:</b> This field is <em>not</em> part of the SWT public API. It is marked public only so that it can be shared within the packages provided by SWT. It is not available on all platforms and should never be accessed from application code. </p>

addListener
void addListener(int eventType, Listener listener)

Adds the listener to the collection of listeners who will be notified when an event of the given type occurs. When the event does occur in the widget, the listener is notified by sending it the <code>handleEvent()</code> message. The event type is one of the event constants defined in class <code>SWT</code>.

addDisposeListener
void addDisposeListener(DisposeListener listener)

Adds the listener to the collection of listeners who will be notified when the widget is disposed. When the widget is disposed, the listener is notified by sending it the <code>widgetDisposed()</code> message.

checkParent
void checkParent(Widget parent)

Throws an exception if the specified widget can not be used as a parent for the receiver.

checkSubclass
void checkSubclass()

Checks that this class can be subclassed. <p> The SWT class library is intended to be subclassed only at specific, controlled points (most notably, <code>Composite</code> and <code>Canvas</code> when implementing new widgets). This method enforces this rule unless it is overridden. </p><p> <em>IMPORTANT:</em> By providing an implementation of this method that allows a subclass of a class which does not normally allow subclassing to be created, the implementer agrees to be fully responsible for the fact that any such subclass will likely fail between SWT releases and will be strongly platform specific. No support is provided for user-written classes which are implemented in this fashion. </p><p> The ability to subclass outside of the allowed SWT classes is intended purely to enable those not on the SWT development team to implement patches in order to get around specific limitations in advance of when those limitations can be addressed by the team. Subclassing should not be attempted without an intimate and detailed understanding of the hierarchy. </p>

checkWidget
void checkWidget()

Throws an <code>SWTException</code> if the receiver can not be accessed by the caller. This may include both checks on the state of the receiver and more generally on the entire execution context. This method <em>should</em> be called by widget implementors to enforce the standard SWT invariants. <p> Currently, it is an error to invoke any method (other than <code>isDisposed()</code>) on a widget that has had its <code>dispose()</code> method called. It is also an error to call widget methods from any thread that is different from the thread that created the widget. </p><p> In future releases of SWT, there may be more or fewer error checks and exceptions may be thrown for different reasons. </p>

dispose
void dispose()

Disposes of the operating system resources associated with the receiver and all its descendants. After this method has been invoked, the receiver and all descendants will answer <code>true</code> when sent the message <code>isDisposed()</code>. Any internal connections between the widgets in the tree will have been removed to facilitate garbage collection. <p> NOTE: This method is not called recursively on the descendants of the receiver. This means that, widget implementers can not detect when a widget is being disposed of by re-implementing this method, but should instead listen for the <code>Dispose</code> event. </p>

getData
Object getData()

Returns the application defined widget data associated with the receiver, or null if it has not been set. The <em>widget data</em> is a single, unnamed field that is stored with every widget. <p> Applications may put arbitrary objects in this field. If the object stored in the widget data needs to be notified when the widget is disposed of, it is the application's responsibility to hook the Dispose event on the widget and do so. </p>

getData
Object getData(String key)

Returns the application defined property of the receiver with the specified name, or null if it has not been set. <p> Applications may have associated arbitrary objects with the receiver in this fashion. If the objects stored in the properties need to be notified when the widget is disposed of, it is the application's responsibility to hook the Dispose event on the widget and do so. </p>

getDisplay
Display getDisplay()

Returns the <code>Display</code> that is associated with the receiver. <p> A widget's display is either provided when it is created (for example, top level <code>Shell</code>s) or is the same as its parent's display. </p>

getListeners
Listener[] getListeners(int eventType)

Returns an array of listeners who will be notified when an event of the given type occurs. The event type is one of the event constants defined in class <code>SWT</code>.

getStyle
int getStyle()

Returns the receiver's style information. <p> Note that the value which is returned by this method <em>may not match</em> the value which was provided to the constructor when the receiver was created. This can occur when the underlying operating system does not support a particular combination of requested styles. For example, if the platform widget used to implement a particular SWT widget always has scroll bars, the result of calling this method would always have the <code>SWT.H_SCROLL</code> and <code>SWT.V_SCROLL</code> bits set. </p>

isDisposed
bool isDisposed()

Returns <code>true</code> if the widget has been disposed, and <code>false</code> otherwise. <p> This method gets the dispose state for the widget. When a widget has been disposed, it is an error to invoke any other method using the widget. </p>

isListening
bool isListening(int eventType)

Returns <code>true</code> if there are any listeners for the specified event type associated with the receiver, and <code>false</code> otherwise. The event type is one of the event constants defined in class <code>SWT</code>.

notifyListeners
void notifyListeners(int eventType, Event event)

Notifies all of the receiver's listeners for events of the given type that one such event has occurred by invoking their <code>handleEvent()</code> method. The event type is one of the event constants defined in class <code>SWT</code>.

removeListener
void removeListener(int eventType, Listener handler)

Removes the listener from the collection of listeners who will be notified when an event of the given type occurs. The event type is one of the event constants defined in class <code>SWT</code>.

removeListener
void removeListener(int eventType, SWTEventListener handler)

Removes the listener from the collection of listeners who will be notified when an event of the given type occurs. <p> <b>IMPORTANT:</b> This method is <em>not</em> part of the SWT public API. It is marked public only so that it can be shared within the packages provided by SWT. It should never be referenced from application code. </p>

removeDisposeListener
void removeDisposeListener(DisposeListener listener)

Removes the listener from the collection of listeners who will be notified when the widget is disposed.

setData
void setData(Object data)

Sets the application defined widget data associated with the receiver to be the argument. The <em>widget data</em> is a single, unnamed field that is stored with every widget. <p> Applications may put arbitrary objects in this field. If the object stored in the widget data needs to be notified when the widget is disposed of, it is the application's responsibility to hook the Dispose event on the widget and do so. </p>

setData
void setData(String key, Object value)

Sets the application defined property of the receiver with the specified name to the given value. <p> Applications may associate arbitrary objects with the receiver in this fashion. If the objects stored in the properties need to be notified when the widget is disposed of, it is the application's responsibility to hook the Dispose event on the widget and do so. </p>

toString
String toString()

Returns a string containing a concise, human-readable description of the receiver.

Meta