-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGandrGUIMain.cpp
174 lines (144 loc) · 5.26 KB
/
GandrGUIMain.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
/***************************************************************
* Name: GandrguiMain.cpp
* Desc.: This code is part of the software GANDR GUI,
* developed to provide a user friendly interface to
* some of the functions of GANDR software.
* Purpose: Code for the application frame.
* Author: Jan (jan.malec@gmail.com)
* Created: 2018-09-12
* License: GPL-3
**************************************************************/
#ifdef WX_PRECOMP
#include "wx_pch.h"
#endif
#ifdef __BORLANDC__
#pragma hdrstop
#endif //__BORLANDC__
#include "wx/richtext/richtextctrl.h"
#include "GandrGUIMain.h"
#include "GlobalConfiguration.h"
#include "GlobalSettingsDialog.h"
//helper functions
enum wxbuildinfoformat {
short_f, long_f
};
wxString wxbuildinfo(wxbuildinfoformat format) {
wxString wxbuild(wxVERSION_STRING);
if (format == long_f)
{
#if defined(__WXMSW__)
wxbuild << _T("-Windows");
#elif defined(__WXMAC__)
wxbuild << _T("-Mac");
#elif defined(__UNIX__)
wxbuild << _T("-Linux");
#endif
#if wxUSE_UNICODE
wxbuild << _T("-Unicode build");
#else
wxbuild << _T("-ANSI build");
#endif // wxUSE_UNICODE
}
return wxbuild;
}
BEGIN_EVENT_TABLE(GandrguiFrame, wxFrame)
EVT_CLOSE(GandrguiFrame::OnClose)
EVT_MENU(idMenuLoad, GandrguiFrame::OnLoad)
EVT_MENU(idMenuSave, GandrguiFrame::OnSave)
EVT_MENU(idMenuPref, GandrguiFrame::OnPref)
EVT_MENU(idMenuQuit, GandrguiFrame::OnQuit)
EVT_MENU(idMenuAbout, GandrguiFrame::OnAbout)
EVT_MENU(idMenuDocs, GandrguiFrame::OnDocs)
END_EVENT_TABLE()
GandrguiFrame::GandrguiFrame(wxFrame *frame, const wxString& title)
: wxFrame(frame, -1, title) {
this->SetSize(wxSize(900, 400));
wxPanel *panel = new wxPanel(this, wxID_ANY);
wxBoxSizer *BoxSizerH = new wxBoxSizer(wxHORIZONTAL);
wxBoxSizer *BoxSizerLeft = new wxBoxSizer(wxVERTICAL);
eventPanel = new EventListPanel(panel);
BoxSizerLeft->Add(eventPanel, 1, wxEXPAND, 10);
BoxSizerH->Add(BoxSizerLeft, 1, wxEXPAND, 10);
BoxSizerH->SetSizeHints(this);
panel->SetSizerAndFit(BoxSizerH);
#if wxUSE_MENUS
// create a menu bar
wxMenuBar* mbar = new wxMenuBar();
wxMenu* fileMenu = new wxMenu(_T(""));
fileMenu->Append(idMenuLoad, _("&Load Configuration"), _("Load configuration from a file."));
fileMenu->Append(idMenuSave, _("&Save Configuration"), _("Save configuration to a file"));
fileMenu->Append(idMenuPref, _("&Global settings"), _("Edit global settings"));
fileMenu->Append(idMenuQuit, _("&Quit\tAlt-F4"), _("Quit the application"));
mbar->Append(fileMenu, _("&File"));
wxMenu* helpMenu = new wxMenu(_T(""));
helpMenu->Append(idMenuDocs, _("&Documentation"), _("Show info available documentation"));
helpMenu->Append(idMenuAbout, _("&About"), _("Show info about this application"));
mbar->Append(helpMenu, _("&Help"));
SetMenuBar(mbar);
#endif // wxUSE_MENUS
#if wxUSE_STATUSBAR
// create a status bar with some information about the used wxWidgets version
//CreateStatusBar(2);
//SetStatusText("In-development software", 0);
//SetStatusText(wxbuildinfo(short_f), 1);
#endif // wxUSE_STATUSBAR
Singleton* s = Singleton::getInstance();
wxString readDir;
if (wxGetEnv("ZOTTDIR", &readDir))
s->zottDir = readDir;
else {
wxDirDialog
openFolderDialog(this, _("Select path to ZOTTVL directory"));
if (openFolderDialog.ShowModal() == wxID_CANCEL) {
wxMessageBox("ZOTTVL directory not selected, some functionality will not be available.");
return; // the user changed idea...
}
else {
s->zottDir = openFolderDialog.GetPath();
}
}
if (wxGetEnv("GANDRDIR", &readDir))
s->gandrDir = readDir;
}
GandrguiFrame::~GandrguiFrame() {
}
void GandrguiFrame::OnClose(wxCloseEvent &event) {
Destroy();
}
void GandrguiFrame::OnLoad(wxCommandEvent &event) {
eventPanel->evList->loadRuns();
}
void GandrguiFrame::OnSave(wxCommandEvent &event) {
eventPanel->evList->saveRuns();
}
void GandrguiFrame::OnPref(wxCommandEvent &event) {
GlobalSettingsDialog *sframe = new GlobalSettingsDialog(this);
sframe->Show(true);
}
void GandrguiFrame::OnQuit(wxCommandEvent &event) {
Destroy();
}
void GandrguiFrame::OnAbout(wxCommandEvent &event) {
// wxString msg = wxbuildinfo(long_f);
wxMessageBox(("GANDR User Interface, version 1.0.\n9.1.2020, Vienna"));
}
void GandrguiFrame::OnDocs(wxCommandEvent &event) {
wxDialog *dialog = new wxDialog(this, wxID_ANY, "Documentation");
wxRichTextCtrl *text = new wxRichTextCtrl(dialog, wxID_ANY, wxEmptyString, wxDefaultPosition,
wxSize(600, 300));
wxBoxSizer *BoxSizer = new wxBoxSizer(wxHORIZONTAL);
text->SetEditable(false);
text->WriteText("The documentation can be located on the official website:\n");
text->BeginURL("");
text->BeginTextColour(wxColour(0, 0, 255));
text->BeginUnderline();
text->WriteText("https://www-nds.iaea.org/gandr/GandrGuiUserManual.pdf");
text->EndUnderline();
text->EndTextColour();
text->EndURL();
text->WriteText("For the source code consult the official GitHub website.\n");
text->Update();
BoxSizer->Add(text);
dialog->SetSizerAndFit(BoxSizer);
dialog->ShowModal();
}