-IMPLEMENT_DYNAMIC_CLASS(wxFileDialog, wxGenericFileDialog);
-
-// ----------------------------------------------------------------------------
-// global functions
-// ----------------------------------------------------------------------------
-
-// common part of both wxFileSelectorEx() and wxFileSelector()
-static wxString
-DoSelectFile(const wxChar *title,
- const wxChar *defaultDir,
- const wxChar *defaultFileName,
- const wxChar *defaultExtension,
- int *indexDefaultExtension,
- const wxChar *filter,
- int flags,
- wxWindow *parent,
- int x,
- int y)
-{
- // the filter may be either given explicitly or created automatically from
- // the default extension
- wxString filterReal;
- if ( filter )
- {
- // the user has specified the filter explicitly, use it
- filterReal = filter;
- }
- else if ( !wxIsEmpty(defaultExtension) )
- {
- // create the filter to match the given extension
- filterReal << wxT("*.") << defaultExtension;
- }
-
- wxFileDialog fileDialog(parent,
- title,
- defaultDir,
- defaultFileName,
- filterReal,
- flags,
- wxPoint(x, y));
-
- wxString path;
- if ( fileDialog.ShowModal() == wxID_OK )
- {
- path = fileDialog.GetPath();
- if ( indexDefaultExtension )
- {
- *indexDefaultExtension = fileDialog.GetFilterIndex();
- }
- }
-
- return path;
-}
-
-wxString
-wxFileSelectorEx(const wxChar *title,
- const wxChar *defaultDir,
- const wxChar *defaultFileName,
- int *indexDefaultExtension,
- const wxChar *filter,
- int flags,
- wxWindow *parent,
- int x,
- int y)
-{
- return DoSelectFile(title,
- defaultDir,
- defaultFileName,
- wxT(""), // def ext determined by index
- indexDefaultExtension,
- filter,
- flags,
- parent,
- x,
- y);
-}
-
-wxString
-wxFileSelector(const wxChar *title,
- const wxChar *defaultDir,
- const wxChar *defaultFileName,
- const wxChar *defaultExtension,
- const wxChar *filter,
- int flags,
- wxWindow *parent,
- int x,
- int y)
-{
- return DoSelectFile(title,
- defaultDir,
- defaultFileName,
- defaultExtension,
- NULL, // not interested in filter index
- filter,
- flags,
- parent,
- x,
- y);
-}
-
-static wxString GetWildcardString(const wxChar *ext)
-{
- wxString wild;
- if ( ext )
- {
- if ( *ext == wxT('.') )
- ext++;
-
- wild << _T("*.") << ext;
- }
- else // no extension specified
- {
- wild = wxFileSelectorDefaultWildcardStr;
- }
-
- return wild;
-}
-
-wxString wxLoadFileSelector(const wxChar *what,
- const wxChar *ext,
- const wxChar *nameDef,
- wxWindow *parent)
-{
- wxString prompt;
- if ( what && *what )
- prompt = wxString::Format(_("Load %s file"), what);
- else
- prompt = _("Load file");
-
- return wxFileSelector(prompt, NULL, nameDef, ext,
- GetWildcardString(ext), 0, parent);
-}
-
-wxString wxSaveFileSelector(const wxChar *what,
- const wxChar *ext,
- const wxChar *nameDef,
- wxWindow *parent)
-{
- wxString prompt;
- if ( what && *what )
- prompt = wxString::Format(_("Save %s file"), what);
- else
- prompt = _("Save file");
-
- return wxFileSelector(prompt, NULL, nameDef, ext,
- GetWildcardString(ext), 0, parent);
-}