]> git.saurik.com Git - wxWidgets.git/blob - include/wx/filedlg.h
Remove RPM .spec files from the repository.
[wxWidgets.git] / include / wx / filedlg.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/filedlg.h
3 // Purpose: wxFileDialog base header
4 // Author: Robert Roebling
5 // Modified by:
6 // Created: 8/17/99
7 // Copyright: (c) Robert Roebling
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 #ifndef _WX_FILEDLG_H_BASE_
12 #define _WX_FILEDLG_H_BASE_
13
14 #include "wx/defs.h"
15
16 #if wxUSE_FILEDLG
17
18 #include "wx/dialog.h"
19 #include "wx/arrstr.h"
20
21 // this symbol is defined for the platforms which support multiple
22 // ('|'-separated) filters in the file dialog
23 #if defined(__WXMSW__) || defined(__WXGTK__) || defined(__WXMAC__)
24 #define wxHAS_MULTIPLE_FILEDLG_FILTERS
25 #endif
26
27 //----------------------------------------------------------------------------
28 // wxFileDialog data
29 //----------------------------------------------------------------------------
30
31 /*
32 The flags below must coexist with the following flags in m_windowStyle
33 #define wxCAPTION 0x20000000
34 #define wxMAXIMIZE 0x00002000
35 #define wxCLOSE_BOX 0x00001000
36 #define wxSYSTEM_MENU 0x00000800
37 wxBORDER_NONE = 0x00200000
38 #define wxRESIZE_BORDER 0x00000040
39 */
40
41 enum
42 {
43 wxFD_OPEN = 0x0001,
44 wxFD_SAVE = 0x0002,
45 wxFD_OVERWRITE_PROMPT = 0x0004,
46 wxFD_FILE_MUST_EXIST = 0x0010,
47 wxFD_MULTIPLE = 0x0020,
48 wxFD_CHANGE_DIR = 0x0080,
49 wxFD_PREVIEW = 0x0100
50 };
51
52 #if WXWIN_COMPATIBILITY_2_6
53 enum
54 {
55 wxOPEN = wxFD_OPEN,
56 wxSAVE = wxFD_SAVE,
57 wxOVERWRITE_PROMPT = wxFD_OVERWRITE_PROMPT,
58 wxFILE_MUST_EXIST = wxFD_FILE_MUST_EXIST,
59 wxMULTIPLE = wxFD_MULTIPLE,
60 wxCHANGE_DIR = wxFD_CHANGE_DIR
61 };
62 #endif
63
64 #define wxFD_DEFAULT_STYLE wxFD_OPEN
65
66 extern WXDLLIMPEXP_DATA_CORE(const char) wxFileDialogNameStr[];
67 extern WXDLLIMPEXP_DATA_CORE(const char) wxFileSelectorPromptStr[];
68 extern WXDLLIMPEXP_DATA_CORE(const char) wxFileSelectorDefaultWildcardStr[];
69
70 //----------------------------------------------------------------------------
71 // wxFileDialogBase
72 //----------------------------------------------------------------------------
73
74 class WXDLLIMPEXP_CORE wxFileDialogBase: public wxDialog
75 {
76 public:
77 wxFileDialogBase () { Init(); }
78
79 wxFileDialogBase(wxWindow *parent,
80 const wxString& message = wxFileSelectorPromptStr,
81 const wxString& defaultDir = wxEmptyString,
82 const wxString& defaultFile = wxEmptyString,
83 const wxString& wildCard = wxFileSelectorDefaultWildcardStr,
84 long style = wxFD_DEFAULT_STYLE,
85 const wxPoint& pos = wxDefaultPosition,
86 const wxSize& sz = wxDefaultSize,
87 const wxString& name = wxFileDialogNameStr)
88 {
89 Init();
90 Create(parent, message, defaultDir, defaultFile, wildCard, style, pos, sz, name);
91 }
92
93 virtual ~wxFileDialogBase() {}
94
95
96 bool Create(wxWindow *parent,
97 const wxString& message = wxFileSelectorPromptStr,
98 const wxString& defaultDir = wxEmptyString,
99 const wxString& defaultFile = wxEmptyString,
100 const wxString& wildCard = wxFileSelectorDefaultWildcardStr,
101 long style = wxFD_DEFAULT_STYLE,
102 const wxPoint& pos = wxDefaultPosition,
103 const wxSize& sz = wxDefaultSize,
104 const wxString& name = wxFileDialogNameStr);
105
106 bool HasFdFlag(int flag) const { return HasFlag(flag); }
107
108 virtual void SetMessage(const wxString& message) { m_message = message; }
109 virtual void SetPath(const wxString& path);
110 virtual void SetDirectory(const wxString& dir);
111 virtual void SetFilename(const wxString& name);
112 virtual void SetWildcard(const wxString& wildCard) { m_wildCard = wildCard; }
113 virtual void SetFilterIndex(int filterIndex) { m_filterIndex = filterIndex; }
114
115 virtual wxString GetMessage() const { return m_message; }
116 virtual wxString GetPath() const { return m_path; }
117 virtual void GetPaths(wxArrayString& paths) const { paths.Empty(); paths.Add(m_path); }
118 virtual wxString GetDirectory() const { return m_dir; }
119 virtual wxString GetFilename() const { return m_fileName; }
120 virtual void GetFilenames(wxArrayString& files) const { files.Empty(); files.Add(m_fileName); }
121 virtual wxString GetWildcard() const { return m_wildCard; }
122 virtual int GetFilterIndex() const { return m_filterIndex; }
123
124 virtual wxString GetCurrentlySelectedFilename() const
125 { return m_currentlySelectedFilename; }
126
127 // this function is called with wxFileDialog as parameter and should
128 // create the window containing the extra controls we want to show in it
129 typedef wxWindow *(*ExtraControlCreatorFunction)(wxWindow*);
130
131 virtual bool SupportsExtraControl() const { return false; }
132
133 bool SetExtraControlCreator(ExtraControlCreatorFunction creator);
134 wxWindow *GetExtraControl() const { return m_extraControl; }
135
136 // Utility functions
137
138 #if WXWIN_COMPATIBILITY_2_6
139
140 wxDEPRECATED( long GetStyle() const );
141 wxDEPRECATED( void SetStyle(long style) );
142
143 #endif // WXWIN_COMPATIBILITY_2_6
144
145
146 // Append first extension to filePath from a ';' separated extensionList
147 // if filePath = "path/foo.bar" just return it as is
148 // if filePath = "foo[.]" and extensionList = "*.jpg;*.png" return "foo.jpg"
149 // if the extension is "*.j?g" (has wildcards) or "jpg" then return filePath
150 static wxString AppendExtension(const wxString &filePath,
151 const wxString &extensionList);
152
153 protected:
154 wxString m_message;
155 wxString m_dir;
156 wxString m_path; // Full path
157 wxString m_fileName;
158 wxString m_wildCard;
159 int m_filterIndex;
160
161 // Currently selected, but not yet necessarily accepted by the user, file.
162 // This should be updated whenever the selection in the control changes by
163 // the platform-specific code to provide a useful implementation of
164 // GetCurrentlySelectedFilename().
165 wxString m_currentlySelectedFilename;
166
167 wxWindow* m_extraControl;
168
169 // returns true if control is created (if it already exists returns false)
170 bool CreateExtraControl();
171 // return true if SetExtraControlCreator() was called
172 bool HasExtraControlCreator() const
173 { return m_extraControlCreator != NULL; }
174 // get the size of the extra control by creating and deleting it
175 wxSize GetExtraControlSize();
176
177 private:
178 ExtraControlCreatorFunction m_extraControlCreator;
179
180 void Init();
181 DECLARE_DYNAMIC_CLASS(wxFileDialogBase)
182 wxDECLARE_NO_COPY_CLASS(wxFileDialogBase);
183 };
184
185
186 //----------------------------------------------------------------------------
187 // wxFileDialog convenience functions
188 //----------------------------------------------------------------------------
189
190 // File selector - backward compatibility
191 WXDLLIMPEXP_CORE wxString
192 wxFileSelector(const wxString& message = wxFileSelectorPromptStr,
193 const wxString& default_path = wxEmptyString,
194 const wxString& default_filename = wxEmptyString,
195 const wxString& default_extension = wxEmptyString,
196 const wxString& wildcard = wxFileSelectorDefaultWildcardStr,
197 int flags = 0,
198 wxWindow *parent = NULL,
199 int x = wxDefaultCoord, int y = wxDefaultCoord);
200
201 // An extended version of wxFileSelector
202 WXDLLIMPEXP_CORE wxString
203 wxFileSelectorEx(const wxString& message = wxFileSelectorPromptStr,
204 const wxString& default_path = wxEmptyString,
205 const wxString& default_filename = wxEmptyString,
206 int *indexDefaultExtension = NULL,
207 const wxString& wildcard = wxFileSelectorDefaultWildcardStr,
208 int flags = 0,
209 wxWindow *parent = NULL,
210 int x = wxDefaultCoord, int y = wxDefaultCoord);
211
212 // Ask for filename to load
213 WXDLLIMPEXP_CORE wxString
214 wxLoadFileSelector(const wxString& what,
215 const wxString& extension,
216 const wxString& default_name = wxEmptyString,
217 wxWindow *parent = NULL);
218
219 // Ask for filename to save
220 WXDLLIMPEXP_CORE wxString
221 wxSaveFileSelector(const wxString& what,
222 const wxString& extension,
223 const wxString& default_name = wxEmptyString,
224 wxWindow *parent = NULL);
225
226
227 #if defined (__WXUNIVERSAL__)
228 #define wxHAS_GENERIC_FILEDIALOG
229 #include "wx/generic/filedlgg.h"
230 #elif defined(__WXMSW__)
231 #include "wx/msw/filedlg.h"
232 #elif defined(__WXMOTIF__)
233 #include "wx/motif/filedlg.h"
234 #elif defined(__WXGTK20__)
235 #include "wx/gtk/filedlg.h" // GTK+ > 2.4 has native version
236 #elif defined(__WXGTK__)
237 #include "wx/gtk1/filedlg.h"
238 #elif defined(__WXMAC__)
239 #include "wx/osx/filedlg.h"
240 #elif defined(__WXCOCOA__)
241 #include "wx/cocoa/filedlg.h"
242 #elif defined(__WXPM__)
243 #include "wx/os2/filedlg.h"
244 #endif
245
246 #endif // wxUSE_FILEDLG
247
248 #endif // _WX_FILEDLG_H_BASE_