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 "../CommonCommandFlags.h"
21#include "CommandContext.h"
22#include "CommandDispatch.h"
23#include "CommandTargets.h"
25#include "LoadCommands.h"
26#include "MenuRegistry.h"
27#include "PluginManager.h"
28#include "SettingsVisitor.h"
29#include "ShuttleGui.h"
30
32{ XO("Help") };
33
35{ XO("Comment") };
36
39
40enum {
45};
46
48{
49 // These are acceptable dual purpose internal/visible names
50
51 /* i18n-hint JavaScript Object Notation */
52 { XO("JSON") },
53 /* i18n-hint name of a computer programming language */
54 { XO("LISP") },
55 { XO("Brief") }
56};
57
58template<bool Const>
60 S.Define( mCommandName, wxT("Command"), wxString{"Help"} );
61 S.DefineEnum( mFormat, wxT("Format"), 0, kFormats, nFormats );
62 return true;
63}
65 { return VisitSettings<false>(S); }
66
68 { return VisitSettings<true>(S); }
69
71{
72 S.AddSpace(0, 5);
73
74 S.StartMultiColumn(2, wxALIGN_CENTER);
75 {
76 S.TieTextBox(XXO("Command:"),mCommandName);
77 S.TieChoice( XXO("Format:"),
79 }
80 S.EndMultiColumn();
81}
82
84{
85 if( mFormat == kJson )
86 return ApplyInner( context );
87
88 if( mFormat == kLisp )
89 {
90 CommandContext LispyContext(
91 context.project,
92 std::make_unique<LispifiedCommandOutputTargets>( *context.pOutput.get() )
93 );
94 return ApplyInner( LispyContext );
95 }
96
97 if( mFormat == kBrief )
98 {
99 CommandContext BriefContext(
100 context.project,
101 std::make_unique<BriefCommandOutputTargets>( *context.pOutput.get() )
102 );
103 return ApplyInner( BriefContext );
104 }
105
106 return false;
107}
108
111 if( ID.empty() )
112 context.Status( "Command not found" );
113 else
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")
@ kBrief
Definition: HelpCommand.cpp:43
@ nFormats
Definition: HelpCommand.cpp:44
@ kJson
Definition: HelpCommand.cpp:41
@ kLisp
Definition: HelpCommand.cpp:42
static const EnumValueSymbol kFormats[nFormats]
Definition: HelpCommand.cpp:47
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,...
void GetCommandDefinition(const PluginID &ID, const CommandContext &context, int flags)
static EffectAndCommandPluginManager & Get()
void PopulateOrExchange(ShuttleGui &S) override
Definition: HelpCommand.cpp:70
wxString mCommandName
Definition: HelpCommand.h:45
static const ComponentInterfaceSymbol Symbol
Definition: HelpCommand.h:29
bool Apply(const CommandContext &context) override
Definition: HelpCommand.cpp:83
bool ApplyInner(const CommandContext &context)
bool VisitSettings(SettingsVisitorBase< Const > &S)
Definition: HelpCommand.cpp:59
const PluginID & GetByCommandIdentifier(const CommandID &strTarget)
static PluginManager & Get()
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:640
AUDACITY_DLL_API void OnAudacityCommand(const CommandContext &ctx)
constexpr auto Command
Definition: MenuRegistry.h:456
BuiltinCommandsModule::Registration< HelpCommand > reg
Definition: HelpCommand.cpp:37
BuiltinCommandsModule::Registration< CommentCommand > reg2
Definition: HelpCommand.cpp:38