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