Changeset 5b9bba


Ignore:
Timestamp:
Dec 16, 2009, 12:30:16 PM (15 years ago)
Author:
Frederik Heber <heber@…>
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:
9d8609
Parents:
f767d4
git-author:
Tillmann Crueger <crueger@…> (12/14/09 10:31:58)
git-committer:
Frederik Heber <heber@…> (12/16/09 12:30:16)
Message:

Changed formating of menus and added protection to keep MenuItems from being added twice. Signed-off-by: Tillmann Crueger <crueger@…>

Location:
src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • src/Menu/MenuItem.cpp

    rf767d4 r5b9bba  
    1616{
    1717  description = new string(_description);
    18   menu->addItem(this);
     18  add_to_menu(menu);
    1919}
    2020
     
    4343  return s.str();
    4444}
     45
     46void MenuItem::add_to_menu(Menu* menu) {
     47  if(!wasAdded()) {
     48    menu->addItem(this);
     49    added=true;
     50  }
     51}
     52
     53bool MenuItem::wasAdded(){
     54  return added;
     55}
  • src/Menu/MenuItem.hpp

    rf767d4 r5b9bba  
    1919  char trigger;
    2020  string *description;
     21  bool added;
    2122
    2223public:
     
    3233  char getTrigger();
    3334
     35  void add_to_menu(Menu*);
     36  bool wasAdded();
     37
    3438protected:
    3539  void setDescription(string);
  • src/Menu/SeperatorItem.cpp

    rf767d4 r5b9bba  
    55 *      Author: crueger
    66 */
     7#include <string>
     8#include <sstream>
    79
    810#include "Menu/SeperatorItem.hpp"
    911#include "Menu/Menu.hpp"
    10 #include <string>
     12#include "defs.hpp"
     13
    1114
    1215SeperatorItem::SeperatorItem(Menu* menu):
    13 MenuItem('\0',"",menu)
     16MenuItem('\0',"",menu),
     17spacer(STD_SEPERATOR_SPACER),
     18length(STD_MENU_LENGTH)
     19{
     20  // TODO Auto-generated constructor stub
     21
     22}
     23
     24SeperatorItem::SeperatorItem(Menu* menu,char _spacer, int _length):
     25MenuItem('\0',"",menu),
     26spacer(_spacer),
     27length(_length)
    1428{
    1529  // TODO Auto-generated constructor stub
     
    3145
    3246const string SeperatorItem::formatEntry(){
    33   return string ("---------------------------------------------------");
     47  stringstream s;
     48  for(int i=0; i<length;i++)
     49    s << spacer;
     50  return s.str();
    3451}
  • src/Menu/SeperatorItem.hpp

    rf767d4 r5b9bba  
    1515public:
    1616  SeperatorItem(Menu*);
     17  SeperatorItem(Menu*,char,int);
    1718  virtual ~SeperatorItem();
    1819
     
    2324
    2425  virtual const string formatEntry();
     26private:
     27  char spacer;
     28  int length;
    2529};
    2630
  • src/Menu/SubMenuItem.cpp

    rf767d4 r5b9bba  
    88#include "SubMenuItem.hpp"
    99
    10 SubMenuItem::SubMenuItem(char _trigger,const char* _description,Menu* _menu,ostream& _outputter,string _title) :
     10SubMenuItem::SubMenuItem(char _trigger,const char* _description,Menu* _menu,
     11                         ostream& _outputter,string _title,char _spacer, int _length) :
     12MenuItem(_trigger,_description,_menu),
     13TextMenu(_outputter,_title,_spacer,_length)
     14{
     15}
     16
     17SubMenuItem::SubMenuItem(char _trigger,const char* _description,Menu* _menu,
     18                         ostream& _outputter,string _title) :
    1119MenuItem(_trigger,_description,_menu),
    1220TextMenu(_outputter,_title)
  • src/Menu/SubMenuItem.hpp

    rf767d4 r5b9bba  
    1010{
    1111public:
     12  SubMenuItem(char,const char*,Menu *,ostream&,string,char,int);
    1213  SubMenuItem(char,const char*,Menu *,ostream&,string);
    1314  virtual ~SubMenuItem();
  • src/Menu/TextMenu.cpp

    rf767d4 r5b9bba  
    88#include <boost/bind.hpp>
    99#include <iostream>
    10 #include "TextMenu.hpp"
    11 #include "MenuItem.hpp"
     10#include <cmath>
     11#include "defs.hpp"
     12#include "Menu/TextMenu.hpp"
     13#include "Menu/MenuItem.hpp"
     14
     15TextMenu::TextMenu(ostream& _outputter, string _title, char _spacer,int _length) :
     16outputter(_outputter),
     17title(_title),
     18spacer(_spacer),
     19length(_length),
     20quit(false)
     21{
     22}
    1223
    1324TextMenu::TextMenu(ostream& _outputter, string _title) :
    1425outputter(_outputter),
    1526title(_title),
     27spacer(STD_MENU_TITLE_SPACER),
     28length(STD_MENU_LENGTH),
    1629quit(false)
    1730{
     
    4861  char choice;
    4962  do {
    50     outputter << title << "\n";
     63    int pre = floor((length - title.length()) /2.0);
     64    int post = ceil((length - title.length()) /2.0);
     65    for(int i=0;i<pre;i++)
     66      outputter << spacer;
     67    outputter << title;
     68    for(int i=0;i<post;i++)
     69          outputter << spacer;
     70    outputter << '\n';
    5171    for_each(items.begin(), items.end(), boost::bind(&TextMenu::showEntry,this,_1));
    5272    outputter.flush();
  • src/Menu/TextMenu.hpp

    rf767d4 r5b9bba  
    2020{
    2121public:
     22  TextMenu(ostream&,string,char,int);
    2223  TextMenu(ostream&,string);
    2324  virtual ~TextMenu();
     
    3738  ostream& outputter;
    3839  string title;
     40  char spacer;
     41  int length;
     42
    3943  bool quit;
    4044};
  • src/defs.hpp

    rf767d4 r5b9bba  
    7777#define UPDATECOUNT 10  //!< update ten sites per BOSSANOVA interval
    7878
     79#define STD_MENU_LENGTH 60
     80#define STD_MENU_TITLE_SPACER '='
     81#define STD_SEPERATOR_SPACER '-'
     82
    7983#endif /*DEFS_HPP_*/
Note: See TracChangeset for help on using the changeset viewer.