From e3f54c8f7c20587c81726cd5f4b90e659f818bbe Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 14 Mar 2012 12:32:27 +0000 Subject: [PATCH] Implement wxDirDialog:: and wxFileDialog::Create() in wxGTK. Simply move the code from non-default constructor to Create(). This allows to create the dialogs using 2-step creation if necessary. Closes #14069. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70898 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + include/wx/gtk/dirdlg.h | 8 +++++++- include/wx/gtk/filedlg.h | 9 +++++++++ src/gtk/dirdlg.cpp | 14 +++++++++++++- src/gtk/filedlg.cpp | 17 +++++++++++++++-- 5 files changed, 45 insertions(+), 4 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index ceb551bb94..ef71794515 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -499,6 +499,7 @@ GTK: - Implement support for wxBG_STYLE_TRANSPARENT (Armel Asselin). - Fix wxNotebook best size calculation. +- Implement wxDirDialog::Create() and wxFileDialog::Create() (vinayakgarg). MSW: diff --git a/include/wx/gtk/dirdlg.h b/include/wx/gtk/dirdlg.h index e8f905c67e..fe457b7755 100644 --- a/include/wx/gtk/dirdlg.h +++ b/include/wx/gtk/dirdlg.h @@ -26,7 +26,13 @@ public: const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, const wxString& name = wxDirDialogNameStr); - + bool Create(wxWindow *parent, + const wxString& message = wxDirSelectorPromptStr, + const wxString& defaultPath = wxEmptyString, + long style = wxDD_DEFAULT_STYLE, + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + const wxString& name = wxDirDialogNameStr); virtual ~wxDirDialog() { } diff --git a/include/wx/gtk/filedlg.h b/include/wx/gtk/filedlg.h index 08854018e5..209a098a6e 100644 --- a/include/wx/gtk/filedlg.h +++ b/include/wx/gtk/filedlg.h @@ -30,6 +30,15 @@ public: const wxPoint& pos = wxDefaultPosition, const wxSize& sz = wxDefaultSize, const wxString& name = wxFileDialogNameStr); + bool Create(wxWindow *parent, + const wxString& message = wxFileSelectorPromptStr, + const wxString& defaultDir = wxEmptyString, + const wxString& defaultFile = wxEmptyString, + const wxString& wildCard = wxFileSelectorDefaultWildcardStr, + long style = wxFD_DEFAULT_STYLE, + const wxPoint& pos = wxDefaultPosition, + const wxSize& sz = wxDefaultSize, + const wxString& name = wxFileDialogNameStr); virtual ~wxFileDialog(); virtual wxString GetPath() const; diff --git a/src/gtk/dirdlg.cpp b/src/gtk/dirdlg.cpp index 07cc55c8d1..3843eb3ac5 100644 --- a/src/gtk/dirdlg.cpp +++ b/src/gtk/dirdlg.cpp @@ -98,6 +98,17 @@ wxDirDialog::wxDirDialog(wxWindow* parent, const wxPoint& pos, const wxSize& WXUNUSED(sz), const wxString& WXUNUSED(name)) +{ + Create(parent, title, defaultPath, style, pos); +} + +bool wxDirDialog::Create(wxWindow* parent, + const wxString& title, + const wxString& defaultPath, + long style, + const wxPoint& pos, + const wxSize& WXUNUSED(sz), + const wxString& WXUNUSED(name)) { m_message = title; @@ -108,7 +119,7 @@ wxDirDialog::wxDirDialog(wxWindow* parent, wxDefaultValidator, wxT("dirdialog"))) { wxFAIL_MSG( wxT("wxDirDialog creation failed") ); - return; + return false; } GtkWindow* gtk_parent = NULL; @@ -147,6 +158,7 @@ wxDirDialog::wxDirDialog(wxWindow* parent, if ( !defaultPath.empty() ) gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER(m_widget), defaultPath.fn_str() ); + return true; } void wxDirDialog::OnFakeOk(wxCommandEvent& WXUNUSED(event)) diff --git a/src/gtk/filedlg.cpp b/src/gtk/filedlg.cpp index 85118048ed..b1a370e376 100644 --- a/src/gtk/filedlg.cpp +++ b/src/gtk/filedlg.cpp @@ -174,13 +174,24 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message, const wxSize& sz, const wxString& name) : wxFileDialogBase() +{ + Create(parent, message, defaultDir, defaultFileName, wildCard, style, pos, sz, name); +} + +bool wxFileDialog::Create(wxWindow *parent, const wxString& message, + const wxString& defaultDir, + const wxString& defaultFileName, + const wxString& wildCard, + long style, const wxPoint& pos, + const wxSize& sz, + const wxString& name) { parent = GetParentForModalDialog(parent, style); if (!wxFileDialogBase::Create(parent, message, defaultDir, defaultFileName, wildCard, style, pos, sz, name)) { - return; + return false; } if (!PreCreation(parent, pos, wxDefaultSize) || @@ -188,7 +199,7 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message, wxDefaultValidator, wxT("filedialog"))) { wxFAIL_MSG( wxT("wxFileDialog creation failed") ); - return; + return false; } GtkFileChooserAction gtk_action; @@ -311,6 +322,8 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message, G_CALLBACK(gtk_filedialog_update_preview_callback), previewImage); } + + return true; } wxFileDialog::~wxFileDialog() -- 2.45.2