/* * TextMenu.h * * Created on: Dec 10, 2009 * Author: crueger */ #ifndef TEXTMENU_H_ #define TEXTMENU_H_ #include #include #include #include "Menu/Menu.hpp" #include "Actions/Action.hpp" #include "defs.hpp" class MenuItem; /** * Used to produce any kind of text menu * * All Items are displayed and user is prompted for a key. The item corresponding to that key is then activated. */ class TextMenu : public Menu { public: class LeaveAction : public Action { public: LeaveAction(TextMenu*); virtual ~LeaveAction(); bool canUndo(); bool shouldUndo(); private: virtual Action::state_ptr performCall(); virtual Action::state_ptr performUndo(Action::state_ptr); virtual Action::state_ptr performRedo(Action::state_ptr); TextMenu* menu; static const string nameBase; }; TextMenu(ostream& _outputter, string _title, char _spacer=STD_MENU_TITLE_SPACER,int _length=STD_MENU_LENGTH); virtual ~TextMenu(); virtual void addItem(MenuItem*); virtual void removeItem(MenuItem*); virtual void display(); virtual string getTitle(); /** * Call doQuit if you want to return from this menu. */ virtual void doQuit(); /** * Check whether someone has chosen to quit */ virtual bool hasQuit(); virtual void addDefault(MenuItem*); protected: virtual void showEntry(MenuItem*); private: list items; MenuItem* defaultItem; ostream& outputter; string title; char spacer; int length; bool quit; }; #endif /* TEXTMENU_H_ */