]> git.saurik.com Git - wxWidgets.git/blob - docs/latex/wx/filedlg.tex
add support for custom controls in file dialog in wxGTK and generic versions; also...
[wxWidgets.git] / docs / latex / wx / filedlg.tex
1 \section{\class{wxFileDialog}}\label{wxfiledialog}
2
3 This class represents the file chooser dialog.
4
5 \wxheading{Derived from}
6
7 \helpref{wxDialog}{wxdialog}\\
8 \helpref{wxTopLevelWindow}{wxtoplevelwindow}\\
9 \helpref{wxWindow}{wxwindow}\\
10 \helpref{wxEvtHandler}{wxevthandler}\\
11 \helpref{wxObject}{wxobject}
12
13 \wxheading{Include files}
14
15 <wx/filedlg.h>
16
17 \wxheading{Library}
18
19 \helpref{wxCore}{librarieslist}
20
21 \wxheading{Window styles}
22
23 \begin{twocollist}\itemsep=0pt
24 \twocolitem{\windowstyle{wxFD\_DEFAULT\_STYLE}}{Equivalent to wxFD\_OPEN.}
25 \twocolitem{\windowstyle{wxFD\_OPEN}}{This is an open dialog; usually this means that the default button's label of the dialog is "Open". Cannot be combined with wxFD\_SAVE.}
26 \twocolitem{\windowstyle{wxFD\_SAVE}}{This is a save dialog; usually this means that the default button's label of the dialog is "Save". Cannot be combined with wxFD\_OPEN.}
27 \twocolitem{{\windowstyle wxFD\_OVERWRITE\_PROMPT}}{For save dialog only: prompt for a confirmation if a file will be overwritten.}
28 \twocolitem{{\windowstyle wxFD\_FILE\_MUST\_EXIST}}{For open dialog only: the user may only select files that actually exist.}
29 \twocolitem{{\windowstyle wxFD\_MULTIPLE}}{For open dialog only: allows selecting multiple files.}
30 \twocolitem{{\windowstyle wxFD\_CHANGE\_DIR}}{Change the current working directory to the directory where the file(s) chosen by the user are.}
31 \twocolitem{{\windowstyle wxFD\_PREVIEW}}{Show the preview of the selected files (currently only supported by wxGTK using GTK+ 2.4 or later).}
32 \end{twocollist}
33
34 {\bf NB:} Previous versions of wxWidgets used {\tt wxFD\_CHANGE\_DIR} by default
35 under MS Windows which allowed the program to simply remember the last
36 directory where user selected the files to open/save. This (desired)
37 functionality must be implemented in the program itself now (manually remember
38 the last path used and pass it to the dialog the next time it is called) or
39 by using this flag.
40
41
42 \wxheading{See also}
43
44 \helpref{wxFileDialog overview}{wxfiledialogoverview}, \helpref{wxFileSelector}{wxfileselector}
45
46 \wxheading{Remarks}
47
48 Pops up a file selector box. In Windows and GTK2.4+, this is the common
49 file selector dialog. In X, this is a file selector box with somewhat less
50 functionality. The path and filename are distinct elements of a full file pathname.
51 If path is ``", the current directory will be used. If filename is ``",
52 no default filename will be supplied. The wildcard determines what files
53 are displayed in the file selector, and file extension supplies a type
54 extension for the required filename.
55
56 Both the X and Windows versions implement a wildcard filter. Typing a
57 filename containing wildcards (*, ?) in the filename text item, and
58 clicking on Ok, will result in only those files matching the pattern being
59 displayed. The wildcard may be a specification for multiple
60 types of file with a description for each, such as:
61
62 \begin{verbatim}
63 "BMP and GIF files (*.bmp;*.gif)|*.bmp;*.gif|PNG files (*.png)|*.png"
64 \end{verbatim}
65
66 It must be noted that wildcard support in the native Motif file
67 dialog is quite limited: only one alternative is supported,
68 and it is displayed without the descriptive test; ``BMP files (*.bmp)|*.bmp''
69 is displayed as ``*.bmp'', and both
70 ``BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif'' and
71 ``Image files|*.bmp;*.gif'' are errors.
72
73 \latexignore{\rtfignore{\wxheading{Members}}}
74
75 \membersection{wxFileDialog::wxFileDialog}\label{wxfiledialogctor}
76
77 \func{}{wxFileDialog}{\param{wxWindow* }{parent}, \param{const wxString\& }{message = "Choose a file"},\rtfsp
78 \param{const wxString\& }{defaultDir = ""}, \param{const wxString\& }{defaultFile = ``"},\rtfsp
79 \param{const wxString\& }{wildcard = ``*.*"}, \param{long }{style = wxFD\_DEFAULT\_STYLE}, \param{const wxPoint\& }{pos = wxDefaultPosition}, \param{const wxSize\& }{sz = wxDefaultSize}, \param{const wxString\& }{name = "filedlg"}}
80
81 Constructor. Use \helpref{wxFileDialog::ShowModal}{wxfiledialogshowmodal} to show the dialog.
82
83 \wxheading{Parameters}
84
85 \docparam{parent}{Parent window.}
86
87 \docparam{message}{Message to show on the dialog.}
88
89 \docparam{defaultDir}{The default directory, or the empty string.}
90
91 \docparam{defaultFile}{The default filename, or the empty string.}
92
93 \docparam{wildcard}{A wildcard, such as ``*.*" or ``BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif".
94
95 Note that the native Motif dialog has some limitations with respect to
96 wildcards; see the Remarks section above.}
97
98 \docparam{style}{A dialog style. See wxFD\_* styles for more info.}
99
100 \docparam{pos}{Dialog position. Not implemented.}
101
102 \docparam{size}{Dialog size. Not implemented.}
103
104 \docparam{name}{Dialog name. Not implemented.}
105
106
107 \membersection{wxFileDialog::\destruct{wxFileDialog}}\label{wxfiledialogdtor}
108
109 \func{}{\destruct{wxFileDialog}}{\void}
110
111 Destructor.
112
113 \membersection{wxFileDialog::GetDirectory}\label{wxfiledialoggetdirectory}
114
115 \constfunc{wxString}{GetDirectory}{\void}
116
117 Returns the default directory.
118
119 \membersection{wxFileDialog::GetExtraControl}\label{wxfiledialoggetextracontrol}
120
121 \constfunc{wxWindow* }{GetExtraControl}{\void}
122
123 If functions
124 \helpref{SetExtraControlCreator}{wxfiledialogsetextracontrolcreator}
125 and \helpref{ShowModal}{wxfiledialogshowmodal} were called,
126 returns the extra window. Otherwise returns \NULL.
127
128 \membersection{wxFileDialog::GetFilename}\label{wxfiledialoggetfilename}
129
130 \constfunc{wxString}{GetFilename}{\void}
131
132 Returns the default filename.
133
134 \membersection{wxFileDialog::GetFilenames}\label{wxfiledialoggetfilenames}
135
136 \constfunc{void}{GetFilenames}{\param{wxArrayString\& }{filenames}}
137
138 Fills the array {\it filenames} with the names of the files chosen. This
139 function should only be used with the dialogs which have {\tt wxFD\_MULTIPLE} style,
140 use \helpref{GetFilename}{wxfiledialoggetfilename} for the others.
141
142 Note that under Windows, if the user selects shortcuts, the filenames
143 include paths, since the application cannot determine the full path
144 of each referenced file by appending the directory containing the shortcuts
145 to the filename.
146
147 \membersection{wxFileDialog::GetFilterIndex}\label{wxfiledialoggetfilterindex}
148
149 \constfunc{int}{GetFilterIndex}{\void}
150
151 Returns the index into the list of filters supplied, optionally, in the wildcard parameter.
152 Before the dialog is shown, this is the index which will be used when the dialog is first displayed.
153 After the dialog is shown, this is the index selected by the user.
154
155 \membersection{wxFileDialog::GetMessage}\label{wxfiledialoggetmessage}
156
157 \constfunc{wxString}{GetMessage}{\void}
158
159 Returns the message that will be displayed on the dialog.
160
161 \membersection{wxFileDialog::GetPath}\label{wxfiledialoggetpath}
162
163 \constfunc{wxString}{GetPath}{\void}
164
165 Returns the full path (directory and filename) of the selected file.
166
167 \membersection{wxFileDialog::GetPaths}\label{wxfiledialoggetpaths}
168
169 \constfunc{void}{GetPaths}{\param{wxArrayString\& }{paths}}
170
171 Fills the array {\it paths} with the full paths of the files chosen. This
172 function should only be used with the dialogs which have {\tt wxFD\_MULTIPLE} style,
173 use \helpref{GetPath}{wxfiledialoggetpath} for the others.
174
175 \membersection{wxFileDialog::GetWildcard}\label{wxfiledialoggetwildcard}
176
177 \constfunc{wxString}{GetWildcard}{\void}
178
179 Returns the file dialog wildcard.
180
181 \membersection{wxFileDialog::SetDirectory}\label{wxfiledialogsetdirectory}
182
183 \func{void}{SetDirectory}{\param{const wxString\& }{directory}}
184
185 Sets the default directory.
186
187 \membersection{wxFileDialog::SetExtraControlCreator}\label{wxfiledialogsetextracontrolcreator}
188
189 \begin{verbatim}
190 typedef wxWindow* (*ExtraControlCreatorFunction)(wxWindow*);
191 \end{verbatim}
192 \func{bool}{SetExtraControlCreator}{\param{t\_extraControlCreator }{creator}}
193
194 Customize file dialog by adding extra window, which is typically placed
195 below the list of files and above the buttons.
196
197 SetExtraControlCreator can be called only once, before calling
198 \helpref{ShowModal}{wxfiledialogshowmodal}.
199 The {\tt creator} function should take pointer to parent window (file dialog)
200 and should return a window allocated with operator new.
201
202 Supported platforms: wxGTK, wxUniv.
203
204 \wxheading{Return value}
205 {\tt true} if adding extra controls is supported, {\tt false} otherwise.
206
207 \membersection{wxFileDialog::SetFilename}\label{wxfiledialogsetfilename}
208
209 \func{void}{SetFilename}{\param{const wxString\& }{setfilename}}
210
211 Sets the default filename.
212
213 \membersection{wxFileDialog::SetFilterIndex}\label{wxfiledialogsetfilterindex}
214
215 \func{void}{SetFilterIndex}{\param{int }{filterIndex}}
216
217 Sets the default filter index, starting from zero.
218
219 \membersection{wxFileDialog::SetMessage}\label{wxfiledialogsetmessage}
220
221 \func{void}{SetMessage}{\param{const wxString\& }{message}}
222
223 Sets the message that will be displayed on the dialog.
224
225 \membersection{wxFileDialog::SetPath}\label{wxfiledialogsetpath}
226
227 \func{void}{SetPath}{\param{const wxString\& }{path}}
228
229 Sets the path (the combined directory and filename that will be returned when the dialog is dismissed).
230
231 \membersection{wxFileDialog::SetWildcard}\label{wxfiledialogsetwildcard}
232
233 \func{void}{SetWildcard}{\param{const wxString\& }{wildCard}}
234
235 Sets the wildcard, which can contain multiple file types, for example:
236
237 ``BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif"
238
239 Note that the native Motif dialog has some limitations with respect to
240 wildcards; see the Remarks section above.
241
242 \membersection{wxFileDialog::ShowModal}\label{wxfiledialogshowmodal}
243
244 \func{int}{ShowModal}{\void}
245
246 Shows the dialog, returning wxID\_OK if the user pressed OK, and wxID\_CANCEL
247 otherwise.
248
249