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"
21 IMPLEMENT_CLASS(wxFileDialog
, wxDialog
)
23 char *wxFileSelector(const char *title
,
24 const char *defaultDir
, const char *defaultFileName
,
25 const char *defaultExtension
, const char *filter
, int flags
,
26 wxWindow
*parent
, int x
, int y
)
28 // If there's a default extension specified but no filter, we create a suitable
32 if ( defaultExtension
&& !filter
)
33 filter2
= wxString("*.") + wxString(defaultExtension
) ;
37 wxString defaultDirString
;
39 defaultDirString
= defaultDir
;
41 defaultDirString
= "";
43 wxString defaultFilenameString
;
45 defaultFilenameString
= defaultFileName
;
47 defaultFilenameString
= "";
49 wxFileDialog
fileDialog(parent
, title
, defaultDirString
, defaultFilenameString
, filter2
, flags
, wxPoint(x
, y
));
51 if ( fileDialog
.ShowModal() == wxID_OK
)
53 strcpy(wxBuffer
, (const char *)fileDialog
.GetPath());
60 char *wxFileSelectorEx(const char *title
,
61 const char *defaultDir
,
62 const char *defaultFileName
,
63 int* defaultFilterIndex
,
71 wxFileDialog
fileDialog(parent
, title
? title
: "", defaultDir
? defaultDir
: "",
72 defaultFileName
? defaultFileName
: "", filter
? filter
: "", flags
, wxPoint(x
, y
));
74 if ( fileDialog
.ShowModal() == wxID_OK
)
76 *defaultFilterIndex
= fileDialog
.GetFilterIndex();
77 strcpy(wxBuffer
, (const char *)fileDialog
.GetPath());
84 wxFileDialog::wxFileDialog(wxWindow
*parent
, const wxString
& message
,
85 const wxString
& defaultDir
, const wxString
& defaultFileName
, const wxString
& wildCard
,
86 long style
, const wxPoint
& pos
)
89 m_dialogStyle
= style
;
92 m_fileName
= defaultFileName
;
94 m_wildCard
= wildCard
;
98 int wxFileDialog::ShowModal()
104 // Generic file load/save dialog
106 wxDefaultFileSelector(bool load
, const char *what
, const char *extension
, const char *default_name
, wxWindow
*parent
)
108 char *ext
= (char *)extension
;
113 str
= "Load %s file";
115 str
= "Save %s file";
116 sprintf(prompt
, wxGetTranslation(str
), what
);
118 if (*ext
== '.') ext
++;
120 sprintf(wild
, "*.%s", ext
);
122 return wxFileSelector (prompt
, NULL
, default_name
, ext
, wild
, 0, parent
);
125 // Generic file load dialog
127 wxLoadFileSelector(const char *what
, const char *extension
, const char *default_name
, wxWindow
*parent
)
129 return wxDefaultFileSelector(TRUE
, what
, extension
, default_name
, parent
);
133 // Generic file save dialog
135 wxSaveFileSelector(const char *what
, const char *extension
, const char *default_name
, wxWindow
*parent
)
137 return wxDefaultFileSelector(FALSE
, what
, extension
, default_name
, parent
);