2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: filedlg.h
|
2008-03-10 11:24:38 -04:00
|
|
|
// Purpose: interface of wxFileDialog
|
2008-03-08 08:52:38 -05:00
|
|
|
// Author: wxWidgets team
|
2010-07-13 09:29:13 -04:00
|
|
|
// Licence: wxWindows licence
|
2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2011-09-16 13:03:01 -04:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
wxFD_OPEN = 0x0001,
|
|
|
|
wxFD_SAVE = 0x0002,
|
|
|
|
wxFD_OVERWRITE_PROMPT = 0x0004,
|
2014-03-05 11:29:46 -05:00
|
|
|
wxFD_NO_FOLLOW = 0x0008,
|
2011-09-16 13:03:01 -04:00
|
|
|
wxFD_FILE_MUST_EXIST = 0x0010,
|
|
|
|
wxFD_CHANGE_DIR = 0x0080,
|
2015-03-02 08:32:53 -05:00
|
|
|
wxFD_PREVIEW = 0x0100,
|
2019-07-14 15:26:29 -04:00
|
|
|
wxFD_MULTIPLE = 0x0200,
|
|
|
|
wxFD_SHOW_HIDDEN = 0x0400
|
2011-09-16 13:03:01 -04:00
|
|
|
};
|
|
|
|
|
2011-12-30 01:14:17 -05:00
|
|
|
#define wxFD_DEFAULT_STYLE wxFD_OPEN
|
|
|
|
|
2012-03-03 19:29:07 -05:00
|
|
|
/**
|
|
|
|
Default wildcard string used in wxFileDialog corresponding to all files.
|
|
|
|
|
2015-11-28 17:34:42 -05:00
|
|
|
It is defined as "*.*" under MSW and "*" everywhere else.
|
2012-03-03 19:29:07 -05:00
|
|
|
*/
|
|
|
|
const char wxFileSelectorDefaultWildcardStr[];
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxFileDialog
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
This class represents the file chooser dialog.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-04-01 09:55:38 -04:00
|
|
|
The path and filename are distinct elements of a full file pathname.
|
2010-05-28 16:31:45 -04:00
|
|
|
If path is ::wxEmptyString, the current directory will be used.
|
|
|
|
If filename is ::wxEmptyString, no default filename will be supplied.
|
2009-01-10 13:31:45 -05:00
|
|
|
The wildcard determines what files are displayed in the file selector,
|
|
|
|
and file extension supplies a type extension for the required filename.
|
2008-04-01 09:55:38 -04:00
|
|
|
|
2010-05-28 16:31:45 -04:00
|
|
|
The typical usage for the open file dialog is:
|
|
|
|
@code
|
|
|
|
void MyFrame::OnOpen(wxCommandEvent& WXUNUSED(event))
|
|
|
|
{
|
|
|
|
if (...current content has not been saved...)
|
|
|
|
{
|
|
|
|
if (wxMessageBox(_("Current content has not been saved! Proceed?"), _("Please confirm"),
|
|
|
|
wxICON_QUESTION | wxYES_NO, this) == wxNO )
|
|
|
|
return;
|
|
|
|
//else: proceed asking to the user the new file to open
|
|
|
|
}
|
2019-01-30 11:28:08 -05:00
|
|
|
|
|
|
|
wxFileDialog
|
2010-05-28 16:31:45 -04:00
|
|
|
openFileDialog(this, _("Open XYZ file"), "", "",
|
|
|
|
"XYZ files (*.xyz)|*.xyz", wxFD_OPEN|wxFD_FILE_MUST_EXIST);
|
|
|
|
|
|
|
|
if (openFileDialog.ShowModal() == wxID_CANCEL)
|
|
|
|
return; // the user changed idea...
|
2019-01-30 11:28:08 -05:00
|
|
|
|
2010-05-28 16:31:45 -04:00
|
|
|
// proceed loading the file chosen by the user;
|
|
|
|
// this can be done with e.g. wxWidgets input streams:
|
|
|
|
wxFileInputStream input_stream(openFileDialog.GetPath());
|
|
|
|
if (!input_stream.IsOk())
|
|
|
|
{
|
|
|
|
wxLogError("Cannot open file '%s'.", openFileDialog.GetPath());
|
|
|
|
return;
|
|
|
|
}
|
2019-01-30 11:28:08 -05:00
|
|
|
|
2010-05-28 16:31:45 -04:00
|
|
|
...
|
|
|
|
}
|
|
|
|
@endcode
|
2019-01-30 11:28:08 -05:00
|
|
|
|
2010-05-28 16:31:45 -04:00
|
|
|
The typical usage for the save file dialog is instead somewhat simpler:
|
|
|
|
@code
|
|
|
|
void MyFrame::OnSaveAs(wxCommandEvent& WXUNUSED(event))
|
|
|
|
{
|
2019-01-30 11:28:08 -05:00
|
|
|
wxFileDialog
|
2010-05-28 16:31:45 -04:00
|
|
|
saveFileDialog(this, _("Save XYZ file"), "", "",
|
|
|
|
"XYZ files (*.xyz)|*.xyz", wxFD_SAVE|wxFD_OVERWRITE_PROMPT);
|
|
|
|
|
|
|
|
if (saveFileDialog.ShowModal() == wxID_CANCEL)
|
|
|
|
return; // the user changed idea...
|
2019-01-30 11:28:08 -05:00
|
|
|
|
2010-05-28 16:31:45 -04:00
|
|
|
// save the current contents in the file;
|
|
|
|
// this can be done with e.g. wxWidgets output streams:
|
|
|
|
wxFileOutputStream output_stream(saveFileDialog.GetPath());
|
|
|
|
if (!output_stream.IsOk())
|
|
|
|
{
|
|
|
|
wxLogError("Cannot save current contents in file '%s'.", saveFileDialog.GetPath());
|
|
|
|
return;
|
|
|
|
}
|
2019-01-30 11:28:08 -05:00
|
|
|
|
2010-05-28 16:31:45 -04:00
|
|
|
...
|
|
|
|
}
|
|
|
|
@endcode
|
|
|
|
|
2008-04-01 09:55:38 -04:00
|
|
|
@remarks
|
|
|
|
All implementations of the wxFileDialog provide a wildcard filter. Typing a filename
|
|
|
|
containing wildcards (*, ?) in the filename text item, and clicking on Ok, will
|
|
|
|
result in only those files matching the pattern being displayed.
|
|
|
|
The wildcard may be a specification for multiple types of file with a description
|
|
|
|
for each, such as:
|
2008-09-25 15:15:28 -04:00
|
|
|
@code
|
2008-04-01 09:55:38 -04:00
|
|
|
"BMP and GIF files (*.bmp;*.gif)|*.bmp;*.gif|PNG files (*.png)|*.png"
|
2008-09-25 15:15:28 -04:00
|
|
|
@endcode
|
2008-04-01 09:55:38 -04:00
|
|
|
It must be noted that wildcard support in the native Motif file dialog is quite
|
2010-11-14 19:11:21 -05:00
|
|
|
limited: only one file type is supported, and it is displayed without the
|
2008-04-01 09:55:38 -04:00
|
|
|
descriptive test; "BMP files (*.bmp)|*.bmp" is displayed as "*.bmp", and both
|
|
|
|
"BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif" and "Image files|*.bmp;*.gif"
|
|
|
|
are errors.
|
2019-10-20 19:36:18 -04:00
|
|
|
On Mac OS X in the open file dialog the filter choice box is not shown by default.
|
|
|
|
Instead all given wildcards are appplied at the same time: So in the above
|
|
|
|
example all bmp, gif and png files are displayed. To enforce the
|
|
|
|
display of the filter choice set the corresponding wxSystemOptions before calling
|
|
|
|
the file open dialog:
|
|
|
|
@code
|
|
|
|
wxSystemOptions::SetOption(wxOSX_FILEDIALOG_ALWAYS_SHOW_TYPES, 1)
|
|
|
|
@endcode
|
|
|
|
But in contrast to Windows and Unix, where the file type choice filters only
|
|
|
|
the selected files, on Mac OS X even in this case the dialog shows all files
|
|
|
|
matching all file types. The files which does not match the currently selected
|
|
|
|
file type are greyed out and are not selectable.
|
2008-04-01 09:55:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@beginStyleTable
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxFD_DEFAULT_STYLE}
|
2010-05-28 16:31:45 -04:00
|
|
|
Equivalent to @c wxFD_OPEN.
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxFD_OPEN}
|
2008-03-08 08:52:38 -05:00
|
|
|
This is an open dialog; usually this means that the default
|
2010-05-28 16:31:45 -04:00
|
|
|
button's label of the dialog is "Open". Cannot be combined with @c wxFD_SAVE.
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxFD_SAVE}
|
2008-03-08 08:52:38 -05:00
|
|
|
This is a save dialog; usually this means that the default button's
|
2010-05-28 16:31:45 -04:00
|
|
|
label of the dialog is "Save". Cannot be combined with @c wxFD_OPEN.
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxFD_OVERWRITE_PROMPT}
|
2008-03-08 08:52:38 -05:00
|
|
|
For save dialog only: prompt for a confirmation if a file will be
|
|
|
|
overwritten.
|
2014-03-05 11:29:46 -05:00
|
|
|
@style{wxFD_NO_FOLLOW}
|
|
|
|
Directs the dialog to return the path and file name of the selected
|
|
|
|
shortcut file, not its target as it does by default. Currently this
|
2019-08-11 20:46:25 -04:00
|
|
|
flag is only implemented in wxMSW and wxOSX (where it prevents
|
|
|
|
aliases from being resolved). The non-dereferenced link path
|
2014-03-05 11:29:46 -05:00
|
|
|
is always returned, even without this flag, under Unix and so using
|
|
|
|
it there doesn't do anything. This flag was added in wxWidgets
|
|
|
|
3.1.0.
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxFD_FILE_MUST_EXIST}
|
2010-08-22 19:45:58 -04:00
|
|
|
For open dialog only: the user may only select files that actually
|
|
|
|
exist. Notice that under OS X the file dialog with @c wxFD_OPEN
|
|
|
|
style always behaves as if this style was specified, because it is
|
|
|
|
impossible to choose a file that doesn't exist from a standard OS X
|
|
|
|
file dialog.
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxFD_MULTIPLE}
|
2008-03-08 08:52:38 -05:00
|
|
|
For open dialog only: allows selecting multiple files.
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxFD_CHANGE_DIR}
|
2019-01-30 11:28:08 -05:00
|
|
|
Change the current working directory (when the dialog is dismissed)
|
2010-05-28 16:31:45 -04:00
|
|
|
to the directory where the file(s) chosen by the user are.
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxFD_PREVIEW}
|
2008-03-08 08:52:38 -05:00
|
|
|
Show the preview of the selected files (currently only supported by
|
2009-01-24 09:04:25 -05:00
|
|
|
wxGTK).
|
2019-07-14 15:26:29 -04:00
|
|
|
@style{wxFD_SHOW_HIDDEN}
|
|
|
|
Show hidden files. This flag was added in wxWidgets 3.1.3
|
2008-03-08 08:52:38 -05:00
|
|
|
@endStyleTable
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxcore}
|
|
|
|
@category{cmndlg}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-09-25 10:03:38 -04:00
|
|
|
@see @ref overview_cmndlg_file, ::wxFileSelector()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxFileDialog : public wxDialog
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
Constructor. Use ShowModal() to show the dialog.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param parent
|
2008-03-09 08:33:59 -04:00
|
|
|
Parent window.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param message
|
2008-03-09 08:33:59 -04:00
|
|
|
Message to show on the dialog.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param defaultDir
|
2008-03-09 08:33:59 -04:00
|
|
|
The default directory, or the empty string.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param defaultFile
|
2008-03-09 08:33:59 -04:00
|
|
|
The default filename, or the empty string.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param wildcard
|
2008-04-01 09:55:38 -04:00
|
|
|
A wildcard, such as "*.*" or "BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif".
|
2008-03-09 08:33:59 -04:00
|
|
|
Note that the native Motif dialog has some limitations with respect to
|
|
|
|
wildcards; see the Remarks section above.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param style
|
2010-05-28 16:31:45 -04:00
|
|
|
A dialog style. See @c wxFD_* styles for more info.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param pos
|
2008-03-09 08:33:59 -04:00
|
|
|
Dialog position. Not implemented.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param size
|
2008-03-09 08:33:59 -04:00
|
|
|
Dialog size. Not implemented.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param name
|
2008-03-09 08:33:59 -04:00
|
|
|
Dialog name. Not implemented.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
wxFileDialog(wxWindow* parent,
|
2008-11-09 11:46:52 -05:00
|
|
|
const wxString& message = wxFileSelectorPromptStr,
|
|
|
|
const wxString& defaultDir = wxEmptyString,
|
|
|
|
const wxString& defaultFile = wxEmptyString,
|
|
|
|
const wxString& wildcard = wxFileSelectorDefaultWildcardStr,
|
2008-03-08 08:52:38 -05:00
|
|
|
long style = wxFD_DEFAULT_STYLE,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
2008-10-04 16:49:51 -04:00
|
|
|
const wxSize& size = wxDefaultSize,
|
2008-11-09 11:46:52 -05:00
|
|
|
const wxString& name = wxFileDialogNameStr);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Destructor.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual ~wxFileDialog();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
2013-05-31 19:21:27 -04:00
|
|
|
/**
|
|
|
|
Returns the path of the file currently selected in dialog.
|
|
|
|
|
|
|
|
Notice that this file is not necessarily going to be accepted by the
|
|
|
|
user, so calling this function mostly makes sense from an update UI
|
|
|
|
event handler of a custom file dialog extra control to update its state
|
|
|
|
depending on the currently selected file.
|
|
|
|
|
|
|
|
Currently this function is fully implemented under GTK and MSW and
|
|
|
|
always returns an empty string elsewhere.
|
|
|
|
|
|
|
|
@since 2.9.5
|
|
|
|
|
|
|
|
@return The path of the currently selected file or an empty string if
|
|
|
|
nothing is selected.
|
|
|
|
|
|
|
|
@see SetExtraControlCreator()
|
|
|
|
*/
|
|
|
|
virtual wxString GetCurrentlySelectedFilename() const;
|
|
|
|
|
2019-04-30 15:55:15 -04:00
|
|
|
/**
|
|
|
|
Returns the file type filter index currently selected in dialog.
|
|
|
|
|
|
|
|
Notice that this file type filter is not necessarily going to be the
|
|
|
|
one finally accepted by the user, so calling this function mostly makes
|
|
|
|
sense from an update UI event handler of a custom file dialog extra
|
|
|
|
control to update its state depending on the currently selected file
|
|
|
|
type filter.
|
|
|
|
|
|
|
|
Currently this function is fully implemented only under MSW and
|
|
|
|
always returns @c wxNOT_FOUND elsewhere.
|
|
|
|
|
|
|
|
@since 3.1.3
|
|
|
|
|
|
|
|
@return The 0-based index of the currently selected file type filter or
|
|
|
|
wxNOT_FOUND if nothing is selected.
|
|
|
|
|
|
|
|
@see SetExtraControlCreator()
|
|
|
|
@see GetFilterIndex()
|
|
|
|
@see SetFilterIndex()
|
|
|
|
*/
|
|
|
|
virtual int GetCurrentlySelectedFilterIndex () const;
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
Returns the default directory.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual wxString GetDirectory() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-01 09:55:38 -04:00
|
|
|
If functions SetExtraControlCreator() and ShowModal() were called,
|
2008-03-08 08:52:38 -05:00
|
|
|
returns the extra window. Otherwise returns @NULL.
|
2009-01-24 09:04:25 -05:00
|
|
|
|
|
|
|
@since 2.9.0
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
wxWindow* GetExtraControl() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the default filename.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual wxString GetFilename() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-01 09:55:38 -04:00
|
|
|
Fills the array @a filenames with the names of the files chosen.
|
|
|
|
|
|
|
|
This function should only be used with the dialogs which have @c wxFD_MULTIPLE style,
|
2008-03-08 08:52:38 -05:00
|
|
|
use GetFilename() for the others.
|
2008-04-01 09:55:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
Note that under Windows, if the user selects shortcuts, the filenames
|
|
|
|
include paths, since the application cannot determine the full path
|
|
|
|
of each referenced file by appending the directory containing the shortcuts
|
|
|
|
to the filename.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual void GetFilenames(wxArrayString& filenames) const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the index into the list of filters supplied, optionally, in the
|
|
|
|
wildcard parameter.
|
2008-04-01 09:55:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
Before the dialog is shown, this is the index which will be used when the
|
|
|
|
dialog is first displayed.
|
2008-04-01 09:55:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
After the dialog is shown, this is the index selected by the user.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual int GetFilterIndex() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the message that will be displayed on the dialog.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual wxString GetMessage() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the full path (directory and filename) of the selected file.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual wxString GetPath() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-01 09:55:38 -04:00
|
|
|
Fills the array @a paths with the full paths of the files chosen.
|
|
|
|
|
|
|
|
This function should only be used with the dialogs which have @c wxFD_MULTIPLE style,
|
2008-03-08 08:52:38 -05:00
|
|
|
use GetPath() for the others.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual void GetPaths(wxArrayString& paths) const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the file dialog wildcard.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual wxString GetWildcard() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the default directory.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual void SetDirectory(const wxString& directory);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
2009-01-24 09:04:25 -05:00
|
|
|
/**
|
|
|
|
The type of function used as an argument for SetExtraControlCreator().
|
|
|
|
|
|
|
|
@since 2.9.0
|
|
|
|
*/
|
|
|
|
typedef wxWindow *(*ExtraControlCreatorFunction)(wxWindow*);
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
Customize file dialog by adding extra window, which is typically placed
|
|
|
|
below the list of files and above the buttons.
|
2008-04-01 09:55:38 -04:00
|
|
|
|
|
|
|
SetExtraControlCreator() can be called only once, before calling ShowModal().
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
The @c creator function should take pointer to parent window (file dialog)
|
|
|
|
and should return a window allocated with operator new.
|
2008-04-01 09:55:38 -04:00
|
|
|
|
2009-01-24 09:04:25 -05:00
|
|
|
@since 2.9.0
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2009-01-24 09:04:25 -05:00
|
|
|
bool SetExtraControlCreator(ExtraControlCreatorFunction creator);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the default filename.
|
2019-01-30 11:28:08 -05:00
|
|
|
|
2009-09-24 16:36:46 -04:00
|
|
|
In wxGTK this will have little effect unless a default directory has previously been set.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual void SetFilename(const wxString& setfilename);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the default filter index, starting from zero.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual void SetFilterIndex(int filterIndex);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the message that will be displayed on the dialog.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual void SetMessage(const wxString& message);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the path (the combined directory and filename that will be returned when
|
|
|
|
the dialog is dismissed).
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual void SetPath(const wxString& path);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the wildcard, which can contain multiple file types, for example:
|
2008-04-01 09:55:38 -04:00
|
|
|
"BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif".
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
Note that the native Motif dialog has some limitations with respect to
|
|
|
|
wildcards; see the Remarks section above.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual void SetWildcard(const wxString& wildCard);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2010-05-28 16:31:45 -04:00
|
|
|
Shows the dialog, returning @c wxID_OK if the user pressed OK, and @c wxID_CANCEL
|
2008-03-08 08:52:38 -05:00
|
|
|
otherwise.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual int ShowModal();
|
2008-03-08 08:52:38 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
// ============================================================================
|
|
|
|
// Global functions/macros
|
|
|
|
// ============================================================================
|
|
|
|
|
2009-01-05 15:48:06 -05:00
|
|
|
/** @addtogroup group_funcmacro_dialog */
|
2008-03-18 15:30:01 -04:00
|
|
|
//@{
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
Pops up a file selector box. In Windows, this is the common file selector
|
2008-03-18 15:30:01 -04:00
|
|
|
dialog. In X, this is a file selector box with the same functionality. The
|
|
|
|
path and filename are distinct elements of a full file pathname. If path
|
|
|
|
is empty, the current directory will be used. If filename is empty, no
|
|
|
|
default filename will be supplied. The wildcard determines what files are
|
|
|
|
displayed in the file selector, and file extension supplies a type
|
|
|
|
extension for the required filename. Flags may be a combination of
|
|
|
|
wxFD_OPEN, wxFD_SAVE, wxFD_OVERWRITE_PROMPT or wxFD_FILE_MUST_EXIST.
|
|
|
|
|
|
|
|
@note wxFD_MULTIPLE can only be used with wxFileDialog and not here since
|
|
|
|
this function only returns a single file name.
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
Both the Unix and Windows versions implement a wildcard filter. Typing a
|
|
|
|
filename containing wildcards (*, ?) in the filename text item, and
|
|
|
|
clicking on Ok, will result in only those files matching the pattern being
|
|
|
|
displayed.
|
2008-03-18 15:30:01 -04:00
|
|
|
|
|
|
|
The wildcard may be a specification for multiple types of file with a
|
|
|
|
description for each, such as:
|
2008-03-09 08:33:59 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@code
|
|
|
|
"BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif"
|
|
|
|
@endcode
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
The application must check for an empty return value (the user pressed
|
|
|
|
Cancel). For example:
|
2008-03-09 08:33:59 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@code
|
|
|
|
wxString filename = wxFileSelector("Choose a file to open");
|
|
|
|
if ( !filename.empty() )
|
|
|
|
{
|
|
|
|
// work with the file
|
|
|
|
...
|
|
|
|
}
|
|
|
|
//else: cancelled by user
|
|
|
|
@endcode
|
2008-03-18 15:30:01 -04:00
|
|
|
|
|
|
|
@header{wx/filedlg.h}
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
wxString wxFileSelector(const wxString& message,
|
2009-01-10 13:31:45 -05:00
|
|
|
const wxString& default_path = wxEmptyString,
|
|
|
|
const wxString& default_filename = wxEmptyString,
|
|
|
|
const wxString& default_extension = wxEmptyString,
|
2012-03-03 19:29:07 -05:00
|
|
|
const wxString& wildcard = wxFileSelectorDefaultWildcardStr,
|
2008-03-08 08:52:38 -05:00
|
|
|
int flags = 0,
|
2008-03-09 08:33:59 -04:00
|
|
|
wxWindow* parent = NULL,
|
2012-03-03 19:29:07 -05:00
|
|
|
int x = wxDefaultCoord,
|
|
|
|
int y = wxDefaultCoord);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
2012-03-03 19:29:11 -05:00
|
|
|
/**
|
2019-04-21 11:50:13 -04:00
|
|
|
An extended version of wxFileSelector()
|
|
|
|
|
|
|
|
@header{wx/filedlg.h}
|
2012-03-03 19:29:11 -05:00
|
|
|
*/
|
|
|
|
wxString wxFileSelectorEx(const wxString& message = wxFileSelectorPromptStr,
|
|
|
|
const wxString& default_path = wxEmptyString,
|
|
|
|
const wxString& default_filename = wxEmptyString,
|
|
|
|
int *indexDefaultExtension = NULL,
|
|
|
|
const wxString& wildcard = wxFileSelectorDefaultWildcardStr,
|
|
|
|
int flags = 0,
|
|
|
|
wxWindow *parent = NULL,
|
|
|
|
int x = wxDefaultCoord,
|
|
|
|
int y = wxDefaultCoord);
|
|
|
|
|
|
|
|
/**
|
2019-04-21 11:50:13 -04:00
|
|
|
Shows a file dialog asking the user for a file name for opening a file.
|
|
|
|
|
|
|
|
@see wxFileSelector(), wxFileDialog
|
|
|
|
|
|
|
|
@header{wx/filedlg.h}
|
2012-03-03 19:29:11 -05:00
|
|
|
*/
|
|
|
|
wxString wxLoadFileSelector(const wxString& what,
|
|
|
|
const wxString& extension,
|
|
|
|
const wxString& default_name = wxEmptyString,
|
|
|
|
wxWindow *parent = NULL);
|
|
|
|
|
|
|
|
/**
|
2019-04-21 11:50:13 -04:00
|
|
|
Shows a file dialog asking the user for a file name for saving a file.
|
|
|
|
|
|
|
|
@see wxFileSelector(), wxFileDialog
|
|
|
|
|
|
|
|
@header{wx/filedlg.h}
|
2012-03-03 19:29:11 -05:00
|
|
|
*/
|
|
|
|
wxString wxSaveFileSelector(const wxString& what,
|
|
|
|
const wxString& extension,
|
|
|
|
const wxString& default_name = wxEmptyString,
|
|
|
|
wxWindow *parent = NULL);
|
|
|
|
|
2008-03-18 15:30:01 -04:00
|
|
|
//@}
|
|
|
|
|