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. More...
#include <Fl_Valuator.H>
Public Member Functions | |
void | bounds (double a, double b) |
Sets the minimum (a) and maximum (b) values for the valuator widget. | |
double | clamp (double) |
Clamps the passed value to the valuator range. | |
virtual int | format (char *) |
Uses internal rules to format the fields numerical value into the character array pointed to by the passed parameter. | |
double | increment (double, int) |
Adds n times the step value to the passed value. | |
void | maximum (double a) |
Sets the maximum value for the valuator. | |
double | maximum () const |
Gets the maximum value for the valuator. | |
void | minimum (double a) |
Sets the minimum value for the valuator. | |
double | minimum () const |
Gets the minimum value for the valuator. | |
void | precision (int digits) |
Sets the step value to 1.0 / 10digits. | |
void | range (double a, double b) |
Sets the minimum and maximum values for the valuator. | |
double | round (double) |
Round the passed value to the nearest step increment. | |
double | step () const |
Gets or sets the step value. | |
void | step (double s) |
See double Fl_Valuator::step() const. | |
void | step (double a, int b) |
See double Fl_Valuator::step() const. | |
void | step (int a) |
See double Fl_Valuator::step() const. | |
int | value (double) |
Sets the current value. | |
double | value () const |
Gets the floating point(double) value. | |
Protected Member Functions | |
Fl_Valuator (int X, int Y, int W, int H, const char *L) | |
Creates a new Fl_Valuator widget using the given position, size, and label string. | |
void | handle_drag (double newvalue) |
Called during a drag operation, after an FL_WHEN_CHANGED event is received and before the callback. | |
void | handle_push () |
Stores the current value in the previous value. | |
void | handle_release () |
Called after an FL_WHEN_RELEASE event is received and before the callback. | |
int | horizontal () const |
Tells if the valuator is an FL_HORIZONTAL one. | |
double | previous_value () const |
Gets the previous floating point value before an event changed it. | |
void | set_value (double v) |
Sets the current floating point value. | |
double | softclamp (double) |
Clamps the value, but accepts v if the previous value is not already out of range. | |
virtual void | value_damage () |
Asks for partial redraw. |
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.
Fl_Valuator::Fl_Valuator | ( | int | X, | |
int | Y, | |||
int | W, | |||
int | H, | |||
const char * | L | |||
) | [protected] |
Creates a new Fl_Valuator widget using the given position, size, and label string.
The default boxtype is FL_NO_BOX.
void Fl_Valuator::bounds | ( | double | a, | |
double | b | |||
) | [inline] |
Sets the minimum (a) and maximum (b) values for the valuator widget.
Reimplemented in Fl_Slider.
double Fl_Valuator::clamp | ( | double | v | ) |
Clamps the passed value to the valuator range.
int Fl_Valuator::format | ( | char * | buffer | ) | [virtual] |
Uses internal rules to format the fields numerical value into the character array pointed to by the passed parameter.
The actual format used depends on the current step value. If the step value has been set to zero then a %g format is used. If the step value is non-zero, then a %.*f format is used, where the precision is calculated to show sufficient digits for the current step value. An integer step value, such as 1 or 1.0, gives a precision of 0, so the formatted value will appear as an integer.
This method is used by the Fl_Valuator_... group of widgets to format the current value into a text string. The return value is the length of the formatted text. The formatted value is written into buffer
. buffer
should have space for at least 128 bytes.
You may override this function to create your own text formatting.
void Fl_Valuator::handle_drag | ( | double | v | ) | [protected] |
Called during a drag operation, after an FL_WHEN_CHANGED event is received and before the callback.
void Fl_Valuator::handle_release | ( | ) | [protected] |
Called after an FL_WHEN_RELEASE event is received and before the callback.
double Fl_Valuator::increment | ( | double | v, | |
int | n | |||
) |
void Fl_Valuator::maximum | ( | double | a | ) | [inline] |
Sets the maximum value for the valuator.
double Fl_Valuator::maximum | ( | ) | const [inline] |
Gets the maximum value for the valuator.
void Fl_Valuator::minimum | ( | double | a | ) | [inline] |
Sets the minimum value for the valuator.
double Fl_Valuator::minimum | ( | ) | const [inline] |
Gets the minimum value for the valuator.
void Fl_Valuator::precision | ( | int | digits | ) |
Sets the step value to 1.0 / 10digits.
Precision digits
is limited to 0...9 to avoid internal overflow errors. Values outside this range are clamped.
digits
the step value is set to A
= 1.0 and B
= 1, i.e. 1.0/1 = 1. void Fl_Valuator::range | ( | double | a, | |
double | b | |||
) | [inline] |
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::round | ( | double | v | ) |
Round the passed value to the nearest step increment.
Does nothing if step is zero.
void Fl_Valuator::set_value | ( | double | v | ) | [inline, protected] |
Sets the current floating point value.
double Fl_Valuator::step | ( | ) | const [inline] |
Gets or sets 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 most widgets the default step is zero.
For precision the step is stored as the ratio of a double A
and an integer B
= A/B. You can set these values directly. Currently setting a floating point value sets the nearest A/1 or 1/B value possible.
Reimplemented in Fl_Counter.
int Fl_Valuator::value | ( | double | v | ) |
Sets 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 value(). The widget is redrawn if the new value is different than the current one. The initial value is zero.
changed() will return true if the user has moved the slider, but it will be turned off by value(x) and just before doing a callback (the callback can turn it back on if desired).
double Fl_Valuator::value | ( | ) | const [inline] |