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