Audacity 3.2.0
AudacityCommand.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 AudacityCommand.h
6
7 James Crook
8
9**********************************************************************/
10
11#ifndef __AUDACITY_COMMAND__
12#define __AUDACITY_COMMAND__
13
14
15
16#include <set>
17
18#include <wx/defs.h>
19
20#include "wxPanelWrapper.h" // to inherit
21
22#include "ComponentInterface.h"
24#include "EffectInterface.h" // for SettingsVisitor type alias
25
26#include "Registrar.h"
27
28class ShuttleGui;
29
30#define BUILTIN_GENERIC_COMMAND_PREFIX wxT("Built-in AudacityCommand: ")
31
32class AudacityCommand;
33class AudacityProject;
34class CommandContext;
35class ProgressDialog;
36
37class AUDACITY_DLL_API AudacityCommand /* not final */ :
38 public wxEvtHandler,
40{
41 public:
42 //std::unique_ptr<CommandOutputTargets> mOutput;
43 //CommandOutputTargets * mOutput;
44 public:
46 virtual ~AudacityCommand();
47
48 // ComponentInterface implementation
49
50 //These four can be defaulted....
51 PluginPath GetPath() const override;
52 VendorSymbol GetVendor() const override;
53 wxString GetVersion() const override;
54 // virtual wxString GetFamily();
55
56 //These two must be implemented by instances.
57 ComponentInterfaceSymbol GetSymbol() const override = 0;
58 virtual TranslatableString GetDescription() const override
59 {wxFAIL_MSG( "Implement a Description for this command");return XO("FAIL");};
60
61 // Name of page in the Audacity alpha manual
62 virtual ManualPageID ManualPage() { return {}; }
63 virtual bool IsBatchProcessing() const { return mIsBatch; }
64 virtual void SetBatchProcessing(bool start) { mIsBatch = start; }
65
66 virtual bool Apply(const CommandContext & WXUNUSED(context) ) { return false; }
67
68 bool ShowInterface(wxWindow *parent, bool forceModal = false);
69
70 wxDialog *CreateUI(wxWindow *parent, AudacityCommand *client);
71
72 bool SaveSettingsAsString(wxString& parms);
73 bool LoadSettingsFromString(const wxString& parms);
74
76 const CommandContext& context, bool shouldPrompt = true);
77
78 // Nonvirtual
79 // Display a message box, using effect's (translated) name as the prefix
80 // for the title.
81 enum : long { DefaultMessageBoxStyle = wxOK | wxCENTRE };
82 int MessageBox(const TranslatableString& message,
83 long style = DefaultMessageBoxStyle,
84 const TranslatableString& titleStr = {});
85
86//
87// protected virtual methods
88//
89// Each subclass of AudacityCommand overrides one or more of these methods to
90// do its processing.
91//
92//protected:
93
94 // Called once each time an effect is called. Perform any initialization;
95 // make sure that the command can be performed and
96 // return false otherwise
97 virtual bool Init();
98
99 // If necessary, open a dialog to get parameters from the user.
100 // This method will not always be called (for example if a user
101 // repeats a command using 'repeat last command') but if it is called,
102 // it will be called after Init.
103 virtual bool PromptUser(AudacityProject&);
104
105 // Check whether command should be skipped
106 // Typically this is only useful in macros, for example
107 // detecting that zero noise reduction is to be done,
108 // or that normalisation is being done without Dc bias shift
109 // or amplitude modification
110 virtual bool CheckWhetherSkipAudacityCommand() { return false; }
111
112 // clean up any temporary memory, needed only per invocation of the
113 // effect, after either successful or failed or exception-aborted processing.
114 // Invoked inside a "finally" block so it must be no-throw.
115 virtual void End(){;};
116 virtual void PopulateOrExchange(ShuttleGui & WXUNUSED(S)){return;};
117 virtual bool TransferDataToWindow();
118 virtual bool TransferDataFromWindow();
119
122 virtual bool VisitSettings( SettingsVisitor & );
125 virtual bool VisitSettings( ConstSettingsVisitor & );
126
127protected:
128
129 ProgressDialog *mProgress; // Temporary pointer, NOT deleted in destructor.
130 // UI
131 wxDialog *mUIDialog;
132 wxWindow *mUIParent;
133
134private:
137};
138
139
140// Base dialog for command dialog.
141class AUDACITY_DLL_API AudacityCommandDialog /* not final */ : public wxDialogWrapper
142{
143public:
144 // constructors and destructors
145 AudacityCommandDialog(wxWindow * parent,
147 AudacityCommand * pCommand,
148 int type = 0,
149 int flags = wxDEFAULT_DIALOG_STYLE,
150 int additionalButtons = 0);
151
152 bool Init();// always returns true. The bool is for the future...
153
154 bool TransferDataToWindow() override;
155 bool TransferDataFromWindow() override;
156 bool Validate() override;
157
158 virtual void PopulateOrExchange(ShuttleGui & S);
159 virtual void OnOk(wxCommandEvent & evt);
160 virtual void OnCancel(wxCommandEvent & evt);
161 virtual void OnHelp(wxCommandEvent & evt);
162
163private:
164 int mType;
167
168 DECLARE_EVENT_TABLE()
169 wxDECLARE_NO_COPY_CLASS(AudacityCommandDialog);
170};
171
172
173
174#endif
XO("Cut/Copy/Paste")
wxString PluginPath
type alias for identifying a Plugin supplied by a module, each module defining its own interpretation...
Definition: Identifier.h:214
static const auto title
#define S(N)
Definition: ToChars.cpp:64
Default dialog used for commands. Is populated using ShuttleGui.
AudacityCommand * mpCommand
Base class for command in Audacity.
virtual bool IsBatchProcessing() const
wxDialog * mUIDialog
virtual bool Apply(const CommandContext &WXUNUSED(context))
virtual void PopulateOrExchange(ShuttleGui &WXUNUSED(S))
ComponentInterfaceSymbol GetSymbol() const override=0
virtual void SetBatchProcessing(bool start)
wxWindow * mUIParent
virtual ManualPageID ManualPage()
virtual void End()
ProgressDialog * mProgress
virtual bool CheckWhetherSkipAudacityCommand()
virtual TranslatableString GetDescription() const 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
CommandContext provides additional information to an 'Apply()' command. It provides the project,...
ComponentInterface provides name / vendor / version functions to identify plugins....
virtual wxString GetVersion() const =0
virtual PluginPath GetPath() const =0
virtual VendorSymbol GetVendor() const =0
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
ProgressDialog Class.
Visitor of effect or command parameters. This is a base class with lots of virtual functions that do ...
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:640
Holds a msgid for the translation catalog; may also bind format arguments.
AUDACITY_DLL_API bool DoAudacityCommand(const PluginID &ID, const CommandContext &context, unsigned flags)
int PromptUser(EffectNoiseReduction::Settings &settings, EffectNoiseReduction *effect, EffectSettingsAccess &access, wxWindow &parent, bool bHasProfile, bool bAllowTwiddleSettings)