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

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

#include <menu.hpp>

Inheritance diagram for menu:
Inheritance graph
[legend]

Public Types

enum  event_response_extended { RESPONSE_LEFT = -20, RESPONSE_RIGHT = -21 }
 extended response for keystrokes More...
 
- Public Types inherited from window
enum  attributes {
  EMPTY = (1 << 0), BORDER = (1 << 1), TITLE = (1 << 2), MINMAX = (1 << 3),
  RESIZE = (1 << 4), SYSTEM = (1 << 5)
}
 
- 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

 menu (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 ~menu ()
 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_menu (struct menuitem *i_menu)
 sets the menu More...
 
void set_response_extended (bool const i_turnon)
 sets the behavior of the response used when the user presses specific keystrokes. More...
 
virtual void focus_enter ()
 handle entering focus More...
 
- Public Member Functions inherited from window
 window (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 ~window ()
 destructor More...
 
enum attributes get_attributes () const
 gets the window attributes More...
 
unsigned char const * get_title () const
 gets the windows title More...
 
void set_attributes (unsigned const i_attributes)
 set the window attributes More...
 
void set_title (unsigned char const *i_str)
 sets the windows title More...
 
- Public Member Functions inherited from group
 group (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 ~group ()
 destructor More...
 
virtual void set_damage (unsigned int const i_damage=DAMAGE_NONE)
 sets damage mask More...
 
virtual int add (widget *const i_widget)
 add child widget More...
 
virtual enum event_response event_key_default (enum scancodes const i_scan)
 default scan code event handler More...
 
virtual void focus_leave ()
 handle leaving focus More...
 
void set_focus (widget &i_widget)
 set widget focus 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 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...
 
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...
 
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...
 

Protected Attributes

bool m_response_extended
 
unsigned int m_selected
 
unsigned int m_offset
 
int m_orig_pos_y
 
struct array m_array
 
struct menuitemm_menu
 
- Protected Attributes inherited from window
unsigned char * m_title
 
enum attributes m_attributes
 
- Protected Attributes inherited from group
widgetm_focused
 widget that has focus
 
size_t m_slot
 focused widget slot (index into array)
 
struct array m_array
 widget container
 
- 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

 menu (const menu &)
 
menuoperator= (menu const &)
 
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 draw_line (int const i_pos_y, int const i_erase) const
 draw a separator line More...
 
void draw_item (int const i_pos_y, int const i_selected, struct menuitem const *const i_menu) const
 draw a menu item More...
 
void draw_items () const
 draw all of the menu items
 
void preflight ()
 configure the menu object (flattens the menu)
 
enum event_response event_key_ascii (unsigned char const i_ascii)
 handle ASCII key events More...
 
enum event_response event_key_scan (enum scancodes const i_scan)
 handle scancode events More...
 
void select (unsigned int const i_slot)
 selects a menu item More...
 
void select_next ()
 selects the next item More...
 
void select_previous ()
 selects the previous item More...
 
enum event_response submenu (struct menuitem *io_menu, unsigned int const i_pos_x, unsigned int const i_pos_y)
 popups sub menu More...
 
int event_in_parent (int const i_pos_x, int const i_pos_y)
 test if event is inside parent 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 a user to choose a value from a list.

Member Enumeration Documentation

◆ event_response_extended

extended response for keystrokes

Enumerator
RESPONSE_LEFT 

response when user presses the left key

RESPONSE_RIGHT 

response when user presses the right key

Constructor & Destructor Documentation

◆ menu()

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

◆ ~menu()

menu::~menu ( )
virtual

destructor

Returns
none

Member Function Documentation

◆ draw()

void menu::draw ( ) const
virtual

draws the widget

This method should not be called directly.

See also
widget::draw for details.

Reimplemented from window.

◆ draw_item()

void menu::draw_item ( int const  i_pos_y,
int const  i_selected,
struct menuitem const *const  i_menu 
) const
private

draw a menu item

Parameters
[in]i_pos_yy position to draw item
[in]i_selectedindicator if menu itme is selected
[in]i_menumenu item to draw
Returns
none

◆ draw_line()

void menu::draw_line ( int const  i_pos_y,
int const  i_erase 
) const
private

draw a separator line

Parameters
[in]i_pos_yy position to draw line
[in]i_eraseindicator if line is being drawn or erased
Returns
none

◆ event_in_parent()

int menu::event_in_parent ( int const  i_pos_x,
int const  i_pos_y 
)
private

test if event is inside parent

Parameters
[in]i_pos_xx position to test
[in]i_pos_yy position to test
Returns
0 event is not in parent
!0 event is in parent

◆ event_key()

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

◆ event_key_ascii()

enum event_response menu::event_key_ascii ( unsigned char const  i_ascii)
private

handle ASCII key events

Returns
response

If the extended response is activated, the left and right arrow keys will produce the menu::RESPONSE_LEFT or menu::RESPONSE_RIGHT response.

◆ event_key_scan()

enum event_response menu::event_key_scan ( enum scancodes const  i_scan)
private

handle scancode events

Returns
response

◆ event_mouse()

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

◆ focus_enter()

void menu::focus_enter ( )
inlinevirtual

handle entering focus

Returns
none

Reimplemented from group.

◆ move()

void menu::move ( int const  i_pos_x,
int const  i_pos_y 
)
inlineprivatevirtual

move the widget to a new position

Parameters
[in]i_pos_xrelative x position to move the widget
[in]i_pos_yrelative y position to move the widget
Returns
none

This method does not redraw the widget

Reimplemented from widget.

◆ resize()

void menu::resize ( unsigned int const  i_len_x,
unsigned int const  i_len_y 
)
inlineprivatevirtual

resize the widget

Parameters
[in]i_len_xnew length of widget
[in]i_len_ynew height of widget
Returns
none

This method does not redraw the widget

Reimplemented from widget.

◆ select()

void menu::select ( unsigned int const  i_slot)
private

selects a menu item

Parameters
[in]i_slotindex of item to select
Returns
none

◆ select_next()

void menu::select_next ( )
private

selects the next item

Returns
none

◆ select_previous()

void menu::select_previous ( )
private

selects the previous item

Returns
none

◆ set_menu()

void menu::set_menu ( struct menuitem i_menu)
inline

sets the menu

Parameters
[in,out]i_menureference to menu items
Returns
none

i_menu must be a valid reference to a menu data structure. This widget does not make a local copy. So, the life time of the object should survive the menu widget.

◆ set_response_extended()

void menu::set_response_extended ( bool const  i_turnon)
inline

sets the behavior of the response used when the user presses specific keystrokes.

Parameters
[in]i_turnonindicator if the extended response is activated

When activated, and the user presses the left or right arrow keys an extended response of menu::RESPONSE_LEFT or menu::RESPONSE_RIGHT is returned to the caller.

An example use case is in the menubar class, which moves from menu to menu.

◆ submenu()

enum event_response menu::submenu ( struct menuitem io_menu,
unsigned int const  i_pos_x,
unsigned int const  i_pos_y 
)
private

popups sub menu

Parameters
[in,out]io_menumenu item containing submenu to popup
[in]i_pos_xx position to display popup
[in]i_pos_yy position to display popup
Returns
response of the submenu

Member Data Documentation

◆ m_array

menu::m_array
protected

flattened menu. contains pointer to the primary menu items (omitting sub-menus).

◆ m_menu

menu::m_menu
protected

reference to the menu items

◆ m_offset

menu::m_offset
protected

scroll offset

◆ m_orig_pos_y

menu::m_orig_pos_y
protected

original y position. used when a sub-menu is activated.

◆ m_response_extended

menu::m_response_extended
protected

indicator if extended response is activated

◆ m_selected

menu::m_selected
protected

index of selected item


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