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 wxOVERWRITE_PROMPT
= 0x0004,
31 #if WXWIN_COMPATIBILITY_2_4
32 wxHIDE_READONLY
= 0x0008,
34 wxFILE_MUST_EXIST
= 0x0010,
39 extern WXDLLEXPORT_DATA(const wxChar
*) wxFileSelectorPromptStr
;
40 extern WXDLLEXPORT_DATA(const wxChar
*) wxFileSelectorDefaultWildcardStr
;
42 //----------------------------------------------------------------------------
44 //----------------------------------------------------------------------------
46 class WXDLLEXPORT wxFileDialogBase
: public wxDialog
49 wxFileDialogBase () { Init(); }
51 wxFileDialogBase(wxWindow
*parent
,
52 const wxString
& message
= wxFileSelectorPromptStr
,
53 const wxString
& defaultDir
= wxEmptyString
,
54 const wxString
& defaultFile
= wxEmptyString
,
55 const wxString
& wildCard
= wxFileSelectorDefaultWildcardStr
,
57 const wxPoint
& pos
= wxDefaultPosition
) : wxDialog()
60 Create(parent
, message
, defaultDir
, defaultFile
, wildCard
, style
, pos
);
63 bool Create(wxWindow
*parent
,
64 const wxString
& message
= wxFileSelectorPromptStr
,
65 const wxString
& defaultDir
= wxEmptyString
,
66 const wxString
& defaultFile
= wxEmptyString
,
67 const wxString
& wildCard
= wxFileSelectorDefaultWildcardStr
,
69 const wxPoint
& pos
= wxDefaultPosition
);
71 virtual void SetMessage(const wxString
& message
) { m_message
= message
; }
72 virtual void SetPath(const wxString
& path
) { m_path
= path
; }
73 virtual void SetDirectory(const wxString
& dir
) { m_dir
= dir
; }
74 virtual void SetFilename(const wxString
& name
) { m_fileName
= name
; }
75 virtual void SetWildcard(const wxString
& wildCard
) { m_wildCard
= wildCard
; }
76 virtual void SetStyle(long style
) { m_dialogStyle
= style
; }
77 virtual void SetFilterIndex(int filterIndex
) { m_filterIndex
= filterIndex
; }
79 virtual wxString
GetMessage() const { return m_message
; }
80 virtual wxString
GetPath() const { return m_path
; }
81 virtual void GetPaths(wxArrayString
& paths
) const { paths
.Empty(); paths
.Add(m_path
); }
82 virtual wxString
GetDirectory() const { return m_dir
; }
83 virtual wxString
GetFilename() const { return m_fileName
; }
84 virtual void GetFilenames(wxArrayString
& files
) const { files
.Empty(); files
.Add(m_fileName
); }
85 virtual wxString
GetWildcard() const { return m_wildCard
; }
86 virtual long GetStyle() const { return m_dialogStyle
; }
87 virtual int GetFilterIndex() const { return m_filterIndex
; }
91 #if WXWIN_COMPATIBILITY_2_4
92 // Parses the wildCard, returning the number of filters.
93 // Returns 0 if none or if there's a problem,
94 // The arrays will contain an equal number of items found before the error.
95 // wildCard is in the form:
96 // "All files (*)|*|Image Files (*.jpeg *.png)|*.jpg;*.png"
97 wxDEPRECATED( static int ParseWildcard(const wxString
& wildCard
,
98 wxArrayString
& descriptions
,
99 wxArrayString
& filters
) );
100 #endif // WXWIN_COMPATIBILITY_2_4
102 // Append first extension to filePath from a ';' separated extensionList
103 // if filePath = "path/foo.bar" just return it as is
104 // if filePath = "foo[.]" and extensionList = "*.jpg;*.png" return "foo.jpg"
105 // if the extension is "*.j?g" (has wildcards) or "jpg" then return filePath
106 static wxString
AppendExtension(const wxString
&filePath
,
107 const wxString
&extensionList
);
114 wxString m_path
; // Full path
121 DECLARE_DYNAMIC_CLASS(wxFileDialogBase
)
122 DECLARE_NO_COPY_CLASS(wxFileDialogBase
)
125 //----------------------------------------------------------------------------
126 // wxFileDialog convenience functions
127 //----------------------------------------------------------------------------
129 // File selector - backward compatibility
131 wxFileSelector(const wxChar
*message
= wxFileSelectorPromptStr
,
132 const wxChar
*default_path
= NULL
,
133 const wxChar
*default_filename
= NULL
,
134 const wxChar
*default_extension
= NULL
,
135 const wxChar
*wildcard
= wxFileSelectorDefaultWildcardStr
,
137 wxWindow
*parent
= NULL
,
138 int x
= wxDefaultCoord
, int y
= wxDefaultCoord
);
140 // An extended version of wxFileSelector
142 wxFileSelectorEx(const wxChar
*message
= wxFileSelectorPromptStr
,
143 const wxChar
*default_path
= NULL
,
144 const wxChar
*default_filename
= NULL
,
145 int *indexDefaultExtension
= NULL
,
146 const wxChar
*wildcard
= wxFileSelectorDefaultWildcardStr
,
148 wxWindow
*parent
= NULL
,
149 int x
= wxDefaultCoord
, int y
= wxDefaultCoord
);
151 // Ask for filename to load
153 wxLoadFileSelector(const wxChar
*what
,
154 const wxChar
*extension
,
155 const wxChar
*default_name
= (const wxChar
*)NULL
,
156 wxWindow
*parent
= (wxWindow
*) NULL
);
158 // Ask for filename to save
160 wxSaveFileSelector(const wxChar
*what
,
161 const wxChar
*extension
,
162 const wxChar
*default_name
= (const wxChar
*) NULL
,
163 wxWindow
*parent
= (wxWindow
*) NULL
);
166 #if defined (__WXUNIVERSAL__)
167 #include "wx/generic/filedlgg.h"
168 #elif defined(__WXMSW__)
169 #include "wx/msw/filedlg.h"
170 #elif defined(__WXMOTIF__)
171 #include "wx/motif/filedlg.h"
172 #elif defined(__WXGTK__)
173 #include "wx/gtk/filedlg.h"
174 #elif defined(__WXX11__)
175 #include "wx/generic/filedlgg.h"
176 #elif defined(__WXMGL__)
177 #include "wx/generic/filedlgg.h"
178 #elif defined(__WXMAC__)
179 #include "wx/mac/filedlg.h"
180 #elif defined(__WXCOCOA__)
181 #include "wx/cocoa/filedlg.h"
182 #elif defined(__WXPM__)
183 #include "wx/os2/filedlg.h"
186 #endif // wxUSE_FILEDLG
188 #endif // _WX_FILEDLG_H_BASE_