2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: filepicker.h
|
2008-03-10 11:24:38 -04:00
|
|
|
// Purpose: interface of wxFilePickerCtrl
|
2008-03-08 08:52:38 -05:00
|
|
|
// Author: wxWidgets team
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Licence: wxWindows license
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
@class wxFilePickerCtrl
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
This control allows the user to select a file. The generic implementation is
|
|
|
|
a button which brings up a wxFileDialog when clicked. Native implementation
|
|
|
|
may differ but this is usually a (small) widget which give access to the
|
2008-09-25 15:15:28 -04:00
|
|
|
file-chooser dialog.
|
2008-03-08 08:52:38 -05:00
|
|
|
It is only available if @c wxUSE_FILEPICKERCTRL is set to 1 (the default).
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@beginStyleTable
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxFLP_DEFAULT_STYLE}
|
2008-03-08 08:52:38 -05:00
|
|
|
The default style: includes wxFLP_OPEN | wxFLP_FILE_MUST_EXIST and,
|
|
|
|
under wxMSW only, wxFLP_USE_TEXTCTRL.
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxFLP_USE_TEXTCTRL}
|
2008-03-08 08:52:38 -05:00
|
|
|
Creates a text control to the left of the picker button which is
|
|
|
|
completely managed by the wxFilePickerCtrl and which can be used by
|
|
|
|
the user to specify a path (see SetPath). The text control is
|
|
|
|
automatically synchronized with button's value. Use functions
|
|
|
|
defined in wxPickerBase to modify the text control.
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxFLP_OPEN}
|
2008-03-08 08:52:38 -05:00
|
|
|
Creates a picker which allows the user to select a file to open.
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxFLP_SAVE}
|
2008-03-08 08:52:38 -05:00
|
|
|
Creates a picker which allows the user to select a file to save.
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxFLP_OVERWRITE_PROMPT}
|
2008-03-08 08:52:38 -05:00
|
|
|
Can be combined with wxFLP_SAVE only: ask confirmation to the user
|
|
|
|
before selecting a file.
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxFLP_FILE_MUST_EXIST}
|
2008-03-08 08:52:38 -05:00
|
|
|
Can be combined with wxFLP_OPEN only: the selected file must be an
|
|
|
|
existing file.
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxFLP_CHANGE_DIR}
|
2008-03-08 08:52:38 -05:00
|
|
|
Change current working directory on each user file selection change.
|
|
|
|
@endStyleTable
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-09-25 15:15:28 -04:00
|
|
|
|
2009-02-18 12:58:51 -05:00
|
|
|
@beginEventEmissionTable{wxFileDirPickerEvent}
|
2008-09-25 15:15:28 -04:00
|
|
|
@event{EVT_FILEPICKER_CHANGED(id, func)}
|
|
|
|
The user changed the file selected in the control either using the
|
|
|
|
button or using text control (see wxFLP_USE_TEXTCTRL; note that in
|
|
|
|
this case the event is fired only if the user's input is valid,
|
|
|
|
e.g. an existing file path if wxFLP_FILE_MUST_EXIST was given).
|
|
|
|
@endEventTable
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxcore}
|
2008-04-08 01:34:11 -04:00
|
|
|
@category{pickers}
|
2008-10-13 04:05:18 -04:00
|
|
|
@appearance{filepickerctrl.png}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
@see wxFileDialog, wxFileDirPickerEvent
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxFilePickerCtrl : public wxPickerBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
Initializes the object and calls Create() with
|
|
|
|
all the parameters.
|
|
|
|
*/
|
2008-03-09 08:33:59 -04:00
|
|
|
wxFilePickerCtrl(wxWindow* parent, wxWindowID id,
|
2008-03-08 08:52:38 -05:00
|
|
|
const wxString& path = wxEmptyString,
|
2008-11-09 11:46:52 -05:00
|
|
|
const wxString& message = wxFileSelectorPromptStr,
|
|
|
|
const wxString& wildcard = wxFileSelectorDefaultWildcardStr,
|
2008-03-08 08:52:38 -05:00
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = wxFLP_DEFAULT_STYLE,
|
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
2008-11-09 11:46:52 -05:00
|
|
|
const wxString& name = wxFilePickerCtrlNameStr);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-09-25 15:15:28 -04:00
|
|
|
Creates this widget with the given parameters.
|
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param parent
|
2008-03-09 08:33:59 -04:00
|
|
|
Parent window, must not be non-@NULL.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param id
|
2008-03-09 08:33:59 -04:00
|
|
|
The identifier for the control.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param path
|
2008-03-09 08:33:59 -04:00
|
|
|
The initial file shown in the control. Must be a valid path to a file or
|
2008-09-25 15:15:28 -04:00
|
|
|
the empty string.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param message
|
2008-03-09 08:33:59 -04:00
|
|
|
The message shown to the user in the wxFileDialog shown by the control.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param wildcard
|
2008-03-09 08:33:59 -04:00
|
|
|
A wildcard which defines user-selectable files (use the same syntax as for
|
2008-09-25 15:15:28 -04:00
|
|
|
wxFileDialog's wildcards).
|
2008-03-08 09:43:31 -05:00
|
|
|
@param pos
|
2008-03-09 08:33:59 -04:00
|
|
|
Initial position.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param size
|
2008-03-09 08:33:59 -04:00
|
|
|
Initial size.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param style
|
2008-03-09 08:33:59 -04:00
|
|
|
The window style, see wxFLP_* flags.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param validator
|
2008-10-04 10:52:38 -04:00
|
|
|
Validator which can be used for additional data checks.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param name
|
2008-03-09 08:33:59 -04:00
|
|
|
Control name.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-05-10 21:38:53 -04:00
|
|
|
@return @true if the control was successfully created or @false if
|
2008-09-25 15:15:28 -04:00
|
|
|
creation failed.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 08:33:59 -04:00
|
|
|
bool Create(wxWindow* parent, wxWindowID id,
|
2008-03-08 08:52:38 -05:00
|
|
|
const wxString& path = wxEmptyString,
|
2008-10-28 11:36:26 -04:00
|
|
|
const wxString& message = wxFileSelectorPromptStr,
|
|
|
|
const wxString& wildcard = wxFileSelectorDefaultWildcardStr,
|
2008-03-08 08:52:38 -05:00
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = wxFLP_DEFAULT_STYLE,
|
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
2008-10-28 11:36:26 -04:00
|
|
|
const wxString& name = wxFilePickerCtrlNameStr);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-09-25 15:15:28 -04:00
|
|
|
Similar to GetPath() but returns the path of the currently selected
|
|
|
|
file as a wxFileName object.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
wxFileName GetFileName() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the absolute path of the currently selected file.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
wxString GetPath() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-09-25 15:15:28 -04:00
|
|
|
This method does the same thing as SetPath() but takes a wxFileName
|
|
|
|
object instead of a string.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 08:33:59 -04:00
|
|
|
void SetFileName(const wxFileName& filename);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-09-25 15:15:28 -04:00
|
|
|
Sets the absolute path of the currently selected file.
|
|
|
|
This must be a valid file if the @c wxFLP_FILE_MUST_EXIST style was given.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 08:33:59 -04:00
|
|
|
void SetPath(const wxString& filename);
|
2008-03-08 08:52:38 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxDirPickerCtrl
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
This control allows the user to select a directory. The generic implementation
|
2008-09-25 15:15:28 -04:00
|
|
|
is a button which brings up a wxDirDialog when clicked. Native implementation
|
2008-03-08 08:52:38 -05:00
|
|
|
may differ but this is usually a (small) widget which give access to the
|
2008-09-25 15:15:28 -04:00
|
|
|
dir-chooser dialog.
|
2008-03-08 08:52:38 -05:00
|
|
|
It is only available if @c wxUSE_DIRPICKERCTRL is set to 1 (the default).
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@beginStyleTable
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxDIRP_DEFAULT_STYLE}
|
2008-03-08 08:52:38 -05:00
|
|
|
The default style: includes wxDIRP_DIR_MUST_EXIST and, under wxMSW
|
|
|
|
only, wxDIRP_USE_TEXTCTRL.
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxDIRP_USE_TEXTCTRL}
|
2008-03-08 08:52:38 -05:00
|
|
|
Creates a text control to the left of the picker button which is
|
|
|
|
completely managed by the wxDirPickerCtrl and which can be used by
|
|
|
|
the user to specify a path (see SetPath). The text control is
|
|
|
|
automatically synchronized with button's value. Use functions
|
|
|
|
defined in wxPickerBase to modify the text control.
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxDIRP_DIR_MUST_EXIST}
|
2008-03-08 08:52:38 -05:00
|
|
|
Creates a picker which allows to select only existing directories.
|
|
|
|
wxGTK control always adds this flag internally as it does not
|
|
|
|
support its absence.
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxDIRP_CHANGE_DIR}
|
2008-09-25 15:15:28 -04:00
|
|
|
Change current working directory on each user directory selection change.
|
2008-03-08 08:52:38 -05:00
|
|
|
@endStyleTable
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2009-02-18 12:58:51 -05:00
|
|
|
@beginEventEmissionTable{wxFileDirPickerEvent}
|
2008-09-25 15:15:28 -04:00
|
|
|
@event{EVT_DIRPICKER_CHANGED(id, func)}
|
|
|
|
The user changed the directory selected in the control either using the
|
|
|
|
button or using text control (see wxDIRP_USE_TEXTCTRL; note that in this
|
|
|
|
case the event is fired only if the user's input is valid, e.g. an
|
|
|
|
existing directory path).
|
|
|
|
@endEventTable
|
|
|
|
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxcore}
|
2008-04-08 01:34:11 -04:00
|
|
|
@category{pickers}
|
2008-10-13 04:05:18 -04:00
|
|
|
@appearance{dirpickerctrl.png}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
@see wxDirDialog, wxFileDirPickerEvent
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxDirPickerCtrl : public wxPickerBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
Initializes the object and calls Create() with
|
|
|
|
all the parameters.
|
|
|
|
*/
|
2008-03-09 08:33:59 -04:00
|
|
|
wxDirPickerCtrl(wxWindow* parent, wxWindowID id,
|
2008-03-08 08:52:38 -05:00
|
|
|
const wxString& path = wxEmptyString,
|
2008-11-08 10:17:16 -05:00
|
|
|
const wxString& message = wxDirSelectorPromptStr,
|
2008-03-08 08:52:38 -05:00
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = wxDIRP_DEFAULT_STYLE,
|
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
2008-11-08 10:17:16 -05:00
|
|
|
const wxString& name = wxDirPickerCtrlNameStr);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-09-25 15:15:28 -04:00
|
|
|
Creates the widgets with the given parameters.
|
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param parent
|
2008-03-09 08:33:59 -04:00
|
|
|
Parent window, must not be non-@NULL.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param id
|
2008-03-09 08:33:59 -04:00
|
|
|
The identifier for the control.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param path
|
2008-03-09 08:33:59 -04:00
|
|
|
The initial directory shown in the control. Must be a valid path to a
|
2008-09-25 15:15:28 -04:00
|
|
|
directory or the empty string.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param message
|
2008-03-09 08:33:59 -04:00
|
|
|
The message shown to the user in the wxDirDialog shown by the control.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param pos
|
2008-03-09 08:33:59 -04:00
|
|
|
Initial position.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param size
|
2008-03-09 08:33:59 -04:00
|
|
|
Initial size.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param style
|
2008-03-09 08:33:59 -04:00
|
|
|
The window style, see wxDIRP_* flags.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param validator
|
2008-03-09 08:33:59 -04:00
|
|
|
Validator which can be used for additional date checks.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param name
|
2008-03-09 08:33:59 -04:00
|
|
|
Control name.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-05-10 21:38:53 -04:00
|
|
|
@return @true if the control was successfully created or @false if
|
2008-09-25 15:15:28 -04:00
|
|
|
creation failed.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 08:33:59 -04:00
|
|
|
bool Create(wxWindow* parent, wxWindowID id,
|
2008-03-08 08:52:38 -05:00
|
|
|
const wxString& path = wxEmptyString,
|
2008-10-28 11:36:26 -04:00
|
|
|
const wxString& message = wxDirSelectorPromptStr,
|
2008-03-08 08:52:38 -05:00
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = wxDIRP_DEFAULT_STYLE,
|
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
2008-10-28 11:36:26 -04:00
|
|
|
const wxString& name = wxDirPickerCtrlNameStr);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-09-25 15:15:28 -04:00
|
|
|
Returns the absolute path of the currently selected directory as a
|
|
|
|
wxFileName object.
|
|
|
|
This function is equivalent to GetPath().
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
wxFileName GetDirName() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the absolute path of the currently selected directory.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
wxString GetPath() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-09-25 15:15:28 -04:00
|
|
|
Just like SetPath() but this function takes a wxFileName object.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 08:33:59 -04:00
|
|
|
void SetDirName(const wxFileName& dirname);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the absolute path of (the default converter uses current locale's
|
2008-09-25 15:15:28 -04:00
|
|
|
charset)the currently selected directory.
|
|
|
|
This must be a valid directory if @c wxDIRP_DIR_MUST_EXIST style was given.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 08:33:59 -04:00
|
|
|
void SetPath(const wxString& dirname);
|
2008-03-08 08:52:38 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxFileDirPickerEvent
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
This event class is used for the events generated by
|
|
|
|
wxFilePickerCtrl and by wxDirPickerCtrl.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-09-25 16:00:31 -04:00
|
|
|
@beginEventTable{wxFileDirPickerEvent}
|
|
|
|
@event{EVT_FILEPICKER_CHANGED(id, func)}
|
|
|
|
Generated whenever the selected file changes.
|
|
|
|
@event{EVT_DIRPICKER_CHANGED(id, func)}
|
|
|
|
Generated whenever the selected directory changes.
|
|
|
|
@endEventTable
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxcore}
|
2008-09-25 15:15:28 -04:00
|
|
|
@category{events}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-09-25 15:15:28 -04:00
|
|
|
@see wxFilePickerCtrl, wxDirPickerCtrl
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxFileDirPickerEvent : public wxCommandEvent
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
The constructor is not normally used by the user code.
|
|
|
|
*/
|
2008-03-09 08:33:59 -04:00
|
|
|
wxFileDirPickerEvent(wxEventType type, wxObject* generator,
|
2008-03-08 08:52:38 -05:00
|
|
|
int id,
|
2008-11-09 11:46:52 -05:00
|
|
|
const wxString& path);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Retrieve the absolute path of the file/directory the user has just selected.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
wxString GetPath() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Set the absolute path of the file/directory associated with the event.
|
|
|
|
*/
|
2008-03-09 08:33:59 -04:00
|
|
|
void SetPath(const wxString& path);
|
2008-03-08 08:52:38 -05:00
|
|
|
};
|
2008-03-10 11:24:38 -04:00
|
|
|
|