forked from Sneeds-Feed-and-Seed/sneedacity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSneedacityApp.h
122 lines (84 loc) · 2.89 KB
/
SneedacityApp.h
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
/**********************************************************************
Sneedacity: A Digital Audio Editor
SneedacityApp.h
Dominic Mazzoni
This is the main source file for Sneedacity which handles
initialization and termination by subclassing wxApp.
**********************************************************************/
#ifndef __SNEEDACITY_APP__
#define __SNEEDACITY_APP__
#include "Identifier.h"
#include <wx/app.h> // to inherit
#include <wx/timer.h> // member variable
#include <memory>
class wxSingleInstanceChecker;
class wxSocketEvent;
class wxSocketServer;
class IPCServ;
class Importer;
class CommandHandler;
class AppCommandEvent;
class SneedacityProject;
class SneedacityApp final : public wxApp {
public:
SneedacityApp();
~SneedacityApp();
bool OnInit(void) override;
bool InitPart2();
int OnExit(void) override;
void OnFatalException() override;
bool OnExceptionInMainLoop() override;
// These are currently only used on Mac OS, where it's
// possible to have a menu bar but no windows open. It doesn't
// hurt any other platforms, though.
void OnMenuAbout(wxCommandEvent & event);
void OnMenuNew(wxCommandEvent & event);
void OnMenuOpen(wxCommandEvent & event);
void OnMenuPreferences(wxCommandEvent & event);
void OnMenuExit(wxCommandEvent & event);
void OnQueryEndSession(wxCloseEvent & event);
void OnEndSession(wxCloseEvent & event);
// Most Recently Used File support (for all platforms).
void OnMRUClear(wxCommandEvent &event);
void OnMRUFile(wxCommandEvent &event);
// Backend for above - returns true for success, false for failure
bool MRUOpen(const FilePath &fileName);
// A wrapper of the above that does not throw
bool SafeMRUOpen(const wxString &fileName);
void OnReceiveCommand(AppCommandEvent &event);
void OnKeyDown(wxKeyEvent &event);
void OnTimer(wxTimerEvent & event);
// IPC communication
void OnServerEvent(wxSocketEvent & evt);
void OnSocketEvent(wxSocketEvent & evt);
#ifdef __WXMAC__
// In response to Apple Events
void MacOpenFile(const wxString &fileName) override;
void MacPrintFile(const wxString &fileName) override;
void MacNewFile() override;
#endif
#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) && !defined(__CYGWIN__)
void AssociateFileTypes();
#endif
#ifdef __WXMAC__
void MacActivateApp();
void MacFinishLaunching();
#endif
private:
std::unique_ptr<CommandHandler> mCmdHandler;
std::unique_ptr<wxSingleInstanceChecker> mChecker;
wxTimer mTimer;
void InitCommandHandler();
bool InitTempDir();
bool CreateSingleInstanceChecker(const wxString &dir);
std::unique_ptr<wxCmdLineParser> ParseCommandLine();
#if defined(__WXMSW__)
std::unique_ptr<IPCServ> mIPCServ;
#else
std::unique_ptr<wxSocketServer> mIPCServ;
#endif
public:
DECLARE_EVENT_TABLE()
};
extern SneedacityApp & wxGetApp();
#endif