class Fl_Valuator


Class Hierarchy

Include Files

Description

The Fl_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 FL_VERTICAL is defined as zero.

Methods

Fl_Valuator::Fl_Valuator(int x, int y, int w, int h, const char *label = 0)

Creates a new Fl_Valuator widget using the given position, size, and label string. The default boxtype is FL_NO_BOX.

virtual Fl_Valuator::~Fl_Valuator()

Destroys the valuator.

double Fl_Valuator::value() const
int Fl_Valuator::value(double)

Get or set the current value. The new value is not clamped or otherwise changed before storing it. Use clamp() or round() to modify the value before calling this if you want. If the new value is different than the current one the object is redrawn. The initial value is zero.

double Fl_Valuator::minimum() const
void Fl_Valuator::minimum(double)

Gets or sets the minimum value for the valuator.

double Fl_Valuator::maximum() const
void Fl_Valuator::maximum(double)

Gets or sets the maximum value for the valuator.

void Fl_Valuator::range(double min, double max);

Sets the minimum and maximum values for the valuator. When the user manipulates the widget, the value is limited to this range. This clamping is done after rounding to the step value (this makes a difference if the range is not a multiple of the step).

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.

Some widgets consider this a "soft" range. This means they will stop at the range, but if the user releases and grabs the control again and tries to move it further, it is allowed.

The range may affect the display. You must redraw() the widget after changing the range.

double Fl_Valuator::step() const
void Fl_Valuator::step(double)

Get or set the step value. As the user moves the mouse the value is rounded to the nearest multiple of the step value. This is done before clamping it to the range. For many widgets this is also the amount the widget changes when the user drags the mouse 1 pixel.

For most widgets the default step is zero. If the widget needs a non-zero value (for instance to calculate the linesize() or how far the mouse dragged the value) it acts as though step() is 1/100 the distance between the minimum and maximum.

int Fl_Valuator::linesize() const
void Fl_Valuator::linesize(int)

The linesize is the number of step() that the valuator moves in response to an arrow key. The default value is 1.

int Fl_Valuator::pagesize() const
void Fl_Valuator::pagesize(int)

The pagesize is the number of step() that the valuator moves in response to a page up/down key, or shift-arrow key. The default value is 10.

int Fl_Valuator::format(char*)

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

double Fl_Valuator::round(double)

Round the passed value to the nearest step increment. Does nothing if step is zero.

double Fl_Valuator::clamp(double)

Clamp the passed value to the valuator range and returns it.

double Fl_Valuator::increment(double,int n)

Adds n times the step value to the passed value and returns it.