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
This commit is contained in:
Vadim Zeitlin
2012-03-14 12:32:27 +00:00
parent 4cfe5fa88a
commit e3f54c8f7c
5 changed files with 45 additions and 4 deletions

View File

@@ -499,6 +499,7 @@ GTK:
- Implement support for wxBG_STYLE_TRANSPARENT (Armel Asselin). - Implement support for wxBG_STYLE_TRANSPARENT (Armel Asselin).
- Fix wxNotebook best size calculation. - Fix wxNotebook best size calculation.
- Implement wxDirDialog::Create() and wxFileDialog::Create() (vinayakgarg).
MSW: MSW:

View File

@@ -26,7 +26,13 @@ public:
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, const wxSize& size = wxDefaultSize,
const wxString& name = wxDirDialogNameStr); 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() { } virtual ~wxDirDialog() { }

View File

@@ -30,6 +30,15 @@ public:
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& sz = wxDefaultSize, const wxSize& sz = wxDefaultSize,
const wxString& name = wxFileDialogNameStr); 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 ~wxFileDialog();
virtual wxString GetPath() const; virtual wxString GetPath() const;

View File

@@ -98,6 +98,17 @@ wxDirDialog::wxDirDialog(wxWindow* parent,
const wxPoint& pos, const wxPoint& pos,
const wxSize& WXUNUSED(sz), const wxSize& WXUNUSED(sz),
const wxString& WXUNUSED(name)) 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; m_message = title;
@@ -108,7 +119,7 @@ wxDirDialog::wxDirDialog(wxWindow* parent,
wxDefaultValidator, wxT("dirdialog"))) wxDefaultValidator, wxT("dirdialog")))
{ {
wxFAIL_MSG( wxT("wxDirDialog creation failed") ); wxFAIL_MSG( wxT("wxDirDialog creation failed") );
return; return false;
} }
GtkWindow* gtk_parent = NULL; GtkWindow* gtk_parent = NULL;
@@ -147,6 +158,7 @@ wxDirDialog::wxDirDialog(wxWindow* parent,
if ( !defaultPath.empty() ) if ( !defaultPath.empty() )
gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER(m_widget), gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER(m_widget),
defaultPath.fn_str() ); defaultPath.fn_str() );
return true;
} }
void wxDirDialog::OnFakeOk(wxCommandEvent& WXUNUSED(event)) void wxDirDialog::OnFakeOk(wxCommandEvent& WXUNUSED(event))

View File

@@ -174,13 +174,24 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
const wxSize& sz, const wxSize& sz,
const wxString& name) const wxString& name)
: wxFileDialogBase() : 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); parent = GetParentForModalDialog(parent, style);
if (!wxFileDialogBase::Create(parent, message, defaultDir, defaultFileName, if (!wxFileDialogBase::Create(parent, message, defaultDir, defaultFileName,
wildCard, style, pos, sz, name)) wildCard, style, pos, sz, name))
{ {
return; return false;
} }
if (!PreCreation(parent, pos, wxDefaultSize) || if (!PreCreation(parent, pos, wxDefaultSize) ||
@@ -188,7 +199,7 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
wxDefaultValidator, wxT("filedialog"))) wxDefaultValidator, wxT("filedialog")))
{ {
wxFAIL_MSG( wxT("wxFileDialog creation failed") ); wxFAIL_MSG( wxT("wxFileDialog creation failed") );
return; return false;
} }
GtkFileChooserAction gtk_action; GtkFileChooserAction gtk_action;
@@ -311,6 +322,8 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
G_CALLBACK(gtk_filedialog_update_preview_callback), G_CALLBACK(gtk_filedialog_update_preview_callback),
previewImage); previewImage);
} }
return true;
} }
wxFileDialog::~wxFileDialog() wxFileDialog::~wxFileDialog()