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; | |
| virtual | ~menu_base () |
| DEFINE_CLASS_NAME ("menu_base") | |
| bool | validate (bool recursive=true) |
| checks that all of the menu_items | |
| astring | text_form () const |
| returns a string version of all the information here. | |
| astring | recursive_text_form () const |
| does a text_form on all menus and submenus rooted here. | |
| menu_common_base * | evaluate_trigger (char trigger) |
| returns the item or menu associated with the "trigger" value. | |
| virtual void | activate () |
| runs the menu structure by requesting input from the user. | |
| int | items () const |
| returns the number of menu items stored. | |
| void | add_item (menu_item *to_invoke) |
| adds a new menu_item onto this menu. | |
| menu_item * | get_item (int index) |
| gets the item at position "index". NIL is returned if out of range. | |
| bool | zap_item (int index) |
| removes the item at "index" if possible. | |
| bool | enable_item (int index, bool enable=true) |
| enables or disabled the item at "index". | |
| int | submenus () const |
| number of submenus total. | |
| void | add_submenu (menu_base *sub) |
| add a new submenu into "sub". | |
| menu_base * | get_submenu (int index) |
| returns the submenu stored at "index". | |
| bool | zap_submenu (int index) |
| removes the submenu at the "index". | |
| bool | enable_submenu (int index, bool enable=true) |
| enables or disables the submenu at the "index". | |
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.
| menu_base::~menu_base | ( | ) | [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().
| void menu_base::activate | ( | ) | [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.
| 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.
| 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. NIL 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 NIL.
| menu_item * menu_base::get_item | ( | int | index | ) |
gets the item at position "index". NIL is returned if out of range.
Definition at line 118 of file menu_base.cpp.
References bounds_return, and NIL.
| 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 NIL.
| 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.
1.6.3