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 bool HasFdFlag(int flag
) const { return (m_fdStyle
& flag
) != 0; }
93 virtual void SetMessage(const wxString
& message
) { m_message
= message
; }
94 virtual void SetPath(const wxString
& path
) { m_path
= path
; }
95 virtual void SetDirectory(const wxString
& dir
) { m_dir
= dir
; }
96 virtual void SetFilename(const wxString
& name
) { m_fileName
= name
; }
97 virtual void SetWildcard(const wxString
& wildCard
) { m_wildCard
= wildCard
; }
98 virtual void SetFilterIndex(int filterIndex
) { m_filterIndex
= filterIndex
; }
100 virtual wxString
GetMessage() const { return m_message
; }
101 virtual wxString
GetPath() const { return m_path
; }
102 virtual void GetPaths(wxArrayString
& paths
) const { paths
.Empty(); paths
.Add(m_path
); }
103 virtual wxString
GetDirectory() const { return m_dir
; }
104 virtual wxString
GetFilename() const { return m_fileName
; }
105 virtual void GetFilenames(wxArrayString
& files
) const { files
.Empty(); files
.Add(m_fileName
); }
106 virtual wxString
GetWildcard() const { return m_wildCard
; }
107 virtual int GetFilterIndex() const { return m_filterIndex
; }
111 #if WXWIN_COMPATIBILITY_2_4
112 // Parses the wildCard, returning the number of filters.
113 // Returns 0 if none or if there's a problem,
114 // The arrays will contain an equal number of items found before the error.
115 // wildCard is in the form:
116 // "All files (*)|*|Image Files (*.jpeg *.png)|*.jpg;*.png"
117 wxDEPRECATED( static int ParseWildcard(const wxString
& wildCard
,
118 wxArrayString
& descriptions
,
119 wxArrayString
& filters
) );
120 #endif // WXWIN_COMPATIBILITY_2_4
122 // Append first extension to filePath from a ';' separated extensionList
123 // if filePath = "path/foo.bar" just return it as is
124 // if filePath = "foo[.]" and extensionList = "*.jpg;*.png" return "foo.jpg"
125 // if the extension is "*.j?g" (has wildcards) or "jpg" then return filePath
126 static wxString
AppendExtension(const wxString
&filePath
,
127 const wxString
&extensionList
);
132 wxString m_path
; // Full path
140 DECLARE_DYNAMIC_CLASS(wxFileDialogBase
)
141 DECLARE_NO_COPY_CLASS(wxFileDialogBase
)
144 //----------------------------------------------------------------------------
145 // wxFileDialog convenience functions
146 //----------------------------------------------------------------------------
148 // File selector - backward compatibility
150 wxFileSelector(const wxChar
*message
= wxFileSelectorPromptStr
,
151 const wxChar
*default_path
= NULL
,
152 const wxChar
*default_filename
= NULL
,
153 const wxChar
*default_extension
= NULL
,
154 const wxChar
*wildcard
= wxFileSelectorDefaultWildcardStr
,
156 wxWindow
*parent
= NULL
,
157 int x
= wxDefaultCoord
, int y
= wxDefaultCoord
);
159 // An extended version of wxFileSelector
161 wxFileSelectorEx(const wxChar
*message
= wxFileSelectorPromptStr
,
162 const wxChar
*default_path
= NULL
,
163 const wxChar
*default_filename
= NULL
,
164 int *indexDefaultExtension
= NULL
,
165 const wxChar
*wildcard
= wxFileSelectorDefaultWildcardStr
,
167 wxWindow
*parent
= NULL
,
168 int x
= wxDefaultCoord
, int y
= wxDefaultCoord
);
170 // Ask for filename to load
172 wxLoadFileSelector(const wxChar
*what
,
173 const wxChar
*extension
,
174 const wxChar
*default_name
= (const wxChar
*)NULL
,
175 wxWindow
*parent
= (wxWindow
*) NULL
);
177 // Ask for filename to save
179 wxSaveFileSelector(const wxChar
*what
,
180 const wxChar
*extension
,
181 const wxChar
*default_name
= (const wxChar
*) NULL
,
182 wxWindow
*parent
= (wxWindow
*) NULL
);
185 #if defined (__WXUNIVERSAL__)
186 #define wxUSE_GENERIC_FILEDIALOG
187 #include "wx/generic/filedlgg.h"
188 #elif defined(__WXMSW__)
189 #include "wx/msw/filedlg.h"
190 #elif defined(__WXMOTIF__)
191 #include "wx/motif/filedlg.h"
192 #elif defined(__WXGTK24__)
193 #include "wx/gtk/filedlg.h" // GTK+ > 2.4 has native version
194 #elif defined(__WXGTK20__)
195 #define wxUSE_GENERIC_FILEDIALOG
196 #include "wx/generic/filedlgg.h"
197 #elif defined(__WXGTK__)
198 #include "wx/gtk1/filedlg.h"
199 #elif defined(__WXMAC__)
200 #include "wx/mac/filedlg.h"
201 #elif defined(__WXCOCOA__)
202 #include "wx/cocoa/filedlg.h"
203 #elif defined(__WXPM__)
204 #include "wx/os2/filedlg.h"
207 #endif // wxUSE_FILEDLG
209 #endif // _WX_FILEDLG_H_BASE_