2010-01-23 19:44:49 +00:00
|
|
|
/**********************************************************************
|
|
|
|
|
|
|
|
Audacity: A Digital Audio Editor
|
|
|
|
|
|
|
|
ErrorDialog.cpp
|
|
|
|
|
|
|
|
Jimmy Johnson
|
|
|
|
Leland Lucius
|
|
|
|
|
|
|
|
*******************************************************************//**
|
|
|
|
|
|
|
|
\class ErrorDialog
|
2017-11-09 18:32:29 +00:00
|
|
|
\brief Gives an Error message with an option for help.
|
|
|
|
|
|
|
|
*//*****************************************************************//**
|
|
|
|
|
|
|
|
\class AliasedFileMissingDialog
|
|
|
|
\brief Special case of ErrorDialog for reporting missing alias files.
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
*//********************************************************************/
|
|
|
|
|
|
|
|
#include "../Audacity.h"
|
|
|
|
|
|
|
|
#include <wx/button.h>
|
|
|
|
#include <wx/icon.h>
|
|
|
|
#include <wx/dialog.h>
|
|
|
|
#include <wx/intl.h>
|
|
|
|
#include <wx/sizer.h>
|
|
|
|
#include <wx/stattext.h>
|
|
|
|
#include <wx/utils.h>
|
|
|
|
#include <wx/html/htmlwin.h>
|
|
|
|
#include <wx/settings.h>
|
2010-02-14 06:37:45 +00:00
|
|
|
#include <wx/statusbr.h>
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
#include "LinkingHtmlWindow.h"
|
|
|
|
#include "../Theme.h"
|
|
|
|
#include "../AllThemeResources.h"
|
|
|
|
#include "../ShuttleGui.h"
|
|
|
|
#include "../HelpText.h"
|
|
|
|
#include "../Internat.h"
|
|
|
|
#include "../Project.h"
|
|
|
|
#include "../Prefs.h"
|
2014-06-06 21:34:36 +00:00
|
|
|
#include "HelpSystem.h"
|
2011-03-23 01:01:17 +00:00
|
|
|
|
2013-02-22 21:29:19 +00:00
|
|
|
#include "ErrorDialog.h"
|
|
|
|
|
2011-03-23 01:01:17 +00:00
|
|
|
// special case for alias missing dialog because we keep track of if it exists.
|
2016-02-24 06:06:39 +00:00
|
|
|
class AliasedFileMissingDialog final : public ErrorDialog
|
2011-03-23 01:01:17 +00:00
|
|
|
{
|
|
|
|
public:
|
2014-06-03 20:30:19 +00:00
|
|
|
AliasedFileMissingDialog(AudacityProject *parent,
|
|
|
|
const wxString & dlogTitle,
|
|
|
|
const wxString & message,
|
2011-03-23 01:01:17 +00:00
|
|
|
const wxString & helpURL,
|
|
|
|
const bool Close = true, const bool modal = true);
|
|
|
|
virtual ~AliasedFileMissingDialog();
|
|
|
|
};
|
|
|
|
|
2016-07-10 21:10:50 +00:00
|
|
|
BEGIN_EVENT_TABLE(ErrorDialog, wxDialogWrapper)
|
2010-01-23 19:44:49 +00:00
|
|
|
EVT_BUTTON( wxID_OK, ErrorDialog::OnOk)
|
|
|
|
EVT_BUTTON( wxID_HELP, ErrorDialog::OnHelp)
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
2011-03-23 01:01:17 +00:00
|
|
|
|
2014-06-03 20:30:19 +00:00
|
|
|
AliasedFileMissingDialog::AliasedFileMissingDialog(AudacityProject *parent,
|
|
|
|
const wxString & dlogTitle,
|
|
|
|
const wxString & message,
|
2011-03-23 01:01:17 +00:00
|
|
|
const wxString & helpURL,
|
|
|
|
const bool Close, const bool modal):
|
|
|
|
ErrorDialog(parent, dlogTitle, message, helpURL, Close, modal)
|
|
|
|
{
|
2011-04-02 13:03:02 +00:00
|
|
|
parent->SetMissingAliasFileDialog(this);
|
2011-03-23 01:01:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
AliasedFileMissingDialog::~AliasedFileMissingDialog()
|
|
|
|
{
|
2011-04-02 13:03:02 +00:00
|
|
|
((AudacityProject*)GetParent())->SetMissingAliasFileDialog(NULL);
|
2011-03-23 01:01:17 +00:00
|
|
|
}
|
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
ErrorDialog::ErrorDialog(
|
2014-06-03 20:30:19 +00:00
|
|
|
wxWindow *parent,
|
|
|
|
const wxString & dlogTitle,
|
|
|
|
const wxString & message,
|
2017-08-25 12:54:37 +00:00
|
|
|
const wxString & helpPage,
|
2011-03-01 01:29:03 +00:00
|
|
|
const bool Close, const bool modal):
|
2016-07-10 21:10:50 +00:00
|
|
|
wxDialogWrapper(parent, (wxWindowID)-1, dlogTitle)
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2015-05-18 12:57:05 +00:00
|
|
|
SetName(GetTitle());
|
|
|
|
|
2011-03-06 18:07:12 +00:00
|
|
|
long buttonMask;
|
|
|
|
|
|
|
|
// only add the help button if we have a URL
|
2017-08-25 12:54:37 +00:00
|
|
|
buttonMask = (helpPage == wxT("")) ? eOkButton : (eHelpButton | eOkButton);
|
|
|
|
dhelpPage = helpPage;
|
2010-12-11 22:32:07 +00:00
|
|
|
dClose = Close;
|
2011-03-01 01:29:03 +00:00
|
|
|
dModal = modal;
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
ShuttleGui S(this, eIsCreating);
|
|
|
|
|
|
|
|
S.StartVerticalLay();
|
|
|
|
{
|
|
|
|
S.SetBorder( 20 );
|
|
|
|
S.AddFixedText( message );
|
|
|
|
S.SetBorder( 2 );
|
2011-03-06 18:07:12 +00:00
|
|
|
S.AddStandardButtons( buttonMask );
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
S.EndVerticalLay();
|
|
|
|
|
|
|
|
Layout();
|
2015-07-31 11:09:02 +00:00
|
|
|
GetSizer()->Fit(this);
|
2010-01-23 19:44:49 +00:00
|
|
|
SetMinSize(GetSize());
|
|
|
|
Center();
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
// Original non ShuttleGui based code.
|
|
|
|
// Layout did not look good on Windows.
|
2016-02-18 19:53:43 +00:00
|
|
|
wxBoxSizer mainSizer;
|
|
|
|
{
|
|
|
|
auto uMainSizer = std::make_unique<wxBoxSizer>(wxVERTICAL);
|
|
|
|
mainSizer = uMainSizer.get();
|
|
|
|
auto vSizer = make_unique<xBoxSizer>(wxVERTICAL);
|
|
|
|
|
|
|
|
auto hSizer = make_unique<wxBoxSizer>(wxHORIZONTAL);
|
2014-06-03 20:30:19 +00:00
|
|
|
|
2016-02-18 19:53:43 +00:00
|
|
|
wxStaticText *statText = safenew wxStaticText(this, -1, message);
|
|
|
|
mainSizer->Add(statText, 0, wxALIGN_LEFT|wxALL, 5);
|
2014-06-03 20:30:19 +00:00
|
|
|
|
2016-02-18 19:53:43 +00:00
|
|
|
wxButton *help = safenew wxButton(this, wxID_HELP, _("Help"));
|
|
|
|
hSizer->Add(help, 0, wxALIGN_LEFT|wxALL, 5);
|
2013-02-23 04:33:20 +00:00
|
|
|
|
2016-02-18 19:53:43 +00:00
|
|
|
wxButton *ok = safenew wxButton(this, wxID_OK, _("OK"));
|
|
|
|
ok->SetDefault();
|
|
|
|
ok->SetFocus();
|
|
|
|
hSizer->Add(ok, 0, wxALIGN_RIGHT|wxALL, 5);
|
2013-02-23 04:33:20 +00:00
|
|
|
|
2016-02-18 19:53:43 +00:00
|
|
|
vSizer->Add(hSizer.release(), 0, wxALIGN_CENTER|wxALL, 5);
|
2014-06-03 20:30:19 +00:00
|
|
|
|
2016-02-18 19:53:43 +00:00
|
|
|
mainSizer->Add(vSizer.release(), 0, wxALL, 15 );
|
2014-06-03 20:30:19 +00:00
|
|
|
|
2016-02-18 19:53:43 +00:00
|
|
|
SetAutoLayout(true);
|
|
|
|
SetSizer(uMainSizer.release());
|
|
|
|
}
|
2014-06-03 20:30:19 +00:00
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
mainSizer->Fit(this);
|
|
|
|
mainSizer->SetSizeHints(this);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2013-08-25 21:51:26 +00:00
|
|
|
void ErrorDialog::OnOk(wxCommandEvent & WXUNUSED(event))
|
2011-03-01 01:29:03 +00:00
|
|
|
{
|
|
|
|
if (dModal)
|
|
|
|
EndModal(true);
|
|
|
|
else
|
|
|
|
Destroy();
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-08-25 21:51:26 +00:00
|
|
|
void ErrorDialog::OnHelp(wxCommandEvent & WXUNUSED(event))
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2017-08-25 12:54:37 +00:00
|
|
|
if( dhelpPage.StartsWith(wxT("innerlink:")) )
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2014-06-09 18:42:19 +00:00
|
|
|
HelpSystem::ShowHtmlText(
|
2014-06-03 20:30:19 +00:00
|
|
|
this,
|
2017-08-25 12:54:37 +00:00
|
|
|
TitleText(dhelpPage.Mid( 10 ) ),
|
|
|
|
HelpText( dhelpPage.Mid( 10 )),
|
2010-01-23 19:44:49 +00:00
|
|
|
false,
|
|
|
|
true );
|
|
|
|
return;
|
|
|
|
}
|
2017-08-25 12:54:37 +00:00
|
|
|
HelpSystem::ShowHelp( this, dhelpPage, dClose );
|
|
|
|
//OpenInDefaultBrowser( dhelpURL );
|
2010-12-11 22:32:07 +00:00
|
|
|
if(dClose)
|
2013-02-23 04:33:20 +00:00
|
|
|
EndModal(true);
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ShowErrorDialog(wxWindow *parent,
|
|
|
|
const wxString &dlogTitle,
|
2013-02-22 21:29:19 +00:00
|
|
|
const wxString &message,
|
2017-08-25 12:54:37 +00:00
|
|
|
const wxString &helpPage,
|
2010-12-11 22:32:07 +00:00
|
|
|
const bool Close)
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2017-08-25 12:54:37 +00:00
|
|
|
ErrorDialog dlog(parent, dlogTitle, message, helpPage, Close);
|
2010-01-23 19:44:49 +00:00
|
|
|
dlog.CentreOnParent();
|
|
|
|
dlog.ShowModal();
|
|
|
|
}
|
|
|
|
|
2017-08-25 12:54:37 +00:00
|
|
|
|
|
|
|
// unused.
|
2011-03-01 01:29:03 +00:00
|
|
|
void ShowModelessErrorDialog(wxWindow *parent,
|
2013-02-22 21:29:19 +00:00
|
|
|
const wxString &dlogTitle,
|
|
|
|
const wxString &message,
|
2017-08-25 12:54:37 +00:00
|
|
|
const wxString &helpPage,
|
2013-02-22 21:29:19 +00:00
|
|
|
const bool Close)
|
2011-03-01 01:29:03 +00:00
|
|
|
{
|
2017-08-25 12:54:37 +00:00
|
|
|
// ensure it has some parent.
|
|
|
|
if( !parent )
|
|
|
|
parent = wxTheApp->GetTopWindow();
|
2016-08-14 03:16:05 +00:00
|
|
|
wxASSERT(parent);
|
2017-08-25 12:54:37 +00:00
|
|
|
ErrorDialog *dlog = safenew ErrorDialog(parent, dlogTitle, message, helpPage, Close, false);
|
2011-03-01 01:29:03 +00:00
|
|
|
dlog->CentreOnParent();
|
|
|
|
dlog->Show();
|
2017-08-25 12:54:37 +00:00
|
|
|
// ANSWER-ME: Vigilant Sentry flagged this method as not deleting dlog, so
|
|
|
|
// is this actually a mem leak.
|
2016-08-08 13:54:53 +00:00
|
|
|
// PRL: answer is that the parent window guarantees destruction of the dialog
|
|
|
|
// but in practice Destroy() in OnOK does that
|
2011-03-01 01:29:03 +00:00
|
|
|
}
|
|
|
|
|
2011-04-02 13:03:02 +00:00
|
|
|
void ShowAliasMissingDialog(AudacityProject *parent,
|
2013-02-22 21:29:19 +00:00
|
|
|
const wxString &dlogTitle,
|
|
|
|
const wxString &message,
|
2017-08-25 12:54:37 +00:00
|
|
|
const wxString &helpPage,
|
2013-02-22 21:29:19 +00:00
|
|
|
const bool Close)
|
2011-03-23 01:01:17 +00:00
|
|
|
{
|
2016-08-14 03:16:05 +00:00
|
|
|
wxASSERT(parent); // to justify safenew
|
2017-08-25 12:54:37 +00:00
|
|
|
ErrorDialog *dlog = safenew AliasedFileMissingDialog(parent, dlogTitle, message, helpPage, Close, false);
|
2011-03-23 01:01:17 +00:00
|
|
|
// Don't center because in many cases (effect, export, etc) there will be a progress bar in the center that blocks this.
|
|
|
|
// instead put it just above or on the top of the project.
|
|
|
|
wxPoint point;
|
|
|
|
point.x = 0;
|
2014-06-03 20:30:19 +00:00
|
|
|
|
2011-03-23 01:01:17 +00:00
|
|
|
point.y = parent ? parent->GetPosition().y - 200 : 100;
|
2014-06-03 20:30:19 +00:00
|
|
|
|
2011-03-23 01:01:17 +00:00
|
|
|
if (point.y < 100)
|
|
|
|
point.y = 100;
|
|
|
|
dlog->SetPosition(point);
|
|
|
|
dlog->CentreOnParent(wxHORIZONTAL);
|
2012-02-08 05:09:14 +00:00
|
|
|
|
2014-06-12 18:29:09 +00:00
|
|
|
// This needs to be modeless because user may need to
|
|
|
|
// stop playback AND read dialog's instructions.
|
2011-03-23 01:01:17 +00:00
|
|
|
dlog->Show();
|
2014-06-03 20:30:19 +00:00
|
|
|
// ANSWER-ME: Vigilant Sentry flags this method as not deleting dlog, so a mem leak.
|
2016-08-08 13:54:53 +00:00
|
|
|
// PRL: answer is that the parent window guarantees destruction of the dialog
|
|
|
|
// but in practice Destroy() in OnOK does that
|
2011-03-23 01:01:17 +00:00
|
|
|
}
|
2017-09-06 21:39:33 +00:00
|
|
|
|
|
|
|
extern wxString AudacityMessageBoxCaptionStr()
|
|
|
|
{
|
|
|
|
return _("Message");
|
|
|
|
}
|
2018-03-21 14:16:05 +00:00
|
|
|
|
|
|
|
void AudacityTextEntryDialog::SetInsertionPointEnd()
|
|
|
|
{
|
|
|
|
// m_textctrl is protected member of wxTextEntryDialog
|
|
|
|
m_textctrl->SetInsertionPointEnd();
|
|
|
|
}
|