1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxFileDialog
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "filedlg.h"
18 #include "wx/dialog.h"
19 #include "wx/filedlg.h"
22 #if !USE_SHARED_LIBRARY
23 IMPLEMENT_CLASS(wxFileDialog
, wxDialog
)
26 WXDLLEXPORT wxString
wxFileSelector(const char *title
,
27 const char *defaultDir
, const char *defaultFileName
,
28 const char *defaultExtension
, const char *filter
, int flags
,
29 wxWindow
*parent
, int x
, int y
)
31 // If there's a default extension specified but no filter, we create a suitable
35 if ( defaultExtension
&& !filter
)
36 filter2
= wxString("*.") + wxString(defaultExtension
) ;
40 wxString defaultDirString
;
42 defaultDirString
= defaultDir
;
44 defaultDirString
= "";
46 wxString defaultFilenameString
;
48 defaultFilenameString
= defaultFileName
;
50 defaultFilenameString
= "";
52 wxFileDialog
fileDialog(parent
, title
, defaultDirString
, defaultFilenameString
, filter2
, flags
, wxPoint(x
, y
));
54 if ( fileDialog
.ShowModal() == wxID_OK
)
56 strcpy(wxBuffer
, (const char *)fileDialog
.GetPath());
63 WXDLLEXPORT wxString
wxFileSelectorEx(const char *title
,
64 const char *defaultDir
,
65 const char *defaultFileName
,
66 int* defaultFilterIndex
,
74 wxFileDialog
fileDialog(parent
, title
? title
: "", defaultDir
? defaultDir
: "",
75 defaultFileName
? defaultFileName
: "", filter
? filter
: "", flags
, wxPoint(x
, y
));
77 if ( fileDialog
.ShowModal() == wxID_OK
)
79 *defaultFilterIndex
= fileDialog
.GetFilterIndex();
80 strcpy(wxBuffer
, (const char *)fileDialog
.GetPath());
87 wxFileDialog::wxFileDialog(wxWindow
*parent
, const wxString
& message
,
88 const wxString
& defaultDir
, const wxString
& defaultFileName
, const wxString
& wildCard
,
89 long style
, const wxPoint
& pos
)
92 m_dialogStyle
= style
;
95 m_fileName
= defaultFileName
;
97 m_wildCard
= wildCard
;
101 int wxFileDialog::ShowModal()
107 // Generic file load/save dialog
109 wxDefaultFileSelector(bool load
, const char *what
, const char *extension
, const char *default_name
, wxWindow
*parent
)
111 char *ext
= (char *)extension
;
116 str
= "Load %s file";
118 str
= "Save %s file";
119 sprintf(prompt
, wxGetTranslation(str
), what
);
121 if (*ext
== '.') ext
++;
123 sprintf(wild
, "*.%s", ext
);
125 return wxFileSelector (prompt
, NULL
, default_name
, ext
, wild
, 0, parent
);
128 // Generic file load dialog
130 wxLoadFileSelector(const char *what
, const char *extension
, const char *default_name
, wxWindow
*parent
)
132 return wxDefaultFileSelector(TRUE
, what
, extension
, default_name
, parent
);
136 // Generic file save dialog
138 wxSaveFileSelector(const char *what
, const char *extension
, const char *default_name
, wxWindow
*parent
)
140 return wxDefaultFileSelector(FALSE
, what
, extension
, default_name
, parent
);