FLTK Valuators

A "valuator" widget controls a single floating-point value. All valuators are subclasses of the widget Fl_Valuator. This widget 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 labelling the widget. The ones labelled "0" are the default versions with a type(0). For consistency the symbol "FL_VERTICAL" is defined as zero.

class Fl_Valuator : public Fl_Widget

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

double Fl_Valuator::minimum() const ;
void Fl_Valuator::minimum(double);
double Fl_Valuator::maximum() const ;
void Fl_Valuator::maximum(double);
void Fl_Valuator::range(double min, double max);

double Fl_Valuator::step() const;
void Fl_Valuator::step(double);
void Fl_Valuator::step(int A, int B);

int Fl_Valuator::format(char*, double);

double Fl_Valuator::round(double);

double Fl_Valuator::clamp(double);

double Fl_Valuator::increment(double,int n);

int Fl_Widget::changed() const;
void Fl_Widget::set_changed();
void Fl_Widget::clear_changed();

Fl_When Fl_Widget::when() const;
void Fl_Widget::when(Fl_When);

Fl_Valuator Protected methods

If you are making your own subclass of Fl_Valuator you should call these to handle events, along with the public clamp, double, increment methods shown above.

void Fl_Valuator::handle_push();

double Fl_Valuator::previous_value();

double Fl_Valuator::softclamp(double);

void Fl_Valuator::handle_drag(double newvalue);

void Fl_Valuator::handle_release();

virtual void Fl_Valuator::value_damage();


class Fl_Slider : public Fl_Valuator


A sliding knob inside a box, Often used as a scrollbar. Moving the box all the way to the top/left sets it to the minimum(), and to the bottom/right to the maximum(). The minimum() may be greater than the maximum() to "reverse" the slider direction.

Fl_Slider::Fl_Slider(int x,int y,int w,int h, const char *l = 0);

uchar Fl_Widget::type() const;
void Fl_Widget::type(uchar);

float Fl_Slider::slider_size() const;
void Fl_Slider::slider_size(float);

Fl_Boxtype Fl_Slider::slider() const;
void Fl_Slider::slider(Fl_Boxtype);

int Fl_Slider::scrollvalue(int windowtop,int windowsize,int first,int totalsize);


class Fl_Scrollbar : public Fl_Slider

Clicking on the arrows move up and down by linesize(). Scrollbars also accept FL_SHORTCUT events: the arrows move by linesize(), and vertical scrollbars take Page Up/Down (they move by the page size minus linesize()) and Home/End (they jump to the top or bottom).

Scrollbars have step(1) preset (they always return integers). If desired you can set the step() to non-integer values. You will then have to use casts to get at the floating-point versions of value() from Fl_Slider.

Fl_Scrollbar::Fl_Scrollbar(int x,int y,int w,int h, const char *l = 0);

int Fl_Scrollbar::value();

int Fl_Scrollbar::value(int position, int size, int top, int total);

int Fl_Scrollbar::linesize() const;
void Fl_Scrollbar::linesize(int i);


class Fl_Value_Slider : public Fl_Slider


These are sliders with a box displaying the current value. All the methods for an Fl_Slider work.

Fl_Value_Slider::Fl_Value_Slider(int x,int y,int w,int h, const char *l = 0);

Fl_Font Fl_Value_Slider::textfont() const;
void Fl_Value_Slider::textfont(Fl_Font);
uchar Fl_Value_Slider::textsize() const;
void Fl_Value_Slider::textsize(uchar);
Fl_Color Fl_Value_Slider::textcolor() const;
void Fl_Value_Slider::textcolor(Fl_Color);


class Fl_Adjuster : public Fl_Valuator


(The appearance is determined by which dimension is larger)
This type of control was stolen from Prisms, and has proven to be very useful for values that need a large dynamic range. When you press a button and drag to the right the value increases, when you drag to the left it decreases. The largest button adjusts by 100*step(), the next by 10*step() and that smallest button by step(). Clicking on the buttons increments by 10 times the amount dragging by a pixel does. Shift+click decrements by 10 times the amount.

Fl_Adjuster::Fl_Adjuster(int x,int y,int w,int h,const char* l=0);

uchar Fl_Adjuster::soft() const;
void Fl_Adjuster::soft(uchar);


class Fl_Counter : public Fl_Valuator


This widget is provided for forms compatibility. It controls a single floating point value.

Fl_Counter::Fl_Counter(int x,int y,int w,int h,const char* l=0);

type(uchar);

double Fl_Counter::lstep() const; void Fl_Counter::lstep(double);


class Fl_Dial : public Fl_Valuator


Circular dial to control a single floating point value.

Fl_Dial::Fl_Dial(int x,int y,int w,int h,const char* l=0);

type(uchar);

void Fl_Dial::angles(short a, short b);


class Fl_Roller : public Fl_Valuator


A knob similar to the zoom/dolly control in SGI's RapidApp toolkit. As you drag the mouse, each pixel of movement advances the value by step() (which defaults to 1/1000).

Fl_Roller::Fl_Roller(int x,int y,int w,int h,const char* l=0);

Fl_Widget::type(uchar);


class Fl_Value_Input : public Fl_Valuator


The user can click in the text field and edit it (there is in fact a hidden Fl_Input with type(FL_FLOAT_INPUT) in there), and when they hit return or tab the value updates to what they typed and the callback is done.

If step() is not zero, the user can also drag the mouse across the object and thus slide the value. The left button moves one step() per pixel, the middle by 10*step(), and the left button by 100*step(). It is then impossible to select text by dragging across it, although clicking can still move the insertion cursor.

Fl_Value_Input::Fl_Value_Input(int x,int y,int w,int h,const char* l=0);

Fl_Font Fl_Value_Input::textfont() const;
void Fl_Value_Input::textfont(Fl_Font);
uchar Fl_Value_Input::textsize() const;
void Fl_Value_Input::textsize(uchar);
Fl_Color Fl_Value_Input::textcolor() const;
void Fl_Value_Input::textcolor(Fl_Color);
Fl_Color Fl_Value_Input::cursor_color() const;
void Fl_Value_Input::cursor_color(Fl_Color);

uchar Fl_Value_Input::soft() const;
void Fl_Value_Input::soft(uchar);


class Fl_Value_Output : public Fl_Valuator

If you don't set the step() of this widget, it can be used as an output display for a floating point value.
If step() is not zero, the user can adjust the value by dragging the mouse left and right. The left button moves one step() per pixel, the middle by 10*step(), and the left button by 100*step().

This is much lighter-weight than a Fl_Value_Input because it contains no text editing code or character buffer.

Fl_Value_Output::Fl_Value_Output(int x,int y,int w,int h,const char* l=0);

Fl_Font Fl_Value_Output::textfont() const;
void Fl_Value_Output::textfont(Fl_Font);
uchar Fl_Value_Output::textsize() const;
void Fl_Value_Output::textsize(uchar);
FL_Color Fl_Value_Output::textcolor() const;
void Fl_Value_Output::textcolor(Fl_Color);

uchar Fl_Value_Output::soft() const;
void Fl_Value_Output::soft(uchar);

(back to contents)