Changeset b59da6 for src/UIElements/Menu/TextMenu
- Timestamp:
- Dec 4, 2010, 11:33:47 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:
- 0af7ef
- Parents:
- 5813ac
- git-author:
- Frederik Heber <heber@…> (11/08/10 09:36:45)
- git-committer:
- Frederik Heber <heber@…> (12/04/10 23:33:47)
- Location:
- src/UIElements/Menu/TextMenu
- Files:
-
- 2 added
- 11 moved
Legend:
- Unmodified
- Added
- Removed
-
src/UIElements/Menu/TextMenu/ActionMenuItem.cpp
r5813ac rb59da6 22 22 #include <iostream> 23 23 24 #include "Menu/ActionMenuItem.hpp" 25 #include "Actions/MethodAction.hpp" 24 #include "Menu/TextMenu/ActionMenuItem.hpp" 25 #include "Actions/Action.hpp" 26 #include "Actions/ActionRegistry.hpp" 26 27 27 28 using namespace std; 28 29 29 ActionMenuItem::ActionMenuItem(char _trigger, const char* _description,Menu* _menu,Action* _action)30 ActionMenuItem::ActionMenuItem(char _trigger, const std::string &_description,TxMenu* const _menu,const std::string &_ActionName) 30 31 : MenuItem(_trigger,_description,_menu), 31 action(_action)32 ActionName(_ActionName) 32 33 { 33 34 } … … 37 38 38 39 void ActionMenuItem::doTrigger() { 40 Action* action = ActionRegistry::getInstance().getActionByName(ActionName); 39 41 action->call(); 40 42 } 41 43 42 44 bool ActionMenuItem::isActive() { 45 Action* action = ActionRegistry::getInstance().getActionByName(ActionName); 43 46 return action->isActive(); 44 47 } -
src/UIElements/Menu/TextMenu/ActionMenuItem.hpp
r5813ac rb59da6 11 11 #include <string> 12 12 13 #include "Menu/ MenuItem.hpp"13 #include "Menu/TextMenu/MenuItem.hpp" 14 14 15 15 class Action; 16 class TxMenu; 16 17 17 18 /** … … 21 22 { 22 23 public: 23 ActionMenuItem(char,const char*,Menu*,Action*);24 ActionMenuItem(char,const std::string &,TxMenu* const,const std::string &); 24 25 virtual ~ActionMenuItem(); 25 26 … … 29 30 30 31 private: 31 Action* action; //!< this action will be called when the trigger matches32 const std::string ActionName; //!< this action will be called when the trigger matches 32 33 }; 33 34 -
src/UIElements/Menu/TextMenu/DisplayMenuItem.cpp
r5813ac rb59da6 23 23 #include <cmath> 24 24 25 #include "Menu/ DisplayMenuItem.hpp"25 #include "Menu/TextMenu/DisplayMenuItem.hpp" 26 26 #include "Views/StringView.hpp" 27 27 28 28 29 DisplayMenuItem::DisplayMenuItem( Menu*_menu, StringView *_view):29 DisplayMenuItem::DisplayMenuItem(TxMenu* const _menu, StringView *_view): 30 30 MenuItem('\0',"",_menu), 31 31 view(_view), … … 34 34 } 35 35 36 DisplayMenuItem::DisplayMenuItem( Menu* _menu, StringView *_view, string_title, char _spacer, int _length ):36 DisplayMenuItem::DisplayMenuItem(TxMenu* const _menu, StringView *_view, const std::string &_title, char _spacer, int _length ): 37 37 MenuItem('\0',"",_menu), 38 38 view(_view), … … 52 52 } 53 53 54 const st ring DisplayMenuItem::formatEntry(){55 st ringstream s;54 const std::string DisplayMenuItem::formatEntry(){ 55 std::stringstream s; 56 56 if(title.length()>0) { 57 57 int pre = floor((length-title.length())/2.0); … … 69 69 70 70 71 const st ring DisplayMenuItem::getDescription(){72 return st ring("");71 const std::string DisplayMenuItem::getDescription(){ 72 return std::string(""); 73 73 } -
src/UIElements/Menu/TextMenu/DisplayMenuItem.hpp
r5813ac rb59da6 9 9 #define DISPLAYMENUITEM_HPP_ 10 10 11 #include "Menu/MenuItem.hpp" 11 #include <string> 12 13 #include "Menu/TextMenu/MenuItem.hpp" 12 14 #include "defs.hpp" 13 15 14 16 class StringView; 17 class TxMenu; 15 18 16 19 /** … … 22 25 { 23 26 public: 24 DisplayMenuItem( Menu*_menu, StringView *_view);25 DisplayMenuItem( Menu* _menu, StringView *_view, string_title,27 DisplayMenuItem(TxMenu* const _menu, StringView *_view); 28 DisplayMenuItem(TxMenu* const _menu, StringView *_view, const std::string &_title, 26 29 char _spacer=STD_MENU_TITLE_SPACER, int _length=STD_MENU_LENGTH); 27 30 virtual ~DisplayMenuItem(); … … 30 33 virtual bool checkTrigger(char); 31 34 32 virtual const st ring formatEntry();35 virtual const std::string formatEntry(); 33 36 34 virtual const st ring getDescription();37 virtual const std::string getDescription(); 35 38 36 39 private: 37 40 StringView *view; 38 st ring title;41 std::string title; 39 42 int length; 40 43 char spacer; -
src/UIElements/Menu/TextMenu/MenuItem.cpp
r5813ac rb59da6 20 20 #include "Helpers/MemDebug.hpp" 21 21 22 #include "Menu/MenuItem.hpp" 22 #include "Menu/TextMenu/MenuItem.hpp" 23 #include "Menu/TextMenu/TxMenu.hpp" 23 24 #include "Menu/Menu.hpp" 24 25 #include <sstream> 25 #include <iostream>26 26 27 27 /** … … 29 29 * The MenuItem is then added to the menu passed to it. 30 30 */ 31 MenuItem::MenuItem(char _trigger, const char* _description,Menu*menu) :31 MenuItem::MenuItem(char _trigger, const std::string &_description,TxMenu* const menu) : 32 32 trigger(_trigger), 33 description(_description), 33 34 added(false) 34 35 { 35 description = new string(_description);36 36 add_to_menu(menu); 37 37 } 38 38 39 39 MenuItem::~MenuItem() 40 { 41 delete description; 42 } 40 {} 43 41 44 42 /** … … 59 57 } 60 58 61 const st ring MenuItem::getDescription() {62 return *description;59 const std::string MenuItem::getDescription() { 60 return description; 63 61 } 64 62 … … 67 65 * Normal format is: "<trigger> - <description>" 68 66 */ 69 const st ring MenuItem::formatEntry(){70 st ringstream s;67 const std::string MenuItem::formatEntry(){ 68 std::stringstream s; 71 69 s << getTrigger() << " - " << getDescription(); 72 70 … … 80 78 * TODO: include funtionality to move Items from one menu to another 81 79 */ 82 void MenuItem::add_to_menu( Menu*menu) {80 void MenuItem::add_to_menu(TxMenu* const menu) { 83 81 if(!wasAdded()) { 84 82 menu->addItem(this); -
src/UIElements/Menu/TextMenu/MenuItem.hpp
r5813ac rb59da6 11 11 #include <string> 12 12 13 using namespace std; 14 15 class Menu; 13 class TxMenu; 16 14 17 15 /** … … 22 20 class MenuItem { 23 21 public: 24 MenuItem(char,const char*,Menu*);22 MenuItem(char,const std::string &,TxMenu* const); 25 23 virtual ~MenuItem(); 26 24 … … 28 26 virtual bool checkTrigger(char); 29 27 30 virtual const st ring formatEntry();28 virtual const std::string formatEntry(); 31 29 32 virtual const st ring getDescription();30 virtual const std::string getDescription(); 33 31 char getTrigger(); 34 32 35 void add_to_menu( Menu*);33 void add_to_menu(TxMenu* const); 36 34 bool wasAdded(); 37 35 38 36 virtual bool isActive(); 39 37 40 protected:41 void setDescription(string);42 43 38 private: 44 39 char trigger; 45 string *description;40 const std::string description; 46 41 bool added; 47 42 }; -
src/UIElements/Menu/TextMenu/SeperatorItem.cpp
r5813ac rb59da6 23 23 #include <sstream> 24 24 25 #include "Menu/SeperatorItem.hpp" 26 #include "Menu/Menu.hpp" 25 #include "Menu/TextMenu/SeperatorItem.hpp" 27 26 #include "defs.hpp" 28 27 29 28 30 SeperatorItem::SeperatorItem( Menu*menu):29 SeperatorItem::SeperatorItem(TxMenu* const menu): 31 30 MenuItem('\0',"",menu), 32 31 spacer(STD_SEPERATOR_SPACER), … … 37 36 } 38 37 39 SeperatorItem::SeperatorItem( Menu*menu,char _spacer, int _length):38 SeperatorItem::SeperatorItem(TxMenu* const menu,char _spacer, int _length): 40 39 MenuItem('\0',"",menu), 41 40 spacer(_spacer), … … 57 56 } 58 57 59 const st ring SeperatorItem::getDescription() {60 return st ring("");58 const std::string SeperatorItem::getDescription() { 59 return std::string(""); 61 60 } 62 61 63 const st ring SeperatorItem::formatEntry(){64 st ringstream s;62 const std::string SeperatorItem::formatEntry(){ 63 std::stringstream s; 65 64 for(int i=0; i<length;i++) 66 65 s << spacer; -
src/UIElements/Menu/TextMenu/SeperatorItem.hpp
r5813ac rb59da6 9 9 #define SEPERATORITEM_H_ 10 10 11 #include "Menu/MenuItem.hpp" 11 #include <string> 12 13 #include "Menu/TextMenu/MenuItem.hpp" 14 15 class TxMenu; 12 16 13 17 /** … … 19 23 { 20 24 public: 21 SeperatorItem( Menu*);22 SeperatorItem( Menu*,char,int);25 SeperatorItem(TxMenu* const ); 26 SeperatorItem(TxMenu* const ,char,int); 23 27 virtual ~SeperatorItem(); 24 28 … … 26 30 virtual bool checkTrigger(char); 27 31 28 virtual const st ring getDescription();32 virtual const std::string getDescription(); 29 33 30 virtual const st ring formatEntry();34 virtual const std::string formatEntry(); 31 35 private: 32 36 char spacer; -
src/UIElements/Menu/TextMenu/SubMenuItem.cpp
r5813ac rb59da6 20 20 #include "Helpers/MemDebug.hpp" 21 21 22 #include "SubMenuItem.hpp"22 #include <iostream> 23 23 24 SubMenuItem::SubMenuItem(char _trigger,const char* _description,Menu* _parent, Menu* _theMenu) : 24 #include "Menu/TextMenu/SubMenuItem.hpp" 25 #include "Menu/TextMenu/TxMenu.hpp" 26 27 SubMenuItem::SubMenuItem(char _trigger,const std::string &_description,TxMenu* const _parent, TxMenu* const _instance) : 25 28 MenuItem(_trigger,_description,_parent), 26 theMenu(_theMenu) 27 { 28 } 29 theMenu(_instance) 30 {} 29 31 30 32 SubMenuItem::~SubMenuItem() 31 { 32 delete theMenu; 33 } 33 {} 34 34 35 35 void SubMenuItem::doTrigger() { -
src/UIElements/Menu/TextMenu/TxMenu.cpp
r5813ac rb59da6 7 7 8 8 /* 9 * T extMenu.cpp9 * TxMenu.cpp 10 10 * 11 11 * Created on: Dec 10, 2009 … … 21 21 22 22 #include <boost/bind.hpp> 23 #include <algorithm> 23 24 #include <iostream> 24 25 #include <cmath> 25 #include "Menu/TextMenu.hpp" 26 #include "Menu/MenuItem.hpp" 26 #include "Actions/Action.hpp" 27 #include "Actions/ActionTraits.hpp" 28 #include "Menu/TextMenu/TxMenu.hpp" 29 #include "Menu/TextMenu/MenuItem.hpp" 27 30 #include "Helpers/Assert.hpp" 28 31 … … 32 35 * The text will later be displayed using the stream passed to the constructor. 33 36 */ 34 T extMenu::TextMenu(ostream& _outputter, conststring _title, char _spacer,int _length) :37 TxMenu::TxMenu(std::ostream& _outputter, const std::string _title, char _spacer,int _length) : 35 38 defaultItem(0), 36 39 outputter(_outputter), … … 42 45 } 43 46 44 T extMenu::~TextMenu()47 TxMenu::~TxMenu() 45 48 { 46 for( list<MenuItem*>::iterator it=items.begin(); it != items.end(); it++)49 for(std::list<MenuItem*>::iterator it=items.begin(); it != items.end(); it++) 47 50 delete (*it); 48 51 } 49 52 50 51 void TextMenu::addItem(MenuItem* item) { 53 void TxMenu::addItem(MenuItem* item) { 52 54 items.push_back(item); 53 55 } 54 56 55 void T extMenu::removeItem(MenuItem* item) {57 void TxMenu::removeItem(MenuItem* item) { 56 58 items.remove(item); 57 59 } 58 60 59 void T extMenu::doQuit(){61 void TxMenu::doQuit(){ 60 62 quit = true; 61 63 } 62 64 63 bool T extMenu::hasQuit(){65 bool TxMenu::hasQuit(){ 64 66 return quit; 65 67 } 66 68 67 void T extMenu::showEntry(MenuItem* entry){69 void TxMenu::showEntry(MenuItem* entry){ 68 70 if(entry->isActive()==false){ 69 71 outputter << "("; … … 76 78 } 77 79 78 void T extMenu::display() {80 void TxMenu::display() { 79 81 char choice; 80 82 bool somethingChosen = false; … … 89 91 outputter << spacer; 90 92 outputter << '\n'; 91 for_each(items.begin(), items.end(), boost::bind(&T extMenu::showEntry,this,_1));93 for_each(items.begin(), items.end(), boost::bind(&TxMenu::showEntry,this,_1)); 92 94 outputter.flush(); 93 95 94 cin >> choice;96 std::cin >> choice; 95 97 96 list<MenuItem*>::iterator iter;98 std::list<MenuItem*>::iterator iter; 97 99 for(iter = items.begin(); iter!=items.end();iter++){ 98 100 if((*iter)->isActive()){ … … 106 108 } 107 109 else{ 108 outputter << "Invalid Choice!" << endl;110 outputter << "Invalid Choice!" << std::endl; 109 111 } 110 112 } … … 112 114 } 113 115 114 st ring TextMenu::getTitle(){116 std::string TxMenu::getTitle(){ 115 117 return title; 116 118 } 117 119 118 void TextMenu::addDefault(MenuItem* _defaultItem) { 120 std::ostream& TxMenu::getOutputter() 121 { 122 return outputter; 123 } 124 125 126 void TxMenu::addDefault(MenuItem* _defaultItem) { 119 127 defaultItem = _defaultItem; 120 128 } … … 122 130 /****************************** Contained Actions ****************/ 123 131 124 T extMenu::LeaveAction::LeaveAction(TextMenu*_menu, const ActionTraits & LeaveActionTrait) :125 Action(LeaveActionTrait, false),132 TxMenu::LeaveAction::LeaveAction(TxMenu* const _menu, const ActionTraits & LeaveActionTrait) : 133 Action(LeaveActionTrait, true), 126 134 menu(_menu) 127 135 {} 128 136 129 T extMenu::LeaveAction::~LeaveAction(){}137 TxMenu::LeaveAction::~LeaveAction(){} 130 138 131 bool T extMenu::LeaveAction::canUndo(){139 bool TxMenu::LeaveAction::canUndo(){ 132 140 return false; 133 141 } 134 142 135 bool T extMenu::LeaveAction::shouldUndo(){143 bool TxMenu::LeaveAction::shouldUndo(){ 136 144 return false; 137 145 } 138 146 139 void T extMenu::LeaveAction::getParametersfromValueStorage()147 void TxMenu::LeaveAction::getParametersfromValueStorage() 140 148 {} 141 149 142 Dialog* T extMenu::LeaveAction::fillDialog(Dialog *dialog){150 Dialog* TxMenu::LeaveAction::fillDialog(Dialog *dialog){ 143 151 ASSERT(dialog,"No Dialog given when filling action dialog"); 144 152 return dialog; … … 146 154 147 155 148 Action::state_ptr T extMenu::LeaveAction::performCall(){156 Action::state_ptr TxMenu::LeaveAction::performCall(){ 149 157 menu->doQuit(); 150 158 return Action::success; … … 152 160 153 161 154 Action::state_ptr T extMenu::LeaveAction::performUndo(Action::state_ptr){162 Action::state_ptr TxMenu::LeaveAction::performUndo(Action::state_ptr){ 155 163 ASSERT(0,"Cannot undo leaving a menu"); 156 164 return Action::success; 157 165 } 158 166 159 Action::state_ptr T extMenu::LeaveAction::performRedo(Action::state_ptr){167 Action::state_ptr TxMenu::LeaveAction::performRedo(Action::state_ptr){ 160 168 ASSERT(0,"Cannot redo leaving a menu"); 161 169 return Action::success; -
src/UIElements/Menu/TextMenu/TxMenu.hpp
r5813ac rb59da6 1 1 /* 2 * T extMenu.h2 * TxMenu.h 3 3 * 4 4 * Created on: Dec 10, 2009 … … 6 6 */ 7 7 8 #ifndef T EXTMENU_H_9 #define T EXTMENU_H_8 #ifndef TXMENU_H_ 9 #define TXMENU_H_ 10 10 11 11 #include <list> … … 25 25 * All Items are displayed and user is prompted for a key. The item corresponding to that key is then activated. 26 26 */ 27 class T extMenu : publicMenu27 class TxMenu 28 28 { 29 29 public: 30 30 class LeaveAction : public Action { 31 31 public: 32 LeaveAction(T extMenu*, const ActionTraits &_trait);32 LeaveAction(TxMenu* const, const ActionTraits &_trait); 33 33 virtual ~LeaveAction(); 34 34 … … 44 44 virtual Action::state_ptr performRedo(Action::state_ptr); 45 45 46 ActionTraits *LeaveActionTrait; 47 TextMenu* menu; 46 TxMenu* const menu; 48 47 }; 49 48 50 T extMenu(ostream& _outputter, conststring _title, char _spacer=STD_MENU_TITLE_SPACER,int _length=STD_MENU_LENGTH);51 virtual ~T extMenu();49 TxMenu(std::ostream& _outputter, const std::string _title, char _spacer=STD_MENU_TITLE_SPACER,int _length=STD_MENU_LENGTH); 50 virtual ~TxMenu(); 52 51 53 virtual void addItem(MenuItem*); 54 virtual void removeItem(MenuItem*); 55 virtual void display(); 56 virtual string getTitle(); 52 void addItem(MenuItem*); 53 void removeItem(MenuItem*); 54 void display(); 55 std::string getTitle(); 56 std::ostream& getOutputter(); 57 char getSuitableShortForm(std::set <char> &ShortcutList, const std::string name) const; 57 58 58 59 /** 59 60 * Call doQuit if you want to return from this menu. 60 61 */ 61 v irtual void doQuit();62 void doQuit(); 62 63 /** 63 64 * Check whether someone has chosen to quit 64 65 */ 65 virtualbool hasQuit();66 bool hasQuit(); 66 67 67 v irtual void addDefault(MenuItem*);68 void addDefault(MenuItem*); 68 69 69 70 protected: 70 v irtual void showEntry(MenuItem*);71 void showEntry(MenuItem*); 71 72 72 73 private: 73 list<MenuItem*> items;74 std::list<MenuItem*> items; 74 75 75 76 MenuItem* defaultItem; 76 77 77 ostream& outputter;78 st ring title;78 std::ostream& outputter; 79 std::string title; 79 80 char spacer; 80 81 int length; … … 83 84 }; 84 85 85 #endif /* T EXTMENU_H_ */86 #endif /* TXMENU_H_ */
Note:
See TracChangeset
for help on using the changeset viewer.