FDOSTUI
FreeDOS Text User Interface
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
valuator Class Reference

interface to control a floating point value More...

#include <valuator.hpp>

Inheritance diagram for valuator:
Inheritance graph
[legend]

Public Types

typedef void(* signal_value_t) (widget const *i_widget, void *io_user_data)
 function prototype to recieve signal More...
 

Public Member Functions

 valuator ()
 constructor More...
 
virtual ~valuator ()
 destructor
 
virtual double get_value () const
 gets the current value More...
 
double get_minimum () const
 gets the minimum value More...
 
double get_maximum () const
 gets the maximum value More...
 
double get_step () const
 the amount that the value is incremented or decremented in response to mouse or keyboard movement More...
 
void set_range (double const i_minimum, double const i_maximum)
 sets the minimum and maximum bounds the value can have More...
 
void set_step (double const i_step)
 set the amount that the value is incremented or decremented in response to mouse or keyboard movement More...
 
void set_step (double const i_step, int const i_precision)
 set the step and precision More...
 
virtual bool set_value (double const i_value)
 sets the value More...
 
void set_precision (int const i_digits)
 sets the precision More...
 
virtual int format (char *o_buffer, unsigned int const i_size)
 format a value into string More...
 
void set_signal_value (signal_value_t i_signal)
 set callback More...
 
double round (double const i_value) const
 rounds the value to the nearest step increment More...
 
double clamp (double const i_value) const
 checks the bounds of i_value More...
 
double clamp_soft (double const i_value) const
 checks the bounds of i_value More...
 
double increment (double const i_value, int const i_amount) const
 increment the value More...
 
void set_debounce (bool const i_debounce)
 turns drawing of the widget on or off More...
 

Protected Member Functions

void handle_push ()
 sets previous value to current value More...
 
void handle_drag (widget *const io_widget, double const i_value)
 sets the value and if changed redraws the widget More...
 
void handle_release (widget *const io_widget)
 emit a signal if the previous value is not equal to the current value More...
 

Protected Attributes

bool m_debounce
 
double m_value
 
double m_previous_value
 
double m_minimum
 
double m_maximum
 
double m_step
 
double m_precision
 
signal_value_t m_signal_value
 

Private Member Functions

 valuator (const valuator &)
 
valuatoroperator= (valuator const &)
 

Detailed Description

interface to control a floating point value

Member Typedef Documentation

◆ signal_value_t

void(* valuator::signal_value_t)(widget const *i_widget, void *io_user_data)

function prototype to recieve signal

Parameters
[in]i_widgetwidget class
[in,out]io_user_datauser defined
Returns
none This class is derived from other widgets. When a signal is emitted, the calling class is used. For example, the spinner class will emit the signal with the spinner object as i_widget.

Constructor & Destructor Documentation

◆ valuator()

valuator::valuator ( )

constructor

Returns
none

Member Function Documentation

◆ clamp()

double valuator::clamp ( double const  i_value) const

checks the bounds of i_value

Parameters
[in]i_valuevalue to check
Returns
adjusted value in the range of the bounds

◆ clamp_soft()

double valuator::clamp_soft ( double const  i_value) const

checks the bounds of i_value

Parameters
[in]i_valuevalue to check
Returns
adjusted value in the range of the bounds

This routine will accept the value if the previous value is within the bounds.

◆ format()

int valuator::format ( char *  o_buffer,
unsigned int const  i_size 
)
virtual

format a value into string

Parameters
[in]o_bufferbuffer to hold formatted string
[in]i_sizesize of buffer
Returns
length of formatted string (not including null terminator)

It is recommended that the buffer be at least 128 bytes.

◆ get_maximum()

double valuator::get_maximum ( ) const
inline

gets the maximum value

Returns
maximum value

◆ get_minimum()

double valuator::get_minimum ( ) const
inline

gets the minimum value

Returns
minimum value

◆ get_step()

double valuator::get_step ( ) const
inline

the amount that the value is incremented or decremented in response to mouse or keyboard movement

Returns
step value

◆ get_value()

double valuator::get_value ( ) const
inlinevirtual

gets the current value

Returns
current value

Reimplemented in spinner.

◆ handle_drag()

void valuator::handle_drag ( widget *const  io_widget,
double const  i_value 
)
protected

sets the value and if changed redraws the widget

Parameters
[in]derivedwidget
[in]i_valuevalue to set
Returns
none

◆ handle_push()

void valuator::handle_push ( )
inlineprotected

sets previous value to current value

Returns
none

◆ handle_release()

void valuator::handle_release ( widget *const  io_widget)
protected

emit a signal if the previous value is not equal to the current value

Parameters
[in,out]derivedwidget
Returns
none

◆ increment()

double valuator::increment ( double const  i_value,
int const  i_amount 
) const

increment the value

Parameters
[in]i_valuevalue to increment
[in]i_amountamount to increment/decrement
Returns
i_amount times the step value

The value is not validated against the minimum and maximum bounds. Use ::clamp to make sure the value is within the constraints.

◆ round()

double valuator::round ( double const  i_value) const

rounds the value to the nearest step increment

Parameters
[in]i_valueto round
Returns
rounded value

Rounding does not occur if value is zero.

◆ set_debounce()

void valuator::set_debounce ( bool const  i_debounce)
inline

turns drawing of the widget on or off

Parameters
[in]i_debounceindicator to turn drawing of the widget on or off
Returns
none

When the value is changed, the default behavior is to draw the widget. Changing i_debounce to true, will prevent the widget from being drawn. This is useful in derived classes that already draw the widget when the value has changed.

◆ set_precision()

void valuator::set_precision ( int const  i_digits)

sets the precision

Parameters
[in]i_digitsnumber of digits of precision
Returns
none

The minimum number of digits is zero, and the maximum number of digits is 9. i_digits will be adjusted to these bounds.

◆ set_range()

void valuator::set_range ( double const  i_minimum,
double const  i_maximum 
)
inline

sets the minimum and maximum bounds the value can have

Parameters
[in]i_minimumminimum bound
[in]i_maximummaximum bound
Returns
none

◆ set_signal_value()

void valuator::set_signal_value ( signal_value_t  i_signal)
inline

set callback

Parameters
[in]i_signalcallback signal
Returns
none

◆ set_step() [1/2]

void valuator::set_step ( double const  i_step)
inline

set the amount that the value is incremented or decremented in response to mouse or keyboard movement

Parameters
[in]i_stepstep value
Returns
none

The step value must be zero or a positive value. The behavior of a negative step value is undefined.

◆ set_step() [2/2]

void valuator::set_step ( double const  i_step,
int const  i_precision 
)
inline

set the step and precision

Parameters
[in]i_stepstep value
[in]i_precision
Returns
none

◆ set_value()

bool valuator::set_value ( double const  i_value)
virtual

sets the value

Parameters
[in]i_valuevalue to set
Returns
true value changed
false value did not change

The value is not validated against the minimum and maximum bounds. Use ::clamp to make sure the value is within the constraints.

Reimplemented in spinner.

Member Data Documentation

◆ m_debounce

valuator::m_debounce
protected

indicator if widget should be drawn when the value has changed

◆ m_maximum

valuator::m_maximum
protected

maximum value

◆ m_minimum

valuator::m_minimum
protected

minimum value

◆ m_precision

valuator::m_precision
protected

precision (0..9)

◆ m_previous_value

valuator::m_previous_value
protected

previous value

◆ m_signal_value

valuator::m_signal_value
protected

callback routine when value changes

◆ m_step

valuator::m_step
protected

step value

◆ m_value

valuator::m_value
protected

current value


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