1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxPasswordEntryDialog
4 // Author: wxWidgets team
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
10 Default text dialog style.
12 #define wxTextEntryDialogStyle (wxOK | wxCANCEL | wxCENTRE | wxWS_EX_VALIDATE_RECURSIVELY)
14 /// Default text dialog caption.
15 const char wxGetTextFromUserPromptStr
[] = "Input Text";
17 /// Default password dialog caption.
18 const char wxGetPasswordFromUserPromptStr
[] = "Enter Password";
22 @class wxPasswordEntryDialog
24 This class represents a dialog that requests a one-line password string from
27 It is implemented as a generic wxWidgets dialog.
32 @see @ref overview_cmndlg_password
34 class wxPasswordEntryDialog
: public wxTextEntryDialog
40 Use wxTextEntryDialog::ShowModal to show the dialog.
45 Message to show on the dialog.
47 The caption of the dialog.
49 The default value, which may be the empty string.
51 A dialog style, specifying the buttons (wxOK, wxCANCEL) and an
52 optional wxCENTRE style. You do not need to specify the wxTE_PASSWORD style,
57 wxPasswordEntryDialog(wxWindow
* parent
, const wxString
& message
,
58 const wxString
& caption
= wxGetPasswordFromUserPromptStr
,
59 const wxString
& defaultValue
= wxEmptyString
,
60 long style
= wxTextEntryDialogStyle
,
61 const wxPoint
& pos
= wxDefaultPosition
);
67 @class wxTextEntryDialog
69 This class represents a dialog that requests a one-line text string from the user.
70 It is implemented as a generic wxWidgets dialog.
75 @see @ref overview_cmndlg_textentry
77 class wxTextEntryDialog
: public wxDialog
83 Call Create() to really create the dialog later.
92 Use ShowModal() to show the dialog.
94 See Create() method for parameter description.
96 wxTextEntryDialog(wxWindow
* parent
, const wxString
& message
,
97 const wxString
& caption
= wxGetTextFromUserPromptStr
,
98 const wxString
& value
= wxEmptyString
,
99 long style
= wxTextEntryDialogStyle
,
100 const wxPoint
& pos
= wxDefaultPosition
);
106 Message to show on the dialog.
108 The caption of the dialog.
110 The default value, which may be the empty string.
112 A dialog style, specifying the buttons (wxOK, wxCANCEL)
113 and an optional wxCENTRE style. Additionally, wxTextCtrl styles
114 (such as @c wxTE_PASSWORD or @c wxTE_MULTILINE) may be specified
121 bool Create(wxWindow
* parent
, const wxString
& message
,
122 const wxString
& caption
= wxGetTextFromUserPromptStr
,
123 const wxString
& value
= wxEmptyString
,
124 long style
= wxTextEntryDialogStyle
,
125 const wxPoint
& pos
= wxDefaultPosition
);
130 virtual ~wxTextEntryDialog();
133 Returns the text that the user has entered if the user has pressed OK, or the
134 original value if the user has pressed Cancel.
136 wxString
GetValue() const;
139 Associate a validator with the text control used by the dialog.
141 These methods can be used to limit the user entry to only some
144 wxTextEntryDialog dlg(this, ...);
145 dlg.SetTextValidator(wxFILTER_ALPHA);
146 if ( dlg.ShowModal() == wxID_OK )
148 // We can be certain that this string contains letters only.
149 wxString value = dlg.GetValue();
153 The first overload uses the provided @a validator which can be of a
154 custom class derived from wxTextValidator while the second one creates
155 a wxTextValidator with the specified @a style.
158 void SetTextValidator(const wxTextValidator
& validator
);
159 void SetTextValidator(wxTextValidatorStyle style
= wxFILTER_NONE
);
163 This function sets the maximum number of characters the user can enter
166 @see wxTextEntry::SetMaxLength()
170 void SetMaxLength(unsigned long len
);
173 Sets the default text value.
175 void SetValue(const wxString
& value
);
178 Shows the dialog, returning wxID_OK if the user pressed OK, and wxID_CANCEL
181 Call GetValue() to retrieve the values of the string entered by the
182 user after showing the dialog.
189 // ============================================================================
190 // Global functions/macros
191 // ============================================================================
193 /** @addtogroup group_funcmacro_dialog */
197 Pop up a dialog box with title set to @e caption, @c message, and a
198 @c default_value. The user may type in text and press OK to return this
199 text, or press Cancel to return the empty string.
201 If @c centre is @true, the message text (which may include new line
202 characters) is centred; if @false, the message is left-justified.
204 This function is a wrapper around wxTextEntryDialog and while it is usually
205 more convenient to use, using the dialog directly is more flexible, e.g. it
206 allows you to specify the @c wxTE_MULTILINE to allow the user enter
207 multiple lines of text while this function is limited to single line entry
210 @header{wx/textdlg.h}
212 wxString
wxGetTextFromUser(const wxString
& message
,
213 const wxString
& caption
= wxGetTextFromUserPromptStr
,
214 const wxString
& default_value
= wxEmptyString
,
215 wxWindow
* parent
= NULL
,
216 int x
= wxDefaultCoord
,
217 int y
= wxDefaultCoord
,
221 Similar to wxGetTextFromUser() but the text entered in the dialog is not
222 shown on screen but replaced with stars. This is intended to be used for
223 entering passwords as the function name implies.
225 @header{wx/textdlg.h}
227 wxString
wxGetPasswordFromUser(const wxString
& message
,
228 const wxString
& caption
= wxGetPasswordFromUserPromptStr
,
229 const wxString
& default_value
= wxEmptyString
,
230 wxWindow
* parent
= NULL
,
231 int x
= wxDefaultCoord
,
232 int y
= wxDefaultCoord
,