]> git.saurik.com Git - wxWidgets.git/blame - interface/filedlg.h
fixed links to global variables; fixed categories; use @see instead of @seealso
[wxWidgets.git] / interface / filedlg.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: filedlg.h
3// Purpose: documentation for wxFileDialog class
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
9/**
10 @class wxFileDialog
11 @wxheader{filedlg.h}
7c913512 12
23324ae1 13 This class represents the file chooser dialog.
7c913512 14
23324ae1
FM
15 @beginStyleTable
16 @style{wxFD_DEFAULT_STYLE}:
17 Equivalent to wxFD_OPEN.
18 @style{wxFD_OPEN}:
19 This is an open dialog; usually this means that the default
20 button's label of the dialog is "Open". Cannot be combined with
21 wxFD_SAVE.
22 @style{wxFD_SAVE}:
23 This is a save dialog; usually this means that the default button's
24 label of the dialog is "Save". Cannot be combined with wxFD_OPEN.
25 @style{wxFD_OVERWRITE_PROMPT}:
26 For save dialog only: prompt for a confirmation if a file will be
27 overwritten.
28 @style{wxFD_FILE_MUST_EXIST}:
29 For open dialog only: the user may only select files that actually
30 exist.
31 @style{wxFD_MULTIPLE}:
32 For open dialog only: allows selecting multiple files.
33 @style{wxFD_CHANGE_DIR}:
34 Change the current working directory to the directory where the
35 file(s) chosen by the user are.
36 @style{wxFD_PREVIEW}:
37 Show the preview of the selected files (currently only supported by
38 wxGTK using GTK+ 2.4 or later).
39 @endStyleTable
7c913512 40
23324ae1
FM
41 @library{wxcore}
42 @category{cmndlg}
7c913512 43
23324ae1
FM
44 @seealso
45 @ref overview_wxfiledialogoverview "wxFileDialog overview", wxFileSelector
46*/
47class wxFileDialog : public wxDialog
48{
49public:
50 /**
51 Constructor. Use ShowModal() to show the dialog.
52
7c913512 53 @param parent
4cc4bfaf 54 Parent window.
7c913512 55 @param message
4cc4bfaf 56 Message to show on the dialog.
7c913512 57 @param defaultDir
4cc4bfaf 58 The default directory, or the empty string.
7c913512 59 @param defaultFile
4cc4bfaf 60 The default filename, or the empty string.
7c913512 61 @param wildcard
4cc4bfaf
FM
62 A wildcard, such as "*.*" or "BMP files (*.bmp)|*.bmp|GIF files
63 (*.gif)|*.gif".
64 Note that the native Motif dialog has some limitations with respect to
65 wildcards; see the Remarks section above.
7c913512 66 @param style
4cc4bfaf 67 A dialog style. See wxFD_* styles for more info.
7c913512 68 @param pos
4cc4bfaf 69 Dialog position. Not implemented.
7c913512 70 @param size
4cc4bfaf 71 Dialog size. Not implemented.
7c913512 72 @param name
4cc4bfaf 73 Dialog name. Not implemented.
23324ae1
FM
74 */
75 wxFileDialog(wxWindow* parent,
76 const wxString& message = "Choose a file",
77 const wxString& defaultDir = "",
78 const wxString& defaultFile = "",
79 const wxString& wildcard = ".",
80 long style = wxFD_DEFAULT_STYLE,
81 const wxPoint& pos = wxDefaultPosition,
82 const wxSize& sz = wxDefaultSize,
83 const wxString& name = "filedlg");
84
85 /**
86 Destructor.
87 */
88 ~wxFileDialog();
89
90 /**
91 Returns the default directory.
92 */
328f5751 93 wxString GetDirectory() const;
23324ae1
FM
94
95 /**
7c913512 96 If functions
23324ae1
FM
97 SetExtraControlCreator()
98 and ShowModal() were called,
99 returns the extra window. Otherwise returns @NULL.
100 */
328f5751 101 wxWindow* GetExtraControl() const;
23324ae1
FM
102
103 /**
104 Returns the default filename.
105 */
328f5751 106 wxString GetFilename() const;
23324ae1
FM
107
108 /**
4cc4bfaf 109 Fills the array @a filenames with the names of the files chosen. This
23324ae1
FM
110 function should only be used with the dialogs which have @c wxFD_MULTIPLE style,
111 use GetFilename() for the others.
23324ae1
FM
112 Note that under Windows, if the user selects shortcuts, the filenames
113 include paths, since the application cannot determine the full path
114 of each referenced file by appending the directory containing the shortcuts
115 to the filename.
116 */
328f5751 117 void GetFilenames(wxArrayString& filenames) const;
23324ae1
FM
118
119 /**
120 Returns the index into the list of filters supplied, optionally, in the
121 wildcard parameter.
122 Before the dialog is shown, this is the index which will be used when the
123 dialog is first displayed.
124 After the dialog is shown, this is the index selected by the user.
125 */
328f5751 126 int GetFilterIndex() const;
23324ae1
FM
127
128 /**
129 Returns the message that will be displayed on the dialog.
130 */
328f5751 131 wxString GetMessage() const;
23324ae1
FM
132
133 /**
134 Returns the full path (directory and filename) of the selected file.
135 */
328f5751 136 wxString GetPath() const;
23324ae1
FM
137
138 /**
4cc4bfaf 139 Fills the array @a paths with the full paths of the files chosen. This
23324ae1
FM
140 function should only be used with the dialogs which have @c wxFD_MULTIPLE style,
141 use GetPath() for the others.
142 */
328f5751 143 void GetPaths(wxArrayString& paths) const;
23324ae1
FM
144
145 /**
146 Returns the file dialog wildcard.
147 */
328f5751 148 wxString GetWildcard() const;
23324ae1
FM
149
150 /**
151 Sets the default directory.
152 */
153 void SetDirectory(const wxString& directory);
154
155 /**
156 Customize file dialog by adding extra window, which is typically placed
157 below the list of files and above the buttons.
23324ae1
FM
158 SetExtraControlCreator can be called only once, before calling
159 ShowModal().
160 The @c creator function should take pointer to parent window (file dialog)
161 and should return a window allocated with operator new.
23324ae1
FM
162 Supported platforms: wxGTK, wxUniv.
163 */
164 bool SetExtraControlCreator(t_extraControlCreator creator);
165
166 /**
167 Sets the default filename.
168 */
169 void SetFilename(const wxString& setfilename);
170
171 /**
172 Sets the default filter index, starting from zero.
173 */
174 void SetFilterIndex(int filterIndex);
175
176 /**
177 Sets the message that will be displayed on the dialog.
178 */
179 void SetMessage(const wxString& message);
180
181 /**
182 Sets the path (the combined directory and filename that will be returned when
183 the dialog is dismissed).
184 */
185 void SetPath(const wxString& path);
186
187 /**
188 Sets the wildcard, which can contain multiple file types, for example:
23324ae1 189 "BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif"
23324ae1
FM
190 Note that the native Motif dialog has some limitations with respect to
191 wildcards; see the Remarks section above.
192 */
193 void SetWildcard(const wxString& wildCard);
194
195 /**
196 Shows the dialog, returning wxID_OK if the user pressed OK, and wxID_CANCEL
197 otherwise.
198 */
199 int ShowModal();
200};
201
202
203// ============================================================================
204// Global functions/macros
205// ============================================================================
206
207/**
208 Pops up a file selector box. In Windows, this is the common file selector
209 dialog. In X, this is a file selector box with the same functionality.
210 The path and filename are distinct elements of a full file pathname.
211 If path is empty, the current directory will be used. If filename is empty,
212 no default filename will be supplied. The wildcard determines what files
213 are displayed in the file selector, and file extension supplies a type
214 extension for the required filename. Flags may be a combination of wxFD_OPEN,
215 wxFD_SAVE, wxFD_OVERWRITE_PROMPT or wxFD_FILE_MUST_EXIST. Note that
216 wxFD_MULTIPLE
217 can only be used with wxFileDialog and not here as this
218 function only returns a single file name.
23324ae1
FM
219 Both the Unix and Windows versions implement a wildcard filter. Typing a
220 filename containing wildcards (*, ?) in the filename text item, and
221 clicking on Ok, will result in only those files matching the pattern being
222 displayed.
23324ae1
FM
223 The wildcard may be a specification for multiple types of file
224 with a description for each, such as:
4cc4bfaf 225
23324ae1
FM
226 @code
227 "BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif"
228 @endcode
7c913512 229
23324ae1
FM
230 The application must check for an empty return value (the user pressed
231 Cancel). For example:
4cc4bfaf 232
23324ae1
FM
233 @code
234 wxString filename = wxFileSelector("Choose a file to open");
235 if ( !filename.empty() )
236 {
237 // work with the file
238 ...
239 }
240 //else: cancelled by user
241 @endcode
242*/
243wxString wxFileSelector(const wxString& message,
244 const wxString& default_path = "",
245 const wxString& default_filename = "",
246 const wxString& default_extension = "",
247 const wxString& wildcard = ".",
248 int flags = 0,
4cc4bfaf 249 wxWindow* parent = NULL,
23324ae1
FM
250 int x = -1,
251 int y = -1);
252