Audacity  3.0.3
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 
36 enum {
40  nFormats
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 
54 
56  S.Define( mCommandName, wxT("Command"), "Help" );
57  S.DefineEnum( mFormat, wxT("Format"), 0, kFormats, nFormats );
58  return true;
59 }
60 
62 {
63  S.AddSpace(0, 5);
64 
65  S.StartMultiColumn(2, wxALIGN_CENTER);
66  {
67  S.TieTextBox(XXO("Command:"),mCommandName);
68  S.TieChoice( XXO("Format:"),
70  }
71  S.EndMultiColumn();
72 }
73 
74 bool HelpCommand::Apply(const CommandContext &context)
75 {
76  if( mFormat == kJson )
77  return ApplyInner( context );
78 
79  if( mFormat == kLisp )
80  {
81  CommandContext LispyContext(
82  context.project,
83  std::make_unique<LispifiedCommandOutputTargets>( *context.pOutput.get() )
84  );
85  return ApplyInner( LispyContext );
86  }
87 
88  if( mFormat == kBrief )
89  {
90  CommandContext BriefContext(
91  context.project,
92  std::make_unique<BriefCommandOutputTargets>( *context.pOutput.get() )
93  );
94  return ApplyInner( BriefContext );
95  }
96 
97  return false;
98 }
99 
103  if( ID.empty() )
104  context.Status( "Command not found" );
105  else
106  em.GetCommandDefinition( ID, context, 1);
107  return true;
108 }
109 
111  S.Define( mComment, wxT("_"), "" );
112  return true;
113 }
114 
116 {
117  S.AddSpace(0, 5);
118 
119  S.StartMultiColumn(2, wxALIGN_CENTER);
120  {
121  S.TieTextBox(XXO("_"),mComment,80);
122  }
123  S.EndMultiColumn();
124 }
125 
HelpCommand::Apply
bool Apply(const CommandContext &context) override
Definition: HelpCommand.cpp:74
LoadCommands.h
HelpCommand::ApplyInner
bool ApplyInner(const CommandContext &context)
Definition: HelpCommand.cpp:100
anonymous_namespace{HelpCommand.cpp}::reg
BuiltinCommandsModule::Registration< HelpCommand > reg
Definition: HelpCommand.cpp:33
kLisp
@ kLisp
Definition: HelpCommand.cpp:38
ShuttleGui::AddSpace
wxSizerItem * AddSpace(int width, int height, int prop=0)
Definition: ShuttleGui.cpp:2447
XO
#define XO(s)
Definition: Internat.h:31
ShuttleParams
Shuttle that deals with parameters. This is a base class with lots of virtual functions that do nothi...
Definition: Shuttle.h:62
ShuttleGuiBase::EndMultiColumn
void EndMultiColumn()
Definition: ShuttleGui.cpp:1238
EffectManager::Get
static EffectManager & Get()
Definition: EffectManager.cpp:42
HelpCommand.h
ComponentInterfaceSymbol
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
Definition: ComponentInterfaceSymbol.h:27
kJson
@ kJson
Definition: HelpCommand.cpp:37
ShuttleGuiBase::TieTextBox
wxTextCtrl * TieTextBox(const TranslatableString &Caption, wxString &Value, const int nChars=0)
Definition: ShuttleGui.cpp:1652
BuiltinCommandsModule::Registration
Definition: LoadCommands.h:41
CommentCommand::DefineParams
bool DefineParams(ShuttleParams &S) override
Definition: HelpCommand.cpp:110
CommandContext::Status
virtual void Status(const wxString &message, bool bFlush=false) const
Definition: CommandContext.cpp:63
CommandContext.h
XXO
#define XXO(s)
Definition: Internat.h:44
EffectManager
EffectManager is the class that handles effects and effect categories.
Definition: EffectManager.h:46
anonymous_namespace{HelpCommand.cpp}::reg2
BuiltinCommandsModule::Registration< CommentCommand > reg2
Definition: HelpCommand.cpp:34
CommandContext
CommandContext provides additional information to an 'Apply()' command. It provides the project,...
Definition: CommandContext.h:22
ShuttleGuiBase::StartMultiColumn
void StartMultiColumn(int nCols, int PositionFlags=wxALIGN_LEFT)
Definition: ShuttleGui.cpp:1229
nFormats
@ nFormats
Definition: HelpCommand.cpp:40
CommentCommand::Symbol
static const ComponentInterfaceSymbol Symbol
Definition: HelpCommand.h:49
PluginID
wxString PluginID
Definition: EffectManager.h:30
ShuttleParams::DefineEnum
virtual void DefineEnum(int &var, const wxChar *key, const int vdefault, const EnumValueSymbol strings[], size_t nStrings)
Definition: Shuttle.cpp:339
HelpCommand::PopulateOrExchange
void PopulateOrExchange(ShuttleGui &S) override
Definition: HelpCommand.cpp:61
CommandTargets.h
Msgids
TranslatableStrings Msgids(const EnumValueSymbol strings[], size_t nStrings)
Convenience function often useful when adding choice controls.
Definition: ShuttleGui.cpp:2510
HelpCommand::DefineParams
bool DefineParams(ShuttleParams &S) override
Definition: HelpCommand.cpp:55
HelpCommand::Symbol
static const ComponentInterfaceSymbol Symbol
Definition: HelpCommand.h:29
HelpCommand::mFormat
int mFormat
Definition: HelpCommand.h:30
kBrief
@ kBrief
Definition: HelpCommand.cpp:39
EffectManager::GetEffectByIdentifier
const PluginID & GetEffectByIdentifier(const CommandID &strTarget)
Definition: EffectManager.cpp:821
EffectManager::GetCommandDefinition
void GetCommandDefinition(const PluginID &ID, const CommandContext &context, int flags)
Definition: EffectManager.cpp:163
HelpCommand::mCommandName
wxString mCommandName
Definition: HelpCommand.h:43
ShuttleParams::Define
virtual void Define(bool &var, const wxChar *key, const bool vdefault, const bool vmin=false, const bool vmax=false, const bool vscl=false)
Definition: Shuttle.cpp:332
CommandContext::project
AudacityProject & project
Definition: CommandContext.h:52
ShuttleGuiBase::TieChoice
wxChoice * TieChoice(const TranslatableString &Prompt, TranslatableString &Selected, const TranslatableStrings &choices)
Definition: ShuttleGui.cpp:1727
CommentCommand::PopulateOrExchange
void PopulateOrExchange(ShuttleGui &S) override
Definition: HelpCommand.cpp:115
CommentCommand::mComment
wxString mComment
Definition: HelpCommand.h:63
kFormats
static const EnumValueSymbol kFormats[nFormats]
Definition: HelpCommand.cpp:43
ShuttleGui
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:631
CommandContext::pOutput
std::unique_ptr< CommandOutputTargets > pOutput
Definition: CommandContext.h:53