Changeset b59da6 for src/UIElements/Menu/TextMenu/TxMenu.cpp
- 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)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
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;
Note:
See TracChangeset
for help on using the changeset viewer.