From cf4b9eb5c82dca2a329cc1c170818c843f54793f Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Thu, 12 Oct 2017 15:23:52 -0400 Subject: [PATCH] Define wxDirDialogWrapper, with localized default prompt and name --- src/Screenshot.cpp | 2 +- src/export/ExportMultiple.cpp | 2 +- src/prefs/DirectoriesPrefs.cpp | 2 +- src/widgets/wxPanelWrapper.h | 37 ++++++++++++++++++++++++++++++++++ 4 files changed, 40 insertions(+), 3 deletions(-) diff --git a/src/Screenshot.cpp b/src/Screenshot.cpp index e6408b316..c56d921ba 100644 --- a/src/Screenshot.cpp +++ b/src/Screenshot.cpp @@ -531,7 +531,7 @@ void ScreenFrame::OnDirChoose(wxCommandEvent & WXUNUSED(event)) { wxString current = mDirectoryTextBox->GetValue(); - wxDirDialog dlog(this, + wxDirDialogWrapper dlog(this, _("Choose a location to save screenshot images"), current); diff --git a/src/export/ExportMultiple.cpp b/src/export/ExportMultiple.cpp index 56cf4cfd3..ff4dc9426 100644 --- a/src/export/ExportMultiple.cpp +++ b/src/export/ExportMultiple.cpp @@ -480,7 +480,7 @@ void ExportMultiple::OnCreate(wxCommandEvent& WXUNUSED(event)) void ExportMultiple::OnChoose(wxCommandEvent& WXUNUSED(event)) { - wxDirDialog dlog(this, + wxDirDialogWrapper dlog(this, _("Choose a location to save the exported files"), mDir->GetValue()); dlog.ShowModal(); diff --git a/src/prefs/DirectoriesPrefs.cpp b/src/prefs/DirectoriesPrefs.cpp index ce7bd3e62..40a60b1c8 100644 --- a/src/prefs/DirectoriesPrefs.cpp +++ b/src/prefs/DirectoriesPrefs.cpp @@ -135,7 +135,7 @@ void DirectoriesPrefs::OnChooseTempDir(wxCommandEvent & e) if( !AudacityApp::IsTempDirectoryNameOK( oldTempDir ) ) oldTempDir = wxGetApp().defaultTempDir; - wxDirDialog dlog(this, + wxDirDialogWrapper dlog(this, _("Choose a location to place the temporary directory"), oldTempDir ); int retval = dlog.ShowModal(); diff --git a/src/widgets/wxPanelWrapper.h b/src/widgets/wxPanelWrapper.h index 6ae1bbfb9..bf7961ad2 100644 --- a/src/widgets/wxPanelWrapper.h +++ b/src/widgets/wxPanelWrapper.h @@ -100,4 +100,41 @@ public: } }; +#include + +class wxDirDialogWrapper : public wxTabTraversalWrapper +{ +public: + wxDirDialogWrapper() {} + + // Constructor with no modal flag - the new convention. + wxDirDialogWrapper( + wxWindow *parent, + const wxString& message = _("Select a directory"), + const wxString& defaultPath = wxT(""), + long style = wxDD_DEFAULT_STYLE, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + // Important: default window name localizes! + const wxString& name = _("Directory Dialog")) + : wxTabTraversalWrapper + { parent, message, defaultPath, style, pos, size, name } + {} + + void Create( + wxWindow *parent, + const wxString& message = _("Select a directory"), + const wxString& defaultPath = wxT(""), + long style = wxDD_DEFAULT_STYLE, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + // Important: default window name localizes! + const wxString& name = _("Directory Dialog")) + { + return wxTabTraversalWrapper::Create( + parent, message, defaultPath, style, pos, size, name + ); + } +}; + #endif