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