1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxDirDialog
4 // Author: wxWidgets team
5 // Licence: wxWindows licence
6 /////////////////////////////////////////////////////////////////////////////
8 #define wxDD_CHANGE_DIR 0x0100
9 #define wxDD_DIR_MUST_EXIST 0x0200
10 #define wxDD_NEW_DIR_BUTTON 0 // deprecated, on by default now,
12 #define wxDD_DEFAULT_STYLE (wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
15 Initial folder for generic directory dialog.
17 const char wxDirDialogDefaultFolderStr
[] = "/";
20 Default message for directory selector dialog.
22 const char wxDirSelectorPromptStr
[] = "Select a directory";
25 Default name for directory selector dialog.
27 const char wxDirDialogNameStr
[] = "wxDirCtrl";
32 This class represents the directory chooser dialog.
35 @style{wxDD_DEFAULT_STYLE}
36 Equivalent to a combination of wxDEFAULT_DIALOG_STYLE and
37 wxRESIZE_BORDER (the last one is not used under wxWinCE).
38 @style{wxDD_DIR_MUST_EXIST}
39 The dialog will allow the user to choose only an existing folder.
40 When this style is not given, a "Create new directory" button is
41 added to the dialog (on Windows) or some other way is provided to
42 the user to type the name of a new folder.
43 @style{wxDD_CHANGE_DIR}
44 Change the current working directory to the directory chosen by the
48 Notice that @c wxRESIZE_BORDER has special side effect under recent (i.e.
49 later than Win9x) Windows where two different directory selection dialogs
50 are available and this style also implicitly selects the new version as the
51 old one always has fixed size. As the new version is almost always
52 preferable, it is recommended that @c wxRESIZE_BORDER style be always used.
53 This is the case if the dialog is created with the default style value but
54 if you need to use any additional styles you should still specify @c
55 wxDD_DEFAULT_STYLE unless you explicitly need to use the old dialog version
56 under Windows. E.g. do
58 wxDirDialog dlg(NULL, "Choose input directory", "",
59 wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST);
61 instead of just using @c wxDD_DIR_MUST_EXIST style alone.
66 @see @ref overview_cmndlg_dir, wxFileDialog
68 class wxDirDialog
: public wxDialog
72 Constructor. Use ShowModal() to show the dialog.
77 Message to show on the dialog.
79 The default path, or the empty string.
81 The dialog style. See wxDirDialog
83 Dialog position. Ignored under Windows.
85 Dialog size. Ignored under Windows.
87 The dialog name, not used.
89 wxDirDialog(wxWindow
* parent
,
90 const wxString
& message
= wxDirSelectorPromptStr
,
91 const wxString
& defaultPath
= wxEmptyString
,
92 long style
= wxDD_DEFAULT_STYLE
,
93 const wxPoint
& pos
= wxDefaultPosition
,
94 const wxSize
& size
= wxDefaultSize
,
95 const wxString
& name
= wxDirDialogNameStr
);
100 virtual ~wxDirDialog();
103 Returns the message that will be displayed on the dialog.
105 virtual wxString
GetMessage() const;
108 Returns the default or user-selected path.
110 virtual wxString
GetPath() const;
113 Sets the message that will be displayed on the dialog.
115 virtual void SetMessage(const wxString
& message
);
118 Sets the default path.
120 virtual void SetPath(const wxString
& path
);
123 Shows the dialog, returning wxID_OK if the user pressed OK, and
124 wxID_CANCEL otherwise.
131 // ============================================================================
132 // Global functions/macros
133 // ============================================================================
135 /** @addtogroup group_funcmacro_dialog */
139 Pops up a directory selector dialog. The arguments have the same meaning
140 as those of wxDirDialog::wxDirDialog(). The message is displayed at the
141 top, and the default_path, if specified, is set as the initial selection.
143 The application must check for an empty return value (if the user pressed
144 Cancel). For example:
147 const wxString& dir = wxDirSelector("Choose a folder");
156 wxString
wxDirSelector(const wxString
& message
= wxDirSelectorPromptStr
,
157 const wxString
& default_path
= wxEmptyString
,
159 const wxPoint
& pos
= wxDefaultPosition
,
160 wxWindow
* parent
= NULL
);