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 "../Shuttle.h"
21#include "LoadCommands.h"
22#include "../ShuttleGui.h"
23#include "CommandTargets.h"
24#include "CommandContext.h"
25#include "../effects/EffectManager.h"
26
28{ XO("Help") };
29
31{ XO("Comment") };
32
35
36enum {
41};
42
44{
45 // These are acceptable dual purpose internal/visible names
46
47 /* i18n-hint JavaScript Object Notation */
48 { XO("JSON") },
49 /* i18n-hint name of a computer programming language */
50 { XO("LISP") },
51 { XO("Brief") }
52};
53
54template<bool Const>
56 S.Define( mCommandName, wxT("Command"), wxString{"Help"} );
57 S.DefineEnum( mFormat, wxT("Format"), 0, kFormats, nFormats );
58 return true;
59}
61 { return VisitSettings<false>(S); }
62
64 { return VisitSettings<true>(S); }
65
67{
68 S.AddSpace(0, 5);
69
70 S.StartMultiColumn(2, wxALIGN_CENTER);
71 {
72 S.TieTextBox(XXO("Command:"),mCommandName);
73 S.TieChoice( XXO("Format:"),
75 }
76 S.EndMultiColumn();
77}
78
80{
81 if( mFormat == kJson )
82 return ApplyInner( context );
83
84 if( mFormat == kLisp )
85 {
86 CommandContext LispyContext(
87 context.project,
88 std::make_unique<LispifiedCommandOutputTargets>( *context.pOutput.get() )
89 );
90 return ApplyInner( LispyContext );
91 }
92
93 if( mFormat == kBrief )
94 {
95 CommandContext BriefContext(
96 context.project,
97 std::make_unique<BriefCommandOutputTargets>( *context.pOutput.get() )
98 );
99 return ApplyInner( BriefContext );
100 }
101
102 return false;
103}
104
108 if( ID.empty() )
109 context.Status( "Command not found" );
110 else
111 em.GetCommandDefinition( ID, context, 1);
112 return true;
113}
114
115template<bool Const>
117 S.Define( mComment, wxT("_"), wxString{} );
118 return true;
119}
120
122 { return VisitSettings<false>(S); }
123
125 { return VisitSettings<true>(S); }
126
128{
129 S.AddSpace(0, 5);
130
131 S.StartMultiColumn(2, wxALIGN_CENTER);
132 {
133 S.TieTextBox(XXO("_"),mComment,80);
134 }
135 S.EndMultiColumn();
136}
137
wxString PluginID
Definition: EffectManager.h:30
@ kBrief
Definition: HelpCommand.cpp:39
@ nFormats
Definition: HelpCommand.cpp:40
@ kJson
Definition: HelpCommand.cpp:37
@ kLisp
Definition: HelpCommand.cpp:38
static const EnumValueSymbol kFormats[nFormats]
Definition: HelpCommand.cpp:43
#define XXO(s)
Definition: Internat.h:44
#define XO(s)
Definition: Internat.h:31
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:66
wxString mCommandName
Definition: HelpCommand.h:45
static const ComponentInterfaceSymbol Symbol
Definition: HelpCommand.h:29
bool Apply(const CommandContext &context) override
Definition: HelpCommand.cpp:79
bool ApplyInner(const CommandContext &context)
bool VisitSettings(SettingsVisitorBase< Const > &S)
Definition: HelpCommand.cpp:55
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:631
BuiltinCommandsModule::Registration< HelpCommand > reg
Definition: HelpCommand.cpp:33
BuiltinCommandsModule::Registration< CommentCommand > reg2
Definition: HelpCommand.cpp:34