+// 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;
+}
+