1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxFileDialog
4 // Author: David Webster
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
23 #include "wx/msgdlg.h"
24 #include "wx/dialog.h"
25 #include "wx/filedlg.h"
33 #include "wx/os2/private.h"
39 #if !USE_SHARED_LIBRARY
40 IMPLEMENT_CLASS(wxFileDialog
, wxDialog
)
43 wxString
wxFileSelector( const char* title
44 ,const char* defaultDir
45 ,const char* defaultFileName
46 ,const char* defaultExtension
54 // If there's a default extension specified but no filter, we create a suitable
58 if ( defaultExtension
&& !filter
)
59 filter2
= wxString("*.") + wxString(defaultExtension
) ;
63 wxString defaultDirString
;
65 defaultDirString
= defaultDir
;
67 defaultDirString
= "";
69 wxString defaultFilenameString
;
71 defaultFilenameString
= defaultFileName
;
73 defaultFilenameString
= "";
75 wxFileDialog
fileDialog(parent
, title
, defaultDirString
, defaultFilenameString
, filter2
, flags
, wxPoint(x
, y
));
77 if ( fileDialog
.ShowModal() == wxID_OK
)
79 return fileDialog
.GetPath();
101 wxString
wxFileSelectorEx( const char* title
102 ,const char* defaultDir
103 ,const char* defaultFileName
104 ,int* defaultFilterIndex
112 wxFileDialog
fileDialog(parent
, title
? title
: "", defaultDir
? defaultDir
: "",
113 defaultFileName
? defaultFileName
: "", filter
? filter
: "", flags
, wxPoint(x
, y
));
115 if ( fileDialog
.ShowModal() == wxID_OK
)
117 *defaultFilterIndex
= fileDialog
.GetFilterIndex();
118 return fileDialog
.GetPath();
121 return wxEmptyString
;
124 wxFileDialog::wxFileDialog( wxWindow
* parent
125 ,const wxString
& message
126 ,const wxString
& defaultDir
127 ,const wxString
& defaultFileName
128 ,const wxString
& wildCard
134 m_dialogStyle
= style
;
137 m_fileName
= defaultFileName
;
139 m_wildCard
= wildCard
;
143 int wxFileDialog::ShowModal()
149 // Generic file load/save dialog
150 static wxString
wxDefaultFileSelector( bool load
152 ,const char* extension
153 ,const char* default_name
157 char *ext
= (char *)extension
;
162 str
= "Load %s file";
164 str
= "Save %s file";
165 sprintf(prompt
, wxGetTranslation(str
), what
);
167 if (*ext
== '.') ext
++;
169 sprintf(wild
, "*.%s", ext
);
171 return wxFileSelector (prompt
, NULL
, default_name
, ext
, wild
, 0, parent
);
174 // Generic file load dialog
175 wxString
wxLoadFileSelector( const char* what
176 ,const char* extension
177 ,const char* default_name
181 return wxDefaultFileSelector(TRUE
, what
, extension
, default_name
, parent
);
185 // Generic file save dialog
186 wxString
wxSaveFileSelector( const char* what
187 ,const char* extension
188 ,const char* default_name
192 return wxDefaultFileSelector(FALSE
, what
, extension
, default_name
, parent
);