]> git.saurik.com Git - wxWidgets.git/blame - include/wx/filedlg.h
return const wxString& from wxFontMapper::GetDefaultConfigPath()
[wxWidgets.git] / include / wx / filedlg.h
CommitLineData
b600ed13 1/////////////////////////////////////////////////////////////////////////////
e031f1df 2// Name: wx/filedlg.h
b600ed13
VZ
3// Purpose: wxFileDialog base header
4// Author: Robert Roebling
5// Modified by:
6// Created: 8/17/99
7// Copyright: (c) Robert Roebling
2ecf902b 8// RCS-ID: $Id$
65571936 9// Licence: wxWindows licence
b600ed13
VZ
10/////////////////////////////////////////////////////////////////////////////
11
34138703
JS
12#ifndef _WX_FILEDLG_H_BASE_
13#define _WX_FILEDLG_H_BASE_
c801d85f 14
2ecf902b
WS
15#include "wx/defs.h"
16
1e6feb95
VZ
17#if wxUSE_FILEDLG
18
f74172ab 19#include "wx/dialog.h"
a9711a4d 20#include "wx/arrstr.h"
f74172ab 21
b600ed13 22//----------------------------------------------------------------------------
f74172ab 23// wxFileDialog data
b600ed13
VZ
24//----------------------------------------------------------------------------
25
45f4109c
RR
26/*
27 The flags below must coexist with the following flags in m_windowStyle
28 #define wxCAPTION 0x20000000
29 #define wxMAXIMIZE 0x00002000
30 #define wxCLOSE_BOX 0x00001000
31 #define wxSYSTEM_MENU 0x00000800
32 wxBORDER_NONE = 0x00200000
33 #define wxRESIZE_BORDER 0x00000040
34*/
35
ff3e84ff
VZ
36enum
37{
38 wxFD_OPEN = 0x0001,
39 wxFD_SAVE = 0x0002,
40 wxFD_OVERWRITE_PROMPT = 0x0004,
41 wxFD_FILE_MUST_EXIST = 0x0010,
42 wxFD_MULTIPLE = 0x0020,
45f4109c
RR
43 wxFD_CHANGE_DIR = 0x0080,
44 wxFD_PREVIEW = 0x0100
ff3e84ff
VZ
45};
46
e031f1df
WS
47#if WXWIN_COMPATIBILITY_2_6
48enum
49{
50 wxOPEN = wxFD_OPEN,
51 wxSAVE = wxFD_SAVE,
52 wxOVERWRITE_PROMPT = wxFD_OVERWRITE_PROMPT,
e031f1df
WS
53 wxFILE_MUST_EXIST = wxFD_FILE_MUST_EXIST,
54 wxMULTIPLE = wxFD_MULTIPLE,
55 wxCHANGE_DIR = wxFD_CHANGE_DIR
56};
57#endif
58
ff3e84ff
VZ
59#define wxFD_DEFAULT_STYLE wxFD_OPEN
60
61extern WXDLLEXPORT_DATA(const wxChar) wxFileDialogNameStr[];
63ec432b
MR
62extern WXDLLEXPORT_DATA(const wxChar) wxFileSelectorPromptStr[];
63extern WXDLLEXPORT_DATA(const wxChar) wxFileSelectorDefaultWildcardStr[];
b600ed13 64
f74172ab
VZ
65//----------------------------------------------------------------------------
66// wxFileDialogBase
67//----------------------------------------------------------------------------
68
69class WXDLLEXPORT wxFileDialogBase: public wxDialog
70{
71public:
fe6cf128 72 wxFileDialogBase () { Init(); }
f74172ab
VZ
73
74 wxFileDialogBase(wxWindow *parent,
fe6cf128
VZ
75 const wxString& message = wxFileSelectorPromptStr,
76 const wxString& defaultDir = wxEmptyString,
77 const wxString& defaultFile = wxEmptyString,
78 const wxString& wildCard = wxFileSelectorDefaultWildcardStr,
ff3e84ff
VZ
79 long style = wxFD_DEFAULT_STYLE,
80 const wxPoint& pos = wxDefaultPosition,
81 const wxSize& sz = wxDefaultSize,
82 const wxString& name = wxFileDialogNameStr)
fe6cf128
VZ
83 {
84 Init();
ff3e84ff 85 Create(parent, message, defaultDir, defaultFile, wildCard, style, pos, sz, name);
fe6cf128
VZ
86 }
87
88 bool Create(wxWindow *parent,
89 const wxString& message = wxFileSelectorPromptStr,
90 const wxString& defaultDir = wxEmptyString,
91 const wxString& defaultFile = wxEmptyString,
92 const wxString& wildCard = wxFileSelectorDefaultWildcardStr,
ff3e84ff
VZ
93 long style = wxFD_DEFAULT_STYLE,
94 const wxPoint& pos = wxDefaultPosition,
95 const wxSize& sz = wxDefaultSize,
96 const wxString& name = wxFileDialogNameStr);
f74172ab 97
45f4109c 98 bool HasFdFlag(int flag) const { return HasFlag(flag); }
b014db05 99
f74172ab
VZ
100 virtual void SetMessage(const wxString& message) { m_message = message; }
101 virtual void SetPath(const wxString& path) { m_path = path; }
102 virtual void SetDirectory(const wxString& dir) { m_dir = dir; }
103 virtual void SetFilename(const wxString& name) { m_fileName = name; }
104 virtual void SetWildcard(const wxString& wildCard) { m_wildCard = wildCard; }
f74172ab
VZ
105 virtual void SetFilterIndex(int filterIndex) { m_filterIndex = filterIndex; }
106
107 virtual wxString GetMessage() const { return m_message; }
108 virtual wxString GetPath() const { return m_path; }
109 virtual void GetPaths(wxArrayString& paths) const { paths.Empty(); paths.Add(m_path); }
110 virtual wxString GetDirectory() const { return m_dir; }
111 virtual wxString GetFilename() const { return m_fileName; }
112 virtual void GetFilenames(wxArrayString& files) const { files.Empty(); files.Add(m_fileName); }
113 virtual wxString GetWildcard() const { return m_wildCard; }
f74172ab
VZ
114 virtual int GetFilterIndex() const { return m_filterIndex; }
115
116 // Utility functions
117
cc197ed4
VZ
118#if WXWIN_COMPATIBILITY_2_6
119
120 wxDEPRECATED( long GetStyle() const );
121 wxDEPRECATED( void SetStyle(long style) );
122
123#endif // WXWIN_COMPATIBILITY_2_6
124
125
f74172ab
VZ
126 // Append first extension to filePath from a ';' separated extensionList
127 // if filePath = "path/foo.bar" just return it as is
128 // if filePath = "foo[.]" and extensionList = "*.jpg;*.png" return "foo.jpg"
129 // if the extension is "*.j?g" (has wildcards) or "jpg" then return filePath
130 static wxString AppendExtension(const wxString &filePath,
131 const wxString &extensionList);
132
133protected:
134 wxString m_message;
f74172ab
VZ
135 wxString m_dir;
136 wxString m_path; // Full path
137 wxString m_fileName;
138 wxString m_wildCard;
139 int m_filterIndex;
140
141private:
fe6cf128 142 void Init();
f74172ab
VZ
143 DECLARE_DYNAMIC_CLASS(wxFileDialogBase)
144 DECLARE_NO_COPY_CLASS(wxFileDialogBase)
145};
146
b600ed13
VZ
147//----------------------------------------------------------------------------
148// wxFileDialog convenience functions
149//----------------------------------------------------------------------------
150
f8bcb37d
VS
151// NB: wxFileSelector() etc. used to take const wxChar* arguments in wx-2.8
152// and their default value was NULL. The official way to use these
153// functions is to use wxString, with wxEmptyString as the default value.
154// The templates below exist only to maintain compatibility with wx-2.8.
155
156#if WXWIN_COMPATIBILITY_2_8
157// return wxString created from the argument, return empty string if the
158// argument is NULL:
159inline wxString wxPtrOrStringToString(const wxString& s) { return s; }
160inline wxString wxPtrOrStringToString(const char *s) { return s; }
161inline wxString wxPtrOrStringToString(const wchar_t *s) { return s; }
162inline wxString wxPtrOrStringToString(const wxCStrData& s) { return s; }
163inline wxString wxPtrOrStringToString(const wxCharBuffer& s) { return s; }
164inline wxString wxPtrOrStringToString(const wxWCharBuffer& s) { return s; }
165// this one is for NULL:
166inline wxString wxPtrOrStringToString(int s)
167{
168 wxASSERT_MSG( s == 0, _T("passing non-NULL int as string?") );
169 return wxEmptyString;
170}
171#endif // WXWIN_COMPATIBILITY_2_8
172
173WXDLLEXPORT wxString
174wxDoFileSelector(const wxString& message = wxFileSelectorPromptStr,
175 const wxString& default_path = wxEmptyString,
176 const wxString& default_filename = wxEmptyString,
177 const wxString& default_extension = wxEmptyString,
178 const wxString& wildcard = wxFileSelectorDefaultWildcardStr,
179 int flags = 0,
180 wxWindow *parent = NULL,
181 int x = wxDefaultCoord, int y = wxDefaultCoord);
182
183WXDLLEXPORT wxString
184wxDoFileSelectorEx(const wxString& message = wxFileSelectorPromptStr,
185 const wxString& default_path = wxEmptyString,
186 const wxString& default_filename = wxEmptyString,
187 int *indexDefaultExtension = NULL,
188 const wxString& wildcard = wxFileSelectorDefaultWildcardStr,
189 int flags = 0,
190 wxWindow *parent = NULL,
191 int x = wxDefaultCoord, int y = wxDefaultCoord);
192
b600ed13 193WXDLLEXPORT wxString
f8bcb37d
VS
194wxDoLoadFileSelector(const wxString& what,
195 const wxString& extension,
196 const wxString& default_name = wxEmptyString,
197 wxWindow *parent = NULL);
198
199WXDLLEXPORT wxString
200wxDoSaveFileSelector(const wxString& what,
201 const wxString& extension,
202 const wxString& default_name = wxEmptyString,
203 wxWindow *parent = NULL);
204
205#if WXWIN_COMPATIBILITY_2_8
206
207// File selector - backward compatibility
208inline wxString wxFileSelector()
209{
210 return wxDoFileSelector();
211}
212
213inline wxString wxFileSelector(const wxString& message)
214{
215 return wxDoFileSelector(message);
216}
217
218template<typename T>
219inline wxString wxFileSelector(const wxString& message, const T& default_path)
220{
221 return wxDoFileSelector(message, wxPtrOrStringToString(default_path));
222}
223
224template<typename T1, typename T2>
225inline wxString wxFileSelector(const wxString& message,
226 const T1& default_path,
227 const T2& default_filename)
228{
229 return wxDoFileSelector(message,
230 wxPtrOrStringToString(default_path),
231 wxPtrOrStringToString(default_filename));
232}
233
234template<typename T1, typename T2, typename T3>
235inline wxString
236wxFileSelector(const wxString& message,
237 const T1& default_path,
238 const T2& default_filename,
239 const T3& default_extension,
240 const wxString& wildcard = wxFileSelectorDefaultWildcardStr,
b600ed13
VZ
241 int flags = 0,
242 wxWindow *parent = NULL,
f8bcb37d
VS
243 int x = wxDefaultCoord, int y = wxDefaultCoord)
244{
245 return wxDoFileSelector(message,
246 wxPtrOrStringToString(default_path),
247 wxPtrOrStringToString(default_filename),
248 wxPtrOrStringToString(default_extension),
249 wildcard,
250 flags,
251 parent,
252 x, y);
253}
b600ed13
VZ
254
255// An extended version of wxFileSelector
f8bcb37d
VS
256inline wxString wxFileSelectorEx()
257{
258 return wxDoFileSelectorEx();
259}
260
261inline wxString wxFileSelectorEx(const wxString& message)
262{
263 return wxDoFileSelectorEx(message);
264}
265
266template<typename T>
267inline wxString wxFileSelectorEx(const wxString& message, const T& default_path)
268{
269 return wxDoFileSelectorEx(message, wxPtrOrStringToString(default_path));
270}
271
272template<typename T1, typename T2>
273inline wxString
274wxFileSelectorEx(const wxString& message,
275 const T1& default_path,
276 const T2& default_filename,
b600ed13 277 int *indexDefaultExtension = NULL,
f8bcb37d 278 const wxString& wildcard = wxFileSelectorDefaultWildcardStr,
b600ed13
VZ
279 int flags = 0,
280 wxWindow *parent = NULL,
f8bcb37d
VS
281 int x = wxDefaultCoord, int y = wxDefaultCoord)
282{
283 return wxDoFileSelectorEx(message,
284 wxPtrOrStringToString(default_path),
285 wxPtrOrStringToString(default_filename),
286 indexDefaultExtension,
287 wildcard,
288 flags,
289 parent,
290 x, y);
291}
b600ed13
VZ
292
293// Ask for filename to load
f8bcb37d
VS
294template<typename T>
295inline wxString wxLoadFileSelector(const wxString& what,
296 const wxString& extension,
297 const T& default_name = T(),
298 wxWindow *parent = NULL)
299{
300 return wxDoLoadFileSelector(what, extension,
301 wxPtrOrStringToString(default_name),
302 parent);
303}
b600ed13
VZ
304
305// Ask for filename to save
f8bcb37d
VS
306template<typename T>
307inline wxString wxSaveFileSelector(const wxString& what,
308 const wxString& extension,
309 const T& default_name = T(),
310 wxWindow *parent = NULL)
311{
312 return wxDoSaveFileSelector(what, extension,
313 wxPtrOrStringToString(default_name),
314 parent);
315}
316
317#else // !WXWIN_COMPATIBILITY_2_8
318
319#define wxFileSelector wxDoFileSelector
320#define wxFileSelectorEx wxDoFileSelectorEx
321#define wxLoadFileSelector wxDoLoadFileSelector
322#define wxSaveFileSelector wxDoSaveFileSelector
323
324#endif // WXWIN_COMPATIBILITY_2_8/!WXWIN_COMPATIBILITY_2_8
b600ed13
VZ
325
326
099d4217 327#if defined (__WXUNIVERSAL__)
a84f5f39 328#define wxUSE_GENERIC_FILEDIALOG
099d4217
CE
329#include "wx/generic/filedlgg.h"
330#elif defined(__WXMSW__)
c801d85f 331#include "wx/msw/filedlg.h"
2049ba38 332#elif defined(__WXMOTIF__)
34138703 333#include "wx/motif/filedlg.h"
ff3e84ff
VZ
334#elif defined(__WXGTK24__)
335#include "wx/gtk/filedlg.h" // GTK+ > 2.4 has native version
1be7a35c 336#elif defined(__WXGTK20__)
a84f5f39 337#define wxUSE_GENERIC_FILEDIALOG
ff3e84ff 338#include "wx/generic/filedlgg.h"
1be7a35c 339#elif defined(__WXGTK__)
7e52dfd2 340#include "wx/gtk1/filedlg.h"
34138703
JS
341#elif defined(__WXMAC__)
342#include "wx/mac/filedlg.h"
0201182b 343#elif defined(__WXCOCOA__)
f31424db 344#include "wx/cocoa/filedlg.h"
1777b9bb
DW
345#elif defined(__WXPM__)
346#include "wx/os2/filedlg.h"
c801d85f
KB
347#endif
348
1e6feb95 349#endif // wxUSE_FILEDLG
ba681060 350
b600ed13 351#endif // _WX_FILEDLG_H_BASE_