interface to control a floating point value
More...
#include <valuator.hpp>
interface to control a floating point value
◆ signal_value_t
void(* valuator::signal_value_t)(widget const *i_widget, void *io_user_data) |
function prototype to recieve signal
- Parameters
-
[in] | i_widget | widget class |
[in,out] | io_user_data | user 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.
◆ valuator()
◆ clamp()
double valuator::clamp |
( |
double const |
i_value | ) |
const |
checks the bounds of i_value
- Parameters
-
[in] | i_value | value 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_value | value 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_buffer | buffer to hold formatted string |
[in] | i_size | size 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] | derived | widget |
[in] | i_value | value 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
-
- Returns
- none
◆ increment()
double valuator::increment |
( |
double const |
i_value, |
|
|
int const |
i_amount |
|
) |
| const |
increment the value
- Parameters
-
[in] | i_value | value to increment |
[in] | i_amount | amount 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
-
- 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_debounce | indicator 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_digits | number 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_minimum | minimum bound |
[in] | i_maximum | maximum bound |
- Returns
- none
◆ set_signal_value()
set callback
- Parameters
-
[in] | i_signal | callback 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
-
- 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_step | step value |
[in] | i_precision | |
- Returns
- none
◆ set_value()
bool valuator::set_value |
( |
double const |
i_value | ) |
|
|
virtual |
sets the value
- Parameters
-
- 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.
◆ m_debounce
indicator if widget should be drawn when the value has changed
◆ m_maximum
◆ m_minimum
◆ m_precision
◆ m_previous_value
valuator::m_previous_value |
|
protected |
◆ m_signal_value
callback routine when value changes
◆ m_step
◆ m_value
The documentation for this class was generated from the following files: