source: molecuilder/src/UIElements/TextWindow.cpp@ 91379c

Last change on this file since 91379c was 536380, checked in by Tillmann Crueger <crueger@…>, 16 years ago

Added a progress indicator for the text menu

  • Property mode set to 100644
File size: 4.2 KB
Line 
1/*
2 * TextWindow.cpp
3 *
4 * Created on: Jan 7, 2010
5 * Author: crueger
6 */
7
8#include "UIElements/TextWindow.hpp"
9
10#include <boost/bind.hpp>
11
12
13// TODO: When done with refactoring most of these wont be needed anymore
14#include "analysis_correlation.hpp"
15#include "atom.hpp"
16#include "bond.hpp"
17#include "bondgraph.hpp"
18#include "boundary.hpp"
19#include "config.hpp"
20#include "element.hpp"
21#include "ellipsoid.hpp"
22#include "helpers.hpp"
23#include "leastsquaremin.hpp"
24#include "linkedcell.hpp"
25#include "log.hpp"
26#include "memoryusageobserverunittest.hpp"
27#include "molecule.hpp"
28#include "periodentafel.hpp"
29
30#include "Legacy/oldmenu.hpp"
31
32#include "Menu/Menu.hpp"
33#include "Menu/TextMenu.hpp"
34#include "Menu/ActionMenuItem.hpp"
35#include "Menu/SeperatorItem.hpp"
36#include "Menu/DisplayMenuItem.hpp"
37#include "Menu/SubMenuItem.hpp"
38#include "UIElements/TextStatusIndicator.hpp"
39#include "Actions/MethodAction.hpp"
40#include "Actions/ErrorAction.hpp"
41#include "Views/StreamStringView.hpp"
42#include "Views/MethodStringView.hpp"
43
44#include <iostream>
45
46using namespace std;
47
48// TODO: see what code can be moved to a base class for Graphic and Text Windows
49TextWindow::TextWindow(menuPopulaters populaters,MoleculeListClass *molecules, config *configuration, periodentafel *periode, char *ConfigFileName)
50{
51 old_menu = new oldmenu;
52
53 // build the main menu
54 main_menu = new TextMenu(Log() << Verbose(0), "Main Menu");
55
56 moleculeView = new StreamStringView(boost::bind(&MoleculeListClass::Enumerate,molecules,_1));
57 new DisplayMenuItem(main_menu,moleculeView,"Molecule List");
58
59 new SeperatorItem(main_menu);
60
61 Action *setMoleculeAction = new MethodAction("setMoleculeAction",boost::bind(&MoleculeListClass::flipChosen,molecules));
62 new ActionMenuItem('a',"set molecule (in)active",main_menu,setMoleculeAction);
63
64 TextMenu *editMoleculesMenu = new TextMenu(Log() << Verbose(0), "Edit Molecules");
65 new SubMenuItem('e',"edit molecules (load, parse, save)",main_menu,editMoleculesMenu);
66
67 Action *manipulateMoleculeAction = new MethodAction("manipulateMoleculeAction",boost::bind(&oldmenu::ManipulateMolecules,old_menu,periode, molecules, configuration));
68 new ActionMenuItem('g',"globally manipulate atoms in molecule",main_menu,manipulateMoleculeAction);
69
70 Action *mergeMoleculeAction = new MethodAction("mergeMoleculeAction",boost::bind(&oldmenu::MergeMolecules,old_menu,periode, molecules));
71 new ActionMenuItem('M',"Merge molecules",main_menu,mergeMoleculeAction);
72
73 Action *manipulateAtomsAction = new MethodAction("manipulateAtomsAction",boost::bind(&oldmenu::ManipulateAtoms,old_menu,periode, molecules, configuration));
74 new ActionMenuItem('m',"manipulate atoms",main_menu,manipulateAtomsAction);
75
76 new SeperatorItem(main_menu);
77
78 Action *editConfigAction = new MethodAction("editConfigAction",boost::bind(&config::Edit,configuration));
79 new ActionMenuItem('c',"edit the current configuration",main_menu,editConfigAction);
80
81 new SeperatorItem(main_menu);
82
83 Action *saveConfigAction = new MethodAction("saveConfigAction",boost::bind(&config::SaveAll,configuration, ConfigFileName, periode, molecules));
84 new ActionMenuItem('s',"save current setup to config file",main_menu,saveConfigAction);
85
86 Action *doTestAction = new MethodAction("doTestAction",boost::bind(&oldmenu::testroutine,old_menu,molecules));
87 new ActionMenuItem('T',"call the current test routine",main_menu,doTestAction);
88
89 quitAction = new MethodAction("quitAction",boost::bind(&TextMenu::doQuit,main_menu),false);
90 new ActionMenuItem('q',"quit",main_menu,quitAction);
91
92 // call all functions used to build the submenus
93
94 populaters.MakeEditMoleculesMenu(editMoleculesMenu,molecules,configuration,periode);
95
96 returnFromEditMoleculeAction = new MethodAction("returnAction",boost::bind(&TextMenu::doQuit,editMoleculesMenu),false);
97 MenuItem *returnItem = new ActionMenuItem('q',"return to Main menu",editMoleculesMenu,returnFromEditMoleculeAction);
98
99 editMoleculesMenu->addDefault(returnItem);
100
101 // Add status indicators etc...
102
103 statusIndicator = new TextStatusIndicator();
104}
105
106TextWindow::~TextWindow()
107{
108 delete old_menu;
109 delete quitAction;
110 delete returnFromEditMoleculeAction;
111 delete moleculeView;
112 delete statusIndicator;
113 delete main_menu;
114}
115
116void TextWindow::display() {
117 main_menu->display();
118}
Note: See TracBrowser for help on using the repository browser.