1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxFileDialog base header
4 // Author: Robert Roebling
7 // Copyright: (c) Robert Roebling
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_FILEDLG_H_BASE_
13 #define _WX_FILEDLG_H_BASE_
19 #include "wx/dialog.h"
20 #include "wx/arrstr.h"
22 //----------------------------------------------------------------------------
24 //----------------------------------------------------------------------------
30 wxFD_OVERWRITE_PROMPT
= 0x0004,
31 wxFD_FILE_MUST_EXIST
= 0x0010,
32 wxFD_MULTIPLE
= 0x0020,
33 wxFD_CHANGE_DIR
= 0x0040,
37 #if WXWIN_COMPATIBILITY_2_6
42 wxOVERWRITE_PROMPT
= wxFD_OVERWRITE_PROMPT
,
43 #if WXWIN_COMPATIBILITY_2_4
44 wxHIDE_READONLY
= 0x0008,
46 wxFILE_MUST_EXIST
= wxFD_FILE_MUST_EXIST
,
47 wxMULTIPLE
= wxFD_MULTIPLE
,
48 wxCHANGE_DIR
= wxFD_CHANGE_DIR
52 #define wxFD_DEFAULT_STYLE wxFD_OPEN
54 extern WXDLLEXPORT_DATA(const wxChar
) wxFileDialogNameStr
[];
55 extern WXDLLEXPORT_DATA(const wxChar
) wxFileSelectorPromptStr
[];
56 extern WXDLLEXPORT_DATA(const wxChar
) wxFileSelectorDefaultWildcardStr
[];
58 //----------------------------------------------------------------------------
60 //----------------------------------------------------------------------------
62 class WXDLLEXPORT wxFileDialogBase
: public wxDialog
65 wxFileDialogBase () { Init(); }
67 wxFileDialogBase(wxWindow
*parent
,
68 const wxString
& message
= wxFileSelectorPromptStr
,
69 const wxString
& defaultDir
= wxEmptyString
,
70 const wxString
& defaultFile
= wxEmptyString
,
71 const wxString
& wildCard
= wxFileSelectorDefaultWildcardStr
,
72 long style
= wxFD_DEFAULT_STYLE
,
73 const wxPoint
& pos
= wxDefaultPosition
,
74 const wxSize
& sz
= wxDefaultSize
,
75 const wxString
& name
= wxFileDialogNameStr
)
78 Create(parent
, message
, defaultDir
, defaultFile
, wildCard
, style
, pos
, sz
, name
);
81 bool Create(wxWindow
*parent
,
82 const wxString
& message
= wxFileSelectorPromptStr
,
83 const wxString
& defaultDir
= wxEmptyString
,
84 const wxString
& defaultFile
= wxEmptyString
,
85 const wxString
& wildCard
= wxFileSelectorDefaultWildcardStr
,
86 long style
= wxFD_DEFAULT_STYLE
,
87 const wxPoint
& pos
= wxDefaultPosition
,
88 const wxSize
& sz
= wxDefaultSize
,
89 const wxString
& name
= wxFileDialogNameStr
);
91 virtual void SetMessage(const wxString
& message
) { m_message
= message
; }
92 virtual void SetPath(const wxString
& path
) { m_path
= path
; }
93 virtual void SetDirectory(const wxString
& dir
) { m_dir
= dir
; }
94 virtual void SetFilename(const wxString
& name
) { m_fileName
= name
; }
95 virtual void SetWildcard(const wxString
& wildCard
) { m_wildCard
= wildCard
; }
96 virtual void SetFilterIndex(int filterIndex
) { m_filterIndex
= filterIndex
; }
98 virtual wxString
GetMessage() const { return m_message
; }
99 virtual wxString
GetPath() const { return m_path
; }
100 virtual void GetPaths(wxArrayString
& paths
) const { paths
.Empty(); paths
.Add(m_path
); }
101 virtual wxString
GetDirectory() const { return m_dir
; }
102 virtual wxString
GetFilename() const { return m_fileName
; }
103 virtual void GetFilenames(wxArrayString
& files
) const { files
.Empty(); files
.Add(m_fileName
); }
104 virtual wxString
GetWildcard() const { return m_wildCard
; }
105 virtual int GetFilterIndex() const { return m_filterIndex
; }
109 #if WXWIN_COMPATIBILITY_2_4
110 // Parses the wildCard, returning the number of filters.
111 // Returns 0 if none or if there's a problem,
112 // The arrays will contain an equal number of items found before the error.
113 // wildCard is in the form:
114 // "All files (*)|*|Image Files (*.jpeg *.png)|*.jpg;*.png"
115 wxDEPRECATED( static int ParseWildcard(const wxString
& wildCard
,
116 wxArrayString
& descriptions
,
117 wxArrayString
& filters
) );
118 #endif // WXWIN_COMPATIBILITY_2_4
120 // Append first extension to filePath from a ';' separated extensionList
121 // if filePath = "path/foo.bar" just return it as is
122 // if filePath = "foo[.]" and extensionList = "*.jpg;*.png" return "foo.jpg"
123 // if the extension is "*.j?g" (has wildcards) or "jpg" then return filePath
124 static wxString
AppendExtension(const wxString
&filePath
,
125 const wxString
&extensionList
);
130 wxString m_path
; // Full path
137 DECLARE_DYNAMIC_CLASS(wxFileDialogBase
)
138 DECLARE_NO_COPY_CLASS(wxFileDialogBase
)
141 //----------------------------------------------------------------------------
142 // wxFileDialog convenience functions
143 //----------------------------------------------------------------------------
145 // File selector - backward compatibility
147 wxFileSelector(const wxChar
*message
= wxFileSelectorPromptStr
,
148 const wxChar
*default_path
= NULL
,
149 const wxChar
*default_filename
= NULL
,
150 const wxChar
*default_extension
= NULL
,
151 const wxChar
*wildcard
= wxFileSelectorDefaultWildcardStr
,
153 wxWindow
*parent
= NULL
,
154 int x
= wxDefaultCoord
, int y
= wxDefaultCoord
);
156 // An extended version of wxFileSelector
158 wxFileSelectorEx(const wxChar
*message
= wxFileSelectorPromptStr
,
159 const wxChar
*default_path
= NULL
,
160 const wxChar
*default_filename
= NULL
,
161 int *indexDefaultExtension
= NULL
,
162 const wxChar
*wildcard
= wxFileSelectorDefaultWildcardStr
,
164 wxWindow
*parent
= NULL
,
165 int x
= wxDefaultCoord
, int y
= wxDefaultCoord
);
167 // Ask for filename to load
169 wxLoadFileSelector(const wxChar
*what
,
170 const wxChar
*extension
,
171 const wxChar
*default_name
= (const wxChar
*)NULL
,
172 wxWindow
*parent
= (wxWindow
*) NULL
);
174 // Ask for filename to save
176 wxSaveFileSelector(const wxChar
*what
,
177 const wxChar
*extension
,
178 const wxChar
*default_name
= (const wxChar
*) NULL
,
179 wxWindow
*parent
= (wxWindow
*) NULL
);
182 #if defined (__WXUNIVERSAL__)
183 #define wxUSE_GENERIC_FILEDIALOG
184 #include "wx/generic/filedlgg.h"
185 #elif defined(__WXMSW__)
186 #include "wx/msw/filedlg.h"
187 #elif defined(__WXMOTIF__)
188 #include "wx/motif/filedlg.h"
189 #elif defined(__WXGTK24__)
190 #include "wx/gtk/filedlg.h" // GTK+ > 2.4 has native version
191 #elif defined(__WXGTK20__)
192 #define wxUSE_GENERIC_FILEDIALOG
193 #include "wx/generic/filedlgg.h"
194 #elif defined(__WXGTK__)
195 #include "wx/gtk1/filedlg.h"
196 #elif defined(__WXMAC__)
197 #include "wx/mac/filedlg.h"
198 #elif defined(__WXCOCOA__)
199 #include "wx/cocoa/filedlg.h"
200 #elif defined(__WXPM__)
201 #include "wx/os2/filedlg.h"
204 #endif // wxUSE_FILEDLG
206 #endif // _WX_FILEDLG_H_BASE_