1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxDirDialog
4 // Author: wxWidgets team
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
9 #define wxDD_DEFAULT_STYLE (wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
12 Initial folder for generic directory dialog.
14 const char wxDirDialogDefaultFolderStr
[] = "/";
17 Default message for directory selector dialog.
19 const char wxDirSelectorPromptStr
[] = "Select a directory";
22 Default name for directory selector dialog.
24 const char wxDirDialogNameStr
[] = "wxDirCtrl";
29 This class represents the directory chooser dialog.
32 @style{wxDD_DEFAULT_STYLE}
33 Equivalent to a combination of wxDEFAULT_DIALOG_STYLE and
34 wxRESIZE_BORDER (the last one is not used under wxWinCE).
35 @style{wxDD_DIR_MUST_EXIST}
36 The dialog will allow the user to choose only an existing folder.
37 When this style is not given, a "Create new directory" button is
38 added to the dialog (on Windows) or some other way is provided to
39 the user to type the name of a new folder.
40 @style{wxDD_CHANGE_DIR}
41 Change the current working directory to the directory chosen by the
45 Notice that @c wxRESIZE_BORDER has special side effect under recent (i.e.
46 later than Win9x) Windows where two different directory selection dialogs
47 are available and this style also implicitly selects the new version as the
48 old one always has fixed size. As the new version is almost always
49 preferable, it is recommended that @c wxRESIZE_BORDER style be always used.
50 This is the case if the dialog is created with the default style value but
51 if you need to use any additional styles you should still specify @c
52 wxDD_DEFAULT_STYLE unless you explicitly need to use the old dialog version
53 under Windows. E.g. do
55 wxDirDialog dlg(NULL, "Choose input directory", "",
56 wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST);
58 instead of just using @c wxDD_DIR_MUST_EXIST style alone.
63 @see @ref overview_cmndlg_dir, wxFileDialog
65 class wxDirDialog
: public wxDialog
69 Constructor. Use ShowModal() to show the dialog.
74 Message to show on the dialog.
76 The default path, or the empty string.
78 The dialog style. See wxDirDialog
80 Dialog position. Ignored under Windows.
82 Dialog size. Ignored under Windows.
84 The dialog name, not used.
86 wxDirDialog(wxWindow
* parent
,
87 const wxString
& message
= wxDirSelectorPromptStr
,
88 const wxString
& defaultPath
= wxEmptyString
,
89 long style
= wxDD_DEFAULT_STYLE
,
90 const wxPoint
& pos
= wxDefaultPosition
,
91 const wxSize
& size
= wxDefaultSize
,
92 const wxString
& name
= wxDirDialogNameStr
);
97 virtual ~wxDirDialog();
100 Returns the message that will be displayed on the dialog.
102 virtual wxString
GetMessage() const;
105 Returns the default or user-selected path.
107 virtual wxString
GetPath() const;
110 Sets the message that will be displayed on the dialog.
112 virtual void SetMessage(const wxString
& message
);
115 Sets the default path.
117 virtual void SetPath(const wxString
& path
);
120 Shows the dialog, returning wxID_OK if the user pressed OK, and
121 wxID_CANCEL otherwise.
128 // ============================================================================
129 // Global functions/macros
130 // ============================================================================
132 /** @addtogroup group_funcmacro_dialog */
136 Pops up a directory selector dialog. The arguments have the same meaning
137 as those of wxDirDialog::wxDirDialog(). The message is displayed at the
138 top, and the default_path, if specified, is set as the initial selection.
140 The application must check for an empty return value (if the user pressed
141 Cancel). For example:
144 const wxString& dir = wxDirSelector("Choose a folder");
153 wxString
wxDirSelector(const wxString
& message
= wxDirSelectorPromptStr
,
154 const wxString
& default_path
= wxEmptyString
,
156 const wxPoint
& pos
= wxDefaultPosition
,
157 wxWindow
* parent
= NULL
);