1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxDirDialog
4 // Author: wxWidgets team
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
9 #define wxDD_CHANGE_DIR 0x0100
10 #define wxDD_DIR_MUST_EXIST 0x0200
11 #define wxDD_NEW_DIR_BUTTON 0 // deprecated, on by default now,
13 #define wxDD_DEFAULT_STYLE (wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
16 Initial folder for generic directory dialog.
18 const char wxDirDialogDefaultFolderStr
[] = "/";
21 Default message for directory selector dialog.
23 const char wxDirSelectorPromptStr
[] = "Select a directory";
26 Default name for directory selector dialog.
28 const char wxDirDialogNameStr
[] = "wxDirCtrl";
33 This class represents the directory chooser dialog.
36 @style{wxDD_DEFAULT_STYLE}
37 Equivalent to a combination of wxDEFAULT_DIALOG_STYLE and
38 wxRESIZE_BORDER (the last one is not used under wxWinCE).
39 @style{wxDD_DIR_MUST_EXIST}
40 The dialog will allow the user to choose only an existing folder.
41 When this style is not given, a "Create new directory" button is
42 added to the dialog (on Windows) or some other way is provided to
43 the user to type the name of a new folder.
44 @style{wxDD_CHANGE_DIR}
45 Change the current working directory to the directory chosen by the
49 Notice that @c wxRESIZE_BORDER has special side effect under recent (i.e.
50 later than Win9x) Windows where two different directory selection dialogs
51 are available and this style also implicitly selects the new version as the
52 old one always has fixed size. As the new version is almost always
53 preferable, it is recommended that @c wxRESIZE_BORDER style be always used.
54 This is the case if the dialog is created with the default style value but
55 if you need to use any additional styles you should still specify @c
56 wxDD_DEFAULT_STYLE unless you explicitly need to use the old dialog version
57 under Windows. E.g. do
59 wxDirDialog dlg(NULL, "Choose input directory", "",
60 wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST);
62 instead of just using @c wxDD_DIR_MUST_EXIST style alone.
67 @see @ref overview_cmndlg_dir, wxFileDialog
69 class wxDirDialog
: public wxDialog
73 Constructor. Use ShowModal() to show the dialog.
78 Message to show on the dialog.
80 The default path, or the empty string.
82 The dialog style. See wxDirDialog
84 Dialog position. Ignored under Windows.
86 Dialog size. Ignored under Windows.
88 The dialog name, not used.
90 wxDirDialog(wxWindow
* parent
,
91 const wxString
& message
= wxDirSelectorPromptStr
,
92 const wxString
& defaultPath
= wxEmptyString
,
93 long style
= wxDD_DEFAULT_STYLE
,
94 const wxPoint
& pos
= wxDefaultPosition
,
95 const wxSize
& size
= wxDefaultSize
,
96 const wxString
& name
= wxDirDialogNameStr
);
101 virtual ~wxDirDialog();
104 Returns the message that will be displayed on the dialog.
106 virtual wxString
GetMessage() const;
109 Returns the default or user-selected path.
111 virtual wxString
GetPath() const;
114 Sets the message that will be displayed on the dialog.
116 virtual void SetMessage(const wxString
& message
);
119 Sets the default path.
121 virtual void SetPath(const wxString
& path
);
124 Shows the dialog, returning wxID_OK if the user pressed OK, and
125 wxID_CANCEL otherwise.
132 // ============================================================================
133 // Global functions/macros
134 // ============================================================================
136 /** @addtogroup group_funcmacro_dialog */
140 Pops up a directory selector dialog. The arguments have the same meaning
141 as those of wxDirDialog::wxDirDialog(). The message is displayed at the
142 top, and the default_path, if specified, is set as the initial selection.
144 The application must check for an empty return value (if the user pressed
145 Cancel). For example:
148 const wxString& dir = wxDirSelector("Choose a folder");
157 wxString
wxDirSelector(const wxString
& message
= wxDirSelectorPromptStr
,
158 const wxString
& default_path
= wxEmptyString
,
160 const wxPoint
& pos
= wxDefaultPosition
,
161 wxWindow
* parent
= NULL
);