1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxPasswordEntryDialog
4 // Author: wxWidgets team
5 // Licence: wxWindows licence
6 /////////////////////////////////////////////////////////////////////////////
9 Default text dialog style.
11 #define wxTextEntryDialogStyle (wxOK | wxCANCEL | wxCENTRE | wxWS_EX_VALIDATE_RECURSIVELY)
13 /// Default text dialog caption.
14 const char wxGetTextFromUserPromptStr
[] = "Input Text";
16 /// Default password dialog caption.
17 const char wxGetPasswordFromUserPromptStr
[] = "Enter Password";
21 @class wxPasswordEntryDialog
23 This class represents a dialog that requests a one-line password string from
26 It is implemented as a generic wxWidgets dialog.
31 @see @ref overview_cmndlg_password
33 class wxPasswordEntryDialog
: public wxTextEntryDialog
39 Use wxTextEntryDialog::ShowModal to show the dialog.
44 Message to show on the dialog.
46 The caption of the dialog.
48 The default value, which may be the empty string.
50 A dialog style, specifying the buttons (wxOK, wxCANCEL) and an
51 optional wxCENTRE style. You do not need to specify the wxTE_PASSWORD style,
56 wxPasswordEntryDialog(wxWindow
* parent
, const wxString
& message
,
57 const wxString
& caption
= wxGetPasswordFromUserPromptStr
,
58 const wxString
& defaultValue
= wxEmptyString
,
59 long style
= wxTextEntryDialogStyle
,
60 const wxPoint
& pos
= wxDefaultPosition
);
66 @class wxTextEntryDialog
68 This class represents a dialog that requests a one-line text string from the user.
69 It is implemented as a generic wxWidgets dialog.
74 @see @ref overview_cmndlg_textentry
76 class wxTextEntryDialog
: public wxDialog
82 Call Create() to really create the dialog later.
91 Use ShowModal() to show the dialog.
93 See Create() method for parameter description.
95 wxTextEntryDialog(wxWindow
* parent
, const wxString
& message
,
96 const wxString
& caption
= wxGetTextFromUserPromptStr
,
97 const wxString
& value
= wxEmptyString
,
98 long style
= wxTextEntryDialogStyle
,
99 const wxPoint
& pos
= wxDefaultPosition
);
105 Message to show on the dialog.
107 The caption of the dialog.
109 The default value, which may be the empty string.
111 A dialog style, specifying the buttons (wxOK, wxCANCEL)
112 and an optional wxCENTRE style. Additionally, wxTextCtrl styles
113 (such as @c wxTE_PASSWORD or @c wxTE_MULTILINE) may be specified
120 bool Create(wxWindow
* parent
, const wxString
& message
,
121 const wxString
& caption
= wxGetTextFromUserPromptStr
,
122 const wxString
& value
= wxEmptyString
,
123 long style
= wxTextEntryDialogStyle
,
124 const wxPoint
& pos
= wxDefaultPosition
);
129 virtual ~wxTextEntryDialog();
132 Returns the text that the user has entered if the user has pressed OK, or the
133 original value if the user has pressed Cancel.
135 wxString
GetValue() const;
138 Associate a validator with the text control used by the dialog.
140 These methods can be used to limit the user entry to only some
143 wxTextEntryDialog dlg(this, ...);
144 dlg.SetTextValidator(wxFILTER_ALPHA);
145 if ( dlg.ShowModal() == wxID_OK )
147 // We can be certain that this string contains letters only.
148 wxString value = dlg.GetValue();
152 The first overload uses the provided @a validator which can be of a
153 custom class derived from wxTextValidator while the second one creates
154 a wxTextValidator with the specified @a style.
157 void SetTextValidator(const wxTextValidator
& validator
);
158 void SetTextValidator(wxTextValidatorStyle style
= wxFILTER_NONE
);
162 This function sets the maximum number of characters the user can enter
165 @see wxTextEntry::SetMaxLength()
169 void SetMaxLength(unsigned long len
);
172 Sets the default text value.
174 void SetValue(const wxString
& value
);
177 Shows the dialog, returning wxID_OK if the user pressed OK, and wxID_CANCEL
180 Call GetValue() to retrieve the values of the string entered by the
181 user after showing the dialog.
188 // ============================================================================
189 // Global functions/macros
190 // ============================================================================
192 /** @addtogroup group_funcmacro_dialog */
196 Pop up a dialog box with title set to @e caption, @c message, and a
197 @c default_value. The user may type in text and press OK to return this
198 text, or press Cancel to return the empty string.
200 If @c centre is @true, the message text (which may include new line
201 characters) is centred; if @false, the message is left-justified.
203 This function is a wrapper around wxTextEntryDialog and while it is usually
204 more convenient to use, using the dialog directly is more flexible, e.g. it
205 allows you to specify the @c wxTE_MULTILINE to allow the user enter
206 multiple lines of text while this function is limited to single line entry
209 @header{wx/textdlg.h}
211 wxString
wxGetTextFromUser(const wxString
& message
,
212 const wxString
& caption
= wxGetTextFromUserPromptStr
,
213 const wxString
& default_value
= wxEmptyString
,
214 wxWindow
* parent
= NULL
,
215 int x
= wxDefaultCoord
,
216 int y
= wxDefaultCoord
,
220 Similar to wxGetTextFromUser() but the text entered in the dialog is not
221 shown on screen but replaced with stars. This is intended to be used for
222 entering passwords as the function name implies.
224 @header{wx/textdlg.h}
226 wxString
wxGetPasswordFromUser(const wxString
& message
,
227 const wxString
& caption
= wxGetPasswordFromUserPromptStr
,
228 const wxString
& default_value
= wxEmptyString
,
229 wxWindow
* parent
= NULL
,
230 int x
= wxDefaultCoord
,
231 int y
= wxDefaultCoord
,