Audacity 3.2.0
HelpCommand.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity - A Digital Audio Editor
4 Copyright 1999-2018 Audacity Team
5 License: wxwidgets
6
7 Dan Horgan
8 James Crook
9
10******************************************************************//*******************************************************************/
16
17
18#include "HelpCommand.h"
19
20#include "CommandDispatch.h"
21#include "MenuRegistry.h"
22#include "../CommonCommandFlags.h"
23#include "SettingsVisitor.h"
24#include "LoadCommands.h"
25#include "ShuttleGui.h"
26#include "CommandTargets.h"
27#include "CommandContext.h"
28#include "../effects/EffectManager.h"
29
31{ XO("Help") };
32
34{ XO("Comment") };
35
38
39enum {
44};
45
47{
48 // These are acceptable dual purpose internal/visible names
49
50 /* i18n-hint JavaScript Object Notation */
51 { XO("JSON") },
52 /* i18n-hint name of a computer programming language */
53 { XO("LISP") },
54 { XO("Brief") }
55};
56
57template<bool Const>
59 S.Define( mCommandName, wxT("Command"), wxString{"Help"} );
60 S.DefineEnum( mFormat, wxT("Format"), 0, kFormats, nFormats );
61 return true;
62}
64 { return VisitSettings<false>(S); }
65
67 { return VisitSettings<true>(S); }
68
70{
71 S.AddSpace(0, 5);
72
73 S.StartMultiColumn(2, wxALIGN_CENTER);
74 {
75 S.TieTextBox(XXO("Command:"),mCommandName);
76 S.TieChoice( XXO("Format:"),
78 }
79 S.EndMultiColumn();
80}
81
83{
84 if( mFormat == kJson )
85 return ApplyInner( context );
86
87 if( mFormat == kLisp )
88 {
89 CommandContext LispyContext(
90 context.project,
91 std::make_unique<LispifiedCommandOutputTargets>( *context.pOutput.get() )
92 );
93 return ApplyInner( LispyContext );
94 }
95
96 if( mFormat == kBrief )
97 {
98 CommandContext BriefContext(
99 context.project,
100 std::make_unique<BriefCommandOutputTargets>( *context.pOutput.get() )
101 );
102 return ApplyInner( BriefContext );
103 }
104
105 return false;
106}
107
111 if( ID.empty() )
112 context.Status( "Command not found" );
113 else
114 em.GetCommandDefinition( ID, context, 1);
115 return true;
116}
117
118template<bool Const>
120 S.Define( mComment, wxT("_"), wxString{} );
121 return true;
122}
123
125 { return VisitSettings<false>(S); }
126
128 { return VisitSettings<true>(S); }
129
131{
132 S.AddSpace(0, 5);
133
134 S.StartMultiColumn(2, wxALIGN_CENTER);
135 {
136 S.TieTextBox(XXO("_"),mComment,80);
137 }
138 S.EndMultiColumn();
139}
140
141namespace {
142using namespace MenuRegistry;
143
144// Register menu items
145
147 // Note that the PLUGIN_SYMBOL must have a space between words,
148 // whereas the short-form used here must not.
149 // (So if you did write "Compare Audio" for the PLUGIN_SYMBOL name, then
150 // you would have to use "CompareAudio" here.)
151 Command( wxT("Help"), XXO("Help..."),
153 wxT("Optional/Extra/Part2/Scriptables2")
154};
155
156}
wxT("CloseDown"))
wxString PluginID
const ReservedCommandFlag & AudioIONotBusyFlag()
XO("Cut/Copy/Paste")
XXO("&Cut/Copy/Paste Toolbar")
static const EnumValueSymbol kFormats[nFormats]
Definition: HelpCommand.cpp:46
@ kBrief
Definition: HelpCommand.cpp:42
@ nFormats
Definition: HelpCommand.cpp:43
@ kJson
Definition: HelpCommand.cpp:40
@ kLisp
Definition: HelpCommand.cpp:41
TranslatableStrings Msgids(const EnumValueSymbol strings[], size_t nStrings)
Convenience function often useful when adding choice controls.
#define S(N)
Definition: ToChars.cpp:64
CommandContext provides additional information to an 'Apply()' command. It provides the project,...
virtual void Status(const wxString &message, bool bFlush=false) const
AudacityProject & project
std::unique_ptr< CommandOutputTargets > pOutput
void PopulateOrExchange(ShuttleGui &S) override
wxString mComment
Definition: HelpCommand.h:67
static const ComponentInterfaceSymbol Symbol
Definition: HelpCommand.h:51
bool VisitSettings(SettingsVisitorBase< Const > &S)
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
EffectManager is the class that handles effects and effect categories.
Definition: EffectManager.h:48
void GetCommandDefinition(const PluginID &ID, const CommandContext &context, int flags)
static EffectManager & Get()
const PluginID & GetEffectByIdentifier(const CommandID &strTarget)
void PopulateOrExchange(ShuttleGui &S) override
Definition: HelpCommand.cpp:69
wxString mCommandName
Definition: HelpCommand.h:45
static const ComponentInterfaceSymbol Symbol
Definition: HelpCommand.h:29
bool Apply(const CommandContext &context) override
Definition: HelpCommand.cpp:82
bool ApplyInner(const CommandContext &context)
bool VisitSettings(SettingsVisitorBase< Const > &S)
Definition: HelpCommand.cpp:58
Generates classes whose instances register items at construction.
Definition: Registry.h:388
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:630
AUDACITY_DLL_API void OnAudacityCommand(const CommandContext &ctx)
constexpr auto Command
Definition: MenuRegistry.h:456
BuiltinCommandsModule::Registration< HelpCommand > reg
Definition: HelpCommand.cpp:36
BuiltinCommandsModule::Registration< CommentCommand > reg2
Definition: HelpCommand.cpp:37