]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/filedlg.tex
fixed doc wrong position of \wxheading{Library}
[wxWidgets.git] / docs / latex / wx / filedlg.tex
CommitLineData
a660d684
KB
1\section{\class{wxFileDialog}}\label{wxfiledialog}
2
3This class represents the file chooser dialog.
4
5\wxheading{Derived from}
6
7\helpref{wxDialog}{wxdialog}\\
7376079d 8\helpref{wxTopLevelWindow}{wxtoplevelwindow}\\
a660d684
KB
9\helpref{wxWindow}{wxwindow}\\
10\helpref{wxEvtHandler}{wxevthandler}\\
11\helpref{wxObject}{wxobject}
12
954b8ae6
JS
13\wxheading{Include files}
14
15<wx/filedlg.h>
16
a7af285d
VZ
17\wxheading{Library}
18
19\helpref{wxCore}{librarieslist}
20
ff3e84ff
VZ
21\wxheading{Window styles}
22
23\begin{twocollist}\itemsep=0pt
6bd719f1 24\twocolitem{\windowstyle{wxFD\_DEFAULT\_STYLE}}{Equivalent to wxFD\_OPEN.}
ff3e84ff
VZ
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.}
6bd719f1
MR
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.}
9f057af5 31\twocolitem{{\windowstyle wxFD\_PREVIEW}}{Show the preview of the selected files (currently only supported by wxGTK using GTK+ 2.4 or later).}
ff3e84ff
VZ
32\end{twocollist}
33
6bd719f1 34{\bf NB:} Previous versions of wxWidgets used {\tt wxFD\_CHANGE\_DIR} by default
ff3e84ff
VZ
35under MS Windows which allowed the program to simply remember the last
36directory where user selected the files to open/save. This (desired)
37functionality must be implemented in the program itself now (manually remember
38the last path used and pass it to the dialog the next time it is called) or
39by using this flag.
40
41
a660d684
KB
42\wxheading{See also}
43
44\helpref{wxFileDialog overview}{wxfiledialogoverview}, \helpref{wxFileSelector}{wxfileselector}
a660d684
KB
45
46\wxheading{Remarks}
47
f8bc53eb
JS
48Pops up a file selector box. In Windows and GTK2.4+, this is the common
49file selector dialog. In X, this is a file selector box with somewhat less
50functionality. The path and filename are distinct elements of a full file pathname.
a660d684
KB
51If path is ``", the current directory will be used. If filename is ``",
52no default filename will be supplied. The wildcard determines what files
53are displayed in the file selector, and file extension supplies a type
ff3e84ff 54extension for the required filename.
a660d684
KB
55
56Both the X and Windows versions implement a wildcard filter. Typing a
57filename containing wildcards (*, ?) in the filename text item, and
58clicking on Ok, will result in only those files matching the pattern being
330d6fd0 59displayed. The wildcard may be a specification for multiple
a660d684
KB
60types of file with a description for each, such as:
61
62\begin{verbatim}
8632fc36 63 "BMP and GIF files (*.bmp;*.gif)|*.bmp;*.gif|PNG files (*.png)|*.png"
a660d684
KB
64\end{verbatim}
65
a4e64fb5
MB
66It must be noted that wildcard support in the native Motif file
67dialog is quite limited: only one alternative is supported,
68and it is displayed without the descriptive test; ``BMP files (*.bmp)|*.bmp''
69is displayed as ``*.bmp'', and both
70``BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif'' and
71``Image files|*.bmp;*.gif'' are errors.
72
a660d684
KB
73\latexignore{\rtfignore{\wxheading{Members}}}
74
b236c10f 75\membersection{wxFileDialog::wxFileDialog}\label{wxfiledialogctor}
a660d684
KB
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
ff3e84ff 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"}}
a660d684
KB
80
81Constructor. 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
a4e64fb5
MB
93\docparam{wildcard}{A wildcard, such as ``*.*" or ``BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif".
94
95Note that the native Motif dialog has some limitations with respect to
96wildcards; see the Remarks section above.}
a660d684 97
6bd719f1 98\docparam{style}{A dialog style. See wxFD\_* styles for more info.}
a660d684
KB
99
100\docparam{pos}{Dialog position. Not implemented.}
101
ff3e84ff
VZ
102\docparam{size}{Dialog size. Not implemented.}
103
104\docparam{name}{Dialog name. Not implemented.}
105
3f6638b8 106
b236c10f 107\membersection{wxFileDialog::\destruct{wxFileDialog}}\label{wxfiledialogdtor}
a660d684
KB
108
109\func{}{\destruct{wxFileDialog}}{\void}
110
111Destructor.
112
113\membersection{wxFileDialog::GetDirectory}\label{wxfiledialoggetdirectory}
114
115\constfunc{wxString}{GetDirectory}{\void}
116
117Returns the default directory.
118
119\membersection{wxFileDialog::GetFilename}\label{wxfiledialoggetfilename}
120
121\constfunc{wxString}{GetFilename}{\void}
122
123Returns the default filename.
124
c61f4f6d
VZ
125\membersection{wxFileDialog::GetFilenames}\label{wxfiledialoggetfilenames}
126
127\constfunc{void}{GetFilenames}{\param{wxArrayString\& }{filenames}}
128
129Fills the array {\it filenames} with the names of the files chosen. This
6b5a8c7d 130function should only be used with the dialogs which have {\tt wxFD\_MULTIPLE} style,
c61f4f6d 131use \helpref{GetFilename}{wxfiledialoggetfilename} for the others.
8ad9ca97
JS
132
133Note that under Windows, if the user selects shortcuts, the filenames
134include paths, since the application cannot determine the full path
135of each referenced file by appending the directory containing the shortcuts
136to the filename.
c61f4f6d 137
a660d684
KB
138\membersection{wxFileDialog::GetFilterIndex}\label{wxfiledialoggetfilterindex}
139
140\constfunc{int}{GetFilterIndex}{\void}
141
142Returns the index into the list of filters supplied, optionally, in the wildcard parameter.
143Before the dialog is shown, this is the index which will be used when the dialog is first displayed.
144After the dialog is shown, this is the index selected by the user.
145
146\membersection{wxFileDialog::GetMessage}\label{wxfiledialoggetmessage}
147
148\constfunc{wxString}{GetMessage}{\void}
149
150Returns the message that will be displayed on the dialog.
151
152\membersection{wxFileDialog::GetPath}\label{wxfiledialoggetpath}
153
154\constfunc{wxString}{GetPath}{\void}
155
156Returns the full path (directory and filename) of the selected file.
157
c61f4f6d
VZ
158\membersection{wxFileDialog::GetPaths}\label{wxfiledialoggetpaths}
159
160\constfunc{void}{GetPaths}{\param{wxArrayString\& }{paths}}
161
162Fills the array {\it paths} with the full paths of the files chosen. This
6b5a8c7d 163function should only be used with the dialogs which have {\tt wxFD\_MULTIPLE} style,
c61f4f6d
VZ
164use \helpref{GetPath}{wxfiledialoggetpath} for the others.
165
a660d684
KB
166\membersection{wxFileDialog::GetWildcard}\label{wxfiledialoggetwildcard}
167
168\constfunc{wxString}{GetWildcard}{\void}
169
170Returns the file dialog wildcard.
171
172\membersection{wxFileDialog::SetDirectory}\label{wxfiledialogsetdirectory}
173
174\func{void}{SetDirectory}{\param{const wxString\& }{directory}}
175
176Sets the default directory.
177
178\membersection{wxFileDialog::SetFilename}\label{wxfiledialogsetfilename}
179
180\func{void}{SetFilename}{\param{const wxString\& }{setfilename}}
181
182Sets the default filename.
183
184\membersection{wxFileDialog::SetFilterIndex}\label{wxfiledialogsetfilterindex}
185
186\func{void}{SetFilterIndex}{\param{int }{filterIndex}}
187
2b5f62a0 188Sets the default filter index, starting from zero.
a660d684
KB
189
190\membersection{wxFileDialog::SetMessage}\label{wxfiledialogsetmessage}
191
192\func{void}{SetMessage}{\param{const wxString\& }{message}}
193
194Sets the message that will be displayed on the dialog.
195
196\membersection{wxFileDialog::SetPath}\label{wxfiledialogsetpath}
197
198\func{void}{SetPath}{\param{const wxString\& }{path}}
199
200Sets the path (the combined directory and filename that will be returned when the dialog is dismissed).
201
a660d684
KB
202\membersection{wxFileDialog::SetWildcard}\label{wxfiledialogsetwildcard}
203
204\func{void}{SetWildcard}{\param{const wxString\& }{wildCard}}
205
6a611b39
JS
206Sets the wildcard, which can contain multiple file types, for example:
207
208``BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif"
a660d684 209
a4e64fb5
MB
210Note that the native Motif dialog has some limitations with respect to
211wildcards; see the Remarks section above.
212
a660d684
KB
213\membersection{wxFileDialog::ShowModal}\label{wxfiledialogshowmodal}
214
215\func{int}{ShowModal}{\void}
216
f6bcfd97 217Shows the dialog, returning wxID\_OK if the user pressed OK, and wxID\_CANCEL
a660d684
KB
218otherwise.
219
220