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#include <wx/event.h> // to inherit
20
21#include "../widgets/wxPanelWrapper.h" // to inherit
22
23#include "ComponentInterface.h"
25#include "EffectInterface.h" // for SettingsVisitor type alias
26
27#include "Registrar.h"
28
29class ShuttleGui;
30
31#define BUILTIN_GENERIC_COMMAND_PREFIX wxT("Built-in AudacityCommand: ")
32
33class AudacityCommand;
34class AudacityProject;
35class CommandContext;
36class ProgressDialog;
37
38
39class AUDACITY_DLL_API AudacityCommand /* not final */ : public wxEvtHandler,
41{
42 public:
43 //std::unique_ptr<CommandOutputTargets> mOutput;
44 //CommandOutputTargets * mOutput;
45 public:
47 virtual ~AudacityCommand();
48
49 // ComponentInterface implementation
50
51 //These four can be defaulted....
52 PluginPath GetPath() const override;
53 VendorSymbol GetVendor() const override;
54 wxString GetVersion() const override;
55 // virtual wxString GetFamily();
56
57 //These two must be implemented by instances.
58 ComponentInterfaceSymbol GetSymbol() const override = 0;
59 virtual TranslatableString GetDescription() const override
60 {wxFAIL_MSG( "Implement a Description for this command");return XO("FAIL");};
61
62 // Name of page in the Audacity alpha manual
63 virtual ManualPageID ManualPage() { return {}; }
64 virtual bool IsBatchProcessing() const { return mIsBatch; }
65 virtual void SetBatchProcessing(bool start) { mIsBatch = start; }
66
67 virtual bool Apply(const CommandContext & WXUNUSED(context) ) { return false; }
68
69 bool ShowInterface(wxWindow *parent, bool forceModal = false);
70
71 wxDialog *CreateUI(wxWindow *parent, AudacityCommand *client);
72
73 bool SaveSettingsAsString(wxString & parms);
74 bool LoadSettingsFromString(const wxString & parms);
75
76 bool DoAudacityCommand(wxWindow *parent, 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(wxWindow *parent);
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
wxString PluginPath
type alias for identifying a Plugin supplied by a module, each module defining its own interpretation...
Definition: Identifier.h:214
#define XO(s)
Definition: Internat.h:31
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:89
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 ...
Definition: Shuttle.h:115
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:628
Holds a msgid for the translation catalog; may also bind format arguments.