Audacity  2.2.2
ExecMenuCommand.cpp
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity - A Digital Audio Editor
4  Copyright 1999-2009 Audacity Team
5  License: wxWidgets
6 
7  Dan Horgan
8 
9 ******************************************************************//*******************************************************************/
15 
16 #include "ExecMenuCommand.h"
17 #include "CommandManager.h"
18 #include "../Project.h"
19 
21 {
22  return wxT("MenuCommand");
23 }
24 
26 {
27  auto menuCommandValidator = make_movable<DefaultValidator>();
28  signature.AddParameter(wxT("CommandName"), wxT(""), std::move(menuCommandValidator));
29 }
30 
31 CommandHolder ExecMenuCommandType::Create(std::unique_ptr<CommandOutputTarget> &&target)
32 {
33  return std::make_shared<ExecMenuCommand>(*this, std::move(target));
34 }
35 
37 {
38  CommandManager *cmdManager = context.GetProject()->GetCommandManager();
39 
40  wxString cmdName = GetString(wxT("CommandName"));
41  auto cmdFlags = AlwaysEnabledFlag; // TODO ?
42  auto cmdMask = AlwaysEnabledFlag;
43  return cmdManager->HandleTextualCommand(cmdName, cmdFlags, cmdMask);
44 }
void BuildSignature(CommandSignature &signature) override
Postcondition: signature is a 'signature' map containing parameter.
std::shared_ptr< Command > CommandHolder
void AddParameter(const wxString &name, const wxVariant &dft, movable_ptr< Validator > &&valid)
wxString GetString(const wxString &paramName)
Definition: Command.cpp:165
CommandManager * GetCommandManager()
Definition: Project.h:328
Contains declaration of ExecMenuCommand class.
bool HandleTextualCommand(const wxString &Str, CommandFlag flags, CommandMask mask)
CommandManager implements a system for organizing all user-callable commands.
CommandHolder Create(std::unique_ptr< CommandOutputTarget > &&target) override
Represents a context to which a command may be applied.
Definition: Command.h:50
wxString BuildName() override
bool Apply(CommandExecutionContext context) override
AudacityProject * GetProject() const
Definition: Command.h:60
Class that maps parameter names to default values and validators.