# wxDirPickerCtrl Class Reference
[Picker Controls]

`#include </home/work/projects/wx/2.9/wx/interface/wx/filepicker.h>`

Inheritance diagram for wxDirPickerCtrl:
[legend]

## Detailed Description

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).

## Styles

This class supports the following 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.

## Events emitted by this class

The following event handler macros redirect the events to member function handlers 'func' with prototypes like:

void handlerFuncName(wxFileDirPickerEvent& event)

Event macros for events emitted by this class:

- 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).

##

Library: wxCore
Category: Picker Controls
Appearance:

wxMSW appearance | wxGTK appearance | wxMac appearance

See also:
  wxDirDialog, wxFileDirPickerEvent

## Public Member Functions

| wxDirPickerCtrl (wxWindow *parent, wxWindowID id, const wxString &path=wxEmptyString, const wxString &message=wxDirSelectorPromptStr, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDIRP_DEFAULT_STYLE, const wxValidator &validator=wxDefaultValidator, const wxString &name=wxDirPickerCtrlNameStr)
| Initializes the object and calls Create() with all the parameters.
bool | Create (wxWindow *parent, wxWindowID id, const wxString &path=wxEmptyString, const wxString &message=wxDirSelectorPromptStr, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDIRP_DEFAULT_STYLE, const wxValidator &validator=wxDefaultValidator, const wxString &name=wxDirPickerCtrlNameStr)
| Creates the widgets with the given parameters.
wxFileName | GetDirName () const
| Returns the absolute path of the currently selected directory as a wxFileName object.
wxString | GetPath () const
| Returns the absolute path of the currently selected directory.
void | SetDirName (const wxFileName &dirname)
| Just like SetPath() but this function takes a wxFileName object.
void | SetPath (const wxString &dirname)
| Sets the absolute path of (the default converter uses current locale's charset)the currently selected directory.

List of all members.

## Constructor & Destructor Documentation

wxDirPickerCtrl::wxDirPickerCtrl | ( | wxWindow * | parent,
|  | wxWindowID | id,
|  | const wxString & | path = `wxEmptyString`,
|  | const wxString & | message = `wxDirSelectorPromptStr`,
|  | const wxPoint & | pos = `wxDefaultPosition`,
|  | const wxSize & | size = `wxDefaultSize`,
|  | long | style = `wxDIRP_DEFAULT_STYLE`,
|  | const wxValidator & | validator = `wxDefaultValidator`,
|  | const wxString & | name = `wxDirPickerCtrlNameStr` |
| ) |  |  |

Initializes the object and calls Create() with all the parameters.

## Member Function Documentation

bool wxDirPickerCtrl::Create | ( | wxWindow * | parent,
|  | wxWindowID | id,
|  | const wxString & | path = `wxEmptyString`,
|  | const wxString & | message = `wxDirSelectorPromptStr`,
|  | const wxPoint & | pos = `wxDefaultPosition`,
|  | const wxSize & | size = `wxDefaultSize`,
|  | long | style = `wxDIRP_DEFAULT_STYLE`,
|  | const wxValidator & | validator = `wxDefaultValidator`,
|  | const wxString & | name = `wxDirPickerCtrlNameStr` |
| ) |  |  |

Creates the widgets with the given parameters.

Parameters:

  | parent | Parent window, must not be non-NULL.
  | id | The identifier for the control.
  | path | The initial directory shown in the control. Must be a valid path to a directory or the empty string.
  | message | The message shown to the user in the wxDirDialog shown by the control.
  | pos | Initial position.
  | size | Initial size.
  | style | The window style, see wxDIRP_* flags.
  | validator | Validator which can be used for additional date checks.
  | name | Control name.

Returns:
  true if the control was successfully created or false if creation failed.

wxFileName wxDirPickerCtrl::GetDirName | ( |  | ) | const

Returns the absolute path of the currently selected directory as a wxFileName object.

This function is equivalent to GetPath().

wxString wxDirPickerCtrl::GetPath | ( |  | ) | const

Returns the absolute path of the currently selected directory.

void wxDirPickerCtrl::SetDirName | ( | const wxFileName & | dirname | ) |

Just like SetPath() but this function takes a wxFileName object.

void wxDirPickerCtrl::SetPath | ( | const wxString & | dirname | ) |

Sets the absolute path of (the default converter uses current locale's charset)the currently selected directory.

This must be a valid directory if `wxDIRP_DIR_MUST_EXIST` style was given.

|  | [ top ]