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