Add default ctors and Create() to wxDirDialog and wxFileDialog in wxOSX.

Allow two-step creation of these classes.

Closes #15316.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74476 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2013-07-10 21:12:07 +00:00
parent 497b4e64ce
commit aad2997b67
6 changed files with 66 additions and 8 deletions

View File

@@ -19,7 +19,22 @@
class WXDLLIMPEXP_CORE wxDirDialog : public wxDirDialogBase class WXDLLIMPEXP_CORE wxDirDialog : public wxDirDialogBase
{ {
public: public:
wxDirDialog() { Init(); }
wxDirDialog(wxWindow *parent, wxDirDialog(wxWindow *parent,
const wxString& message = wxDirSelectorPromptStr,
const wxString& defaultPath = wxT(""),
long style = wxDD_DEFAULT_STYLE,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
const wxString& name = wxDirDialogNameStr)
{
Init();
Create(parent,message,defaultPath,style,pos,size,name);
}
void Create(wxWindow *parent,
const wxString& message = wxDirSelectorPromptStr, const wxString& message = wxDirSelectorPromptStr,
const wxString& defaultPath = wxT(""), const wxString& defaultPath = wxT(""),
long style = wxDD_DEFAULT_STYLE, long style = wxDD_DEFAULT_STYLE,
@@ -47,6 +62,9 @@ private:
WX_NSObject m_sheetDelegate; WX_NSObject m_sheetDelegate;
#endif #endif
// Common part of all ctors.
void Init();
DECLARE_DYNAMIC_CLASS(wxDirDialog) DECLARE_DYNAMIC_CLASS(wxDirDialog)
}; };

View File

@@ -31,7 +31,23 @@ protected:
wxArrayString m_paths; wxArrayString m_paths;
public: public:
wxFileDialog() { Init(); }
wxFileDialog(wxWindow *parent, wxFileDialog(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)
{
Init();
Create(parent,message,defaultDir,defaultFile,wildCard,style,pos,sz,name);
}
void Create(wxWindow *parent,
const wxString& message = wxFileSelectorPromptStr, const wxString& message = wxFileSelectorPromptStr,
const wxString& defaultDir = wxEmptyString, const wxString& defaultDir = wxEmptyString,
const wxString& defaultFile = wxEmptyString, const wxString& defaultFile = wxEmptyString,
@@ -87,6 +103,10 @@ protected:
WX_NSObject m_delegate; WX_NSObject m_delegate;
WX_NSObject m_sheetDelegate; WX_NSObject m_sheetDelegate;
#endif #endif
private:
// Common part of all ctors.
void Init();
}; };
#endif // _WX_FILEDLG_H_ #endif // _WX_FILEDLG_H_

View File

@@ -55,7 +55,11 @@ static pascal void NavEventProc(
} }
} }
wxDirDialog::wxDirDialog(wxWindow *parent, void wxDirDialog::Init()
{
}
void wxDirDialog::Create(wxWindow *parent,
const wxString& message, const wxString& message,
const wxString& defaultPath, const wxString& defaultPath,
long style, long style,

View File

@@ -456,12 +456,17 @@ static pascal void NavEventProc(
} }
wxFileDialog::wxFileDialog( void wxFileDialog::Init()
{
}
void wxFileDialog::Create(
wxWindow *parent, const wxString& message, wxWindow *parent, const wxString& message,
const wxString& defaultDir, const wxString& defaultFileName, const wxString& wildCard, const wxString& defaultDir, const wxString& defaultFileName, const wxString& wildCard,
long style, const wxPoint& pos, const wxSize& sz, const wxString& name) long style, const wxPoint& pos, const wxSize& sz, const wxString& name)
: wxFileDialogBase(parent, message, defaultDir, defaultFileName, wildCard, style, pos, sz, name)
{ {
wxFileDialogBase::Create(parent, message, defaultDir, defaultFileName, wildCard, style, pos, sz, name);
wxASSERT_MSG( NavServicesAvailable() , wxT("Navigation Services are not running") ) ; wxASSERT_MSG( NavServicesAvailable() , wxT("Navigation Services are not running") ) ;
} }

View File

@@ -38,7 +38,12 @@
IMPLEMENT_CLASS(wxDirDialog, wxDialog) IMPLEMENT_CLASS(wxDirDialog, wxDialog)
wxDirDialog::wxDirDialog(wxWindow *parent, const wxString& message, void wxDirDialog::Init()
{
m_sheetDelegate = nil;
}
void wxDirDialog::Create(wxWindow *parent, const wxString& message,
const wxString& defaultPath, long style, const wxPoint& WXUNUSED(pos), const wxString& defaultPath, long style, const wxPoint& WXUNUSED(pos),
const wxSize& WXUNUSED(size), const wxString& WXUNUSED(name)) const wxSize& WXUNUSED(size), const wxString& WXUNUSED(name))
{ {

View File

@@ -187,16 +187,22 @@ bool HasAppKit_10_6()
IMPLEMENT_CLASS(wxFileDialog, wxFileDialogBase) IMPLEMENT_CLASS(wxFileDialog, wxFileDialogBase)
wxFileDialog::wxFileDialog( void wxFileDialog::Init()
{
m_filterIndex = -1;
m_delegate = nil;
m_sheetDelegate = nil;
}
void wxFileDialog::Create(
wxWindow *parent, const wxString& message, wxWindow *parent, const wxString& message,
const wxString& defaultDir, const wxString& defaultFileName, const wxString& wildCard, const wxString& defaultDir, const wxString& defaultFileName, const wxString& wildCard,
long style, const wxPoint& pos, const wxSize& sz, const wxString& name) long style, const wxPoint& pos, const wxSize& sz, const wxString& name)
: wxFileDialogBase(parent, message, defaultDir, defaultFileName, wildCard, style, pos, sz, name)
{ {
m_filterIndex = -1; wxFileDialogBase::Create(parent, message, defaultDir, defaultFileName, wildCard, style, pos, sz, name);
m_sheetDelegate = [[ModalDialogDelegate alloc] init]; m_sheetDelegate = [[ModalDialogDelegate alloc] init];
[(ModalDialogDelegate*)m_sheetDelegate setImplementation: this]; [(ModalDialogDelegate*)m_sheetDelegate setImplementation: this];
m_delegate = nil;
} }
wxFileDialog::~wxFileDialog() wxFileDialog::~wxFileDialog()