2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: textdlg.h
|
2008-03-10 11:24:38 -04:00
|
|
|
// Purpose: interface of wxPasswordEntryDialog
|
2008-03-08 08:52:38 -05:00
|
|
|
// Author: wxWidgets team
|
2010-07-13 09:29:13 -04:00
|
|
|
// Licence: wxWindows licence
|
2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-03-03 19:29:07 -05:00
|
|
|
/**
|
|
|
|
Default text dialog style.
|
|
|
|
*/
|
2016-02-06 19:32:22 -05:00
|
|
|
#define wxTextEntryDialogStyle (wxOK | wxCANCEL | wxCENTRE)
|
2012-03-03 19:29:07 -05:00
|
|
|
|
|
|
|
/// Default text dialog caption.
|
|
|
|
const char wxGetTextFromUserPromptStr[] = "Input Text";
|
|
|
|
|
|
|
|
/// Default password dialog caption.
|
|
|
|
const char wxGetPasswordFromUserPromptStr[] = "Enter Password";
|
|
|
|
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxPasswordEntryDialog
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
This class represents a dialog that requests a one-line password string from
|
|
|
|
the user.
|
2008-10-04 07:01:50 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
It is implemented as a generic wxWidgets dialog.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-12-15 17:54:29 -05:00
|
|
|
@library{wxcore}
|
2008-03-08 08:52:38 -05:00
|
|
|
@category{cmndlg}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-10-04 07:01:50 -04:00
|
|
|
@see @ref overview_cmndlg_password
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxPasswordEntryDialog : public wxTextEntryDialog
|
|
|
|
{
|
|
|
|
public:
|
2008-10-04 07:01:50 -04:00
|
|
|
/**
|
|
|
|
Constructor.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-10-04 07:01:50 -04:00
|
|
|
Use wxTextEntryDialog::ShowModal to show the dialog.
|
|
|
|
|
|
|
|
@param parent
|
|
|
|
Parent window.
|
|
|
|
@param message
|
|
|
|
Message to show on the dialog.
|
2008-10-07 12:57:34 -04:00
|
|
|
@param caption
|
|
|
|
The caption of the dialog.
|
2008-10-04 07:01:50 -04:00
|
|
|
@param defaultValue
|
|
|
|
The default value, which may be the empty string.
|
|
|
|
@param style
|
|
|
|
A dialog style, specifying the buttons (wxOK, wxCANCEL) and an
|
|
|
|
optional wxCENTRE style. You do not need to specify the wxTE_PASSWORD style,
|
|
|
|
it is always applied.
|
|
|
|
@param pos
|
|
|
|
Dialog position.
|
|
|
|
*/
|
|
|
|
wxPasswordEntryDialog(wxWindow* parent, const wxString& message,
|
2008-10-13 09:46:42 -04:00
|
|
|
const wxString& caption = wxGetPasswordFromUserPromptStr,
|
2008-10-04 07:01:50 -04:00
|
|
|
const wxString& defaultValue = wxEmptyString,
|
2012-03-03 19:29:07 -05:00
|
|
|
long style = wxTextEntryDialogStyle,
|
2008-10-04 07:01:50 -04:00
|
|
|
const wxPoint& pos = wxDefaultPosition);
|
2008-03-08 08:52:38 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxTextEntryDialog
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-10-04 07:01:50 -04:00
|
|
|
This class represents a dialog that requests a one-line text string from the user.
|
2008-03-08 08:52:38 -05:00
|
|
|
It is implemented as a generic wxWidgets dialog.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-12-15 17:54:29 -05:00
|
|
|
@library{wxcore}
|
2008-03-08 08:52:38 -05:00
|
|
|
@category{cmndlg}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-10-04 07:01:50 -04:00
|
|
|
@see @ref overview_cmndlg_textentry
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxTextEntryDialog : public wxDialog
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
2012-09-27 18:41:33 -04:00
|
|
|
Default constructor.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2012-09-27 18:41:33 -04:00
|
|
|
Call Create() to really create the dialog later.
|
|
|
|
|
|
|
|
@since 2.9.5
|
|
|
|
*/
|
|
|
|
wxTextEntryDialog();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Constructor.
|
|
|
|
|
|
|
|
Use ShowModal() to show the dialog.
|
|
|
|
|
|
|
|
See Create() method for parameter description.
|
|
|
|
*/
|
|
|
|
wxTextEntryDialog(wxWindow* parent, const wxString& message,
|
|
|
|
const wxString& caption = wxGetTextFromUserPromptStr,
|
|
|
|
const wxString& value = wxEmptyString,
|
|
|
|
long style = wxTextEntryDialogStyle,
|
|
|
|
const wxPoint& pos = wxDefaultPosition);
|
|
|
|
|
|
|
|
/**
|
2008-03-08 09:43:31 -05:00
|
|
|
@param parent
|
2008-03-09 08:33:59 -04:00
|
|
|
Parent window.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param message
|
2008-03-09 08:33:59 -04:00
|
|
|
Message to show on the dialog.
|
2008-10-04 10:52:38 -04:00
|
|
|
@param caption
|
2011-03-22 10:17:38 -04:00
|
|
|
The caption of the dialog.
|
2008-10-19 12:07:00 -04:00
|
|
|
@param value
|
2008-03-09 08:33:59 -04:00
|
|
|
The default value, which may be the empty string.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param style
|
2008-03-09 08:33:59 -04:00
|
|
|
A dialog style, specifying the buttons (wxOK, wxCANCEL)
|
2008-10-04 07:01:50 -04:00
|
|
|
and an optional wxCENTRE style. Additionally, wxTextCtrl styles
|
2011-03-13 09:33:12 -04:00
|
|
|
(such as @c wxTE_PASSWORD or @c wxTE_MULTILINE) may be specified
|
|
|
|
here.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param pos
|
2008-03-09 08:33:59 -04:00
|
|
|
Dialog position.
|
2012-09-27 18:41:33 -04:00
|
|
|
|
|
|
|
@since 2.9.5
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2012-09-27 18:41:33 -04:00
|
|
|
bool Create(wxWindow* parent, const wxString& message,
|
2008-10-13 09:46:42 -04:00
|
|
|
const wxString& caption = wxGetTextFromUserPromptStr,
|
|
|
|
const wxString& value = wxEmptyString,
|
2012-03-03 19:29:07 -05:00
|
|
|
long style = wxTextEntryDialogStyle,
|
2008-03-08 08:52:38 -05:00
|
|
|
const wxPoint& pos = wxDefaultPosition);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Destructor.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual ~wxTextEntryDialog();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the text that the user has entered if the user has pressed OK, or the
|
2008-10-04 07:01:50 -04:00
|
|
|
original value if the user has pressed Cancel.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
wxString GetValue() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
2013-04-03 20:11:03 -04:00
|
|
|
/**
|
|
|
|
Associate a validator with the text control used by the dialog.
|
|
|
|
|
|
|
|
These methods can be used to limit the user entry to only some
|
|
|
|
characters, e.g.
|
|
|
|
@code
|
|
|
|
wxTextEntryDialog dlg(this, ...);
|
|
|
|
dlg.SetTextValidator(wxFILTER_ALPHA);
|
|
|
|
if ( dlg.ShowModal() == wxID_OK )
|
|
|
|
{
|
|
|
|
// We can be certain that this string contains letters only.
|
|
|
|
wxString value = dlg.GetValue();
|
|
|
|
}
|
|
|
|
@endcode
|
|
|
|
|
|
|
|
The first overload uses the provided @a validator which can be of a
|
|
|
|
custom class derived from wxTextValidator while the second one creates
|
|
|
|
a wxTextValidator with the specified @a style.
|
|
|
|
*/
|
|
|
|
//@{
|
|
|
|
void SetTextValidator(const wxTextValidator& validator);
|
|
|
|
void SetTextValidator(wxTextValidatorStyle style = wxFILTER_NONE);
|
|
|
|
//@}
|
|
|
|
|
2013-04-20 18:13:33 -04:00
|
|
|
/**
|
|
|
|
This function sets the maximum number of characters the user can enter
|
|
|
|
into this dialog.
|
|
|
|
|
|
|
|
@see wxTextEntry::SetMaxLength()
|
|
|
|
|
|
|
|
@since 2.9.5
|
|
|
|
*/
|
|
|
|
void SetMaxLength(unsigned long len);
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
Sets the default text value.
|
|
|
|
*/
|
|
|
|
void SetValue(const wxString& value);
|
|
|
|
|
2016-01-22 08:41:06 -05:00
|
|
|
/**
|
|
|
|
Convert all text entered into the text control used by the dialog to upper case.
|
|
|
|
|
|
|
|
Call this method to ensure that all text entered into the text control
|
|
|
|
used by the dialog is converted on the fly to upper case. If the text
|
|
|
|
control is not empty, its existing contents is also converted to upper
|
|
|
|
case.
|
|
|
|
|
|
|
|
@see wxTextEntry::ForceUpper()
|
|
|
|
|
|
|
|
@since 3.1.0
|
|
|
|
*/
|
|
|
|
void ForceUpper();
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
Shows the dialog, returning wxID_OK if the user pressed OK, and wxID_CANCEL
|
|
|
|
otherwise.
|
2013-04-03 20:11:03 -04:00
|
|
|
|
|
|
|
Call GetValue() to retrieve the values of the string entered by the
|
|
|
|
user after showing the dialog.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
int ShowModal();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
// ============================================================================
|
|
|
|
// Global functions/macros
|
|
|
|
// ============================================================================
|
|
|
|
|
2009-01-05 15:48:06 -05:00
|
|
|
/** @addtogroup group_funcmacro_dialog */
|
2008-03-18 15:30:01 -04:00
|
|
|
//@{
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
2008-03-18 15:30:01 -04:00
|
|
|
Pop up a dialog box with title set to @e caption, @c message, and a
|
|
|
|
@c default_value. The user may type in text and press OK to return this
|
|
|
|
text, or press Cancel to return the empty string.
|
|
|
|
|
|
|
|
If @c centre is @true, the message text (which may include new line
|
|
|
|
characters) is centred; if @false, the message is left-justified.
|
|
|
|
|
2011-03-13 09:33:12 -04:00
|
|
|
This function is a wrapper around wxTextEntryDialog and while it is usually
|
|
|
|
more convenient to use, using the dialog directly is more flexible, e.g. it
|
|
|
|
allows you to specify the @c wxTE_MULTILINE to allow the user enter
|
|
|
|
multiple lines of text while this function is limited to single line entry
|
|
|
|
only.
|
|
|
|
|
2008-03-18 15:30:01 -04:00
|
|
|
@header{wx/textdlg.h}
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
wxString wxGetTextFromUser(const wxString& message,
|
2012-03-03 19:29:07 -05:00
|
|
|
const wxString& caption = wxGetTextFromUserPromptStr,
|
2009-01-10 13:31:45 -05:00
|
|
|
const wxString& default_value = wxEmptyString,
|
2008-03-09 08:33:59 -04:00
|
|
|
wxWindow* parent = NULL,
|
2008-03-08 08:52:38 -05:00
|
|
|
int x = wxDefaultCoord,
|
|
|
|
int y = wxDefaultCoord,
|
2008-03-09 08:33:59 -04:00
|
|
|
bool centre = true);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-03-18 15:30:01 -04:00
|
|
|
Similar to wxGetTextFromUser() but the text entered in the dialog is not
|
|
|
|
shown on screen but replaced with stars. This is intended to be used for
|
|
|
|
entering passwords as the function name implies.
|
|
|
|
|
|
|
|
@header{wx/textdlg.h}
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
wxString wxGetPasswordFromUser(const wxString& message,
|
2012-03-03 19:29:07 -05:00
|
|
|
const wxString& caption = wxGetPasswordFromUserPromptStr,
|
2009-01-10 13:31:45 -05:00
|
|
|
const wxString& default_value = wxEmptyString,
|
2008-03-09 08:33:59 -04:00
|
|
|
wxWindow* parent = NULL,
|
2008-03-08 08:52:38 -05:00
|
|
|
int x = wxDefaultCoord,
|
|
|
|
int y = wxDefaultCoord,
|
2008-03-09 08:33:59 -04:00
|
|
|
bool centre = true);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
2008-03-18 15:30:01 -04:00
|
|
|
//@}
|
|
|
|
|