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

Allows user to select a value by moving a thumb within a defined range of the slider. More...

#include <slider.hpp>

Inheritance diagram for slider:
Inheritance graph
[legend]

Public Types

enum  orientation { HORIZONTAL, VERTICAL }
 indicator of the orientation of the widget. The defualt orientation is HORIZONTAL. More...
 
- Public Types inherited from widget
enum  damage {
  DAMAGE_NONE = 0, DAMAGE_ALL = (1<<0), DAMAGE_LABEL = (1<<1), DAMAGE_VALUE = (1<<2),
  DAMAGE_SCROLL = (1<<3), DAMAGE_MOVED = (1<<4), DAMAGE_RESERVED1 = (1<<5), DAMAGE_RESERVED2 = (1<<6),
  DAMAGE_RESERVED3 = (1<<7)
}
 bit mask indicating what needs to be redrawn More...
 
- Public Types inherited from valuator
typedef void(* signal_value_t) (widget const *i_widget, void *io_user_data)
 function prototype to recieve signal More...
 

Public Member Functions

 slider (int const i_pos_x, int const i_pos_y, unsigned int const i_len_x, unsigned int const i_len_y)
 constructor More...
 
virtual ~slider ()
 destructor More...
 
virtual void draw () const
 draws the widget More...
 
virtual enum event_response event_key (struct event_key const &i_event)
 handle key event More...
 
virtual enum event_response event_mouse (struct event_mouse const &i_event)
 handle mouse event More...
 
void set_orientation (enum orientation const i_orientation)
 sets the orientation More...
 
- Public Member Functions inherited from widget
 widget (int const i_pos_x, int const i_pos_y, unsigned int const i_len_x, unsigned int const i_len_y)
 constructor More...
 
virtual ~widget ()
 destructor More...
 
virtual void set_damage (unsigned int const i_damage=DAMAGE_NONE)
 set the damage bits More...
 
virtual bool close (bool const i_shutting_down)
 called when widget is about to be destroyed More...
 
bool contains (int const i_pos_x, int const i_pos_y) const
 test if point is contained within the widget More...
 
bool contains (struct box const &i_box) const
 test if rectangular region is contained within the widget More...
 
virtual enum event_response event_key_default (enum scancodes const i_scan)
 default key event handler More...
 
virtual void focus_enter ()
 called when the widget receives focus More...
 
virtual void focus_leave ()
 called when the widget looses focus More...
 
void get_box (struct box &o_box) const
 gets the rectangular region this widget occupies More...
 
bool get_can_focus () const
 gets whether or not the widget can receive focus More...
 
bool get_enabled () const
 gets whether or not the widget is enabled More...
 
bool get_has_focus () const
 gets whether or not the widget has focus More...
 
group *const get_parent () const
 gets the parent widget More...
 
void * get_user_data () const
 gets user defined data pointer More...
 
bool get_visible () const
 gets whether or not the widget is visible More...
 
int get_pos_x () const
 gets the relative x position of the widget More...
 
int get_pos_y () const
 gets the relative y position of the widget More...
 
unsigned int get_len_x () const
 gets the horizontal length of the widget More...
 
unsigned int get_len_y () const
 gets the vertical length of the widget More...
 
virtual void move (int const i_pos_x, int const i_pos_y)
 move the widget to a new position More...
 
virtual void resize (unsigned int const i_len_x, unsigned int const i_len_y)
 resize the widget More...
 
void set_can_close (bool const i_can_close)
 set internal indicator if widget can be closed More...
 
void set_disabled ()
 disable the widget More...
 
void set_enabled ()
 enable the widget
 
void set_hidden ()
 hide the widget More...
 
virtual void set_parent (group *const i_parent)
 sets the parent group of the widget More...
 
void set_user_data (void *io_user_data)
 sets the user defined data pointer More...
 
void set_visible ()
 sets the widget as visible More...
 
void translate_screen (int *const o_pos_x, int *const o_pos_y) const
 translate a widgets relative coordinates to screen coordinates More...
 
- Public Member Functions inherited from valuator
 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

double value2pct (double const i_value) const
 converts value to percentage More...
 
int value2screen (double const i_value, int const i_len) const
 converts value to screen units More...
 
double screen2value (int const i_pos, int const i_len) const
 convert position to value More...
 
void draw (struct box const &i_box) const
 draw the widget within teh bounding box boundries More...
 
enum event_response event_mouse (struct event_mouse const &i_event, struct box const &i_box)
 test event according to a boundbox More...
 
- Protected Member Functions inherited from valuator
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

enum orientation m_orientation
 
- Protected Attributes inherited from widget
unsigned int m_damage
 
unsigned int m_flags
 
struct box m_box
 
groupm_parent
 
void * m_user_data
 
- Protected Attributes inherited from valuator
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

 slider (const slider &)
 
slideroperator= (slider const &)
 
enum event_response event_key_horizontal (struct event_key const &i_event)
 handle event for horizontal slider More...
 
enum event_response event_key_vertical (struct event_key const &i_event)
 handle key even for vertical slider More...
 

Additional Inherited Members

- Protected Types inherited from widget
enum  flags {
  VISIBLE = (1 << 0), ENABLED = (1 << 1), CAN_FOCUS = (1 << 2), HAS_FOCUS = (1 << 3),
  CAN_CLOSE = (1 << 4)
}
 

Detailed Description

Allows user to select a value by moving a thumb within a defined range of the slider.

The slider class is also the base class for other widgets such as scrollbar.

Member Enumeration Documentation

◆ orientation

indicator of the orientation of the widget. The defualt orientation is HORIZONTAL.

Enumerator
HORIZONTAL 

horizontal orientation

VERTICAL 

vertical orinetation

Constructor & Destructor Documentation

◆ slider()

slider::slider ( int const  i_pos_x,
int const  i_pos_y,
unsigned int const  i_len_x,
unsigned int const  i_len_y 
)

constructor

Parameters
[in]i_pos_xx position to place widget
[in]i_pos_yy position to place widget
[in]i_len_xx length of widget
[in]i_len_yy length of widget
Returns
none

◆ ~slider()

slider::~slider ( )
virtual

destructor

Returns
none

Member Function Documentation

◆ draw() [1/2]

void slider::draw ( ) const
virtual

draws the widget

This method should not be called directly.

See also
widget::draw for details.

Implements widget.

Reimplemented in scrollbar.

◆ draw() [2/2]

void slider::draw ( struct box const &  i_box) const
protected

draw the widget within teh bounding box boundries

Parameters
[in]i_boxbounding box

◆ event_key()

enum event_response slider::event_key ( struct event_key const &  i_event)
virtual

handle key event

Parameters
[in]i_eventkey event to handle
Returns
response how event was handled

Reimplemented from widget.

Reimplemented in scrollbar.

◆ event_key_horizontal()

enum event_response slider::event_key_horizontal ( struct event_key const &  i_event)
private

handle event for horizontal slider

Parameters
[in]i_eventkeyboard event
Returns
response

◆ event_key_vertical()

enum event_response slider::event_key_vertical ( struct event_key const &  i_event)
private

handle key even for vertical slider

Parameters
[in]i_eventkeyboard event
Returns
response

◆ event_mouse() [1/2]

enum event_response slider::event_mouse ( struct event_mouse const &  i_event)
virtual

handle mouse event

Parameters
[in]i_eventmouse event to handle
Returns
response how event was handled

Reimplemented from widget.

Reimplemented in scrollbar.

◆ event_mouse() [2/2]

enum event_response slider::event_mouse ( struct event_mouse const &  i_event,
struct box const &  i_box 
)
protected

test event according to a boundbox

Parameters
[in]i_eventmouse event
[in]i_boxbounding box
Returns
response

◆ screen2value()

double slider::screen2value ( int const  i_pos,
int const  i_len 
) const
protected

convert position to value

Parameters
[in]i_posposition to convert
[in]i_leni_len if horizontal, length in the x direction. Otherwise, length in the y direction.
Returns
value

/*!

◆ set_orientation()

void slider::set_orientation ( enum orientation const  i_orientation)
inline

sets the orientation

This does not redraw. In addition, it does not resize the widget to fit the new data type.

◆ value2pct()

double slider::value2pct ( double const  i_value) const
protected

converts value to percentage

Parameters
[in]i_valuevalue to convert
Returns
percentage

◆ value2screen()

int slider::value2screen ( double const  i_value,
int const  i_len 
) const
protected

converts value to screen units

Parameters
[in]i_valuevalue to convert
[in]i_lenif horizontal, length in the x direction. Otherwise, length in the y direction.
Returns
position

Member Data Documentation

◆ m_orientation

slider::m_orientation
protected

orientation of the slider


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