mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-22 15:38:02 +02:00
Move AudacityTextEntryDialog out of ErrorDialog.h...
... Because what's in ErrorDialog needs to hide behind the facade, but AudacityTextEntryDialog doesn't, yet
This commit is contained in:
parent
f39973bf19
commit
062abdde5d
@ -58,8 +58,8 @@
|
||||
#include "widgets/FileDialog/FileDialog.h"
|
||||
#include "FileNames.h"
|
||||
#include "import/Import.h"
|
||||
#include "widgets/ErrorDialog.h"
|
||||
#include "widgets/AudacityMessageBox.h"
|
||||
#include "widgets/AudacityTextEntryDialog.h"
|
||||
#include "widgets/HelpSystem.h"
|
||||
|
||||
#if wxUSE_ACCESSIBILITY
|
||||
|
@ -914,6 +914,8 @@ list( APPEND SOURCES
|
||||
widgets/AttachableScrollBar.h
|
||||
widgets/AudacityMessageBox.cpp
|
||||
widgets/AudacityMessageBox.h
|
||||
widgets/AudacityTextEntryDialog.cpp
|
||||
widgets/AudacityTextEntryDialog.h
|
||||
widgets/BackedPanel.cpp
|
||||
widgets/BackedPanel.h
|
||||
widgets/ErrorDialog.cpp
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include "Project.h"
|
||||
#include "ProjectFileIO.h"
|
||||
#include "prefs/GUIPrefs.h"
|
||||
#include "widgets/ErrorDialog.h"
|
||||
#include "widgets/AudacityTextEntryDialog.h"
|
||||
|
||||
namespace CrashReport {
|
||||
|
||||
|
@ -37,7 +37,7 @@
|
||||
#include "ViewInfo.h"
|
||||
#include "tracks/labeltrack/ui/LabelTrackView.h"
|
||||
#include "widgets/AudacityMessageBox.h"
|
||||
#include "widgets/ErrorDialog.h"
|
||||
#include "widgets/AudacityTextEntryDialog.h"
|
||||
#include "widgets/Grid.h"
|
||||
#include "widgets/HelpSystem.h"
|
||||
|
||||
|
@ -44,7 +44,6 @@ Paul Licameli split from AudacityProject.cpp
|
||||
#include "toolbars/ToolManager.h"
|
||||
#include "widgets/AudacityMessageBox.h"
|
||||
#include "widgets/FileHistory.h"
|
||||
#include "widgets/ErrorDialog.h"
|
||||
#include "widgets/WindowAccessible.h"
|
||||
|
||||
#include <wx/dataobj.h>
|
||||
|
@ -51,7 +51,6 @@
|
||||
#include "widgets/NumericTextCtrl.h"
|
||||
#include "widgets/HelpSystem.h"
|
||||
#include "widgets/AudacityMessageBox.h"
|
||||
#include "widgets/ErrorDialog.h"
|
||||
#include "widgets/ProgressDialog.h"
|
||||
#include "widgets/wxTextCtrlWrapper.h"
|
||||
|
||||
|
@ -31,7 +31,7 @@ or "OFF" point
|
||||
|
||||
#include "WaveTrack.h"
|
||||
#include "widgets/AudacityMessageBox.h"
|
||||
#include "widgets/ErrorDialog.h"
|
||||
#include "widgets/wxPanelWrapper.h"
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
@ -25,7 +25,6 @@
|
||||
#include "../widgets/HelpSystem.h"
|
||||
#include "../widgets/NumericTextCtrl.h"
|
||||
#include "../widgets/AudacityMessageBox.h"
|
||||
#include "../widgets/ErrorDialog.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <limits>
|
||||
@ -40,6 +39,7 @@
|
||||
#include <wx/log.h>
|
||||
#include <wx/wfstream.h>
|
||||
#include <wx/txtstrm.h>
|
||||
#include <wx/textctrl.h>
|
||||
|
||||
#include "../PlatformCompatibility.h"
|
||||
|
||||
|
@ -93,7 +93,6 @@
|
||||
#include "../FileNames.h"
|
||||
#include "../Envelope.h"
|
||||
#include "../EnvelopeEditor.h"
|
||||
#include "../widgets/ErrorDialog.h"
|
||||
#include "../FFT.h"
|
||||
#include "../Prefs.h"
|
||||
#include "../Project.h"
|
||||
@ -103,6 +102,7 @@
|
||||
#include "../ViewInfo.h"
|
||||
#include "../WaveTrack.h"
|
||||
#include "../widgets/Ruler.h"
|
||||
#include "../widgets/AudacityTextEntryDialog.h"
|
||||
#include "../xml/XMLFileReader.h"
|
||||
#include "../AllThemeResources.h"
|
||||
#include "../float_cast.h"
|
||||
|
@ -38,7 +38,6 @@ function.
|
||||
#include "../Tags.h"
|
||||
#include "../Track.h"
|
||||
#include "../widgets/AudacityMessageBox.h"
|
||||
#include "../widgets/ErrorDialog.h"
|
||||
#include "../widgets/ProgressDialog.h"
|
||||
#include "../wxFileNameWrapper.h"
|
||||
|
||||
|
@ -49,7 +49,7 @@
|
||||
#include "../WaveTrack.h"
|
||||
#include "../widgets/HelpSystem.h"
|
||||
#include "../widgets/AudacityMessageBox.h"
|
||||
#include "../widgets/ErrorDialog.h"
|
||||
#include "../widgets/AudacityTextEntryDialog.h"
|
||||
#include "../widgets/ProgressDialog.h"
|
||||
|
||||
|
||||
|
@ -67,7 +67,6 @@
|
||||
#include "../ProjectWindow.h"
|
||||
#include "../Track.h"
|
||||
#include "../widgets/AButton.h"
|
||||
#include "../widgets/ErrorDialog.h"
|
||||
#include "../FileNames.h"
|
||||
|
||||
#include "../tracks/ui/Scrubbing.h"
|
||||
|
@ -32,7 +32,7 @@ Paul Licameli split from TrackPanel.cpp
|
||||
#include "../../../TrackPanelMouseEvent.h"
|
||||
#include "../../../UndoManager.h"
|
||||
#include "../../../ViewInfo.h"
|
||||
#include "../../../widgets/ErrorDialog.h"
|
||||
#include "../../../widgets/AudacityTextEntryDialog.h"
|
||||
|
||||
#include <wx/clipbrd.h>
|
||||
#include <wx/dcclient.h>
|
||||
|
@ -1,203 +1,14 @@
|
||||
/**********************************************************************
|
||||
/*!********************************************************************
|
||||
|
||||
Audacity: A Digital Audio Editor
|
||||
|
||||
@file AudacityTextEntryDialog.cpp
|
||||
|
||||
Paul Licameli split from ErrorDialog.cpp
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
Audacity: A Digital Audio Editor
|
||||
|
||||
ErrorDialog.cpp
|
||||
|
||||
Jimmy Johnson
|
||||
Leland Lucius
|
||||
|
||||
*******************************************************************//**
|
||||
|
||||
\class ErrorDialog
|
||||
\brief Gives an Error message with an option for help.
|
||||
|
||||
*//********************************************************************/
|
||||
|
||||
|
||||
#include "ErrorDialog.h"
|
||||
|
||||
#include <wx/app.h>
|
||||
#include <wx/button.h>
|
||||
#include <wx/collpane.h>
|
||||
#include <wx/icon.h>
|
||||
#include <wx/dialog.h>
|
||||
#include <wx/intl.h>
|
||||
#include <wx/sizer.h>
|
||||
#include <wx/statbmp.h>
|
||||
#include <wx/stattext.h>
|
||||
#include <wx/utils.h>
|
||||
#include <wx/html/htmlwin.h>
|
||||
#include <wx/settings.h>
|
||||
#include <wx/statusbr.h>
|
||||
#include <wx/artprov.h>
|
||||
|
||||
#include "../AllThemeResources.h"
|
||||
#include "CodeConversions.h"
|
||||
#include "../ShuttleGui.h"
|
||||
#include "../HelpText.h"
|
||||
#include "../Prefs.h"
|
||||
#include "HelpSystem.h"
|
||||
|
||||
#ifdef HAS_SENTRY_REPORTING
|
||||
# include "ErrorReportDialog.h"
|
||||
#endif
|
||||
|
||||
BEGIN_EVENT_TABLE(ErrorDialog, wxDialogWrapper)
|
||||
EVT_COLLAPSIBLEPANE_CHANGED( wxID_ANY, ErrorDialog::OnPane )
|
||||
EVT_BUTTON( wxID_OK, ErrorDialog::OnOk)
|
||||
EVT_BUTTON( wxID_HELP, ErrorDialog::OnHelp)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
ErrorDialog::ErrorDialog(
|
||||
wxWindow *parent,
|
||||
const TranslatableString & dlogTitle,
|
||||
const TranslatableString & message,
|
||||
const ManualPageID & helpPage,
|
||||
const std::wstring & log,
|
||||
const bool Close, const bool modal)
|
||||
: wxDialogWrapper(parent, wxID_ANY, dlogTitle,
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
|
||||
{
|
||||
SetName();
|
||||
|
||||
long buttonMask;
|
||||
|
||||
// only add the help button if we have a URL
|
||||
buttonMask = (helpPage.empty()) ? eOkButton : (eHelpButton | eOkButton);
|
||||
dhelpPage = helpPage;
|
||||
dClose = Close;
|
||||
dModal = modal;
|
||||
|
||||
ShuttleGui S(this, eIsCreating);
|
||||
|
||||
S.SetBorder(2);
|
||||
S.StartHorizontalLay(wxEXPAND, 0);
|
||||
{
|
||||
S.SetBorder(20);
|
||||
wxBitmap bitmap = wxArtProvider::GetBitmap(wxART_WARNING);
|
||||
S.AddWindow(safenew wxStaticBitmap(S.GetParent(), -1, bitmap));
|
||||
|
||||
S.SetBorder(20);
|
||||
S.AddFixedText(message, false, 500);
|
||||
}
|
||||
S.EndHorizontalLay();
|
||||
|
||||
S.SetBorder(2);
|
||||
if (!log.empty())
|
||||
{
|
||||
S.StartHorizontalLay(wxEXPAND, 1);
|
||||
{
|
||||
S.SetBorder(5);
|
||||
|
||||
auto pane = safenew wxCollapsiblePane(S.GetParent(),
|
||||
wxID_ANY,
|
||||
XO("Show &Log...").Translation());
|
||||
S.Style(wxEXPAND | wxALIGN_LEFT);
|
||||
S.Prop(1);
|
||||
S.AddWindow(pane);
|
||||
|
||||
ShuttleGui SI(pane->GetPane(), eIsCreating);
|
||||
auto text = SI.AddTextWindow(log);
|
||||
text->SetInsertionPointEnd();
|
||||
text->ShowPosition(text->GetLastPosition());
|
||||
text->SetMinSize(wxSize(700, 250));
|
||||
}
|
||||
S.EndHorizontalLay();
|
||||
}
|
||||
|
||||
S.SetBorder(2);
|
||||
S.AddStandardButtons(buttonMask);
|
||||
|
||||
Layout();
|
||||
GetSizer()->Fit(this);
|
||||
SetMinSize(GetSize());
|
||||
Center();
|
||||
}
|
||||
|
||||
void ErrorDialog::OnPane(wxCollapsiblePaneEvent & event)
|
||||
{
|
||||
if (!event.GetCollapsed())
|
||||
{
|
||||
Center();
|
||||
}
|
||||
}
|
||||
|
||||
void ErrorDialog::OnOk(wxCommandEvent & WXUNUSED(event))
|
||||
{
|
||||
if (dModal)
|
||||
EndModal(true);
|
||||
else
|
||||
Destroy();
|
||||
}
|
||||
|
||||
void ErrorDialog::OnHelp(wxCommandEvent & WXUNUSED(event))
|
||||
{
|
||||
const auto &str = dhelpPage.GET();
|
||||
if( str.StartsWith(wxT("innerlink:")) )
|
||||
{
|
||||
HelpSystem::ShowHtmlText(
|
||||
this,
|
||||
TitleText(str.Mid( 10 ) ),
|
||||
HelpText( str.Mid( 10 )),
|
||||
false,
|
||||
true );
|
||||
return;
|
||||
}
|
||||
HelpSystem::ShowHelp( this, dhelpPage, dClose );
|
||||
//OpenInDefaultBrowser( dhelpURL );
|
||||
if(dClose)
|
||||
EndModal(true);
|
||||
}
|
||||
|
||||
void ShowErrorDialog(wxWindow *parent,
|
||||
const TranslatableString &dlogTitle,
|
||||
const TranslatableString &message,
|
||||
const ManualPageID &helpPage,
|
||||
const bool Close,
|
||||
const std::wstring &log)
|
||||
{
|
||||
ErrorDialog dlog(parent, dlogTitle, message, helpPage, log, Close);
|
||||
dlog.CentreOnParent();
|
||||
dlog.ShowModal();
|
||||
}
|
||||
|
||||
|
||||
void ShowExceptionDialog(
|
||||
wxWindow* parent, const TranslatableString& dlogTitle,
|
||||
const TranslatableString& message, const wxString& helpPage, bool Close,
|
||||
const wxString& log)
|
||||
{
|
||||
#ifndef HAS_SENTRY_REPORTING
|
||||
ShowErrorDialog(parent, dlogTitle, message, helpPage, Close,
|
||||
audacity::ToWString(log));
|
||||
#else
|
||||
ShowErrorReportDialog(parent, dlogTitle, message, helpPage,
|
||||
audacity::ToWString(log));
|
||||
#endif // !HAS_SENTRY_REPORTING
|
||||
}
|
||||
|
||||
// unused.
|
||||
void ShowModelessErrorDialog(wxWindow *parent,
|
||||
const TranslatableString &dlogTitle,
|
||||
const TranslatableString &message,
|
||||
const ManualPageID &helpPage,
|
||||
const bool Close,
|
||||
const std::wstring &log)
|
||||
{
|
||||
// ensure it has some parent.
|
||||
if( !parent )
|
||||
parent = wxTheApp->GetTopWindow();
|
||||
wxASSERT(parent);
|
||||
ErrorDialog *dlog = safenew ErrorDialog(parent, dlogTitle, message, helpPage, log, Close, false);
|
||||
dlog->CentreOnParent();
|
||||
dlog->Show();
|
||||
// ANSWER-ME: Vigilant Sentry flagged this method as not deleting dlog, so
|
||||
// is this actually a mem leak.
|
||||
// PRL: answer is that the parent window guarantees destruction of the dialog
|
||||
// but in practice Destroy() in OnOK does that
|
||||
}
|
||||
#include "AudacityTextEntryDialog.h"
|
||||
|
||||
void AudacityTextEntryDialog::SetInsertionPointEnd()
|
||||
{
|
||||
|
@ -1,76 +1,18 @@
|
||||
/**********************************************************************
|
||||
/*!********************************************************************
|
||||
|
||||
Audacity: A Digital Audio Editor
|
||||
|
||||
@file AudacityTextEntryDialog.h
|
||||
|
||||
Paul Licameli split from ErrorDialog.h
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
Audacity: A Digital Audio Editor
|
||||
|
||||
ErrorDialog.h
|
||||
|
||||
Jimmy Johnson
|
||||
James Crook
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef __AUDACITY_ERRORDIALOG__
|
||||
#define __AUDACITY_ERRORDIALOG__
|
||||
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <wx/defs.h>
|
||||
#include <wx/msgdlg.h> // to inherit
|
||||
#include "wxPanelWrapper.h" // to inherit
|
||||
|
||||
class AudacityProject;
|
||||
class wxCollapsiblePaneEvent;
|
||||
|
||||
class ErrorDialog /* not final */ : public wxDialogWrapper
|
||||
{
|
||||
public:
|
||||
// constructors and destructors
|
||||
ErrorDialog(wxWindow *parent,
|
||||
const TranslatableString & dlogTitle,
|
||||
const TranslatableString & message,
|
||||
const ManualPageID & helpPage,
|
||||
const std::wstring & log,
|
||||
const bool Close = true, const bool modal = true);
|
||||
|
||||
virtual ~ErrorDialog(){}
|
||||
|
||||
private:
|
||||
ManualPageID dhelpPage;
|
||||
bool dClose;
|
||||
bool dModal;
|
||||
|
||||
void OnPane( wxCollapsiblePaneEvent &event );
|
||||
void OnOk( wxCommandEvent &event );
|
||||
void OnHelp( wxCommandEvent &event );
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
/// Displays an error dialog with a button that offers help
|
||||
AUDACITY_DLL_API
|
||||
void ShowErrorDialog(wxWindow *parent,
|
||||
const TranslatableString &dlogTitle,
|
||||
const TranslatableString &message,
|
||||
const ManualPageID &helpPage,
|
||||
bool Close = true,
|
||||
const std::wstring &log = {});
|
||||
|
||||
/// Displays an error dialog, possibly allowing to send error report.
|
||||
AUDACITY_DLL_API
|
||||
void ShowExceptionDialog(
|
||||
wxWindow* parent, const TranslatableString& dlogTitle,
|
||||
const TranslatableString& message, const wxString& helpPage,
|
||||
bool Close = true, const wxString& log = {});
|
||||
|
||||
/// Displays a modeless error dialog with a button that offers help
|
||||
void ShowModelessErrorDialog(wxWindow *parent,
|
||||
const TranslatableString &dlogTitle,
|
||||
const TranslatableString &message,
|
||||
const ManualPageID &helpPage,
|
||||
bool Close = true,
|
||||
const std::wstring &log = {});
|
||||
#ifndef __AUDACITY_TEXT_ENTRY_DIALOG__
|
||||
#define __AUDACITY_TEXT_ENTRY_DIALOG__
|
||||
|
||||
#include <wx/textdlg.h> // to inherit
|
||||
#include "wxPanelWrapper.h" // to inherit
|
||||
|
||||
/**************************************************************************//**
|
||||
\class AudacityTextEntryDialog
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include <wx/html/htmlwin.h>
|
||||
#include <wx/settings.h>
|
||||
#include <wx/statusbr.h>
|
||||
#include <wx/textctrl.h>
|
||||
#include <wx/artprov.h>
|
||||
|
||||
#include "../AllThemeResources.h"
|
||||
@ -198,20 +199,3 @@ void ShowModelessErrorDialog(wxWindow *parent,
|
||||
// PRL: answer is that the parent window guarantees destruction of the dialog
|
||||
// but in practice Destroy() in OnOK does that
|
||||
}
|
||||
|
||||
void AudacityTextEntryDialog::SetInsertionPointEnd()
|
||||
{
|
||||
mSetInsertionPointEnd = true;
|
||||
}
|
||||
|
||||
bool AudacityTextEntryDialog::Show(bool show)
|
||||
{
|
||||
bool ret = wxTabTraversalWrapper< wxTextEntryDialog >::Show(show);
|
||||
|
||||
if (show && mSetInsertionPointEnd) {
|
||||
// m_textctrl is protected member of wxTextEntryDialog
|
||||
m_textctrl->SetInsertionPointEnd();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -70,33 +70,4 @@ void ShowModelessErrorDialog(wxWindow *parent,
|
||||
bool Close = true,
|
||||
const std::wstring &log = {});
|
||||
|
||||
#include <wx/textdlg.h> // to inherit
|
||||
|
||||
/**************************************************************************//**
|
||||
\class AudacityTextEntryDialog
|
||||
\brief Wrap wxTextEntryDialog so that caption IS translatable.
|
||||
********************************************************************************/
|
||||
class AUDACITY_DLL_API AudacityTextEntryDialog
|
||||
: public wxTabTraversalWrapper< wxTextEntryDialog >
|
||||
{
|
||||
public:
|
||||
AudacityTextEntryDialog(
|
||||
wxWindow *parent,
|
||||
const TranslatableString& message,
|
||||
const TranslatableString& caption, // don't use = wxGetTextFromUserPromptStr,
|
||||
const wxString& value = {},
|
||||
long style = wxTextEntryDialogStyle,
|
||||
const wxPoint& pos = wxDefaultPosition)
|
||||
: wxTabTraversalWrapper< wxTextEntryDialog>(
|
||||
parent,
|
||||
message.Translation(), caption.Translation(), value, style, pos )
|
||||
{}
|
||||
|
||||
void SetInsertionPointEnd();
|
||||
bool Show(bool show = true) override;
|
||||
|
||||
private:
|
||||
bool mSetInsertionPointEnd{};
|
||||
};
|
||||
|
||||
#endif // __AUDACITY_ERRORDIALOG__
|
||||
|
Loading…
x
Reference in New Issue
Block a user