Audacity 3.2.0
AudacityApp.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 AudacityApp.h
6
7 Dominic Mazzoni
8
9 This is the main source file for Audacity which handles
10 initialization and termination by subclassing wxApp.
11
12**********************************************************************/
13
14#ifndef __AUDACITY_APP__
15#define __AUDACITY_APP__
16
17
18#include "Identifier.h"
19#include "Observer.h"
20#include "Theme.h"
21#include "AppEvents.h"
22
23#include <wx/app.h> // to inherit
24#include <wx/timer.h> // member variable
25
26#include <memory>
27
28class wxSingleInstanceChecker;
29class wxSocketEvent;
30class wxSocketServer;
31
32class IPCServ;
33class Importer;
34class CommandHandler;
35class AppCommandEvent;
36class AudacityProject;
37
38class AudacityApp final
39 : public wxApp
41{
42 public:
45
46 bool Initialize(int& argc, wxChar** argv) override;
47#ifdef __WXMAC__
48 bool OSXIsGUIApplication() override;
49#endif
50
51 void CleanUp() override;
52 bool OnInit() override;
53 bool InitPart2();
54 int OnRun() override;
55 int OnExit(void) override;
56 void OnFatalException() override;
57 bool OnExceptionInMainLoop() override;
58
59 void OnIdle( wxIdleEvent & );
60
61 // These are currently only used on Mac OS, where it's
62 // possible to have a menu bar but no windows open. It doesn't
63 // hurt any other platforms, though.
64 void OnMenuAbout(wxCommandEvent & event);
65 void OnMenuNew(wxCommandEvent & event);
66 void OnMenuOpen(wxCommandEvent & event);
67 void OnMenuPreferences(wxCommandEvent & event);
68 void OnMenuExit(wxCommandEvent & event);
69
70 void OnQueryEndSession(wxCloseEvent & event);
71 void OnEndSession(wxCloseEvent & event);
72
73 // Most Recently Used File support (for all platforms).
74 void OnMRUClear(wxCommandEvent &event);
75 void OnMRUFile(wxCommandEvent &event);
76 // Backend for above - returns true for success, false for failure
77 bool MRUOpen(const FilePath &fileName);
78 // A wrapper of the above that does not throw
79 bool SafeMRUOpen(const wxString &fileName);
80
82
83 void OnKeyDown(wxKeyEvent &event);
84
85 void OnTimer(wxTimerEvent & event);
86
87 // IPC communication
88 void OnServerEvent(wxSocketEvent & evt);
89 void OnSocketEvent(wxSocketEvent & evt);
90
91 #ifdef __WXMAC__
92 // In response to Apple Events
93 void MacOpenFile(const wxString &fileName) override;
94 void MacPrintFile(const wxString &fileName) override;
95 void MacNewFile() override;
96 #ifdef HAS_CUSTOM_URL_HANDLING
97 void MacOpenURL(const wxString &url) override;
98 #endif
99 #endif
100
101 #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) && !defined(__CYGWIN__)
102 void AssociateFileTypes();
103 #endif
104
106
107#ifdef __WXMAC__
110#endif
111
112
113 private:
114 void OnInit0();
116
117 std::unique_ptr<CommandHandler> mCmdHandler;
118
119 std::unique_ptr<wxSingleInstanceChecker> mChecker;
120
121 wxTimer mTimer;
122
123 void InitCommandHandler();
124
125 bool InitTempDir();
126 bool CreateSingleInstanceChecker(const wxString &dir);
127
128 std::unique_ptr<wxCmdLineParser> ParseCommandLine();
129
130#if defined(__WXMSW__)
131 std::unique_ptr<IPCServ> mIPCServ;
132#else
133 std::unique_ptr<wxSocketServer> mIPCServ;
134#endif
135
136 public:
137 DECLARE_EVENT_TABLE()
138};
139
141
142#endif
AudacityApp & wxGetApp()
wxString FilePath
Definition: Project.h:21
An event 'envelope' for sending Command objects through the wxwidgets event loop.
AudacityApp is the 'main' class for Audacity.
Definition: AudacityApp.h:41
void OnQueryEndSession(wxCloseEvent &event)
void OnMenuExit(wxCommandEvent &event)
void MacPrintFile(const wxString &fileName) override
wxTimer mTimer
Definition: AudacityApp.h:121
bool OSXIsGUIApplication() override
bool MRUOpen(const FilePath &fileName)
void OnKeyDown(wxKeyEvent &event)
void MacActivateApp()
void OnMenuPreferences(wxCommandEvent &event)
bool OnExceptionInMainLoop() override
void OnServerEvent(wxSocketEvent &evt)
bool InitPart2()
void OnEndSession(wxCloseEvent &event)
void MacNewFile() override
void OnTimer(wxTimerEvent &event)
bool Initialize(int &argc, wxChar **argv) override
std::unique_ptr< CommandHandler > mCmdHandler
Definition: AudacityApp.h:117
std::unique_ptr< wxSingleInstanceChecker > mChecker
Definition: AudacityApp.h:119
void MacFinishLaunching()
Observer::Subscription mThemeChangeSubscription
Definition: AudacityApp.h:115
void OnMRUFile(wxCommandEvent &event)
void AssociateFileTypes()
void OnMenuOpen(wxCommandEvent &event)
int OnRun() override
bool InitTempDir()
std::unique_ptr< wxCmdLineParser > ParseCommandLine()
void OnFatalException() override
void OnIdle(wxIdleEvent &)
void OnMRUClear(wxCommandEvent &event)
int OnExit(void) override
void OnMenuAbout(wxCommandEvent &event)
bool CreateSingleInstanceChecker(const wxString &dir)
void InitCommandHandler()
void MacOpenFile(const wxString &fileName) override
void OnMenuNew(wxCommandEvent &event)
static void OnThemeChange(struct ThemeChangeMessage)
bool SafeMRUOpen(const wxString &fileName)
void CleanUp() override
void OnReceiveCommand(AppCommandEvent &event)
std::unique_ptr< IPCServ > mIPCServ
Definition: AudacityApp.h:131
void OnSocketEvent(wxSocketEvent &evt)
bool OnInit() override
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
Contains methods for applying commands that are passed to it.
Singleton class which actually imports the audio, using ImportPlugin objects that are registered by m...
Definition: Import.h:84
A move-only handle representing a connection to a Publisher.
Definition: Observer.h:70
UTILITY_API const char *const * argv
A copy of argv; responsibility of application startup to assign it.
UTILITY_API int argc
A copy of argc; responsibility of application startup to assign it.