This control allows the user to select a directory. The generic implementation is a button which brings up a wxDirDialog when clicked. Native implementation may differ but this is usually a (small) widget which give access to the dir-chooser dialog. It is only available if wxUSE_DIRPICKERCTRL is set to 1 (the default).
Derived from
wxPickerBase
wxControl
wxWindow
wxEvtHandler
wxObject
Include files
<wx/filepicker.h>
Window styles
wxDIRP_DEFAULT_STYLE | The default style: includes wxDIRP_DIR_MUST_EXIST and, under wxMSW only, wxDIRP_USE_TEXTCTRL. |
wxDIRP_USE_TEXTCTRL | 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. |
wxDIRP_DIR_MUST_EXIST | Creates a picker which allows to select only existing directories. wxGTK control always adds this flag internally as it does not support its absence. |
wxDIRP_CHANGE_DIR | Change current working directory on each user directory selection change. |
Event handling
To process a directory picker event, use these event handler macros to direct input to member functions that take a wxFileDirPickerEvent argument.
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). |
See also
wxDirDialog,
wxFileDirPickerEvent
Members
wxDirPickerCtrl::wxDirPickerCtrl
wxDirPickerCtrl::Create
wxDirPickerCtrl::GetPath
wxDirPickerCtrl::SetPath
wxDirPickerCtrl(wxWindow *parent, wxWindowID id, const wxString& path = wxEmptyString, const wxString& message = "Select a folder", const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDIRP_DEFAULT_STYLE, const wxValidator& validator = wxDefaultValidator, const wxString& name = "dirpickerctrl")
Initializes the object and calls Create with all the parameters.
bool Create(wxWindow *parent, wxWindowID id, const wxString& path = wxEmptyString, const wxString& message = "Select a folder", const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDIRP_DEFAULT_STYLE, const wxValidator& validator = wxDefaultValidator, const wxString& name = "dirpickerctrl")
Parameters
parent
id
path
message
pos
size
style
validator
name
Return value
true if the control was successfully created or false if creation failed.
wxString GetPath() const
Returns the absolute path of the currently selected directory.
void SetPath(const wxString &dirname)
Sets the absolute path of the currently selected directory. This must be a valid directory if wxDIRP_DIR_MUST_EXIST style was given.