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 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 return 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 return fileDialog
.GetPath();
85 wxFileDialog::wxFileDialog(wxWindow
*parent
, const wxString
& message
,
86 const wxString
& defaultDir
, const wxString
& defaultFileName
, const wxString
& wildCard
,
87 long style
, const wxPoint
& pos
)
90 m_dialogStyle
= style
;
93 m_fileName
= defaultFileName
;
95 m_wildCard
= wildCard
;
99 int wxFileDialog::ShowModal()
105 // Generic file load/save dialog
106 static wxString
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
126 wxString
wxLoadFileSelector(const char *what
, const char *extension
, const char *default_name
, wxWindow
*parent
)
128 return wxDefaultFileSelector(TRUE
, what
, extension
, default_name
, parent
);
132 // Generic file save dialog
133 wxString
wxSaveFileSelector(const char *what
, const char *extension
, const char *default_name
, wxWindow
*parent
)
135 return wxDefaultFileSelector(FALSE
, what
, extension
, default_name
, parent
);