-
-
-// ----------------------------------------------------------------------------
-// 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)