fltk::ValueSlider Class Reference

Inherits fltk::Slider.

List of all members.

Public Member Functions

void draw ()
int handle (int)
void layout ()
virtual void value_damage ()

Detailed Description

Controls a single floating point value through a combination of a FloatInput and a Slider.


As this is a subclass of Slider, all slider methods work, for setting the slider size, tick marks, etc.

The user can type a new value into the input area. If step() is greater or equal to 1.0 an IntInput is used, this prevents the user from typing anything other than digits. If step() is less than one then the user can type floating point values with decimal points and exponents.

The user can type any value they want into the text field, including ones outside the range() or non-multiples of the step(). If you want to prevent this, make the callback function reset the value to a legal one.

By default the callback is done when the user moves the slider, when they use up/down keys to change the number in the text, or if they edit the text, when they hit the Enter key or they click on another widget or put the focus on another widget. Changing when() to fltk::WHEN_CHANGED will make it do the callback on every edit of the text.

You can get at the input field by using the public "input" instance variable. For instance you can clobber the text to a word with value_input->input.static_text("word"). You can also set the size of it (call layout() first).

Member Function Documentation

void ValueSlider::draw ( void  ) [virtual]

Fltk calls this virtual function to draw the widget, after setting up the graphics (current window, xy translation, etc) so that any drawing functions will go into this widget.

User code should not call this! You probably want to call redraw().

The default version calls draw_box() and draw_label(), thus drawing the box() to fill the widget and putting the label() and image() inside it to fill it, unless the align() flags are set to put it outside.

Information on how to write your own version is here.

Reimplemented from fltk::Slider.

int ValueSlider::handle ( int  event) [virtual]

The base class handle() accepts FOCUS and recognizes a number of keystrokes that adjust the value. A subclass can call this to get these keystrokes, it can also do it's own keystroke handling if it wants.

Reimplemented from fltk::Slider.

void ValueSlider::layout ( ) [virtual]

Virtual function to respond to layout_damage(), it should calculate the correct size of this widget and all it's children. This function is called by fltk or by the layout() method in other widgets. User programs should not call it.

A widget is allowed to alter it's own size in a layout() method, to indicate a size that the data will fit in. A parent widget is then expected to rearrange itself to accomodate the new size. This may mean it will move the widget and thus layout() will be called again.

You can look at layout_damage() to find out why this is being called.

The base class redraws the widget.

Reimplemented from fltk::Widget.

void ValueSlider::value_damage ( ) [virtual]

Subclasses must implement this. It is called whenever the value() changes. They must call redraw() if necessary.

Reimplemented from fltk::Valuator.

The documentation for this class was generated from the following files: