Changeset 5d4b73 for src/UIElements/Menu
- Timestamp:
- Dec 5, 2010, 12:17:34 AM (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:
- 589112
- Parents:
- 41e15b (diff), d754bb (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- src/UIElements/Menu
- Files:
-
- 2 added
- 4 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/Menu/Menu.hpp
r41e15b r5d4b73 21 21 * Note that this Class is never to be used directly but only via derived 22 22 * specializations. 23 * 24 * Note that we do not call member function init() directly in the constructor 25 * to allow for something to be add to the menu beforehand which is necessary 26 * for the TextMenu for example. 27 * 28 * <h1>Howto</h1> 29 * 30 * First, derive your own menu class, see QtMenu or TextMenu for example. These 31 * have been templated because of the two Qt classes QMenu and QMenuBar to be 32 * addressable in a unified manner. TextMenu does not actually need to be a 33 * template but it does not hurt either. 34 * 35 * Basically, the structure is as follows: 36 * -# Menu implements the initialization: it goes through MenuDescription's and 37 * ActionRegistry's contents and adds MenuItem's and Action's as requested. 38 * -# It does so by calling virtual functions defined in MenuInterface. These 39 * allow for adding of specific type of items: separators, Actions, menus 40 * -# Your derived Menu implements add these specific adders, basically just as 41 * wrappers. If you really have another UI type, implement its Menu 42 * functionality separately, such as TxMenu does. 43 * -# It also inherits both Menu and virtually MenuInterface such that it 44 * contains initializing and adding functionality 45 * 46 * Note that MenuInterface is inherited by both Menu and your class and hence has 47 * to be declared as a "virtual" base class for both. 23 48 */ 24 49 class Menu : virtual public MenuInterface -
src/UIElements/Menu/TextMenu/SeparatorMenuItem.cpp
r41e15b r5d4b73 7 7 8 8 /* 9 * Sep eratorItem.cpp9 * SeparatorMenuItem.cpp 10 10 * 11 11 * Created on: Dec 11, 2009 … … 23 23 #include <sstream> 24 24 25 #include "Menu/TextMenu/Sep eratorItem.hpp"25 #include "Menu/TextMenu/SeparatorMenuItem.hpp" 26 26 #include "defs.hpp" 27 27 28 28 29 Sep eratorItem::SeperatorItem(TxMenu* const menu):29 SeparatorMenuItem::SeparatorMenuItem(TxMenu* const menu): 30 30 MenuItem('\0',"",menu), 31 31 spacer(STD_SEPERATOR_SPACER), … … 36 36 } 37 37 38 Sep eratorItem::SeperatorItem(TxMenu* const menu,char _spacer, int _length):38 SeparatorMenuItem::SeparatorMenuItem(TxMenu* const menu,char _spacer, int _length): 39 39 MenuItem('\0',"",menu), 40 40 spacer(_spacer), … … 45 45 } 46 46 47 Sep eratorItem::~SeperatorItem()47 SeparatorMenuItem::~SeparatorMenuItem() 48 48 { 49 49 // TODO Auto-generated destructor stub … … 51 51 52 52 53 void Sep eratorItem::doTrigger(){}54 bool Sep eratorItem::checkTrigger(char){53 void SeparatorMenuItem::doTrigger(){} 54 bool SeparatorMenuItem::checkTrigger(char){ 55 55 return false; 56 56 } 57 57 58 const std::string Sep eratorItem::getDescription() {58 const std::string SeparatorMenuItem::getDescription() { 59 59 return std::string(""); 60 60 } 61 61 62 const std::string Sep eratorItem::formatEntry(){62 const std::string SeparatorMenuItem::formatEntry(){ 63 63 std::stringstream s; 64 64 for(int i=0; i<length;i++) -
src/UIElements/Menu/TextMenu/SeparatorMenuItem.hpp
r41e15b r5d4b73 1 1 /* 2 * Sep eratorItem.h2 * SeparatorMenuItem.h 3 3 * 4 4 * Created on: Dec 11, 2009 … … 6 6 */ 7 7 8 #ifndef SEP ERATORITEM_H_9 #define SEP ERATORITEM_H_8 #ifndef SEPARATORITEM_H_ 9 #define SEPARATORITEM_H_ 10 10 11 11 #include <string> … … 16 16 17 17 /** 18 * Produce a Sep erator within a Menu.18 * Produce a Separator within a Menu. 19 19 * 20 20 * All triggers are ignored for this Item. 21 21 */ 22 class Sep eratorItem : public MenuItem22 class SeparatorMenuItem : public MenuItem 23 23 { 24 24 public: 25 Sep eratorItem(TxMenu* const );26 Sep eratorItem(TxMenu* const ,char,int);27 virtual ~Sep eratorItem();25 SeparatorMenuItem(TxMenu* const ); 26 SeparatorMenuItem(TxMenu* const ,char,int); 27 virtual ~SeparatorMenuItem(); 28 28 29 29 virtual void doTrigger(); … … 38 38 }; 39 39 40 #endif /* SEP ERATORITEM_H_ */40 #endif /* SEPARATORITEM_H_ */ -
src/UIElements/Menu/TextMenu/TextMenu.hpp
r41e15b r5d4b73 12 12 #include <string> 13 13 14 #include "Helpers/MemDebug.hpp" 15 14 16 #include "Helpers/Log.hpp" 15 17 #include "Helpers/Verbose.hpp" … … 19 21 #include "Actions/ActionRegistry.hpp" 20 22 #include "Actions/ActionTraits.hpp" 21 #include "Menu/TextMenu/TxMenu .hpp"23 #include "Menu/TextMenu/TxMenuLeaveAction.hpp" 22 24 #include "Menu/TextMenu/ActionMenuItem.hpp" 23 #include "Menu/TextMenu/Sep eratorItem.hpp"25 #include "Menu/TextMenu/SeparatorMenuItem.hpp" 24 26 #include "Menu/TextMenu/SubMenuItem.hpp" 25 27 26 28 /** TextMenu is a specialization of MenuInterface to access TxMenu-like menus. 29 * 30 * Basically, this class is to be used in the MainWindow class of the TextUI. 31 * There, we simply instantiate the class and call init() in order to add all 32 * MenuItem's from MenuDescriptions and Action's ActionRegistry. 33 * 27 34 * \sa QtMenu. 28 35 */ … … 31 38 { 32 39 public: 40 /** Constructor for class TextMenu. 41 * Initializes outputter and token and takes note whether to delete the 42 * MenuInstance or not. 43 */ 33 44 TextMenu(std::ostream &_outputter, const std::string &_token) : 34 45 MenuInterface(_token), … … 46 57 {} 47 58 59 /** Destructor of MenuInstance. 60 * 61 */ 48 62 virtual ~TextMenu() 49 63 { … … 52 66 } 53 67 68 /** Display this MenuInstance. 69 * 70 */ 54 71 void display() 55 72 { … … 57 74 } 58 75 76 /** Returns a pointer to the contained/wrapped MenuInstance. 77 * \return pointer to template class pointer 78 */ 59 79 T * const getMenuInstance() 60 80 { … … 62 82 } 63 83 84 /** Reserves a specific trigger key such that it is not used during init(). 85 * \param trigger trigger key 86 * \param &name token given for reference. 87 */ 64 88 void reserveShortcut(char trigger, const std::string &name) 65 89 { … … 78 102 MenuShortcutMap ShortcutMap; 79 103 104 /** Adds an ActionItem by simply creating a new one. 105 * \param &token token of Action (token in ActionRegistry) 106 * \param &description descriptive text to be shown 107 */ 80 108 virtual void addActionItem(const std::string &token, const std::string &description) 81 109 { … … 83 111 } 84 112 113 /** Adds a (dead) separator item. 114 * 115 */ 85 116 virtual void addSeparatorItem() 86 117 { 87 new Sep eratorItem(MenuInstance);118 new SeparatorMenuItem(MenuInstance); 88 119 } 89 120 121 /** Adds a Menu to this current Menu. 122 * We also create here a leave action for this submenu to be able to return 123 * to the current one again 124 * \param &token token of the menu 125 * \param &description descriptive text 126 */ 90 127 virtual void addSubmenuItem(const std::string &token, const std::string &description) 91 128 { … … 102 139 } 103 140 141 /** Return the next available trigger key suitable to this name. 142 * This function is used internally to make sure that each key is unique to 143 * each Action/Menu. The chosen trigger key is also stored in an internal ShortcutMap. 144 * \param &name text shown in menu 145 * \return trigger key 146 */ 104 147 char getSuitableShortForm(const std::string &name) 105 148 { -
src/UIElements/Menu/TextMenu/TxMenu.cpp
r41e15b r5d4b73 24 24 #include <iostream> 25 25 #include <cmath> 26 #include "Actions/Action.hpp"27 #include "Actions/ActionTraits.hpp"28 26 #include "Menu/TextMenu/TxMenu.hpp" 29 27 #include "Menu/TextMenu/MenuItem.hpp" 30 #include "Helpers/Assert.hpp"31 28 32 29 33 /** 30 /** Constructor for class TxMenu. 31 * 34 32 * produce a text menu with a given title. 35 33 * The text will later be displayed using the stream passed to the constructor. 34 * \param &_outputter output stream to use for displaying the text 35 * \param _title title of this menu 36 * \param _spacer key to separate trigger key from descriptive text shown 37 * \param _length maximum length of the descriptive text 36 38 */ 37 39 TxMenu::TxMenu(std::ostream& _outputter, const std::string _title, char _spacer,int _length) : … … 45 47 } 46 48 49 /** Destructor for class TxMenu. 50 * 51 */ 47 52 TxMenu::~TxMenu() 48 53 { … … 51 56 } 52 57 58 /** Adds an MenuItem to the internal list. 59 * \param *item item to add 60 */ 53 61 void TxMenu::addItem(MenuItem* item) { 54 62 items.push_back(item); 55 63 } 56 64 65 /** Removes an MenuItem to the internal list. 66 * \param *item item to remove 67 */ 57 68 void TxMenu::removeItem(MenuItem* item) { 58 69 items.remove(item); 59 70 } 60 71 72 /** Function to quit this TxMenu. 73 */ 61 74 void TxMenu::doQuit(){ 62 75 quit = true; 63 76 } 64 77 78 /** Return the current state of quitting. 79 * \return quit boolean 80 */ 65 81 bool TxMenu::hasQuit(){ 66 82 return quit; 67 83 } 68 84 85 /** Display in a formatted manner a given entry of this menu. 86 * \param *entry MenuItem to show 87 */ 69 88 void TxMenu::showEntry(MenuItem* entry){ 70 89 if(entry->isActive()==false){ … … 78 97 } 79 98 99 /** Display this menu. 100 * 101 */ 80 102 void TxMenu::display() { 81 103 char choice; … … 114 136 } 115 137 138 /** Return the internally stored title of the menu. 139 * \return title string 140 */ 116 141 std::string TxMenu::getTitle(){ 117 142 return title; 118 143 } 119 144 145 /** Return the internally stored outputter of the menu. 146 * \return output stream reference 147 */ 120 148 std::ostream& TxMenu::getOutputter() 121 149 { … … 123 151 } 124 152 125 153 /** Add a default item to the menu. 154 * \param *_defaultItem MenuItem to act as default item. 155 */ 126 156 void TxMenu::addDefault(MenuItem* _defaultItem) { 127 157 defaultItem = _defaultItem; 128 158 } 129 159 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 } -
src/UIElements/Menu/TextMenu/TxMenu.hpp
r41e15b r5d4b73 14 14 15 15 #include "Menu/Menu.hpp" 16 #include "Actions/Action.hpp"17 #include "Actions/ActionTraits.hpp"18 16 #include "defs.hpp" 19 17 20 18 class MenuItem; 21 19 22 /** 23 * Used to produce any kind of text menu 20 /** Menu for the TextUI. 24 21 * 25 * All Items are displayed and user is prompted for a key. The item corresponding to that key is then activated. 22 * Used to produce any kind of text menu. This is a generic text menu user 23 * interface, i.e. we have a list of MenuItem's, which can either be 24 * -# Action's 25 * -# Displayers 26 * -# Separators 27 * -# other Menu's 28 * 29 * In this manner we have a tree structure, the (sub)menus generating new 30 * branches, the rest making up the leaves. 31 * 32 * All Items are displayed via a given output stream and user is prompted 33 * for a key. The item corresponding to that key is then activated. 26 34 */ 27 35 class TxMenu 28 36 { 29 37 public: 30 class LeaveAction : public Action { 31 public: 32 LeaveAction(TxMenu* const, const ActionTraits &_trait); 33 virtual ~LeaveAction(); 34 35 bool canUndo(); 36 bool shouldUndo(); 37 38 protected: 39 virtual Dialog* fillDialog(Dialog *dialog); 40 private: 41 virtual void getParametersfromValueStorage(); 42 virtual Action::state_ptr performCall(); 43 virtual Action::state_ptr performUndo(Action::state_ptr); 44 virtual Action::state_ptr performRedo(Action::state_ptr); 45 46 TxMenu* const menu; 47 }; 38 class LeaveAction; 48 39 49 40 TxMenu(std::ostream& _outputter, const std::string _title, char _spacer=STD_MENU_TITLE_SPACER,int _length=STD_MENU_LENGTH);
Note:
See TracChangeset
for help on using the changeset viewer.