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
37
38class AUDACITY_DLL_API AudacityCommand /* not final */ : 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
75 bool DoAudacityCommand(wxWindow *parent, const CommandContext & context,bool shouldPrompt = true);
76
77 // Nonvirtual
78 // Display a message box, using effect's (translated) name as the prefix
79 // for the title.
80 enum : long { DefaultMessageBoxStyle = wxOK | wxCENTRE };
81 int MessageBox(const TranslatableString& message,
82 long style = DefaultMessageBoxStyle,
83 const TranslatableString& titleStr = {});
84
85//
86// protected virtual methods
87//
88// Each subclass of AudacityCommand overrides one or more of these methods to
89// do its processing.
90//
91//protected:
92
93 // Called once each time an effect is called. Perform any initialization;
94 // make sure that the command can be performed and
95 // return false otherwise
96 virtual bool Init();
97
98 // If necessary, open a dialog to get parameters from the user.
99 // This method will not always be called (for example if a user
100 // repeats a command using 'repeat last command') but if it is called,
101 // it will be called after Init.
102 virtual bool PromptUser(wxWindow *parent);
103
104 // Check whether command should be skipped
105 // Typically this is only useful in macros, for example
106 // detecting that zero noise reduction is to be done,
107 // or that normalisation is being done without Dc bias shift
108 // or amplitude modification
109 virtual bool CheckWhetherSkipAudacityCommand() { return false; }
110
111 // clean up any temporary memory, needed only per invocation of the
112 // effect, after either successful or failed or exception-aborted processing.
113 // Invoked inside a "finally" block so it must be no-throw.
114 virtual void End(){;};
115 virtual void PopulateOrExchange(ShuttleGui & WXUNUSED(S)){return;};
116 virtual bool TransferDataToWindow();
117 virtual bool TransferDataFromWindow();
118
121 virtual bool VisitSettings( SettingsVisitor & );
124 virtual bool VisitSettings( ConstSettingsVisitor & );
125
126protected:
127
128 ProgressDialog *mProgress; // Temporary pointer, NOT deleted in destructor.
129 // UI
130 wxDialog *mUIDialog;
131 wxWindow *mUIParent;
132
133private:
136};
137
138
139// Base dialog for command dialog.
140class AUDACITY_DLL_API AudacityCommandDialog /* not final */ : public wxDialogWrapper
141{
142public:
143 // constructors and destructors
144 AudacityCommandDialog(wxWindow * parent,
146 AudacityCommand * pCommand,
147 int type = 0,
148 int flags = wxDEFAULT_DIALOG_STYLE,
149 int additionalButtons = 0);
150
151 bool Init();// always returns true. The bool is for the future...
152
153 bool TransferDataToWindow() override;
154 bool TransferDataFromWindow() override;
155 bool Validate() override;
156
157 virtual void PopulateOrExchange(ShuttleGui & S);
158 virtual void OnOk(wxCommandEvent & evt);
159 virtual void OnCancel(wxCommandEvent & evt);
160 virtual void OnHelp(wxCommandEvent & evt);
161
162private:
163 int mType;
166
167 DECLARE_EVENT_TABLE()
168 wxDECLARE_NO_COPY_CLASS(AudacityCommandDialog);
169};
170
171
172
173#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)