diff --git a/src/Menus.cpp b/src/Menus.cpp index 643fb318f..42a011933 100644 --- a/src/Menus.cpp +++ b/src/Menus.cpp @@ -44,6 +44,7 @@ simplifies construction of menu items. #include #include #include +#include #include "Project.h" #include "effects/EffectManager.h" @@ -5421,28 +5422,11 @@ void AudacityProject::OnScreenshot() void AudacityProject::OnAudioDeviceInfo() { wxString info = gAudioIO->GetDeviceInfo(); - wxTextCtrl *tc; - - wxDialog dlg(this, wxID_ANY, - wxString(wxT("Audio Device Info")), - wxDefaultPosition, wxDefaultSize, - wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ); - - ShuttleGui S(&dlg, eIsCreating); - - S.StartHorizontalLay(wxEXPAND, true); - { - S.SetStyle( wxTE_MULTILINE | wxTE_READONLY | wxTE_RICH | wxTE_RICH2 | - wxTE_AUTO_URL | wxTE_NOHIDESEL | wxHSCROLL ); - tc = S.AddTextWindow(wxT("")); - tc->WriteText(info); - } - S.EndHorizontalLay(); - - S.AddStandardButtons(eOkButton); - - dlg.Center(); - dlg.ShowModal(); + ShowInfoDialog( this, + _("Audio Device Info"), + wxT(""), + info, + 350,450); } void AudacityProject::OnSeparator() diff --git a/src/ShuttleGui.cpp b/src/ShuttleGui.cpp index 654fb1ec2..acb86c60c 100644 --- a/src/ShuttleGui.cpp +++ b/src/ShuttleGui.cpp @@ -521,6 +521,9 @@ wxTextCtrl * ShuttleGuiBase::AddTextWindow(const wxString &Value) mpWind = pTextCtrl = new wxTextCtrl(mpParent, miId, Value, wxDefaultPosition, wxDefaultSize, Style( wxTE_MULTILINE )); UpdateSizers(); + // Start off at start of window... + pTextCtrl->SetInsertionPoint( 0 ); + pTextCtrl->ShowPosition( 0 ); return pTextCtrl; } diff --git a/src/effects/nyquist/Nyquist.cpp b/src/effects/nyquist/Nyquist.cpp index c8ca23e7a..05998839d 100644 --- a/src/effects/nyquist/Nyquist.cpp +++ b/src/effects/nyquist/Nyquist.cpp @@ -1278,12 +1278,8 @@ NyquistOutputDialog::NyquistOutputDialog(wxWindow * parent, wxWindowID id, item = new wxStaticText(this, -1, prompt); mainSizer->Add(item, 0, wxALIGN_LEFT | wxLEFT | wxTOP | wxRIGHT, 10); - // TODO: Convert this to using ShuttleGui. - // using S.AddTextWindow(); - // TODO: Consider using: - // wxTE_MULTILINE | wxTE_READONLY | wxTE_RICH | wxTE_RICH2 | - // wxTE_AUTO_URL | wxTE_NOHIDESEL | wxHSCROLL - // Haven't made this change as this dialog MUST work with screen readers. + // TODO use ShowInfoDialog() instead. + // Beware this dialog MUST work with screen readers. item = new wxTextCtrl(this, -1, message, wxDefaultPosition, wxSize(400, 200), wxTE_MULTILINE | wxTE_READONLY); diff --git a/src/export/ExportCL.cpp b/src/export/ExportCL.cpp index 8d00b3d74..8b3da1024 100644 --- a/src/export/ExportCL.cpp +++ b/src/export/ExportCL.cpp @@ -418,6 +418,7 @@ int ExportCL::Export(AudacityProject *project, // Display output on error or if the user wants to see it if (p->GetStatus() != 0 || show) { + // TODO use ShowInfoDialog() instead. wxDialog dlg(NULL, wxID_ANY, wxString(_("Command Output")), diff --git a/src/export/ExportMultiple.cpp b/src/export/ExportMultiple.cpp index d33bbca19..e827afc86 100644 --- a/src/export/ExportMultiple.cpp +++ b/src/export/ExportMultiple.cpp @@ -47,6 +47,7 @@ #include "../Project.h" #include "../Prefs.h" #include "../Tags.h" +#include "../widgets/ErrorDialog.h" /* define our dynamic array of export settings */ @@ -534,30 +535,17 @@ void ExportMultiple::OnExport(wxCommandEvent& event) ) ), mExported.GetCount()); - // This results dialog is a child of this dialog. - SuccessDialog dlg(this, - wxID_ANY, - wxString(_("Export Multiple")) ); - ShuttleGui S(&dlg, eIsCreating); - - S.StartVerticalLay(); - { - S.AddTitle(msg); - wxString FileList; - for (size_t i = 0; i < mExported.GetCount(); i++) { - FileList += mExported[i]; - FileList += '\n'; - } - S.SetStyle( wxTE_MULTILINE | wxTE_READONLY | wxTE_RICH | wxTE_RICH2 | - wxTE_AUTO_URL | wxTE_NOHIDESEL | wxHSCROLL ); - S.AddTextWindow( FileList ); - S.AddStandardButtons(eOkButton); + wxString FileList; + for (size_t i = 0; i < mExported.GetCount(); i++) { + FileList += mExported[i]; + FileList += '\n'; } - S.EndVerticalLay(); - dlg.SetMinSize( wxSize(125,200) ); - dlg.SetSize( wxSize(450,400) ); - dlg.Center(); - dlg.ShowModal(); + // This results dialog is a child of this dialog. + ShowInfoDialog( this, + _("Export Multiple"), + msg, + FileList, + 450,400); } if (ok == eProgressSuccess || ok == eProgressStopped) { diff --git a/src/widgets/ErrorDialog.cpp b/src/widgets/ErrorDialog.cpp index e03079e29..f1e624bb5 100644 --- a/src/widgets/ErrorDialog.cpp +++ b/src/widgets/ErrorDialog.cpp @@ -247,6 +247,49 @@ void ShowErrorDialog(wxWindow *parent, } +/// Mostly we use this so that we have the code for resizability +/// in one place. Other considerations like screen readers are also +/// handled by having the code in one place. +void ShowInfoDialog( wxWindow *parent, + const wxString &dlogTitle, + const wxString &shortMsg, + const wxString &message, + const int xSize, const int ySize) +{ + wxDialog dlog(parent, wxID_ANY, + dlogTitle, + wxDefaultPosition, wxDefaultSize, + wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMAXIMIZE_BOX /*| wxDEFAULT_FRAME_STYLE */); + + ShuttleGui S(&dlog, eIsCreating); + + S.StartVerticalLay(1); + { + S.AddTitle( shortMsg); + S.SetStyle( wxTE_MULTILINE | wxTE_READONLY | wxTE_RICH | wxTE_RICH2 | + wxTE_AUTO_URL | wxTE_NOHIDESEL | wxHSCROLL ); + S.AddTextWindow(message); + } + S.SetBorder( 0 ); + S.StartHorizontalLay(wxALIGN_RIGHT|wxALIGN_BOTTOM, 0); + S.AddStandardButtons(eOkButton); + + // Next three lines add a tiny dragger. + wxStatusBar * pBar = new wxStatusBar( &dlog ); + pBar->SetSize( 18, 38); + S.AddWindow( pBar, wxALIGN_BOTTOM|wxALIGN_RIGHT ); + + S.EndHorizontalLay(); + S.EndVerticalLay(); + + // Smallest size is half default size. Seems reasonable. + dlog.SetMinSize( wxSize(xSize/2, ySize/2) ); + dlog.SetSize( wxSize(xSize, ySize) ); + dlog.Center(); + dlog.ShowModal(); +} + + void ShowHelpDialog(wxWindow *parent, const wxString &localFileName, const wxString &remoteURL) diff --git a/src/widgets/ErrorDialog.h b/src/widgets/ErrorDialog.h index 38b5e8da4..cbb9649aa 100644 --- a/src/widgets/ErrorDialog.h +++ b/src/widgets/ErrorDialog.h @@ -5,6 +5,7 @@ ErrorDialog.h Jimmy Johnson + James Crook **********************************************************************/ @@ -19,7 +20,14 @@ void ShowErrorDialog(wxWindow *parent, const wxString &dlogTitle, const wxString &message, - const wxString &helpURL); + const wxString &helpURL); + +/// Displays cutable information in a text ctrl, with an OK button. +void ShowInfoDialog( wxWindow *parent, + const wxString &dlogTitle, + const wxString &shortMsg, + const wxString &message, + const int xSize, const int ySize); /// Displays a new window with wxHTML help. void ShowHtmlText( wxWindow * pParent,