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
22#include <wx/app.h> // to inherit
23#include <wx/timer.h> // member variable
24
25#include <memory>
26
27class wxSingleInstanceChecker;
28class wxSocketEvent;
29class wxSocketServer;
30
31class IPCServ;
32class Importer;
33class CommandHandler;
34class AppCommandEvent;
35class AudacityProject;
36
37class AudacityApp final : public wxApp {
38 public:
41
42 bool Initialize(int& argc, wxChar** argv) override;
43#ifdef __WXMAC__
44 bool OSXIsGUIApplication() override;
45#endif
46
47 void CleanUp() override;
48 bool OnInit() override;
49 bool InitPart2();
50 int OnRun() override;
51 int OnExit(void) override;
52 void OnFatalException() override;
53 bool OnExceptionInMainLoop() override;
54
55 void OnIdle( wxIdleEvent & );
56
57 // These are currently only used on Mac OS, where it's
58 // possible to have a menu bar but no windows open. It doesn't
59 // hurt any other platforms, though.
60 void OnMenuAbout(wxCommandEvent & event);
61 void OnMenuNew(wxCommandEvent & event);
62 void OnMenuOpen(wxCommandEvent & event);
63 void OnMenuPreferences(wxCommandEvent & event);
64 void OnMenuExit(wxCommandEvent & event);
65
66 void OnQueryEndSession(wxCloseEvent & event);
67 void OnEndSession(wxCloseEvent & event);
68
69 // Most Recently Used File support (for all platforms).
70 void OnMRUClear(wxCommandEvent &event);
71 void OnMRUFile(wxCommandEvent &event);
72 // Backend for above - returns true for success, false for failure
73 bool MRUOpen(const FilePath &fileName);
74 // A wrapper of the above that does not throw
75 bool SafeMRUOpen(const wxString &fileName);
76
78
79 void OnKeyDown(wxKeyEvent &event);
80
81 void OnTimer(wxTimerEvent & event);
82
83 // IPC communication
84 void OnServerEvent(wxSocketEvent & evt);
85 void OnSocketEvent(wxSocketEvent & evt);
86
87 #ifdef __WXMAC__
88 // In response to Apple Events
89 void MacOpenFile(const wxString &fileName) override;
90 void MacPrintFile(const wxString &fileName) override;
91 void MacNewFile() override;
92 #ifdef HAS_CUSTOM_URL_HANDLING
93 void MacOpenURL(const wxString &url) override;
94 #endif
95 #endif
96
97 #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) && !defined(__CYGWIN__)
98 void AssociateFileTypes();
99 #endif
100
102
103#ifdef __WXMAC__
106#endif
107
108
109 private:
110 void OnInit0();
112
113 std::unique_ptr<CommandHandler> mCmdHandler;
114
115 std::unique_ptr<wxSingleInstanceChecker> mChecker;
116
117 wxTimer mTimer;
118
119 void InitCommandHandler();
120
121 bool InitTempDir();
122 bool CreateSingleInstanceChecker(const wxString &dir);
123
124 std::unique_ptr<wxCmdLineParser> ParseCommandLine();
125
126#if defined(__WXMSW__)
127 std::unique_ptr<IPCServ> mIPCServ;
128#else
129 std::unique_ptr<wxSocketServer> mIPCServ;
130#endif
131
132 public:
133 DECLARE_EVENT_TABLE()
134};
135
137
138#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:37
void OnQueryEndSession(wxCloseEvent &event)
void OnMenuExit(wxCommandEvent &event)
void MacPrintFile(const wxString &fileName) override
wxTimer mTimer
Definition: AudacityApp.h:117
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:113
std::unique_ptr< wxSingleInstanceChecker > mChecker
Definition: AudacityApp.h:115
void MacFinishLaunching()
Observer::Subscription mThemeChangeSubscription
Definition: AudacityApp.h:111
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:127
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:79
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.