A horizontal or vertical slider control. More...
#include <Wt/WSlider>
Inherits Wt::WCompositeWidget.
Public Types | |
enum | TickPosition { TicksAbove = 0x1, TicksBelow = 0x2, TicksLeft = 0x1, TicksRight = 0x2 } |
Enumeration that specifies the location of ticks. More... | |
Public Member Functions | |
WSlider (WContainerWidget *parent=0) | |
Creates a default horizontal slider. | |
WSlider (Orientation orientation, WContainerWidget *parent=0) | |
Creates a default slider of the given orientation. | |
~WSlider () | |
Destructor. | |
void | setOrientation (Wt::Orientation orientation) |
Sets the slider orientation. | |
Orientation | orientation () const |
Returns the slider orientation. | |
void | setTickInterval (int tickInterval) |
Sets the tick interval. | |
int | tickInterval () const |
Returns the tick interval. | |
void | setTickPosition (WFlags< TickPosition > tickPosition) |
Sets the tick position. | |
WFlags< TickPosition > | tickPosition () const |
Returns the tick position. | |
void | setValue (int value) |
Sets the slider value. | |
int | value () const |
Returns the current slider value. | |
void | setMaximum (int maximum) |
Sets the maximum value. | |
int | maximum () const |
Returns the maximum value. | |
void | setMinimum (int minimum) |
Sets the minimum value. | |
int | minimum () const |
Returns the minimum value. | |
void | setRange (int minimum, int maximum) |
Sets the value range. | |
Signal< int > & | valueChanged () |
Signal emitted when the user has changed the value of the slider. | |
JSignal< int > & | sliderMoved () |
Signal emitted while the user drags the slider. | |
virtual void | resize (const WLength &width, const WLength &height) |
Resizes the widget. | |
Static Public Attributes | |
static const Wt::WFlags < TickPosition > | NoTicks = 0 |
Do not render ticks. | |
static const Wt::WFlags < TickPosition > | TicksBothSides = TicksAbove | TicksBelow |
Render ticks on both sides. |
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 WWidget::resize(). The default size is 150 x 50 pixels for a horizontal slider, and 50 x 150 pixels for a vertical slider.
Usage example:
Wt::WSlider *scaleSlider = new Wt::WSlider(Wt::Horizontal); scaleSlider->setMinimum(0); scaleSlider->setMaximum(20); scaleSlider->setValue(10); scaleSlider->setTickInterval(5); scaleSlider->setTickPosition(Wt::WSlider::TicksBothSides); scaleSlider->resize(300, 50); scaleSlider->valueChanged().connect(SLOT(this, ThisClass::scaleShape));
Horizontal slider with ticks on both sides.
The slider is styled by the current CSS theme. The look can be overridden using the Wt-slider
CSS class and the following selectors:
.Wt-slider .handle-v : The vertical handle .Wt-slider .handle-h : The horizontal handle
Wt::WSlider::WSlider | ( | WContainerWidget * | parent = 0 |
) |
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.
Wt::WSlider::WSlider | ( | Orientation | orientation, | |
WContainerWidget * | parent = 0 | |||
) |
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.
int Wt::WSlider::maximum | ( | ) | const [inline] |
Returns the maximum value.
int Wt::WSlider::minimum | ( | ) | const [inline] |
Returns the minimum value.
Orientation Wt::WSlider::orientation | ( | ) | const [inline] |
Returns the slider orientation.
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.
Reimplemented from Wt::WCompositeWidget.
void Wt::WSlider::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.
void Wt::WSlider::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.
void Wt::WSlider::setOrientation | ( | Wt::Orientation | orientation | ) |
Sets the slider orientation.
void Wt::WSlider::setRange | ( | int | minimum, | |
int | maximum | |||
) |
Sets the value range.
void Wt::WSlider::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.
void Wt::WSlider::setTickPosition | ( | WFlags< TickPosition > | tickPosition | ) |
Sets the tick position.
The tick position indicates if and where ticks are placed around the slider groove.
void Wt::WSlider::setValue | ( | int | value | ) |
JSignal<int>& Wt::WSlider::sliderMoved | ( | ) | [inline] |
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.
int Wt::WSlider::tickInterval | ( | ) | const [inline] |
Returns the tick interval.
WFlags<TickPosition> Wt::WSlider::tickPosition | ( | ) | const [inline] |
Returns the tick position.
int Wt::WSlider::value | ( | ) | const [inline] |
Returns the current slider value.
Signal<int>& Wt::WSlider::valueChanged | ( | ) | [inline] |
Signal emitted when the user has changed the value of the slider.
The new value is passed as the argument.