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