eu.webtoolkit.jwt
Class WSlider

java.lang.Object
  extended by eu.webtoolkit.jwt.WObject
      extended by eu.webtoolkit.jwt.WWidget
          extended by eu.webtoolkit.jwt.WWebWidget
              extended by eu.webtoolkit.jwt.WInteractWidget
                  extended by eu.webtoolkit.jwt.WFormWidget
                      extended by eu.webtoolkit.jwt.WSlider

public class WSlider
extends WFormWidget

A horizontal or vertical slider control.

A slider allows the user to specify an integer value within a particular range using a visual slider.

The slider must be sized explicitly using resize() or by a layout manager. The default size is 150 x 50 pixels for a horizontal slider, and 50 x 150 pixels for a vertical slider.

Horizontal slider with ticks on both sides.

Horizontal slider with ticks on both sides.

CSS

The non-native slider (HTML4, see setNativeControl()) is styled by the current CSS theme. The look can be overridden using the Wt-slider-[hv] CSS class and the following selectors (shown here for a horizontal slider, the vertical slider is equivalent but using Wt-slider-v instead of Wt-slider-h:

 .Wt-slider-h .Wt-slider-bg : A background sized with 5px left/right margin
 .Wt-slider-h .Wt-e         : A west background image (5px width)
 .Wt-slider-h .Wt-w         : An east background image (5px width)
 .Wt-slider-h .handle       : The handle (20px width)
 


Nested Class Summary
static class WSlider.TickPosition
          Enumeration that specifies the location of ticks.
 
Field Summary
static java.util.EnumSet<WSlider.TickPosition> NoTicks
          Do not render ticks.
static java.util.EnumSet<WSlider.TickPosition> TicksBothSides
          Render ticks on both sides.
 
Constructor Summary
WSlider()
          Creates a default horizontal slider.
WSlider(Orientation orientation)
          Creates a default slider of the given orientation.
WSlider(Orientation orientation, WContainerWidget parent)
          Creates a default slider of the given orientation.
WSlider(WContainerWidget parent)
          Creates a default horizontal slider.
 
Method Summary
 int getMaximum()
          Returns the maximum value.
 int getMinimum()
          Returns the minimum value.
 Orientation getOrientation()
          Returns the slider orientation.
 int getTickInterval()
          Returns the tick interval.
 java.util.EnumSet<WSlider.TickPosition> getTickPosition()
          Returns the tick position.
 int getValue()
          Returns the current slider value.
 java.lang.String getValueText()
          Returns the current value.
 boolean isNativeControl()
          Returns whether a native HTML5 control is used.
protected  void layoutSizeChanged(int width, int height)
          Virtual method that indicates a size change.
 void remove()
          Destructor.
protected  void render(java.util.EnumSet<RenderFlag> flags)
           
 void resize(WLength width, WLength height)
          Resizes the widget.
 void setDisabled(boolean disabled)
          Sets whether the widget is disabled.
 void setMaximum(int maximum)
          Sets the maximum value.
 void setMinimum(int minimum)
          Sets the minimum value.
 void setNativeControl(boolean nativeControl)
          Configures whether a native HTML5 control should be used.
 void setOrientation(Orientation orientation)
          Sets the slider orientation.
 void setRange(int minimum, int maximum)
          Sets the value range.
 void setTickInterval(int tickInterval)
          Sets the tick interval.
 void setTickPosition(java.util.EnumSet<WSlider.TickPosition> tickPosition)
          Sets the tick position.
 void setTickPosition(WSlider.TickPosition tickPositio, WSlider.TickPosition... tickPosition)
          Sets the tick position.
 void setValue(int value)
          Sets the slider value.
 void setValueText(java.lang.String value)
          Sets the value text.
 JSignal1<java.lang.Integer> sliderMoved()
          Signal emitted while the user drags the slider.
 Signal1<java.lang.Integer> valueChanged()
          Signal emitted when the user has changed the value of the slider.
 
Methods inherited from class eu.webtoolkit.jwt.WFormWidget
blurred, changed, enableAjax, focussed, getEmptyText, getLabel, getTabIndex, getValidator, hasFocus, isReadOnly, propagateSetEnabled, refresh, selected, setEmptyText, setEnabled, setFocus, setFocus, setHidden, setReadOnly, setTabIndex, setValidator, validate, validated
 
Methods inherited from class eu.webtoolkit.jwt.WInteractWidget
clicked, doubleClicked, enterPressed, escapePressed, gestureChanged, gestureEnded, gestureStarted, isEnabled, keyPressed, keyWentDown, keyWentUp, load, mouseDragged, mouseMoved, mouseWentDown, mouseWentOut, mouseWentOver, mouseWentUp, mouseWheel, setDraggable, setDraggable, setDraggable, setDraggable, touchEnded, touchMoved, touchStarted
 
Methods inherited from class eu.webtoolkit.jwt.WWebWidget
addStyleClass, callJavaScriptMember, childrenChanged, doJavaScript, domCanBeSaved, escapeText, escapeText, escapeText, escapeText, find, getAttributeValue, getChildren, getClearSides, getDecorationStyle, getFloatSide, getHeight, getId, getJavaScriptMember, getLineHeight, getMargin, getMaximumHeight, getMaximumWidth, getMinimumHeight, getMinimumWidth, getOffset, getPositionScheme, getStyleClass, getToolTip, getVerticalAlignment, getVerticalAlignmentLength, getWidth, isDisabled, isHidden, isHiddenKeepsGeometry, isInline, isLoaded, isPopup, isRendered, isVisible, jsStringLiteral, jsStringLiteral, removeScript, removeStyleClass, setAttributeValue, setClearSides, setDecorationStyle, setFloatSide, setHiddenKeepsGeometry, setId, setInline, setJavaScriptMember, setLineHeight, setLoadLaterWhenInvisible, setMargin, setMaximumSize, setMinimumSize, setOffsets, setPopup, setPositionScheme, setSelectable, setStyleClass, setToolTip, setVerticalAlignment, updateSignalConnection
 
Methods inherited from class eu.webtoolkit.jwt.WWidget
acceptDrops, acceptDrops, addCssRule, addCssRule, addStyleClass, animateHide, animateShow, boxBorder, boxPadding, containsExposed, disable, dropEvent, enable, getDrop, getJsRef, getParent, hide, htmlText, isLayoutSizeAware, positionAt, positionAt, removeStyleClass, resize, setClearSides, setHeight, setHidden, setLayoutSizeAware, setMargin, setMargin, setMargin, setMargin, setMargin, setOffsets, setOffsets, setOffsets, setOffsets, setOffsets, setToolTip, setVerticalAlignment, setWidth, show, stopAcceptDrops, toggleStyleClass, toggleStyleClass, tr
 
Methods inherited from class eu.webtoolkit.jwt.WObject
addChild, getObjectName, setObjectName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NoTicks

public static final java.util.EnumSet<WSlider.TickPosition> NoTicks
Do not render ticks.


TicksBothSides

public static final java.util.EnumSet<WSlider.TickPosition> TicksBothSides
Render ticks on both sides.

Constructor Detail

WSlider

public WSlider(WContainerWidget parent)
Creates a default horizontal slider.

The slider shows no ticks, has a range from 0 to 99, and has tickInterval of 0 (defaulting to three ticks over the whole range).

The initial value is 0.


WSlider

public WSlider()
Creates a default horizontal slider.

Calls this((WContainerWidget)null)


WSlider

public WSlider(Orientation orientation,
               WContainerWidget parent)
Creates a default slider of the given orientation.

The slider shows no ticks, has a range from 0 to 99, and has tickInterval of 0 (defaulting to three ticks over the whole range).

The initial value is 0.


WSlider

public WSlider(Orientation orientation)
Creates a default slider of the given orientation.

Calls this(orientation, (WContainerWidget)null)

Method Detail

remove

public void remove()
Destructor.

Overrides:
remove in class WFormWidget
See Also:
WContainerWidget.removeWidget(WWidget widget)

setNativeControl

public void setNativeControl(boolean nativeControl)
Configures whether a native HTML5 control should be used.

When native, the new "range" input element, specified by HTML5 and when implemented by the browser, is used rather than the built-in element. A native control is styled by the browser (usually in sync with the OS) rather than through the theme chosen. Settings like tick interval and tick position are ignored.

Note: Vertically oriented sliders are in theory supported by the HTML5 input element, but in practice are usually not rendered correctly by the browser.


isNativeControl

public boolean isNativeControl()
Returns whether a native HTML5 control is used.

Taking into account the preference for a native control, configured using setNativeControl(), this method returns whether a native control is actually being used.


setOrientation

public void setOrientation(Orientation orientation)
Sets the slider orientation.

See Also:
getOrientation()

getOrientation

public Orientation getOrientation()
Returns the slider orientation.

See Also:
setOrientation(Orientation orientation)

setTickInterval

public void setTickInterval(int tickInterval)
Sets the tick interval.

The tick interval specifies the interval for placing ticks along the slider. The interval is specified in value units (not pixel units). A value of 0 specifies an automatic tick interval, which defaults to 3 ticks spanning the whole range.

See Also:
getTickInterval(), setTickPosition(EnumSet tickPosition)

getTickInterval

public int getTickInterval()
Returns the tick interval.

See Also:
setTickInterval(int tickInterval)

setTickPosition

public void setTickPosition(java.util.EnumSet<WSlider.TickPosition> tickPosition)
Sets the tick position.

The tick position indicates if and where ticks are placed around the slider groove.

See Also:
getTickPosition(), setTickInterval(int tickInterval)

setTickPosition

public final void setTickPosition(WSlider.TickPosition tickPositio,
                                  WSlider.TickPosition... tickPosition)
Sets the tick position.

Calls setTickPosition(EnumSet.of(tickPositio, tickPosition))


getTickPosition

public java.util.EnumSet<WSlider.TickPosition> getTickPosition()
Returns the tick position.

See Also:
setTickPosition(EnumSet tickPosition), setTickInterval(int tickInterval)

setValue

public void setValue(int value)
Sets the slider value.

The value is automatically trimmed to the valid range ( getMinimum() to getMaximum()).

See Also:
getValue()

getValue

public int getValue()
Returns the current slider value.

See Also:
setValue(int value)

setMaximum

public void setMaximum(int maximum)
Sets the maximum value.

The maximum value defines the upper limit of the valid range. The lower limit and current value are automatically adjusted to remain valid.

See Also:
getMaximum(), setMinimum(int minimum), setRange(int minimum, int maximum)

getMaximum

public int getMaximum()
Returns the maximum value.

See Also:
setMaximum(int maximum)

setMinimum

public void setMinimum(int minimum)
Sets the minimum value.

The minimum value defines the lower limit of the valid range. The upper limit and current value are automatically adjusted to remain valid.

See Also:
getMinimum(), setMaximum(int maximum), setRange(int minimum, int maximum)

getMinimum

public int getMinimum()
Returns the minimum value.

See Also:
setMinimum(int minimum)

setRange

public void setRange(int minimum,
                     int maximum)
Sets the value range.

See Also:
setMinimum(int minimum), setMaximum(int maximum)

valueChanged

public Signal1<java.lang.Integer> valueChanged()
Signal emitted when the user has changed the value of the slider.

The new value is passed as the argument.

See Also:
sliderMoved()

sliderMoved

public JSignal1<java.lang.Integer> sliderMoved()
Signal emitted while the user drags the slider.

The current dragged position is passed as the argument. Note that the slider value is not changed while dragging the slider, but only after the slider has been released.

See Also:
valueChanged()

setDisabled

public void setDisabled(boolean disabled)
Description copied from class: WWidget
Sets whether the widget is disabled.

Enables or disables the widget (including all its descendant widgets). setDisabled(false) will enable this widget and all descendant widgets that are not disabled. A widget is only enabled if it and all its ancestors in the widget tree are disabled.

Typically, a disabled form widget will not allow changing the value, and disabled widgets will not react to mouse click events.

Overrides:
setDisabled in class WWebWidget
See Also:
WWidget.disable(), WWidget.enable()

resize

public void resize(WLength width,
                   WLength height)
Description copied from class: WWidget
Resizes the widget.

Specify a new size for this widget, by specifying width and height. By default a widget has automatic width and height, see WLength#isAuto().

This applies to CSS-based layout, and only block widgets can be given a size reliably.

When inserted in a layout manager, the widget may be informed about its current size using setLayoutSizeAware(). If you have defined a "wtResize()" JavaScript method for the widget, then this method will also be called. operation.

Overrides:
resize in class WWebWidget
See Also:
WWidget.getWidth(), WWidget.getHeight()

getValueText

public java.lang.String getValueText()
Description copied from class: WFormWidget
Returns the current value.

This returns the current value as a string.

Specified by:
getValueText in class WFormWidget

setValueText

public void setValueText(java.lang.String value)
Description copied from class: WFormWidget
Sets the value text.

This sets the current value from a string value.

Specified by:
setValueText in class WFormWidget

layoutSizeChanged

protected void layoutSizeChanged(int width,
                                 int height)
Description copied from class: WWidget
Virtual method that indicates a size change.

This method propagates the client-side width and height of the widget when the widget is contained by a layout manager and setLayoutSizeAware(true) was called.

Overrides:
layoutSizeChanged in class WWidget
See Also:
WWidget.setLayoutSizeAware(boolean aware)

render

protected void render(java.util.EnumSet<RenderFlag> flags)
Overrides:
render in class WFormWidget