#include <MenuSystem.h>
Inheritance diagram for MenuSystem::

Public Methods | |
| MenuSystem () | |
| ~MenuSystem () | |
| void | init (const String &description, const String &label) |
| MenuItemBase* | addItem (int level, const String &command, const String &cl_option_string, const String &description, const String &default_answer, const String &valid_answer, char hot_key, char cl_option_char, MenuCallBack *func=NULL) |
| MenuItemBase* | addItem (int level, const String &command, const String &cl_option_string, const String &description, const String &default_answer, const String &valid_answer, MenuCallBack *func=NULL) |
| MenuItemBase* | addItem (int level, const String &command, const String &description, const String &default_answer) |
| bool | addSubMenu (int level, const String &name_label, const String &command, const String &description, char hot_key) |
| bool | addSubMenu (int level, const String &name_label, const String &command, const String &description) |
| bool | addSubMenu (MenuSystem *menu) |
| bool | disableIfEqual (String item_boss, String value, String item_disable) |
| void | forget () |
| void | prompt () |
| void | forceAnswer (const String &command_and_answer) |
| String | get (const String &command) |
| void | set (const String &command, const String &value) |
| void | setAboutImage (const String &path) |
| void | setAboutText (const String &text) |
| void | setAboutGeometry (int width, int height) |
| String | getAboutImage () const |
| String | getAboutText () const |
| int | getAboutWidth () const |
| int | getAboutHeight () const |
| void | print4awk (Os os) |
| void | multipleLoop (SimCase &user) |
| bool | insideMultipleLoop () const |
| int | getMultipleLoopLimit () const |
| int | getMultipleLoopIndex () const |
| void | setCommandPrefix (const String &prefix) |
| void | unsetCommandPrefix () |
| String | getCommandPrefix () const |
| bool | ok () const |
| bool | empty () const |
| void | writeHeadings4multipleAnswers (StringList &headings) |
| void | writeResults4multipleAnswers (StringList &results) |
| void | writeExtendedResults4multipleAnswers (MultipleReporter &rep, int section_level=1) |
| String | getDescription () const |
| MenuItemBase* | getFirstItem () |
| void | initParallelPrompt (const PromptBase &p) |
| bool | initFromCommandLineArg (const char *option, real &number, real default_value, const char *description=NULL, const char *variable_type=NULL) |
| bool | initFromCommandLineArg (const char *option, int &number, int default_value, const char *description=NULL, const char *variable_type=NULL) |
| bool | initFromCommandLineArg (const char *option, bool &indicator, bool default_value, const char *description=NULL, const char *variable_type=NULL) |
| bool | initFromCommandLineArg (const char *option, String &string, const char *default_value, const char *description=NULL, const char *variable_type=NULL) |
Static Public Methods | |
| void | makeSubMenuHeader (MenuSystem &menu, const String &description, const String &command, int &level, char hot_key) |
Public Attributes | |
| StringList | answers |
Protected Methods | |
| void | search4multipleAnswers (MenuAnswerTable &table) |
| MenuLists* | getMenuListsPtr () |
| bool | levelCheck (int level) |
Protected Attributes | |
| VecSimplest(Handle(MenuLists)) | menu_lists |
| bool | initialized |
| MenuAnswerTable | table |
| bool | disable_add_and_prompt |
| bool | is_inside_multiple_loop |
| String | command_prefix |
| String | save_input_to_file |
| int | ncomb |
| int | icomb |
| String | about_image |
| String | about_text |
| int | about_width |
| int | about_height |
| SetDistinct(String) | init_from_command_line_options |
| StringList | init_from_command_line_defaults |
| StringList | init_from_command_line_descriptions |
| StringList | init_from_command_line_vartypes |
NAME: MenuSystem - a menu system (user interface) for input data
DESCRIPTION:
Class "MenuSystem" makes it possible to create a fairly simple, general and still flexible user interface. The interface is implemented as a hierarchy of menus with submenus and menu items for user input. The interface is defined by the programmer in the program code in terms of a menu with submenus and menuitems. Different menus created in different parts of the program may be combined together to create one common global user interface. Hence it is convenient to let every class be responsible for its own I/O.
|
|
The constructor takes no arguments. The object is not sufficiently initialized if unless the "init" function is called. It takes arguments containing a description of the menu and a label used when prompting the user in the interactive terminal dialog mode. |
|
|
|
|
|
See documentation of one of the overloaded functions. |
|
|
See documentation of one of the overloaded functions. |
|
|
adds a menu item to the menu at the given level. There are convenient "const" variables for the three first levels: "MAIN" (1), "SUB" (2) and "SUBSUB" (3). See [HPL] H.P. Langtangen, "Computational Partial Differential Equations" for explanation of the arguments. There is an overloaded version where the hotkeys can be omitted (convenient in large menus). |
|
|
See documentation of one of the overloaded functions. |
|
|
See documentation of one of the overloaded functions. |
|
|
adds a submenu to the menu at the given level. See [HPL] for explanation of the arguments. There is an overloaded version where the hotkeys can be omitted (convenient in large menus). Another overloaded version imports a whole "MenuSystem" object as a new submenu. |
|
|
|
|
|
returns true if there are no items in the menu. |
|
|
enables the programmer to override the user''s input on the menu. Calling
menu.forceAnswer ("a parameter = 1.0");
|
|
|
erases all the previous menu items. In principle, the old items are still stored and will be printed in the input data manual for example, but the old items are not visible in the user interface. The function is usually called when the user has been prompted and new items are to be defined. All items prior to the last prompt should be forgotten. |
|
|
returns answer for a given command as a "String". There are two ways of feeding answers to a "MenuSystem" object: (1) use the standard approach where "prompt" is called and answers are filled in, or (2) use the "forceAnswer" function. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
returns the current combination number in a multiple loop. |
|
|
returns the total number of possible combinations in the multiple loop. |
|
|
initializes the menu. Requires a description and a prompt label. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
returns true if the menu system is processing a multiple loop. Otherwise it returns false. |
|
|
|
|
|
sets a description, label etc. for a part of the menu. If this part is added as a submenu to the tree ("level" equals "SUB"), the label becomes the submenu name. It may be convenient to call "makeSubMenuHeader" in the beginning of a "defineStatic" function. If the "defineStatic" function is called with a level argument corresponding to one higher than the present level, all the items defined by the "defineStatic" functions will be put on a submenu. The submenu heading and command is then automatically set by the "makeSubMenuHeader" call in "defineStatic". Be careful and add items on the menu immediately after the call to "makeSubMenuHeader" since this function may create a submenu. It's easy to make the error of first calling "makeSubMenuHeader" and then calling a "defineStatic" or "define" function in another class that also calls "makeSubMenuHeader". In such cases one may easily create two submenus with no items in between. The first submenu will then be empty. |
|
|
the administrating function for execution of a large number of simulations, on basis of all possible combinations of multiple menu answers. The argument must be a class derived from class "SimCase". There are certain requirements of this derived class, for example, it must have certain virtual functions implemented. More details can be found in [HPL]. See class "MenuAnswer" for details on the syntax used for multiple answers. |
|
|
returns true if the object is properly initialized (that is, if the "init" function has been called). Otherwise it returns false. |
|
|
prints a list with all data stored in current menu. The output forms the basis for scripts that automatically generate manuals for the usage of the menu in question and `\`LaTeX`\` tables containing the values of the input data from the most recent execution. See [HPL] for more information on automatic manual generation. |
|
|
reads values into the menu, using the type of user interface determined by input source. This input source is usually set on the command line when executing the program. The effect of "prompt" depends on the type of user interface. In the interactive terminal dialog mode, the user is literally prompted. When using the command line option mode, the prompt has no effect, while when using the graphical motif interface, a call to prompt results in an X11 window with the menu system interface. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
after calling this function all commands defined by "addItem" get a prefix string. Likewise, all calls to "get" will result in a search for the command combined with the prefix string. Consider this situation: Let class "X" have "define" and "scan" functions that use the menu system. If you have two "X" objects in another class and want to define two "X" menus for different quantities, there will normally be two calls to "X define" and a duplicate of the menu entries. Also in calls to "X scan" it will be impossible to distinguish between the two "X" objects. However, if one puts a prefix "X1" (by calling the "setCommandPrefix" function) to the first "X" object and "X2" to the second "X" object, the commands made by "X define" will differ for the two objects. Remember to call "unsetCommandPrefix" when you do not want a prefix for every command! Using "setCommandPrefix" and "unsetCommandPrefix" before and after the calls to "X scan" enables reading the menu answers for the two "X" objects. |
|
|
|
|
|
see documentation of the function "writeHeadings4multipleAnswers". The value of the menu items that are varied in a multiple loop is written in a separate section in the report. The extra argument "section_level" determines the level of the section; 0 means a section, and 1 means a subsection. For stand-alone solvers, 1 is appropriate, while 0 is used when solvers are combined (system of PDEs), because then it is appropriate with a common section with the multiple loop parameters before each solver presents its specific part of the report. |
|
|
searches for all menu items that have multiple answers and appends the associated menu commands to the list given as argument. This function is very convenient when used in combination with the summary feature of class "MultipleReporter". In a simulator (derived from class "SimCase") one can in the "writeHeadings" function simply do
menu_system->writeHeadings4multipleAnswers (headings);
menu_system->writeResults4multipleAnswers (results); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|