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 #if !USE_SHARED_LIBRARY
22 IMPLEMENT_CLASS(wxFileDialog
, wxDialog
)
25 char *wxFileSelector(const char *title
,
26 const char *defaultDir
, const char *defaultFileName
,
27 const char *defaultExtension
, const char *filter
, int flags
,
28 wxWindow
*parent
, int x
, int y
)
30 // If there's a default extension specified but no filter, we create a suitable
34 if ( defaultExtension
&& !filter
)
35 filter2
= wxString("*.") + wxString(defaultExtension
) ;
39 wxString defaultDirString
;
41 defaultDirString
= defaultDir
;
43 defaultDirString
= "";
45 wxString defaultFilenameString
;
47 defaultFilenameString
= defaultFileName
;
49 defaultFilenameString
= "";
51 wxFileDialog
fileDialog(parent
, title
, defaultDirString
, defaultFilenameString
, filter2
, flags
, wxPoint(x
, y
));
53 if ( fileDialog
.ShowModal() == wxID_OK
)
55 strcpy(wxBuffer
, (const char *)fileDialog
.GetPath());
62 char *wxFileSelectorEx(const char *title
,
63 const char *defaultDir
,
64 const char *defaultFileName
,
65 int* defaultFilterIndex
,
73 wxFileDialog
fileDialog(parent
, title
? title
: "", defaultDir
? defaultDir
: "",
74 defaultFileName
? defaultFileName
: "", filter
? filter
: "", flags
, wxPoint(x
, y
));
76 if ( fileDialog
.ShowModal() == wxID_OK
)
78 *defaultFilterIndex
= fileDialog
.GetFilterIndex();
79 strcpy(wxBuffer
, (const char *)fileDialog
.GetPath());
86 wxFileDialog::wxFileDialog(wxWindow
*parent
, const wxString
& message
,
87 const wxString
& defaultDir
, const wxString
& defaultFileName
, const wxString
& wildCard
,
88 long style
, const wxPoint
& pos
)
91 m_dialogStyle
= style
;
94 m_fileName
= defaultFileName
;
96 m_wildCard
= wildCard
;
100 int wxFileDialog::ShowModal()
106 // Generic file load/save dialog
108 wxDefaultFileSelector(bool load
, const char *what
, const char *extension
, const char *default_name
, wxWindow
*parent
)
110 char *ext
= (char *)extension
;
115 str
= "Load %s file";
117 str
= "Save %s file";
118 sprintf(prompt
, wxGetTranslation(str
), what
);
120 if (*ext
== '.') ext
++;
122 sprintf(wild
, "*.%s", ext
);
124 return wxFileSelector (prompt
, NULL
, default_name
, ext
, wild
, 0, parent
);
127 // Generic file load dialog
129 wxLoadFileSelector(const char *what
, const char *extension
, const char *default_name
, wxWindow
*parent
)
131 return wxDefaultFileSelector(TRUE
, what
, extension
, default_name
, parent
);
135 // Generic file save dialog
137 wxSaveFileSelector(const char *what
, const char *extension
, const char *default_name
, wxWindow
*parent
)
139 return wxDefaultFileSelector(FALSE
, what
, extension
, default_name
, parent
);