Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

Menu Class Reference

List of all members.

Detailed Description

This creates a simple menu for user interaction.

Author:
John Schneiderman

Definition at line 31 of file menu.h.

Public Member Functions

void addMenuItem (const string &menuItem)
void draw () const
 Menu (const string &title, const string &prompt)
int menuItem (const string &menuItem) const
int selectMenuItem () const
void setFeedback (const string &feedback)

Static Public Attributes

static const int MENU_EXIT = -100

Private Attributes

string m_clearScreen
string m_feedback
char m_menuChar
vector< string > m_menuItems
string m_prompt
string m_title

Static Private Attributes

static const string DEFAULT_MESSAGE = "- - - - - - - - - - - - - - - - - - - - "
static const int MAX_WIDTH = 80
static const int MENU_ITEM_SPACERS = 5


Constructor & Destructor Documentation

Menu::Menu const string &  title,
const string &  prompt
 

General constructor.

Parameters:
title is the title for the menu.
prompt is the prompt to follow the menu.
Returns:

Definition at line 27 of file menu.cpp.

References DEFAULT_MESSAGE, m_clearScreen, m_feedback, m_menuChar, m_prompt, and m_title.


Member Function Documentation

void Menu::addMenuItem const string &  menuItem  ) 
 

Adds an option to the menu.

Parameters:
menuItem is the description of the menu option.

Definition at line 41 of file menu.cpp.

References m_menuItems.

Referenced by createCluster(), interactiveRun(), and selectSimulation().

void Menu::draw  )  const
 

Draws the menu.

Note:
Once the feedback has been displayed it is reset back to DEFAULT_MESSAGE.

Definition at line 63 of file menu.cpp.

References DEFAULT_MESSAGE, m_clearScreen, m_feedback, m_menuChar, m_menuItems, m_title, MAX_WIDTH, and MENU_ITEM_SPACERS.

Referenced by createCluster(), interactiveRun(), selectMenuItem(), and selectSimulation().

int Menu::menuItem const string &  menuItem  )  const
 

Gets the menuItem's ID which can be used in if statements.

Parameters:
menuItem this is the menuItem to search for in the menu.
Returns:
the ID of the menuItem, -1 if menuItem is not found.

Definition at line 50 of file menu.cpp.

References m_menuItems.

Referenced by createCluster(), interactiveRun(), and selectSimulation().

int Menu::selectMenuItem  )  const
 

Prompts a user to select an option.

Returns:
The users menu option selection, MENU_EXIT is returned if they wish to exit.

Definition at line 108 of file menu.cpp.

References draw(), m_feedback, m_menuItems, m_prompt, and MENU_EXIT.

Referenced by createCluster(), interactiveRun(), and selectSimulation().

Here is the call graph for this function:

void Menu::setFeedback const string &  feedback  ) 
 

This will set the feedback the the user will see.

Parameters:
feedback is the message to show the user.

Definition at line 58 of file menu.cpp.

References m_feedback.

Referenced by interactiveRun(), and selectSimulation().


Member Data Documentation

const string Menu::DEFAULT_MESSAGE = "- - - - - - - - - - - - - - - - - - - - " [static, private]
 

Parameters:
DEFAULT_MESSAGE is the default message for the user feedback.

Definition at line 77 of file menu.h.

Referenced by draw(), and Menu().

string Menu::m_clearScreen [private]
 

Parameters:
m_clearScreen is the OS string used to clear the screen.

Definition at line 84 of file menu.h.

Referenced by draw(), and Menu().

string Menu::m_feedback [mutable, private]
 

Parameters:
m_feedback is the feedback message to give the user.

Definition at line 86 of file menu.h.

Referenced by draw(), Menu(), selectMenuItem(), and setFeedback().

char Menu::m_menuChar [private]
 

Parameters:
m_menuChar is the character used to draw the menu.

Definition at line 88 of file menu.h.

Referenced by draw(), and Menu().

vector<string> Menu::m_menuItems [private]
 

Parameters:
menuItems is the options for the menu.

Definition at line 90 of file menu.h.

Referenced by addMenuItem(), draw(), menuItem(), and selectMenuItem().

string Menu::m_prompt [private]
 

Parameters:
m_prompt is the prompt for the menu.

Definition at line 82 of file menu.h.

Referenced by Menu(), and selectMenuItem().

string Menu::m_title [private]
 

Parameters:
m_title is the title of the menu.

Definition at line 80 of file menu.h.

Referenced by draw(), and Menu().

const int Menu::MAX_WIDTH = 80 [static, private]
 

Parameters:
MAX_WIDTH is the maximum wideth a manu can be.

Definition at line 73 of file menu.h.

Referenced by draw().

const int Menu::MENU_EXIT = -100 [static]
 

Parameters:
MENU_EXIT is the signal for a user wishing to exit a menu.

Definition at line 35 of file menu.h.

Referenced by createCluster(), interactiveRun(), selectMenuItem(), and selectSimulation().

const int Menu::MENU_ITEM_SPACERS = 5 [static, private]
 

Parameters:
MENU_ITEM_SPACERS is the spaces between the menu border and the menu option.

Definition at line 75 of file menu.h.

Referenced by draw().


The documentation for this class was generated from the following files:
Generated on Tue Mar 28 23:29:07 2006 for ClusterSim by  doxygen 1.4.4