fltk 1.3.0rc3
About: FLTK (Fast Light Tool Kit) is a cross-platform C++ GUI toolkit for UNIX/Linux (X11), Microsoft Windows, and MacOS X. Release candidate.
  SfR Fresh Dox: fltk-1.3.0rc3-source.tar.gz ("inofficial" and yet experimental doxygen-generated source code documentation)  

Fl_Valuator Class Reference

#include <Fl_Valuator.H>

Inheritance diagram for Fl_Valuator:
Collaboration diagram for Fl_Valuator:

List of all members.

Public Member Functions

void bounds (double a, double b)
double minimum () const
void minimum (double a)
double maximum () const
void maximum (double a)
void range (double a, double b)
void step (int a)
void step (double a, int b)
void step (double s)
double step () const
void precision (int)
double value () const
int value (double)
virtual int format (char *)
double round (double)
double clamp (double)
double increment (double, int)

Protected Member Functions

int horizontal () const
 Fl_Valuator (int X, int Y, int W, int H, const char *L)
double previous_value () const
void handle_push ()
double softclamp (double)
void handle_drag (double newvalue)
void handle_release ()
virtual void value_damage ()
void set_value (double v)

Detailed 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:

valuators.png

In the above diagram each box surrounds an actual subclass. These are further differentiated by setting the type() of the widget t o 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.

Definition at line 55 of file Fl_Valuator.H.


Constructor & Destructor Documentation

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.

Definition at line 37 of file Fl_Valuator.cxx.

References Fl_Widget::align(), FL_ALIGN_BOTTOM, FL_WHEN_CHANGED, and Fl_Widget::when().


Member Function Documentation

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.

Definition at line 81 of file Fl_Valuator.H.

References b, and min.

Referenced by Fl_Counter::Fl_Counter().

double Fl_Valuator::clamp ( double  v)
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_Value_... 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 in buffer. buffer should have space for at least 128 bytes.

You may override this function to create your own text formatting.

Reimplemented in Flcc_Value_Input.

Definition at line 168 of file Fl_Valuator.cxx.

References i, snprintf, and value().

Referenced by Fl_Value_Slider::draw(), Fl_Value_Output::draw(), and Fl_Counter::draw().

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.

Definition at line 99 of file Fl_Valuator.cxx.

References Fl_Widget::do_callback(), FL_WHEN_CHANGED, Fl_Widget::set_changed(), value_damage(), and Fl_Widget::when().

Referenced by Fl_Value_Output::handle(), Fl_Value_Input::handle(), Fl_Slider::handle(), Fl_Scrollbar::handle(), Fl_Roller::handle(), Fl_Dial::handle(), Fl_Counter::handle(), and Fl_Adjuster::handle().

void Fl_Valuator::handle_push ( ) [inline, protected]
void Fl_Valuator::handle_release ( ) [protected]
int Fl_Valuator::horizontal ( ) const [inline, protected]
double Fl_Valuator::increment ( double  v,
int  n 
)

Adds n times the step value to the passed value. If step was set to zero it uses fabs(maximum() - minimum()) / 100.

Definition at line 142 of file Fl_Valuator.cxx.

Referenced by Fl_Value_Output::handle(), Fl_Value_Input::handle(), Fl_Slider::handle(), Fl_Roller::handle(), Fl_Counter::handle(), and Fl_Adjuster::handle().

void Fl_Valuator::maximum ( double  a) [inline]

Sets the maximum value for the valuator.

Definition at line 89 of file Fl_Valuator.H.

void Fl_Valuator::minimum ( double  a) [inline]

Sets the minimum value for the valuator.

Definition at line 85 of file Fl_Valuator.H.

References min.

double Fl_Valuator::minimum ( ) const [inline]
void Fl_Valuator::precision ( int  p)

Sets the step value to 1/10digits.

Definition at line 64 of file Fl_Valuator.cxx.

Referenced by Fl_Table::table_resized().

double Fl_Valuator::previous_value ( ) const [inline, protected]

Gets the previous floating point value before an event changed it

Definition at line 68 of file Fl_Valuator.H.

Referenced by Fl_Value_Output::handle(), Fl_Value_Input::handle(), Fl_Roller::handle(), and Fl_Adjuster::handle().

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.

Definition at line 110 of file Fl_Valuator.H.

References b, and min.

Referenced by Fl_Tree::draw().

double Fl_Valuator::round ( double  v)

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

Definition at line 125 of file Fl_Valuator.cxx.

Referenced by Fl_Value_Output::handle(), Fl_Value_Input::handle(), Fl_Slider::handle(), Fl_Roller::handle(), and Fl_Dial::handle().

void Fl_Valuator::set_value ( double  v) [inline, protected]

Sets the current floating point value.

Definition at line 76 of file Fl_Valuator.H.

double Fl_Valuator::softclamp ( double  v) [protected]

Clamps the value, but accepts v if the previous value is not already out of range

Definition at line 89 of file Fl_Valuator.cxx.

Referenced by Fl_Value_Output::handle(), Fl_Value_Input::handle(), and Fl_Adjuster::handle().

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 two integers, A/B. You can set these integers directly. Currently setting a floating point value sets the nearest A/1 or 1/B value possible.

Reimplemented in Fl_Counter.

Definition at line 127 of file Fl_Valuator.H.

Referenced by Fl_Roller::draw(), Fl_Adjuster::Fl_Adjuster(), Fl_Roller::Fl_Roller(), Fl_Scrollbar::Fl_Scrollbar(), Fl_Value_Slider::Fl_Value_Slider(), Fl_Value_Output::handle(), Fl_Value_Input::handle(), Fl_Slider::scrollvalue(), and Fl_Counter::step().

void Fl_Valuator::step ( double  a,
int  b 
) [inline]

See double Fl_Valuator::step() const

Definition at line 114 of file Fl_Valuator.H.

References b.

void Fl_Valuator::step ( double  s)

See double Fl_Valuator::step() const

Reimplemented in Fl_Counter.

Definition at line 56 of file Fl_Valuator.cxx.

References epsilon.

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).

Definition at line 81 of file Fl_Valuator.cxx.

References Fl_Widget::clear_changed(), and value_damage().

void Fl_Valuator::value_damage ( ) [protected, virtual]

Asks for partial redraw

Reimplemented in Fl_Adjuster.

Definition at line 69 of file Fl_Valuator.cxx.

References Fl_Widget::damage(), and FL_DAMAGE_EXPOSE.

Referenced by Fl_Scrollbar::handle(), handle_drag(), and value().


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