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
36 #if WXWIN_COMPATIBILITY_2_6
41 wxOVERWRITE_PROMPT
= wxFD_OVERWRITE_PROMPT
,
42 #if WXWIN_COMPATIBILITY_2_4
43 wxHIDE_READONLY
= 0x0008,
45 wxFILE_MUST_EXIST
= wxFD_FILE_MUST_EXIST
,
46 wxMULTIPLE
= wxFD_MULTIPLE
,
47 wxCHANGE_DIR
= wxFD_CHANGE_DIR
51 #define wxFD_DEFAULT_STYLE wxFD_OPEN
53 extern WXDLLEXPORT_DATA(const wxChar
) wxFileDialogNameStr
[];
54 extern WXDLLEXPORT_DATA(const wxChar
) wxFileSelectorPromptStr
[];
55 extern WXDLLEXPORT_DATA(const wxChar
) wxFileSelectorDefaultWildcardStr
[];
57 //----------------------------------------------------------------------------
59 //----------------------------------------------------------------------------
61 class WXDLLEXPORT wxFileDialogBase
: public wxDialog
64 wxFileDialogBase () { Init(); }
66 wxFileDialogBase(wxWindow
*parent
,
67 const wxString
& message
= wxFileSelectorPromptStr
,
68 const wxString
& defaultDir
= wxEmptyString
,
69 const wxString
& defaultFile
= wxEmptyString
,
70 const wxString
& wildCard
= wxFileSelectorDefaultWildcardStr
,
71 long style
= wxFD_DEFAULT_STYLE
,
72 const wxPoint
& pos
= wxDefaultPosition
,
73 const wxSize
& sz
= wxDefaultSize
,
74 const wxString
& name
= wxFileDialogNameStr
)
77 Create(parent
, message
, defaultDir
, defaultFile
, wildCard
, style
, pos
, sz
, name
);
80 bool Create(wxWindow
*parent
,
81 const wxString
& message
= wxFileSelectorPromptStr
,
82 const wxString
& defaultDir
= wxEmptyString
,
83 const wxString
& defaultFile
= wxEmptyString
,
84 const wxString
& wildCard
= wxFileSelectorDefaultWildcardStr
,
85 long style
= wxFD_DEFAULT_STYLE
,
86 const wxPoint
& pos
= wxDefaultPosition
,
87 const wxSize
& sz
= wxDefaultSize
,
88 const wxString
& name
= wxFileDialogNameStr
);
90 virtual void SetMessage(const wxString
& message
) { m_message
= message
; }
91 virtual void SetPath(const wxString
& path
) { m_path
= path
; }
92 virtual void SetDirectory(const wxString
& dir
) { m_dir
= dir
; }
93 virtual void SetFilename(const wxString
& name
) { m_fileName
= name
; }
94 virtual void SetWildcard(const wxString
& wildCard
) { m_wildCard
= wildCard
; }
95 virtual void SetFilterIndex(int filterIndex
) { m_filterIndex
= filterIndex
; }
97 virtual wxString
GetMessage() const { return m_message
; }
98 virtual wxString
GetPath() const { return m_path
; }
99 virtual void GetPaths(wxArrayString
& paths
) const { paths
.Empty(); paths
.Add(m_path
); }
100 virtual wxString
GetDirectory() const { return m_dir
; }
101 virtual wxString
GetFilename() const { return m_fileName
; }
102 virtual void GetFilenames(wxArrayString
& files
) const { files
.Empty(); files
.Add(m_fileName
); }
103 virtual wxString
GetWildcard() const { return m_wildCard
; }
104 virtual int GetFilterIndex() const { return m_filterIndex
; }
108 #if WXWIN_COMPATIBILITY_2_4
109 // Parses the wildCard, returning the number of filters.
110 // Returns 0 if none or if there's a problem,
111 // The arrays will contain an equal number of items found before the error.
112 // wildCard is in the form:
113 // "All files (*)|*|Image Files (*.jpeg *.png)|*.jpg;*.png"
114 wxDEPRECATED( static int ParseWildcard(const wxString
& wildCard
,
115 wxArrayString
& descriptions
,
116 wxArrayString
& filters
) );
117 #endif // WXWIN_COMPATIBILITY_2_4
119 // Append first extension to filePath from a ';' separated extensionList
120 // if filePath = "path/foo.bar" just return it as is
121 // if filePath = "foo[.]" and extensionList = "*.jpg;*.png" return "foo.jpg"
122 // if the extension is "*.j?g" (has wildcards) or "jpg" then return filePath
123 static wxString
AppendExtension(const wxString
&filePath
,
124 const wxString
&extensionList
);
129 wxString m_path
; // Full path
136 DECLARE_DYNAMIC_CLASS(wxFileDialogBase
)
137 DECLARE_NO_COPY_CLASS(wxFileDialogBase
)
140 //----------------------------------------------------------------------------
141 // wxFileDialog convenience functions
142 //----------------------------------------------------------------------------
144 // File selector - backward compatibility
146 wxFileSelector(const wxChar
*message
= wxFileSelectorPromptStr
,
147 const wxChar
*default_path
= NULL
,
148 const wxChar
*default_filename
= NULL
,
149 const wxChar
*default_extension
= NULL
,
150 const wxChar
*wildcard
= wxFileSelectorDefaultWildcardStr
,
152 wxWindow
*parent
= NULL
,
153 int x
= wxDefaultCoord
, int y
= wxDefaultCoord
);
155 // An extended version of wxFileSelector
157 wxFileSelectorEx(const wxChar
*message
= wxFileSelectorPromptStr
,
158 const wxChar
*default_path
= NULL
,
159 const wxChar
*default_filename
= NULL
,
160 int *indexDefaultExtension
= NULL
,
161 const wxChar
*wildcard
= wxFileSelectorDefaultWildcardStr
,
163 wxWindow
*parent
= NULL
,
164 int x
= wxDefaultCoord
, int y
= wxDefaultCoord
);
166 // Ask for filename to load
168 wxLoadFileSelector(const wxChar
*what
,
169 const wxChar
*extension
,
170 const wxChar
*default_name
= (const wxChar
*)NULL
,
171 wxWindow
*parent
= (wxWindow
*) NULL
);
173 // Ask for filename to save
175 wxSaveFileSelector(const wxChar
*what
,
176 const wxChar
*extension
,
177 const wxChar
*default_name
= (const wxChar
*) NULL
,
178 wxWindow
*parent
= (wxWindow
*) NULL
);
181 #if defined (__WXUNIVERSAL__)
182 #include "wx/generic/filedlgg.h"
183 #elif defined(__WXMSW__)
184 #include "wx/msw/filedlg.h"
185 #elif defined(__WXMOTIF__)
186 #include "wx/motif/filedlg.h"
187 #elif defined(__WXGTK24__)
188 #include "wx/gtk/filedlg.h" // GTK+ > 2.4 has native version
189 #elif defined(__WXGTK20__)
190 #include "wx/generic/filedlgg.h"
191 #elif defined(__WXGTK__)
192 #include "wx/gtk1/filedlg.h"
193 #elif defined(__WXX11__)
194 #include "wx/generic/filedlgg.h"
195 #elif defined(__WXMGL__)
196 #include "wx/generic/filedlgg.h"
197 #elif defined(__WXMAC__)
198 #include "wx/mac/filedlg.h"
199 #elif defined(__WXCOCOA__)
200 #include "wx/cocoa/filedlg.h"
201 #elif defined(__WXPM__)
202 #include "wx/os2/filedlg.h"
205 #endif // wxUSE_FILEDLG
207 #endif // _WX_FILEDLG_H_BASE_