Wt
3.3.0
|
A horizontal or vertical slider control. More...
#include <Wt/WSlider>
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 | setNativeControl (bool nativeControl) |
Configures whether a native HTML5 control should be used. | |
bool | nativeControl () const |
Returns whether a native HTML5 control is used. | |
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. | |
virtual 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. | |
void | setHandleWidth (int width) |
Sets the slider handle width. | |
int | handleWidth () const |
Returns the handle width. | |
virtual void | setDisabled (bool disabled) |
Sets whether the widget is disabled. | |
virtual void | resize (const WLength &width, const WLength &height) |
Resizes the widget. | |
virtual WString | valueText () const |
Returns the current value. | |
virtual void | setValueText (const WString &value) |
Sets the value text. | |
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. | |
Protected Member Functions | |
virtual void | paintTick (WPainter &painter, int value, int x, int y) |
Paints a slider ticks (for a non-native widget) | |
virtual WInteractWidget * | createHandle () |
Creates the handle (for a non-native widget) | |
virtual void | layoutSizeChanged (int width, int height) |
Virtual method that indicates a size change. | |
virtual void | render (WFlags< RenderFlag > flags) |
Renders the widget. |
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.
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(this, &ThisClass::scaleShape);
The non-native slider (HTML4, see setNativeControl()) is styled by the current CSS theme.
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.
WInteractWidget * Wt::WSlider::createHandle | ( | ) | [protected, virtual] |
Creates the handle (for a non-native widget)
The default implementation creates a container widget. You may want to specialize this function if you want to have more control on the handle appearance or if you want to associate with the handle a tooltip or other information (e.g. a popup balloon).
int Wt::WSlider::handleWidth | ( | ) | const |
Returns the handle width.
void Wt::WSlider::layoutSizeChanged | ( | int | width, |
int | height | ||
) | [protected, virtual] |
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.
Reimplemented from Wt::WWidget.
int Wt::WSlider::maximum | ( | ) | const |
Returns the maximum value.
int Wt::WSlider::minimum | ( | ) | const |
Returns the minimum value.
bool Wt::WSlider::nativeControl | ( | ) | const |
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.
Orientation Wt::WSlider::orientation | ( | ) | const |
Returns the slider orientation.
void Wt::WSlider::paintTick | ( | WPainter & | painter, |
int | value, | ||
int | x, | ||
int | y | ||
) | [protected, virtual] |
Paints a slider ticks (for a non-native widget)
The default implementation draws ticks taking into account the the tickPosition.
The mid point for the tick should be at position (x, y). The value
that corresponds to the tick is also passed.
void Wt::WSlider::render | ( | WFlags< RenderFlag > | flags | ) | [protected, virtual] |
Renders the widget.
This function renders the widget (or an update for the widget), after this has been scheduled using scheduleRender().
The default implementation will render the widget by serializing changes to JavaScript and HTML. You may want to reimplement this widget if you have been postponing some of the layout / rendering implementation until the latest moment possible. In that case you should make sure you call the base implementation however.
Reimplemented from Wt::WFormWidget.
Resizes the widget.
Specifies a fixed size for this widget, setting CSS width
and height
properties. By default a widget has automatic width and height, which sets a size for the widget following CSS rules.
When the widget is not managed by a layout manager, the automatic (natural) size of a widget depends on whether they widget is a block or inline widget:
When inserted in a layout manager, the size set will be used as a widget's preferred size, but the widget may be given a different size by the layout manager based on available space and stretch factors. The actual size given by a layout manager may be retrieved by making the widget "layout size aware", using setLayoutSizeAware(). If you have defined a "wtResize()"
JavaScript method for the widget, then this method will also be called.
The default width and height of a widget is WLength::Auto.
Reimplemented from Wt::WWebWidget.
void Wt::WSlider::setDisabled | ( | bool | disabled | ) | [virtual] |
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.
Reimplemented from Wt::WWebWidget.
void Wt::WSlider::setHandleWidth | ( | int | width | ) |
Sets the slider handle width.
This sets the width for the handle, which is needed to accurately position the handle.
The default value is 20 pixels.
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::setNativeControl | ( | bool | 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.
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 | ) | [virtual] |
void Wt::WSlider::setValueText | ( | const WString & | value | ) | [virtual] |
JSignal<int>& Wt::WSlider::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.
int Wt::WSlider::tickInterval | ( | ) | const |
Returns the tick interval.
WFlags<TickPosition> Wt::WSlider::tickPosition | ( | ) | const |
Returns the tick position.
int Wt::WSlider::value | ( | ) | const |
Returns the current slider value.
Signal<int>& Wt::WSlider::valueChanged | ( | ) |
Signal emitted when the user has changed the value of the slider.
The new value is passed as the argument.
WString Wt::WSlider::valueText | ( | ) | const [virtual] |