Changeset 8f3f40 for src/UIElements/Menu/TextMenu
- Timestamp:
- Dec 4, 2010, 11:42:38 PM (14 years ago)
- Branches:
- Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
- Children:
- f0f9a6
- Parents:
- 0af7ef
- git-author:
- Frederik Heber <heber@…> (11/08/10 10:31:40)
- git-committer:
- Frederik Heber <heber@…> (12/04/10 23:42:38)
- Location:
- src/UIElements/Menu/TextMenu
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/Menu/TextMenu/TextMenu.hpp
r0af7ef r8f3f40 25 25 26 26 /** TextMenu is a specialization of MenuInterface to access TxMenu-like menus. 27 * 28 * Basically, this class is to be used in the MainWindow class of the TextUI. 29 * There, we simply instantiate the class and call init() in order to add all 30 * MenuItem's from MenuDescriptions and Action's ActionRegistry. 31 * 27 32 * \sa QtMenu. 28 33 */ … … 31 36 { 32 37 public: 38 /** Constructor for class TextMenu. 39 * Initializes outputter and token and takes note whether to delete the 40 * MenuInstance or not. 41 */ 33 42 TextMenu(std::ostream &_outputter, const std::string &_token) : 34 43 MenuInterface(_token), … … 46 55 {} 47 56 57 /** Destructor of MenuInstance. 58 * 59 */ 48 60 virtual ~TextMenu() 49 61 { … … 52 64 } 53 65 66 /** Display this MenuInstance. 67 * 68 */ 54 69 void display() 55 70 { … … 57 72 } 58 73 74 /** Returns a pointer to the contained/wrapped MenuInstance. 75 * \return pointer to template class pointer 76 */ 59 77 T * const getMenuInstance() 60 78 { … … 62 80 } 63 81 82 /** Reserves a specific trigger key such that it is not used during init(). 83 * \param trigger trigger key 84 * \param &name token given for reference. 85 */ 64 86 void reserveShortcut(char trigger, const std::string &name) 65 87 { … … 78 100 MenuShortcutMap ShortcutMap; 79 101 102 /** Adds an ActionItem by simply creating a new one. 103 * \param &token token of Action (token in ActionRegistry) 104 * \param &description descriptive text to be shown 105 */ 80 106 virtual void addActionItem(const std::string &token, const std::string &description) 81 107 { … … 83 109 } 84 110 111 /** Adds a (dead) separator item. 112 * 113 */ 85 114 virtual void addSeparatorItem() 86 115 { … … 88 117 } 89 118 119 /** Adds a Menu to this current Menu. 120 * We also create here a leave action for this submenu to be able to return 121 * to the current one again 122 * \param &token token of the menu 123 * \param &description descriptive text 124 */ 90 125 virtual void addSubmenuItem(const std::string &token, const std::string &description) 91 126 { … … 102 137 } 103 138 139 /** Return the next available trigger key suitable to this name. 140 * This function is used internally to make sure that each key is unique to 141 * each Action/Menu. The chosen trigger key is also stored in an internal ShortcutMap. 142 * \param &name text shown in menu 143 * \return trigger key 144 */ 104 145 char getSuitableShortForm(const std::string &name) 105 146 { -
src/UIElements/Menu/TextMenu/TxMenu.cpp
r0af7ef r8f3f40 31 31 32 32 33 /** 33 /** Constructor for class TxMenu. 34 * 34 35 * produce a text menu with a given title. 35 36 * The text will later be displayed using the stream passed to the constructor. 37 * \param &_outputter output stream to use for displaying the text 38 * \param _title title of this menu 39 * \param _spacer key to separate trigger key from descriptive text shown 40 * \param _length maximum length of the descriptive text 36 41 */ 37 42 TxMenu::TxMenu(std::ostream& _outputter, const std::string _title, char _spacer,int _length) : … … 45 50 } 46 51 52 /** Destructor for class TxMenu. 53 * 54 */ 47 55 TxMenu::~TxMenu() 48 56 { … … 51 59 } 52 60 61 /** Adds an MenuItem to the internal list. 62 * \param *item item to add 63 */ 53 64 void TxMenu::addItem(MenuItem* item) { 54 65 items.push_back(item); 55 66 } 56 67 68 /** Removes an MenuItem to the internal list. 69 * \param *item item to remove 70 */ 57 71 void TxMenu::removeItem(MenuItem* item) { 58 72 items.remove(item); 59 73 } 60 74 75 /** Function to quit this TxMenu. 76 */ 61 77 void TxMenu::doQuit(){ 62 78 quit = true; 63 79 } 64 80 81 /** Return the current state of quitting. 82 * \return quit boolean 83 */ 65 84 bool TxMenu::hasQuit(){ 66 85 return quit; 67 86 } 68 87 88 /** Display in a formatted manner a given entry of this menu. 89 * \param *entry MenuItem to show 90 */ 69 91 void TxMenu::showEntry(MenuItem* entry){ 70 92 if(entry->isActive()==false){ … … 78 100 } 79 101 102 /** Display this menu. 103 * 104 */ 80 105 void TxMenu::display() { 81 106 char choice; … … 114 139 } 115 140 141 /** Return the internally stored title of the menu. 142 * \return title string 143 */ 116 144 std::string TxMenu::getTitle(){ 117 145 return title; 118 146 } 119 147 148 /** Return the internally stored outputter of the menu. 149 * \return output stream reference 150 */ 120 151 std::ostream& TxMenu::getOutputter() 121 152 { … … 123 154 } 124 155 125 156 /** Add a default item to the menu. 157 * \param *_defaultItem MenuItem to act as default item. 158 */ 126 159 void TxMenu::addDefault(MenuItem* _defaultItem) { 127 160 defaultItem = _defaultItem; … … 130 163 /****************************** Contained Actions ****************/ 131 164 165 /** Constructor for class TxMenu::LeaveAction. 166 * \param _menu pointer to the containing TxMenu 167 * \param &LeaveActionTrait ActionTraits for this Action 168 */ 132 169 TxMenu::LeaveAction::LeaveAction(TxMenu* const _menu, const ActionTraits & LeaveActionTrait) : 133 170 Action(LeaveActionTrait, true), … … 135 172 {} 136 173 174 /** Destructor for class TxMenu::LeaveAction. 175 * 176 */ 137 177 TxMenu::LeaveAction::~LeaveAction(){} 138 178 179 /** We can't undo the leave action. 180 * \return false 181 */ 139 182 bool TxMenu::LeaveAction::canUndo(){ 140 183 return false; 141 184 } 142 185 186 /** We should never undo the leave action. 187 * \return false 188 */ 143 189 bool TxMenu::LeaveAction::shouldUndo(){ 144 190 return false; 145 191 } 146 192 193 /** Internal function to obtain parameters from a storage. 194 * We do not use this one as we don't need any parameters. 195 */ 147 196 void TxMenu::LeaveAction::getParametersfromValueStorage() 148 197 {} 149 198 199 /** Internal function to construct the dialog. 200 * We do not need this function as there is no dialog to construct. 201 */ 150 202 Dialog* TxMenu::LeaveAction::fillDialog(Dialog *dialog){ 151 203 ASSERT(dialog,"No Dialog given when filling action dialog"); … … 153 205 } 154 206 155 207 /** Calls TxMenu::doQuit() on the stored menu reference. 208 * \return ActionState pointer with success 209 */ 156 210 Action::state_ptr TxMenu::LeaveAction::performCall(){ 157 211 menu->doQuit(); … … 159 213 } 160 214 161 215 /** Implementation of undo function for an Action. 216 * We do not use this functionality. 217 * \return ActionState pointer with failure 218 */ 162 219 Action::state_ptr TxMenu::LeaveAction::performUndo(Action::state_ptr){ 163 220 ASSERT(0,"Cannot undo leaving a menu"); 164 return Action::success; 165 } 166 221 return Action::failure; 222 } 223 224 /** Implementation of redo function for an Action. 225 * We do not use this functionality. 226 * \return ActionState pointer with failure 227 */ 167 228 Action::state_ptr TxMenu::LeaveAction::performRedo(Action::state_ptr){ 168 229 ASSERT(0,"Cannot redo leaving a menu"); 169 return Action:: success;170 } 230 return Action::failure; 231 } -
src/UIElements/Menu/TextMenu/TxMenu.hpp
r0af7ef r8f3f40 20 20 class MenuItem; 21 21 22 /** 23 * Used to produce any kind of text menu 22 /** Menu for the TextUI. 24 23 * 25 * All Items are displayed and user is prompted for a key. The item corresponding to that key is then activated. 24 * Used to produce any kind of text menu. This is a generic text menu user 25 * interface, i.e. we have a list of MenuItem's, which can either be 26 * -# Action's 27 * -# Displayers 28 * -# Separators 29 * -# other Menu's 30 * 31 * In this manner we have a tree structure, the (sub)menus generating new 32 * branches, the rest making up the leaves. 33 * 34 * All Items are displayed via a given output stream and user is prompted 35 * for a key. The item corresponding to that key is then activated. 26 36 */ 27 37 class TxMenu 28 38 { 29 39 public: 40 /** This specific action is used to leave a submenu and return to an upper one. 41 * It differs from other Action's (and thus cannot be put into the usual 42 * structure) that we have to store the reference to the menu it belongs to. 43 * There, we call the doQuit() member function on performCall(). 44 */ 30 45 class LeaveAction : public Action { 31 46 public:
Note:
See TracChangeset
for help on using the changeset viewer.