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