2010-01-23 19:44:49 +00:00
|
|
|
/**********************************************************************
|
|
|
|
|
|
|
|
Audacity: A Digital Audio Editor
|
|
|
|
|
|
|
|
ErrorDialog.cpp
|
|
|
|
|
|
|
|
Jimmy Johnson
|
|
|
|
Leland Lucius
|
|
|
|
|
|
|
|
*******************************************************************//**
|
|
|
|
|
|
|
|
\class ErrorDialog
|
|
|
|
Gives an Error message with an option for help.
|
|
|
|
|
|
|
|
*//********************************************************************/
|
|
|
|
|
|
|
|
#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.
|
|
|
|
class AliasedFileMissingDialog : public ErrorDialog
|
|
|
|
{
|
|
|
|
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();
|
|
|
|
};
|
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
BEGIN_EVENT_TABLE(ErrorDialog, wxDialog)
|
|
|
|
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,
|
2010-12-11 22:32:07 +00:00
|
|
|
const wxString & helpURL,
|
2011-03-01 01:29:03 +00:00
|
|
|
const bool Close, const bool modal):
|
2010-01-23 19:44:49 +00:00
|
|
|
wxDialog(parent, (wxWindowID)-1, dlogTitle)
|
|
|
|
{
|
2011-03-06 18:07:12 +00:00
|
|
|
long buttonMask;
|
|
|
|
|
|
|
|
// only add the help button if we have a URL
|
|
|
|
buttonMask = (helpURL == wxT("")) ? eOkButton : (eHelpButton | eOkButton);
|
2010-01-23 19:44:49 +00:00
|
|
|
dhelpURL = helpURL;
|
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();
|
|
|
|
Fit();
|
|
|
|
SetMinSize(GetSize());
|
|
|
|
Center();
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
// Original non ShuttleGui based code.
|
|
|
|
// Layout did not look good on Windows.
|
|
|
|
wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL);
|
|
|
|
wxBoxSizer *vSizer = new wxBoxSizer(wxVERTICAL);
|
2014-06-03 20:30:19 +00:00
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
wxBoxSizer *hSizer = new wxBoxSizer(wxHORIZONTAL);
|
2014-06-03 20:30:19 +00:00
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
wxStaticText *statText = new wxStaticText(this, -1, message);
|
|
|
|
mainSizer->Add(statText, 0, wxALIGN_LEFT|wxALL, 5);
|
2013-02-23 04:33:20 +00:00
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
wxButton *help = new wxButton(this, wxID_HELP, _("Help"));
|
|
|
|
hSizer->Add(help, 0, wxALIGN_LEFT|wxALL, 5);
|
2013-02-23 04:33:20 +00:00
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
wxButton *ok = new wxButton(this, wxID_OK, _("OK"));
|
|
|
|
ok->SetDefault();
|
|
|
|
ok->SetFocus();
|
2013-02-23 04:33:20 +00:00
|
|
|
hSizer->Add(ok, 0, wxALIGN_RIGHT|wxALL, 5);
|
2014-06-03 20:30:19 +00:00
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
vSizer->Add(hSizer, 0, wxALIGN_CENTER|wxALL, 5);
|
2014-06-03 20:30:19 +00:00
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
mainSizer->Add(vSizer, 0, wxALL, 15 );
|
2014-06-03 20:30:19 +00:00
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
SetAutoLayout(true);
|
|
|
|
SetSizer(mainSizer);
|
|
|
|
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
|
|
|
{
|
|
|
|
if( dhelpURL.StartsWith(wxT("innerlink:")) )
|
|
|
|
{
|
2014-06-09 18:42:19 +00:00
|
|
|
HelpSystem::ShowHtmlText(
|
2014-06-03 20:30:19 +00:00
|
|
|
this,
|
2010-01-23 19:44:49 +00:00
|
|
|
TitleText(dhelpURL.Mid( 10 ) ),
|
|
|
|
HelpText( dhelpURL.Mid( 10 )),
|
|
|
|
false,
|
|
|
|
true );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
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,
|
2010-12-11 22:32:07 +00:00
|
|
|
const wxString &helpURL,
|
|
|
|
const bool Close)
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2010-12-11 22:32:07 +00:00
|
|
|
ErrorDialog dlog(parent, dlogTitle, message, helpURL, Close);
|
2010-01-23 19:44:49 +00:00
|
|
|
dlog.CentreOnParent();
|
|
|
|
dlog.ShowModal();
|
|
|
|
}
|
|
|
|
|
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,
|
|
|
|
const wxString &helpURL,
|
|
|
|
const bool Close)
|
2011-03-01 01:29:03 +00:00
|
|
|
{
|
|
|
|
ErrorDialog *dlog = new ErrorDialog(parent, dlogTitle, message, helpURL, Close, false);
|
|
|
|
dlog->CentreOnParent();
|
|
|
|
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.
|
2012-02-08 05:09:14 +00:00
|
|
|
// ANSWER-ME: This is unused. Delete it or are there plans for it?
|
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,
|
|
|
|
const wxString &helpURL,
|
|
|
|
const bool Close)
|
2011-03-23 01:01:17 +00:00
|
|
|
{
|
|
|
|
ErrorDialog *dlog = new AliasedFileMissingDialog(parent, dlogTitle, message, helpURL, Close, false);
|
|
|
|
// 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.
|
2011-03-23 01:01:17 +00:00
|
|
|
}
|