- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/Menu/TextMenu/TxMenu.cpp
rf0f9a6 rb59da6 24 24 #include <iostream> 25 25 #include <cmath> 26 #include "Actions/Action.hpp" 27 #include "Actions/ActionTraits.hpp" 26 28 #include "Menu/TextMenu/TxMenu.hpp" 27 29 #include "Menu/TextMenu/MenuItem.hpp" 30 #include "Helpers/Assert.hpp" 28 31 29 32 30 /** Constructor for class TxMenu. 31 * 33 /** 32 34 * produce a text menu with a given title. 33 35 * The text will later be displayed using the stream passed to the constructor. 34 * \param &_outputter output stream to use for displaying the text35 * \param _title title of this menu36 * \param _spacer key to separate trigger key from descriptive text shown37 * \param _length maximum length of the descriptive text38 36 */ 39 37 TxMenu::TxMenu(std::ostream& _outputter, const std::string _title, char _spacer,int _length) : … … 47 45 } 48 46 49 /** Destructor for class TxMenu.50 *51 */52 47 TxMenu::~TxMenu() 53 48 { … … 56 51 } 57 52 58 /** Adds an MenuItem to the internal list.59 * \param *item item to add60 */61 53 void TxMenu::addItem(MenuItem* item) { 62 54 items.push_back(item); 63 55 } 64 56 65 /** Removes an MenuItem to the internal list.66 * \param *item item to remove67 */68 57 void TxMenu::removeItem(MenuItem* item) { 69 58 items.remove(item); 70 59 } 71 60 72 /** Function to quit this TxMenu.73 */74 61 void TxMenu::doQuit(){ 75 62 quit = true; 76 63 } 77 64 78 /** Return the current state of quitting.79 * \return quit boolean80 */81 65 bool TxMenu::hasQuit(){ 82 66 return quit; 83 67 } 84 68 85 /** Display in a formatted manner a given entry of this menu.86 * \param *entry MenuItem to show87 */88 69 void TxMenu::showEntry(MenuItem* entry){ 89 70 if(entry->isActive()==false){ … … 97 78 } 98 79 99 /** Display this menu.100 *101 */102 80 void TxMenu::display() { 103 81 char choice; … … 136 114 } 137 115 138 /** Return the internally stored title of the menu.139 * \return title string140 */141 116 std::string TxMenu::getTitle(){ 142 117 return title; 143 118 } 144 119 145 /** Return the internally stored outputter of the menu.146 * \return output stream reference147 */148 120 std::ostream& TxMenu::getOutputter() 149 121 { … … 151 123 } 152 124 153 /** Add a default item to the menu. 154 * \param *_defaultItem MenuItem to act as default item. 155 */ 125 156 126 void TxMenu::addDefault(MenuItem* _defaultItem) { 157 127 defaultItem = _defaultItem; 158 128 } 159 129 130 /****************************** Contained Actions ****************/ 131 132 TxMenu::LeaveAction::LeaveAction(TxMenu* const _menu, const ActionTraits & LeaveActionTrait) : 133 Action(LeaveActionTrait, true), 134 menu(_menu) 135 {} 136 137 TxMenu::LeaveAction::~LeaveAction(){} 138 139 bool TxMenu::LeaveAction::canUndo(){ 140 return false; 141 } 142 143 bool TxMenu::LeaveAction::shouldUndo(){ 144 return false; 145 } 146 147 void TxMenu::LeaveAction::getParametersfromValueStorage() 148 {} 149 150 Dialog* TxMenu::LeaveAction::fillDialog(Dialog *dialog){ 151 ASSERT(dialog,"No Dialog given when filling action dialog"); 152 return dialog; 153 } 154 155 156 Action::state_ptr TxMenu::LeaveAction::performCall(){ 157 menu->doQuit(); 158 return Action::success; 159 } 160 161 162 Action::state_ptr TxMenu::LeaveAction::performUndo(Action::state_ptr){ 163 ASSERT(0,"Cannot undo leaving a menu"); 164 return Action::success; 165 } 166 167 Action::state_ptr TxMenu::LeaveAction::performRedo(Action::state_ptr){ 168 ASSERT(0,"Cannot redo leaving a menu"); 169 return Action::success; 170 }
Note:
See TracChangeset
for help on using the changeset viewer.