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

Allows the user to choose a value from a list. More...

#include <listbox.hpp>

Inheritance diagram for listbox:
Inheritance graph
[legend]

Public Types

typedef void(* signal_selected_t) (listbox const *i_listbox, void *io_user_data)
 function prototype to recieve signal 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 Member Functions

 listbox (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 ~listbox ()
 destructor More...
 
int add (unsigned char const *i_label)
 adds a value to the end of a list 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...
 
unsigned char const * get_item (size_t const i_slot) const
 retrieve an item from the listbox More...
 
size_t get_count () const
 get number of items in listbox More...
 
int get_selected_first () const
 get the first selected item in the listbox More...
 
int get_selected_next (int const i_iter) const
 get the next selected item in the listbox 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 remove (size_t const i_slot)
 remove an item from the listbox More...
 
void remove_all ()
 remove all items from the listbox More...
 
void set_label (unsigned char const *i_str)
 set the text label of the listbox More...
 
void set_multiline (bool const i_multiline)
 set whether or not the user can select more than one item More...
 
virtual void set_parent (group *const i_parent)
 set the parent group of this widget More...
 
void set_response (int const i_response)
 set the response the widget returns when an item is selected More...
 
void set_signal_selected (signal_selected_t i_signal)
 set callback More...
 
void set_selected (size_t const i_slot, bool const i_selected=true)
 set an item as selected or unselected More...
 
void unselect_all ()
 unselect all items in the listbox More...
 
void scroll_internal ()
 called when value in the vertical scrollbar changed
 
- 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...
 
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...
 
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...
 

Protected Attributes

bool m_multiline
 
size_t m_line
 
struct array m_array
 
scrollbar m_vertical
 
unsigned char * m_label
 
enum event_response m_response
 
signal_selected_t m_signal_selected
 
- Protected Attributes inherited from widget
unsigned int m_damage
 
unsigned int m_flags
 
struct box m_box
 
groupm_parent
 
void * m_user_data
 

Private Member Functions

 listbox (const listbox &)
 
listboxoperator= (listbox const &)
 
void select (size_t const i_slot)
 selects an item More...
 
void vertical_configure ()
 configure vertical scrollbar for display More...
 
void emit_selected ()
 emits the selected signal More...
 

Static Private Member Functions

static void vertical_cb (widget const *i_widget, void *io_user_data)
 callback for vertical scrollbar 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 the user to choose a value from a list.

Member Typedef Documentation

◆ signal_selected_t

void(* listbox::signal_selected_t)(listbox const *i_listbox, void *io_user_data)

function prototype to recieve signal

Parameters
[in]i_entryentry widget
[in,out]io_user_datauser defined
Returns
none

Constructor & Destructor Documentation

◆ listbox()

listbox::listbox ( 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

◆ ~listbox()

listbox::~listbox ( )
virtual

destructor

Returns
none

Member Function Documentation

◆ add()

int listbox::add ( unsigned char const *  i_label)

adds a value to the end of a list

Parameters
[in]i_labelvalue to add
Returns
0 success
!0 failure unable to add (out of memory)

◆ draw()

void listbox::draw ( ) const
virtual

draws the widget

This method should not be called directly.

See also
widget::draw for details.

Implements widget.

◆ emit_selected()

void listbox::emit_selected ( )
inlineprivate

emits the selected signal

Returns
none

◆ event_key()

enum event_response listbox::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.

◆ event_mouse()

enum event_response listbox::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.

◆ get_count()

size_t listbox::get_count ( ) const
inline

get number of items in listbox

Returns
the number of items in listbox

◆ get_item()

unsigned char const * listbox::get_item ( size_t const  i_slot) const

retrieve an item from the listbox

Parameters
[in]i_slotindex of item to retrieve
Returns
0 item not found
!0 pointer to list item

◆ get_selected_first()

int listbox::get_selected_first ( ) const

get the first selected item in the listbox

Returns
-1 nothing is selected
>=0 index to the first selected item

◆ get_selected_next()

int listbox::get_selected_next ( int const  i_iter) const

get the next selected item in the listbox

Parameters
[in]i_itercurrent index
Returns
>=0 index to the next selected itm
-1 there are no more selected items

◆ move()

void listbox::move ( int const  i_pos_x,
int const  i_pos_y 
)
virtual

move the widget to a new position

Parameters
[in]i_pos_xx position to move the widget
[in]i_pos_yy position to move the widget
Returns
none

Reimplemented from widget.

◆ remove()

void listbox::remove ( size_t const  i_slot)

remove an item from the listbox

Parameters
[in]i_slotindex of item to remove
Returns
none

◆ remove_all()

void listbox::remove_all ( )

remove all items from the listbox

Returns
none

◆ resize()

void listbox::resize ( unsigned int const  i_len_x,
unsigned int const  i_len_y 
)
virtual

resize the widget

Parameters
[in]i_len_xnew horizontal length
[in]i_len_ynew vertical length
Returns
none

Reimplemented from widget.

◆ select()

void listbox::select ( size_t const  i_slot)
private

selects an item

Returns
none

◆ set_label()

void listbox::set_label ( unsigned char const *  i_label)
inline

set the text label of the listbox

Parameters
[in]i_labelnull terminated string of label
Returns
none To unset the label use NULL.

◆ set_multiline()

void listbox::set_multiline ( bool const  i_multiline)
inline

set whether or not the user can select more than one item

Parameters
[in]i_multilinewhether or not multiline is in affect
Returns
none

◆ set_parent()

void listbox::set_parent ( group *const  i_parent)
inlinevirtual

set the parent group of this widget

Returns
none

Reimplemented from widget.

◆ set_response()

void listbox::set_response ( int const  i_response)
inline

set the response the widget returns when an item is selected

Parameters
[in]i_responseresponse id

◆ set_selected()

void listbox::set_selected ( size_t const  i_slot,
bool const  i_selected = true 
)

set an item as selected or unselected

Parameters
[in]i_slotindex of item to alter
[in]i_selectedwhether or not the item is selected
Returns
none Changing the state of an item will not emit a signal

◆ set_signal_selected()

void listbox::set_signal_selected ( signal_selected_t  i_signal)
inline

set callback

Parameters
[in]i_signalcallback signal
Returns
none

◆ unselect_all()

void listbox::unselect_all ( )

unselect all items in the listbox

Returns
none Changing the state will not emit a signal

◆ vertical_cb()

void listbox::vertical_cb ( widget const *  i_widget,
void *  io_user_data 
)
staticprivate

callback for vertical scrollbar

Parameters
[in]i_widgetscrollbar widget
[in]io_user_datalistbox widget
Returns
none

◆ vertical_configure()

void listbox::vertical_configure ( )
private

configure vertical scrollbar for display

Returns
none

Member Data Documentation

◆ m_array

listbox::m_array
protected

Array to hold items

◆ m_label

listbox::m_label
protected

Label of listbox

◆ m_line

listbox::m_line
protected

Index of currently highlighted item

◆ m_multiline

listbox::m_multiline
protected

Indicator if multi-selection is in affect

◆ m_response

listbox::m_response
protected

Response returned when an item get's selected

◆ m_signal_selected

listbox::m_signal_selected
protected

Callback when an item gets's selected

◆ m_vertical

listbox::m_vertical
protected

Vertical scrollbar


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