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 bool OnInit() override;
48 bool InitPart2();
49 int OnRun() override;
50 int OnExit(void) override;
51 void OnFatalException() override;
52 bool OnExceptionInMainLoop() override;
53
54 void OnIdle( wxIdleEvent & );
55
56 // These are currently only used on Mac OS, where it's
57 // possible to have a menu bar but no windows open. It doesn't
58 // hurt any other platforms, though.
59 void OnMenuAbout(wxCommandEvent & event);
60 void OnMenuNew(wxCommandEvent & event);
61 void OnMenuOpen(wxCommandEvent & event);
62 void OnMenuPreferences(wxCommandEvent & event);
63 void OnMenuExit(wxCommandEvent & event);
64
65 void OnQueryEndSession(wxCloseEvent & event);
66 void OnEndSession(wxCloseEvent & event);
67
68 // Most Recently Used File support (for all platforms).
69 void OnMRUClear(wxCommandEvent &event);
70 void OnMRUFile(wxCommandEvent &event);
71 // Backend for above - returns true for success, false for failure
72 bool MRUOpen(const FilePath &fileName);
73 // A wrapper of the above that does not throw
74 bool SafeMRUOpen(const wxString &fileName);
75
77
78 void OnKeyDown(wxKeyEvent &event);
79
80 void OnTimer(wxTimerEvent & event);
81
82 // IPC communication
83 void OnServerEvent(wxSocketEvent & evt);
84 void OnSocketEvent(wxSocketEvent & evt);
85
86 #ifdef __WXMAC__
87 // In response to Apple Events
88 void MacOpenFile(const wxString &fileName) override;
89 void MacPrintFile(const wxString &fileName) override;
90 void MacNewFile() override;
91 #ifdef HAS_CUSTOM_URL_HANDLING
92 void MacOpenURL(const wxString &url) override;
93 #endif
94 #endif
95
96 #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) && !defined(__CYGWIN__)
97 void AssociateFileTypes();
98 #endif
99
101
102#ifdef __WXMAC__
105#endif
106
107
108 private:
109 void OnInit0();
111
112 std::unique_ptr<CommandHandler> mCmdHandler;
113
114 std::unique_ptr<wxSingleInstanceChecker> mChecker;
115
116 wxTimer mTimer;
117
118 void InitCommandHandler();
119
120 bool InitTempDir();
121 bool CreateSingleInstanceChecker(const wxString &dir);
122
123 std::unique_ptr<wxCmdLineParser> ParseCommandLine();
124
125#if defined(__WXMSW__)
126 std::unique_ptr<IPCServ> mIPCServ;
127#else
128 std::unique_ptr<wxSocketServer> mIPCServ;
129#endif
130
131 public:
132 DECLARE_EVENT_TABLE()
133};
134
136
137#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:116
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:112
std::unique_ptr< wxSingleInstanceChecker > mChecker
Definition: AudacityApp.h:114
void MacFinishLaunching()
Observer::Subscription mThemeChangeSubscription
Definition: AudacityApp.h:110
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 OnReceiveCommand(AppCommandEvent &event)
std::unique_ptr< IPCServ > mIPCServ
Definition: AudacityApp.h:126
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.
Class which actually imports the auido, using functions defined in ImportPCM.cpp, ImportMP3_*....
Definition: Import.h:80
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.