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