1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxFileDialog
4 // Author: David Webster
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
14 #include "wx/dialog.h"
15 #include "wx/filedlg.h"
18 #if !USE_SHARED_LIBRARY
19 IMPLEMENT_CLASS(wxFileDialog
, wxDialog
)
22 wxString
wxFileSelector( const char* title
23 ,const char* defaultDir
24 ,const char* defaultFileName
25 ,const char* defaultExtension
33 // If there's a default extension specified but no filter, we create a suitable
37 if ( defaultExtension
&& !filter
)
38 filter2
= wxString("*.") + wxString(defaultExtension
) ;
42 wxString defaultDirString
;
44 defaultDirString
= defaultDir
;
46 defaultDirString
= "";
48 wxString defaultFilenameString
;
50 defaultFilenameString
= defaultFileName
;
52 defaultFilenameString
= "";
54 wxFileDialog
fileDialog(parent
, title
, defaultDirString
, defaultFilenameString
, filter2
, flags
, wxPoint(x
, y
));
56 if ( fileDialog
.ShowModal() == wxID_OK
)
58 return fileDialog
.GetPath();
64 wxString
wxFileSelectorEx( const char* title
65 ,const char* defaultDir
66 ,const char* defaultFileName
67 ,int* defaultFilterIndex
75 wxFileDialog
fileDialog(parent
, title
? title
: "", defaultDir
? defaultDir
: "",
76 defaultFileName
? defaultFileName
: "", filter
? filter
: "", flags
, wxPoint(x
, y
));
78 if ( fileDialog
.ShowModal() == wxID_OK
)
80 *defaultFilterIndex
= fileDialog
.GetFilterIndex();
81 return fileDialog
.GetPath();
87 wxFileDialog::wxFileDialog( wxWindow
* parent
88 ,const wxString
& message
89 ,const wxString
& defaultDir
90 ,const wxString
& defaultFileName
91 ,const wxString
& wildCard
97 m_dialogStyle
= style
;
100 m_fileName
= defaultFileName
;
102 m_wildCard
= wildCard
;
106 int wxFileDialog::ShowModal()
112 // Generic file load/save dialog
113 static wxString
wxDefaultFileSelector( bool load
115 ,const char* extension
116 ,const char* default_name
120 char *ext
= (char *)extension
;
125 str
= "Load %s file";
127 str
= "Save %s file";
128 sprintf(prompt
, wxGetTranslation(str
), what
);
130 if (*ext
== '.') ext
++;
132 sprintf(wild
, "*.%s", ext
);
134 return wxFileSelector (prompt
, NULL
, default_name
, ext
, wild
, 0, parent
);
137 // Generic file load dialog
138 wxString
wxLoadFileSelector( const char* what
139 ,const char* extension
140 ,const char* default_name
144 return wxDefaultFileSelector(TRUE
, what
, extension
, default_name
, parent
);
148 // Generic file save dialog
149 wxString
wxSaveFileSelector( const char* what
150 ,const char* extension
151 ,const char* default_name
155 return wxDefaultFileSelector(FALSE
, what
, extension
, default_name
, parent
);