mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-19 17:40:15 +02:00
Long message target
This allows interactive display of the results of new commands that generate lots of text.
This commit is contained in:
parent
037df23d3c
commit
4c65a74c03
@ -284,3 +284,12 @@ bool CommandImplementation::Apply(const CommandContext & WXUNUSED(context))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Hackery so that we dont have to update the makefiles on linux (yet)
|
||||
#ifndef __WIN32__
|
||||
|
||||
#include "CommandTargets.cpp"
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -45,7 +45,8 @@ CommandContext::CommandContext(
|
||||
, const CommandParameter ¶m
|
||||
)
|
||||
: project{ p }
|
||||
, pOutput( nullptr )
|
||||
// No target specified? Use the special interactive one that pops up a dialog.
|
||||
, pOutput( std::move( std::make_unique<InteractiveOutputTarget>()) )
|
||||
, pEvt{ e }
|
||||
, index{ ii }
|
||||
, parameter{ param }
|
||||
|
158
src/commands/CommandTargets.cpp
Normal file
158
src/commands/CommandTargets.cpp
Normal file
@ -0,0 +1,158 @@
|
||||
/**********************************************************************
|
||||
|
||||
Audacity - A Digital Audio Editor
|
||||
Copyright 1999-2009 Audacity Team
|
||||
License: wxwidgets
|
||||
|
||||
Dan Horgan
|
||||
|
||||
******************************************************************//**
|
||||
|
||||
\file CommandTargets.cpp
|
||||
\brief Contains definitions for CommandType class
|
||||
|
||||
\class InteractiveOutputTarget
|
||||
\brief InteractiveOutputTarget is an output target that pops up a
|
||||
dialog, if necessary.
|
||||
|
||||
*//*******************************************************************/
|
||||
|
||||
#include "../Audacity.h"
|
||||
#include "CommandTargets.h"
|
||||
#include <wx/string.h>
|
||||
#include "../ShuttleGui.h"
|
||||
#include "../Project.h"
|
||||
|
||||
|
||||
|
||||
/// Dialog for long messages.
|
||||
class AUDACITY_DLL_API LongMessageDialog /* not final */ : public wxDialogWrapper
|
||||
{
|
||||
public:
|
||||
// constructors and destructors
|
||||
LongMessageDialog(wxWindow * parent,
|
||||
const wxString & title,
|
||||
int type = 0,
|
||||
int flags = wxDEFAULT_DIALOG_STYLE,
|
||||
int additionalButtons = 0);
|
||||
~LongMessageDialog();
|
||||
|
||||
bool Init();
|
||||
virtual void OnOk(wxCommandEvent & evt);
|
||||
virtual void OnCancel(wxCommandEvent & evt);
|
||||
|
||||
static void AcceptText( const wxString & Text );
|
||||
|
||||
wxTextCtrl * mText;
|
||||
static LongMessageDialog * pDlg;
|
||||
private:
|
||||
int mType;
|
||||
int mAdditionalButtons;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
wxDECLARE_NO_COPY_CLASS(LongMessageDialog);
|
||||
};
|
||||
|
||||
|
||||
LongMessageDialog * LongMessageDialog::pDlg = NULL;
|
||||
|
||||
|
||||
BEGIN_EVENT_TABLE(LongMessageDialog, wxDialogWrapper)
|
||||
EVT_BUTTON(wxID_OK, LongMessageDialog::OnOk)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
LongMessageDialog::LongMessageDialog(wxWindow * parent,
|
||||
const wxString & title,
|
||||
int type,
|
||||
int flags,
|
||||
int additionalButtons)
|
||||
: wxDialogWrapper(parent, wxID_ANY, title, wxDefaultPosition, wxDefaultSize, flags | wxRESIZE_BORDER)
|
||||
{
|
||||
mType = type;
|
||||
mAdditionalButtons = additionalButtons;
|
||||
}
|
||||
|
||||
LongMessageDialog::~LongMessageDialog(){
|
||||
pDlg = NULL;
|
||||
}
|
||||
|
||||
|
||||
bool LongMessageDialog::Init()
|
||||
{
|
||||
ShuttleGui S(this, eIsCreating);
|
||||
|
||||
S.SetBorder(5);
|
||||
S.StartVerticalLay(true);
|
||||
{
|
||||
mText = S.AddTextWindow( "" );
|
||||
long buttons = eOkButton;
|
||||
S.AddStandardButtons(buttons|mAdditionalButtons);
|
||||
}
|
||||
S.EndVerticalLay();
|
||||
|
||||
Layout();
|
||||
Fit();
|
||||
SetMinSize(wxSize(600,700));
|
||||
Center();
|
||||
return true;
|
||||
}
|
||||
|
||||
void LongMessageDialog::OnOk(wxCommandEvent & WXUNUSED(evt)){
|
||||
//Close(true);
|
||||
Destroy();
|
||||
}
|
||||
|
||||
void LongMessageDialog::OnCancel(wxCommandEvent & WXUNUSED(evt)){
|
||||
//Close(true);
|
||||
Destroy();
|
||||
}
|
||||
|
||||
void LongMessageDialog::AcceptText( const wxString & Text )
|
||||
{
|
||||
if( pDlg == NULL ){
|
||||
pDlg = new LongMessageDialog( GetActiveProject(), "Long Message" );
|
||||
pDlg->Init();
|
||||
pDlg->Show();
|
||||
}
|
||||
pDlg->mText->SetValue( pDlg->mText->GetValue( ) + "\n" + Text );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// Displays messages from a command in an AudacityMessageBox
|
||||
class MessageDialogTarget final : public CommandMessageTarget
|
||||
{
|
||||
public:
|
||||
virtual ~MessageDialogTarget() {}
|
||||
void Update(const wxString &message) override
|
||||
{
|
||||
LongMessageDialog::AcceptText(message);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
/// Extended Target Factory with more options.
|
||||
class ExtTargetFactory : public TargetFactory
|
||||
{
|
||||
public:
|
||||
static std::unique_ptr<CommandMessageTarget> LongMessages()
|
||||
{
|
||||
return std::make_unique<MessageDialogTarget>();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
InteractiveOutputTarget::InteractiveOutputTarget() :
|
||||
CommandOutputTarget(
|
||||
ExtTargetFactory::ProgressDefault(),
|
||||
ExtTargetFactory::LongMessages(),
|
||||
ExtTargetFactory::MessageDefault()
|
||||
)
|
||||
{
|
||||
}
|
@ -185,7 +185,7 @@ public:
|
||||
/// Assumes responsibility for pointers passed into it.
|
||||
class CommandOutputTarget
|
||||
{
|
||||
private:
|
||||
protected:
|
||||
std::unique_ptr<CommandProgressTarget> mProgressTarget;
|
||||
std::shared_ptr<CommandMessageTarget> mStatusTarget;
|
||||
std::shared_ptr<CommandMessageTarget> mErrorTarget;
|
||||
@ -215,4 +215,11 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
class InteractiveOutputTarget : public CommandOutputTarget
|
||||
{
|
||||
public:
|
||||
InteractiveOutputTarget();
|
||||
|
||||
};
|
||||
|
||||
#endif /* End of include guard: __COMMANDTARGETS__ */
|
||||
|
@ -51,10 +51,11 @@ enum {
|
||||
};
|
||||
|
||||
|
||||
const int nFormats =2;
|
||||
const int nFormats =3;
|
||||
static const wxString kFormats[nFormats] =
|
||||
{
|
||||
XO("JSON"),
|
||||
XO("LISP"),
|
||||
XO("Other")
|
||||
};
|
||||
|
||||
@ -80,8 +81,8 @@ void GetInfoCommand::PopulateOrExchange(ShuttleGui & S)
|
||||
|
||||
S.StartMultiColumn(2, wxALIGN_CENTER);
|
||||
{
|
||||
S.TieChoice( _("Types:"), mInfoType, &types);
|
||||
S.TieChoice( _("Formats:"), mFormat, &formats);
|
||||
S.TieChoice( _("Type:"), mInfoType, &types);
|
||||
S.TieChoice( _("Format:"), mFormat, &formats);
|
||||
}
|
||||
S.EndMultiColumn();
|
||||
}
|
||||
|
@ -139,6 +139,7 @@
|
||||
<ClCompile Include="..\..\..\src\blockfile\NotYetAvailableException.cpp" />
|
||||
<ClCompile Include="..\..\..\src\commands\AudacityCommand.cpp" />
|
||||
<ClCompile Include="..\..\..\src\commands\CommandContext.cpp" />
|
||||
<ClCompile Include="..\..\..\src\commands\CommandTargets.cpp" />
|
||||
<ClCompile Include="..\..\..\src\commands\Demo.cpp" />
|
||||
<ClCompile Include="..\..\..\src\commands\LoadCommands.cpp" />
|
||||
<ClCompile Include="..\..\..\src\commands\OpenSaveCommands.cpp" />
|
||||
|
@ -1064,6 +1064,9 @@
|
||||
<ClCompile Include="..\..\..\src\commands\SetTrackInfoCommand.cpp">
|
||||
<Filter>src\commands</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\src\commands\CommandTargets.cpp">
|
||||
<Filter>src\commands</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\..\src\AboutDialog.h">
|
||||
|
Loading…
x
Reference in New Issue
Block a user