]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/textdlg.h
Add wxTimer::StartOnce().
[wxWidgets.git] / interface / wx / textdlg.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: textdlg.h
e54c96f1 3// Purpose: interface of wxPasswordEntryDialog
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
526954c5 6// Licence: wxWindows licence
23324ae1
FM
7/////////////////////////////////////////////////////////////////////////////
8
0b59366f
VZ
9/**
10 Default text dialog style.
11*/
12#define wxTextEntryDialogStyle (wxOK | wxCANCEL | wxCENTRE | wxWS_EX_VALIDATE_RECURSIVELY)
13
14/// Default text dialog caption.
15const char wxGetTextFromUserPromptStr[] = "Input Text";
16
17/// Default password dialog caption.
18const char wxGetPasswordFromUserPromptStr[] = "Enter Password";
19
20
23324ae1
FM
21/**
22 @class wxPasswordEntryDialog
7c913512 23
23324ae1
FM
24 This class represents a dialog that requests a one-line password string from
25 the user.
c6cf894a 26
23324ae1 27 It is implemented as a generic wxWidgets dialog.
7c913512 28
a1e62aaa 29 @library{wxcore}
23324ae1 30 @category{cmndlg}
7c913512 31
c6cf894a 32 @see @ref overview_cmndlg_password
23324ae1
FM
33*/
34class wxPasswordEntryDialog : public wxTextEntryDialog
35{
36public:
c6cf894a
FM
37 /**
38 Constructor.
7c913512 39
c6cf894a
FM
40 Use wxTextEntryDialog::ShowModal to show the dialog.
41
42 @param parent
43 Parent window.
44 @param message
45 Message to show on the dialog.
4701dc09
FM
46 @param caption
47 The caption of the dialog.
c6cf894a
FM
48 @param defaultValue
49 The default value, which may be the empty string.
50 @param style
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,
53 it is always applied.
54 @param pos
55 Dialog position.
56 */
57 wxPasswordEntryDialog(wxWindow* parent, const wxString& message,
8067ee11 58 const wxString& caption = wxGetPasswordFromUserPromptStr,
c6cf894a 59 const wxString& defaultValue = wxEmptyString,
0b59366f 60 long style = wxTextEntryDialogStyle,
c6cf894a 61 const wxPoint& pos = wxDefaultPosition);
23324ae1
FM
62};
63
64
e54c96f1 65
23324ae1
FM
66/**
67 @class wxTextEntryDialog
7c913512 68
c6cf894a 69 This class represents a dialog that requests a one-line text string from the user.
23324ae1 70 It is implemented as a generic wxWidgets dialog.
7c913512 71
a1e62aaa 72 @library{wxcore}
23324ae1 73 @category{cmndlg}
7c913512 74
c6cf894a 75 @see @ref overview_cmndlg_textentry
23324ae1
FM
76*/
77class wxTextEntryDialog : public wxDialog
78{
79public:
80 /**
b8d6be7f 81 Default constructor.
3c4f71cc 82
b8d6be7f
VZ
83 Call Create() to really create the dialog later.
84
85 @since 2.9.5
86 */
87 wxTextEntryDialog();
88
89 /**
90 Constructor.
91
92 Use ShowModal() to show the dialog.
93
94 See Create() method for parameter description.
95 */
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);
101
102 /**
7c913512 103 @param parent
4cc4bfaf 104 Parent window.
7c913512 105 @param message
4cc4bfaf 106 Message to show on the dialog.
77bfb902 107 @param caption
4c51a665 108 The caption of the dialog.
41e69d79 109 @param value
4cc4bfaf 110 The default value, which may be the empty string.
7c913512 111 @param style
4cc4bfaf 112 A dialog style, specifying the buttons (wxOK, wxCANCEL)
c6cf894a 113 and an optional wxCENTRE style. Additionally, wxTextCtrl styles
50a2a355
VZ
114 (such as @c wxTE_PASSWORD or @c wxTE_MULTILINE) may be specified
115 here.
7c913512 116 @param pos
4cc4bfaf 117 Dialog position.
b8d6be7f
VZ
118
119 @since 2.9.5
23324ae1 120 */
b8d6be7f 121 bool Create(wxWindow* parent, const wxString& message,
8067ee11
FM
122 const wxString& caption = wxGetTextFromUserPromptStr,
123 const wxString& value = wxEmptyString,
0b59366f 124 long style = wxTextEntryDialogStyle,
23324ae1
FM
125 const wxPoint& pos = wxDefaultPosition);
126
127 /**
128 Destructor.
129 */
adaaa686 130 virtual ~wxTextEntryDialog();
23324ae1
FM
131
132 /**
133 Returns the text that the user has entered if the user has pressed OK, or the
c6cf894a 134 original value if the user has pressed Cancel.
23324ae1 135 */
328f5751 136 wxString GetValue() const;
23324ae1 137
7ed52474
VZ
138 /**
139 Associate a validator with the text control used by the dialog.
140
141 These methods can be used to limit the user entry to only some
142 characters, e.g.
143 @code
144 wxTextEntryDialog dlg(this, ...);
145 dlg.SetTextValidator(wxFILTER_ALPHA);
146 if ( dlg.ShowModal() == wxID_OK )
147 {
148 // We can be certain that this string contains letters only.
149 wxString value = dlg.GetValue();
150 }
151 @endcode
152
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.
156 */
157 //@{
158 void SetTextValidator(const wxTextValidator& validator);
159 void SetTextValidator(wxTextValidatorStyle style = wxFILTER_NONE);
160 //@}
161
62a58fbe
VZ
162 /**
163 This function sets the maximum number of characters the user can enter
164 into this dialog.
165
166 @see wxTextEntry::SetMaxLength()
167
168 @since 2.9.5
169 */
170 void SetMaxLength(unsigned long len);
171
23324ae1
FM
172 /**
173 Sets the default text value.
174 */
175 void SetValue(const wxString& value);
176
177 /**
178 Shows the dialog, returning wxID_OK if the user pressed OK, and wxID_CANCEL
179 otherwise.
7ed52474
VZ
180
181 Call GetValue() to retrieve the values of the string entered by the
182 user after showing the dialog.
23324ae1
FM
183 */
184 int ShowModal();
185};
186
187
e54c96f1 188
23324ae1
FM
189// ============================================================================
190// Global functions/macros
191// ============================================================================
192
b21126db 193/** @addtogroup group_funcmacro_dialog */
ba2874ff
BP
194//@{
195
23324ae1 196/**
ba2874ff
BP
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.
200
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.
203
50a2a355
VZ
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
208 only.
209
ba2874ff 210 @header{wx/textdlg.h}
23324ae1
FM
211*/
212wxString wxGetTextFromUser(const wxString& message,
0b59366f 213 const wxString& caption = wxGetTextFromUserPromptStr,
e9c3992c 214 const wxString& default_value = wxEmptyString,
4cc4bfaf 215 wxWindow* parent = NULL,
23324ae1
FM
216 int x = wxDefaultCoord,
217 int y = wxDefaultCoord,
4cc4bfaf 218 bool centre = true);
23324ae1
FM
219
220/**
ba2874ff
BP
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.
224
225 @header{wx/textdlg.h}
23324ae1
FM
226*/
227wxString wxGetPasswordFromUser(const wxString& message,
0b59366f 228 const wxString& caption = wxGetPasswordFromUserPromptStr,
e9c3992c 229 const wxString& default_value = wxEmptyString,
4cc4bfaf 230 wxWindow* parent = NULL,
23324ae1
FM
231 int x = wxDefaultCoord,
232 int y = wxDefaultCoord,
4cc4bfaf 233 bool centre = true);
23324ae1 234
ba2874ff
BP
235//@}
236