## class fltk::Valuator

### Class Hierarchy

    fltk::Widget
       |
       +----fltk::Valuator
               |
               +----fltk::Dial, fltk::Roller,
                    fltk::Slider, fltk::ValueInput

### Include Files

    #include <fltk/Valuator.h>

### Description

The `fltk::Valuator` class controls a single floating-point value and provides a consistent interface to set the value(), range(), and step(), and insures that callbacks are done the same for every object.

There are probably more of these classes in FLTK than any others:

In the above diagram each box surrounds an actual subclass. These are further differentiated by setting the `type()` of the widget to the symbolic value labeling the widget. The ones labelled "0" are the default versions with a `type(0)`. For consistency the symbol `fltk::VERTICAL` is defined as zero.

### Methods

fltk::Valuator ~Valuator format | linesize maximum minimum | pagesize range set_changed | step value

#### fltk::Valuator::Valuator(int x, int y, int w, int h, const char *label = 0)

Creates a new `fltk::Valuator` widget using the given position, size, and label string. The default boxtype is `fltk::NO_BOX`.

#### virtual fltk::Valuator::~Valuator()

Destroys the valuator.

#### double fltk::Valuator::value() const
int fltk::Valuator::value(double)

Get or set the current value. The new value is stored unchanged, even if it is outside the range or not a multiple of step().

#### float fltk::Valuator::minimum() const
void fltk::Valuator::minimum(double)
double fltk::Valuator::maximum() const
void fltk::Valuator::maximum(double)
void fltk::Valuator::range(double min, double max);

Sets the minimum and maximum values for the valuator. For most subclasses the user cannot move the value outside this range if it starts inside this range.

These values should be multiples of the step() to avoid ambiguity and possible implementation changes.

For most subclasses, the minimum may be greater than the maximum. This has the effect of "reversing" the object so the larger values are in the opposite direction. This also switches which end of the filled sliders is filled.

You probably need to `redraw()` the widget after changing the range.

#### float fltk::Valuator::step() const
void fltk::Valuator::step(double)

Get or set the step value. As the user moves the mouse the value is rounded to a multiple of this. fltk::Slider is very intelligent and tries to round to a power of 10 times 1, 2, or 5 times this, so you may want to try setting a very small step like .0001.

If this is zero (the default) then all rounding is disabled. This results in the smoothest controller movement but this is not recommended if you want to present the resulting numbers to the user as text, because they will have useless extra digits of precision.

For some widgets like fltk::Roller this is also the distance the value moves when the user drags the mouse 1 pixel. In these cases if step() is zero then it acts like it is .01.

Negative values produce undocumented results.

#### float fltk::Valuator::linesize() const
void fltk::Valuator::linesize(double)

The linesize is the amount the valuator moves in response to an arrow key, or the user clicking an up/down button. The default value is 1. Negative values and values that are not a multiple of step() produce undocumented results.

#### float fltk::Valuator::pagesize() const
void fltk::Valuator::pagesize(double)

The pagesize is the amount the valuator moves in response to a page up/down key, or shift-arrow key, or shift+clicking an up/down button. The default value is 10. Negative values and values that are not a multiple of linesize() produce undocumented results.

#### int fltk::Valuator::format(char*)

Format the passed value to show enough digits for the current step value. If the step has been set to zero then it does a `%g` format. If step is greater or equal to 1 it does `%d` format. The characters are written into the passed buffer (which must be long enough, 40 characters is safe).

#### int fltk::Valuator::handle(int event)

The default handler turns arrow and page up/down keystrokes, and movements of the mouse wheel, into movements of the value. It is up to the subclass to filter out events it does not want to respond to before calling this.

#### double fltk::Valuator::previous_value() const (static,protected)

Value saved when handle_push() was last called.

#### void fltk::Valuator::handle_push() (protected)

Subclasses should call this when the user starts to change the value.

#### void fltk::Valuator::handle_drag(double newvalue); (protected)

Subclasses should call this as the user moves the value. The passed value is clamped to the range if previous_value() is inside the range, and then it is rounded to the nearest multiple of step(), and then stored. This may call the callback if the new value is different than the old one.

#### void fltk::Valuator::handle_release(); (protected)

Subclasses should call this when the user stops moving the value. It may call the callback.

#### void fltk::Valuator::value_damage(); (virtual, protected)

Callback whenever value changes.

#### void fltk::Valuator::set_value(double v) (protected)

Change the value() without calling value_damage().