feisty meow concerns codebase
2.140
|
A base class for a menu-driven interface model. More...
#include <menu_base.h>
Public Member Functions | |
menu_base (const astring &title, const menu_item ¶meters) | |
virtual bool menu_item_activity() = 0; More... | |
virtual | ~menu_base () |
DEFINE_CLASS_NAME ("menu_base") | |
bool | validate (bool recursive=true) |
checks that all of the menu_items More... | |
astring | text_form () const |
returns a string version of all the information here. More... | |
astring | recursive_text_form () const |
does a text_form on all menus and submenus rooted here. More... | |
menu_common_base * | evaluate_trigger (char trigger) |
returns the item or menu associated with the "trigger" value. More... | |
virtual void | activate () |
runs the menu structure by requesting input from the user. More... | |
int | items () const |
returns the number of menu items stored. More... | |
void | add_item (menu_item *to_invoke) |
adds a new menu_item onto this menu. More... | |
menu_item * | get_item (int index) |
gets the item at position "index". NULL_POINTER is returned if out of range. More... | |
bool | zap_item (int index) |
removes the item at "index" if possible. More... | |
bool | enable_item (int index, bool enable=true) |
enables or disabled the item at "index". More... | |
int | submenus () const |
number of submenus total. More... | |
void | add_submenu (menu_base *sub) |
add a new submenu into "sub". More... | |
menu_base * | get_submenu (int index) |
returns the submenu stored at "index". More... | |
bool | zap_submenu (int index) |
removes the submenu at the "index". More... | |
bool | enable_submenu (int index, bool enable=true) |
enables or disables the submenu at the "index". More... | |
Public Member Functions inherited from menu_common_base | |
virtual | ~menu_common_base () |
bool | enabled () const |
void | enable (bool enable=true) |
A base class for a menu-driven interface model.
The base just provides functions for manipulating menu items and submenus.
Definition at line 86 of file menu_base.h.
menu_base::menu_base | ( | const astring & | title, |
const menu_item & | parameters | ||
) |
virtual bool menu_item_activity() = 0;
Definition at line 76 of file menu_base.cpp.
|
virtual |
< the "parameters" record any activation triggers and descriptions for this menu; these are mainly used when this is a sub-menu.
Definition at line 84 of file menu_base.cpp.
References basis::WHACK().
|
virtual |
runs the menu structure by requesting input from the user.
this assumes that they will type a key and hit enter afterwards. the menus are displayed using the program-wide logger. no feedback is provided since the menu_items will be activated automatically. when this method returns, it is assumed that the user has chosen a menu item. overriding this method allows a different type of menu to provide a totally different method for interacting with the user.
Definition at line 173 of file menu_base.cpp.
void menu_base::add_item | ( | menu_item * | to_invoke | ) |
adds a new menu_item onto this menu.
Definition at line 112 of file menu_base.cpp.
void menu_base::add_submenu | ( | menu_base * | sub | ) |
add a new submenu into "sub".
Definition at line 140 of file menu_base.cpp.
menu_base::DEFINE_CLASS_NAME | ( | "menu_base" | ) |
bool menu_base::enable_item | ( | int | index, |
bool | enable = true |
||
) |
enables or disabled the item at "index".
Definition at line 131 of file menu_base.cpp.
References bounds_return, and menu_common_base::enable().
bool menu_base::enable_submenu | ( | int | index, |
bool | enable = true |
||
) |
enables or disables the submenu at the "index".
Definition at line 159 of file menu_base.cpp.
References bounds_return, and menu_common_base::enable().
menu_common_base * menu_base::evaluate_trigger | ( | char | trigger | ) |
returns the item or menu associated with the "trigger" value.
use of dynamic cast enables one to tell what has been returned. NULL_POINTER is returned if there is nothing that answers to that trigger value. note that this does not invoke any activation functions.
Definition at line 166 of file menu_base.cpp.
References NULL_POINTER.
menu_item * menu_base::get_item | ( | int | index | ) |
gets the item at position "index". NULL_POINTER is returned if out of range.
Definition at line 118 of file menu_base.cpp.
References bounds_return, and NULL_POINTER.
menu_base * menu_base::get_submenu | ( | int | index | ) |
returns the submenu stored at "index".
Definition at line 146 of file menu_base.cpp.
References bounds_return, and NULL_POINTER.
int menu_base::items | ( | ) | const |
returns the number of menu items stored.
Definition at line 110 of file menu_base.cpp.
astring menu_base::recursive_text_form | ( | ) | const |
does a text_form on all menus and submenus rooted here.
Definition at line 104 of file menu_base.cpp.
int menu_base::submenus | ( | ) | const |
number of submenus total.
Definition at line 138 of file menu_base.cpp.
astring menu_base::text_form | ( | ) | const |
returns a string version of all the information here.
this just prints out this menu without recursing to sub-menus.
Definition at line 98 of file menu_base.cpp.
bool menu_base::validate | ( | bool | recursive = true | ) |
checks that all of the menu_items
Definition at line 91 of file menu_base.cpp.
bool menu_base::zap_item | ( | int | index | ) |
removes the item at "index" if possible.
Definition at line 124 of file menu_base.cpp.
References bounds_return.
bool menu_base::zap_submenu | ( | int | index | ) |
removes the submenu at the "index".
Definition at line 152 of file menu_base.cpp.
References bounds_return.