OSDN Git Service

The (experimental) command line version does not compile; empty MainView_resizeToFit...
[molby/Molby.git] / wxSources / MyApp.h
1 /*
2  *  MyApp.h
3  *  Molby
4  *
5  *  Created by Toshi Nagata on 08/10/24.
6  *  Copyright 2008 Toshi Nagata. All rights reserved.
7  *
8  This program is free software; you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation version 2 of the License.
11  
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  GNU General Public License for more details.
16  */
17
18 #ifndef __MyApp_H__
19 #define __MyApp_H__
20
21 #include "wx/app.h"
22 #include "wx/mdi.h"
23 #include "wx/docview.h"
24 #include "wx/docmdi.h"
25 #include "wx/hashmap.h"
26 #include "wx/process.h"
27
28 #if __WXMSW__
29 #include "wx/snglinst.h"
30 #endif
31
32 #include "MyDocManager.h"
33
34 class MyDocManager;
35 class wxMenuBar;
36 class wxMenu;
37 class wxProgressDialog;
38
39 class ConsoleFrame;
40 class ProgressFrame;
41 class GlobalParameterFrame;
42 class GlobalParameterFilesFrame;
43 class MyListCtrl;
44
45 enum {
46         myMenuID_MyFirstMenuItem = 100,
47         myMenuID_Import = 101,
48         myMenuID_Export = 102,
49         myMenuID_SelectFragment = 103,
50         myMenuID_SelectReverse = 104,
51         myMenuID_CreateNewAtom = 105,
52         myMenuID_CreateNewParameter = 106,
53         myMenuID_CreateNewVdwParameter = 107,
54         myMenuID_CreateNewBondParameter = 108,
55         myMenuID_CreateNewAngleParameter = 109,
56         myMenuID_CreateNewDihedralParameter = 110,
57         myMenuID_CreateNewImproperParameter = 111,
58         myMenuID_CreateNewVdwPairParameter = 112,
59         myMenuID_CreateNewVdwCutoffParameter = 113,
60         myMenuID_AddHydrogen = 114,
61         myMenuID_AddHydrogenSp3 = 115,
62         myMenuID_AddHydrogenSp2 = 116,
63         myMenuID_AddHydrogenLinear = 117,
64         myMenuID_AddHydrogenPyramidal = 118,
65         myMenuID_AddHydrogenBent = 119,
66         myMenuID_FitToScreen = 150,
67         myMenuID_CenterSelection = 151,
68         myMenuID_ShowUnitCell = 152,
69         myMenuID_ShowPeriodicBox = 153,
70         myMenuID_ShowHydrogens = 154,
71         myMenuID_ShowDummyAtoms = 155,
72         myMenuID_ShowExpandedAtoms = 156,
73         myMenuID_ShowEllipsoids = 157,
74         myMenuID_ShowRotationCenter = 158,
75         myMenuID_ShowGraphite = 159,
76         myMenuID_LineMode = 160,
77         myMenuID_ShowAllAtoms = 161,
78         myMenuID_HideSelected = 162,
79         myMenuID_HideUnselected = 163,
80         myMenuID_HideReverse = 164,
81         myMenuID_MolecularDynamics = 200,
82         myMenuID_Minimize = 201,
83         myMenuID_StopMDRun = 202,
84 //      myMenuID_ReadParameters = 143,
85         myMenuID_ViewGlobalParameters = 204,
86         myMenuID_ViewParameterFilesList = 205,
87         myMenuID_DefinePeriodicBox = 206,
88         myMenuID_ShowPeriodicImage = 207,
89         myMenuID_PressureControl = 208,
90         myMenuID_DefineSymmetry = 209,
91         myMenuID_ExpandBySymmetry = 210,
92         myMenuID_MDTools = 211,
93         myMenuID_RunAntechamber = 212,
94         myMenuID_RunResp = 213,
95         myMenuID_CreateSanderInput = 214,
96         myMenuID_ImportAmberLib = 215,
97         myMenuID_ImportAmberFrcmod = 216,
98         myMenuID_CreateGamessInput = 250,
99         myMenuID_CreateMOCube = 251,
100         myMenuID_ExecuteScript = 300,
101         myMenuID_OpenConsoleWindow = 301,
102         myMenuID_CustomScript = 302,
103         myMenuID_MyLastMenuItem = 499
104 };
105
106 enum {
107         myMenuIndex_File = 0,
108         myMenuIndex_Edit = 1,
109         myMenuIndex_Show = 2,
110         myMenuIndex_MMMD = 3,
111         myMenuIndex_QChem = 4,
112         myMenuIndex_Script = 5
113 };
114
115 WX_DECLARE_STRING_HASH_MAP( wxString, MyStringHash );
116
117 // Define a new application
118 class MyApp: public wxApp
119 {
120   public:
121     MyApp(void);
122     bool OnInit(void);
123     int OnExit(void);
124
125         int AppendConsoleMessage(const char *mes);
126         void FlushConsoleMessage();
127         void SetConsoleColor(int color);
128
129         void ShowProgressPanel(const char *mes);
130         void HideProgressPanel();
131         void SetProgressValue(double dval);
132         void SetProgressMessage(const char *mes);
133         int IsInterrupted();
134         ProgressFrame *GetProgressFrame() { return m_progressFrame; }
135
136     MyDocManager *DocManager() { return m_docManager; }
137
138         wxMenuBar *CreateMenuBar(int kind, wxMenu **out_file_history_menu = NULL, wxMenu **out_edit_menu = NULL);
139
140 //      void OnReadParameters(wxCommandEvent& event);
141
142         static wxString FindResourcePath();
143         static wxString DefaultSettingsPath();
144
145         void LoadDefaultSettings();
146         void SaveDefaultSettings();
147         void SetDefaultSetting(const wxString& key, const wxString& value);
148         wxString& GetDefaultSetting(const wxString& key);
149
150         void RegisterScriptMenu(const char *cmd, const char *title);
151         void UpdateScriptMenu(wxMenuBar *mbar);
152         void OnScriptMenuModified(wxCommandEvent& event);
153         void OnScriptMenuSelected(wxCommandEvent& event);
154         void OnUpdateUI(wxUpdateUIEvent &event);
155         void OnExecuteScript(wxCommandEvent &event);
156         void OnOpenConsoleWindow(wxCommandEvent &event);
157         void OnViewGlobalParameters(wxCommandEvent &event);
158         void OnViewParameterFilesList(wxCommandEvent &event);
159
160         void OnImportAmberLib(wxCommandEvent &event);
161
162         void OnEndProcess(wxProcessEvent &event);
163         int CallSubProcess(const char *cmdline, const char *procname);
164
165         void OnActivate(wxActivateEvent &event);
166
167         MyListCtrl *GetGlobalParameterListCtrl();
168 #if __WXMAC__
169         virtual void MacNewFile();
170 #endif
171         
172 protected:
173     MyDocManager* m_docManager;
174         ProgressFrame *m_progressFrame;
175         bool m_progressCanceled;
176         int m_progressValue;
177         MyStringHash m_defaultSettings;
178
179         bool m_processTerminated;
180         int m_processExitCode;
181
182         ConsoleFrame *consoleFrame;
183         GlobalParameterFrame *parameterFrame;
184         GlobalParameterFilesFrame *parameterFilesFrame;
185         
186         int countNonCustomScriptMenu;
187         int countScriptMenu;
188         char **scriptMenuCommands;
189         char **scriptMenuTitles;
190         bool scriptMenuModifiedEventPosted;
191         
192 #if __WXMSW__
193         wxSingleInstanceChecker *m_checker;
194 #endif
195         
196 private:
197         DECLARE_EVENT_TABLE()
198 };
199
200 DECLARE_APP(MyApp)
201
202 // Define a new frame
203 class MyFrame: public wxDocMDIParentFrame
204 {
205         DECLARE_CLASS(MyFrame)
206 public:
207         wxMenu *editMenu;
208   
209         MyFrame(wxDocManager *manager, wxFrame *frame, const wxString& title, const wxPoint& pos, const wxSize& size, long type);
210
211         void OnAbout(wxCommandEvent& event);
212
213 private:
214         DECLARE_EVENT_TABLE()
215 };
216
217 extern MyFrame *GetMainFrame(void);
218 extern bool singleWindowMode;
219
220 #endif  /* __MyApp_H__ */