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 //----------------------------------------------------------------------------
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
40 wxFD_OVERWRITE_PROMPT
= 0x0004,
41 wxFD_FILE_MUST_EXIST
= 0x0010,
42 wxFD_MULTIPLE
= 0x0020,
43 wxFD_CHANGE_DIR
= 0x0080,
47 #if WXWIN_COMPATIBILITY_2_6
52 wxOVERWRITE_PROMPT
= wxFD_OVERWRITE_PROMPT
,
53 #if WXWIN_COMPATIBILITY_2_4
54 wxHIDE_READONLY
= 0x0008,
56 wxFILE_MUST_EXIST
= wxFD_FILE_MUST_EXIST
,
57 wxMULTIPLE
= wxFD_MULTIPLE
,
58 wxCHANGE_DIR
= wxFD_CHANGE_DIR
62 #define wxFD_DEFAULT_STYLE wxFD_OPEN
64 extern WXDLLEXPORT_DATA(const wxChar
) wxFileDialogNameStr
[];
65 extern WXDLLEXPORT_DATA(const wxChar
) wxFileSelectorPromptStr
[];
66 extern WXDLLEXPORT_DATA(const wxChar
) wxFileSelectorDefaultWildcardStr
[];
68 //----------------------------------------------------------------------------
70 //----------------------------------------------------------------------------
72 class WXDLLEXPORT wxFileDialogBase
: public wxDialog
75 wxFileDialogBase () { Init(); }
77 wxFileDialogBase(wxWindow
*parent
,
78 const wxString
& message
= wxFileSelectorPromptStr
,
79 const wxString
& defaultDir
= wxEmptyString
,
80 const wxString
& defaultFile
= wxEmptyString
,
81 const wxString
& wildCard
= wxFileSelectorDefaultWildcardStr
,
82 long style
= wxFD_DEFAULT_STYLE
,
83 const wxPoint
& pos
= wxDefaultPosition
,
84 const wxSize
& sz
= wxDefaultSize
,
85 const wxString
& name
= wxFileDialogNameStr
)
88 Create(parent
, message
, defaultDir
, defaultFile
, wildCard
, style
, pos
, sz
, name
);
91 bool Create(wxWindow
*parent
,
92 const wxString
& message
= wxFileSelectorPromptStr
,
93 const wxString
& defaultDir
= wxEmptyString
,
94 const wxString
& defaultFile
= wxEmptyString
,
95 const wxString
& wildCard
= wxFileSelectorDefaultWildcardStr
,
96 long style
= wxFD_DEFAULT_STYLE
,
97 const wxPoint
& pos
= wxDefaultPosition
,
98 const wxSize
& sz
= wxDefaultSize
,
99 const wxString
& name
= wxFileDialogNameStr
);
101 bool HasFdFlag(int flag
) const { return HasFlag(flag
); }
103 virtual void SetMessage(const wxString
& message
) { m_message
= message
; }
104 virtual void SetPath(const wxString
& path
) { m_path
= path
; }
105 virtual void SetDirectory(const wxString
& dir
) { m_dir
= dir
; }
106 virtual void SetFilename(const wxString
& name
) { m_fileName
= name
; }
107 virtual void SetWildcard(const wxString
& wildCard
) { m_wildCard
= wildCard
; }
108 virtual void SetFilterIndex(int filterIndex
) { m_filterIndex
= filterIndex
; }
110 virtual wxString
GetMessage() const { return m_message
; }
111 virtual wxString
GetPath() const { return m_path
; }
112 virtual void GetPaths(wxArrayString
& paths
) const { paths
.Empty(); paths
.Add(m_path
); }
113 virtual wxString
GetDirectory() const { return m_dir
; }
114 virtual wxString
GetFilename() const { return m_fileName
; }
115 virtual void GetFilenames(wxArrayString
& files
) const { files
.Empty(); files
.Add(m_fileName
); }
116 virtual wxString
GetWildcard() const { return m_wildCard
; }
117 virtual int GetFilterIndex() const { return m_filterIndex
; }
121 #if WXWIN_COMPATIBILITY_2_4
122 // Parses the wildCard, returning the number of filters.
123 // Returns 0 if none or if there's a problem,
124 // The arrays will contain an equal number of items found before the error.
125 // wildCard is in the form:
126 // "All files (*)|*|Image Files (*.jpeg *.png)|*.jpg;*.png"
127 wxDEPRECATED( static int ParseWildcard(const wxString
& wildCard
,
128 wxArrayString
& descriptions
,
129 wxArrayString
& filters
) );
130 #endif // WXWIN_COMPATIBILITY_2_4
132 #if WXWIN_COMPATIBILITY_2_6
134 wxDEPRECATED( long GetStyle() const );
135 wxDEPRECATED( void SetStyle(long style
) );
137 #endif // WXWIN_COMPATIBILITY_2_6
140 // Append first extension to filePath from a ';' separated extensionList
141 // if filePath = "path/foo.bar" just return it as is
142 // if filePath = "foo[.]" and extensionList = "*.jpg;*.png" return "foo.jpg"
143 // if the extension is "*.j?g" (has wildcards) or "jpg" then return filePath
144 static wxString
AppendExtension(const wxString
&filePath
,
145 const wxString
&extensionList
);
150 wxString m_path
; // Full path
157 DECLARE_DYNAMIC_CLASS(wxFileDialogBase
)
158 DECLARE_NO_COPY_CLASS(wxFileDialogBase
)
161 //----------------------------------------------------------------------------
162 // wxFileDialog convenience functions
163 //----------------------------------------------------------------------------
165 // File selector - backward compatibility
167 wxFileSelector(const wxChar
*message
= wxFileSelectorPromptStr
,
168 const wxChar
*default_path
= NULL
,
169 const wxChar
*default_filename
= NULL
,
170 const wxChar
*default_extension
= NULL
,
171 const wxChar
*wildcard
= wxFileSelectorDefaultWildcardStr
,
173 wxWindow
*parent
= NULL
,
174 int x
= wxDefaultCoord
, int y
= wxDefaultCoord
);
176 // An extended version of wxFileSelector
178 wxFileSelectorEx(const wxChar
*message
= wxFileSelectorPromptStr
,
179 const wxChar
*default_path
= NULL
,
180 const wxChar
*default_filename
= NULL
,
181 int *indexDefaultExtension
= NULL
,
182 const wxChar
*wildcard
= wxFileSelectorDefaultWildcardStr
,
184 wxWindow
*parent
= NULL
,
185 int x
= wxDefaultCoord
, int y
= wxDefaultCoord
);
187 // Ask for filename to load
189 wxLoadFileSelector(const wxChar
*what
,
190 const wxChar
*extension
,
191 const wxChar
*default_name
= (const wxChar
*)NULL
,
192 wxWindow
*parent
= (wxWindow
*) NULL
);
194 // Ask for filename to save
196 wxSaveFileSelector(const wxChar
*what
,
197 const wxChar
*extension
,
198 const wxChar
*default_name
= (const wxChar
*) NULL
,
199 wxWindow
*parent
= (wxWindow
*) NULL
);
202 #if defined (__WXUNIVERSAL__)
203 #define wxUSE_GENERIC_FILEDIALOG
204 #include "wx/generic/filedlgg.h"
205 #elif defined(__WXMSW__)
206 #include "wx/msw/filedlg.h"
207 #elif defined(__WXMOTIF__)
208 #include "wx/motif/filedlg.h"
209 #elif defined(__WXGTK24__)
210 #include "wx/gtk/filedlg.h" // GTK+ > 2.4 has native version
211 #elif defined(__WXGTK20__)
212 #define wxUSE_GENERIC_FILEDIALOG
213 #include "wx/generic/filedlgg.h"
214 #elif defined(__WXGTK__)
215 #include "wx/gtk1/filedlg.h"
216 #elif defined(__WXMAC__)
217 #include "wx/mac/filedlg.h"
218 #elif defined(__WXCOCOA__)
219 #include "wx/cocoa/filedlg.h"
220 #elif defined(__WXPM__)
221 #include "wx/os2/filedlg.h"
224 #endif // wxUSE_FILEDLG
226 #endif // _WX_FILEDLG_H_BASE_