textdlgg.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/generic/textdlgg.h
  3. // Purpose: wxTextEntryDialog class
  4. // Author: Julian Smart
  5. // Modified by:
  6. // Created: 01/02/97
  7. // Copyright: (c) Julian Smart
  8. // Licence: wxWindows licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_TEXTDLGG_H_
  11. #define _WX_TEXTDLGG_H_
  12. #include "wx/defs.h"
  13. #if wxUSE_TEXTDLG
  14. #include "wx/dialog.h"
  15. #if wxUSE_VALIDATORS
  16. #include "wx/valtext.h"
  17. #include "wx/textctrl.h"
  18. #endif
  19. class WXDLLIMPEXP_FWD_CORE wxTextCtrl;
  20. extern WXDLLIMPEXP_DATA_CORE(const char) wxGetTextFromUserPromptStr[];
  21. extern WXDLLIMPEXP_DATA_CORE(const char) wxGetPasswordFromUserPromptStr[];
  22. #define wxTextEntryDialogStyle (wxOK | wxCANCEL | wxCENTRE | wxWS_EX_VALIDATE_RECURSIVELY)
  23. // ----------------------------------------------------------------------------
  24. // wxTextEntryDialog: a dialog with text control, [ok] and [cancel] buttons
  25. // ----------------------------------------------------------------------------
  26. class WXDLLIMPEXP_CORE wxTextEntryDialog : public wxDialog
  27. {
  28. public:
  29. wxTextEntryDialog()
  30. {
  31. m_textctrl = NULL;
  32. }
  33. wxTextEntryDialog(wxWindow *parent,
  34. const wxString& message,
  35. const wxString& caption = wxGetTextFromUserPromptStr,
  36. const wxString& value = wxEmptyString,
  37. long style = wxTextEntryDialogStyle,
  38. const wxPoint& pos = wxDefaultPosition)
  39. {
  40. Create(parent, message, caption, value, style, pos);
  41. }
  42. bool Create(wxWindow *parent,
  43. const wxString& message,
  44. const wxString& caption = wxGetTextFromUserPromptStr,
  45. const wxString& value = wxEmptyString,
  46. long style = wxTextEntryDialogStyle,
  47. const wxPoint& pos = wxDefaultPosition);
  48. void SetValue(const wxString& val);
  49. wxString GetValue() const { return m_value; }
  50. void SetMaxLength(unsigned long len);
  51. #if wxUSE_VALIDATORS
  52. void SetTextValidator( const wxTextValidator& validator );
  53. #if WXWIN_COMPATIBILITY_2_8
  54. wxDEPRECATED( void SetTextValidator( long style ) );
  55. #endif
  56. void SetTextValidator( wxTextValidatorStyle style = wxFILTER_NONE );
  57. wxTextValidator* GetTextValidator() { return (wxTextValidator*)m_textctrl->GetValidator(); }
  58. #endif // wxUSE_VALIDATORS
  59. virtual bool TransferDataToWindow();
  60. virtual bool TransferDataFromWindow();
  61. // implementation only
  62. void OnOK(wxCommandEvent& event);
  63. protected:
  64. wxTextCtrl *m_textctrl;
  65. wxString m_value;
  66. long m_dialogStyle;
  67. private:
  68. DECLARE_EVENT_TABLE()
  69. DECLARE_DYNAMIC_CLASS(wxTextEntryDialog)
  70. wxDECLARE_NO_COPY_CLASS(wxTextEntryDialog);
  71. };
  72. // ----------------------------------------------------------------------------
  73. // wxPasswordEntryDialog: dialog with password control, [ok] and [cancel]
  74. // ----------------------------------------------------------------------------
  75. class WXDLLIMPEXP_CORE wxPasswordEntryDialog : public wxTextEntryDialog
  76. {
  77. public:
  78. wxPasswordEntryDialog(wxWindow *parent,
  79. const wxString& message,
  80. const wxString& caption = wxGetPasswordFromUserPromptStr,
  81. const wxString& value = wxEmptyString,
  82. long style = wxTextEntryDialogStyle,
  83. const wxPoint& pos = wxDefaultPosition);
  84. private:
  85. DECLARE_DYNAMIC_CLASS(wxPasswordEntryDialog)
  86. wxDECLARE_NO_COPY_CLASS(wxPasswordEntryDialog);
  87. };
  88. // ----------------------------------------------------------------------------
  89. // function to get a string from user
  90. // ----------------------------------------------------------------------------
  91. WXDLLIMPEXP_CORE wxString
  92. wxGetTextFromUser(const wxString& message,
  93. const wxString& caption = wxGetTextFromUserPromptStr,
  94. const wxString& default_value = wxEmptyString,
  95. wxWindow *parent = NULL,
  96. wxCoord x = wxDefaultCoord,
  97. wxCoord y = wxDefaultCoord,
  98. bool centre = true);
  99. WXDLLIMPEXP_CORE wxString
  100. wxGetPasswordFromUser(const wxString& message,
  101. const wxString& caption = wxGetPasswordFromUserPromptStr,
  102. const wxString& default_value = wxEmptyString,
  103. wxWindow *parent = NULL,
  104. wxCoord x = wxDefaultCoord,
  105. wxCoord y = wxDefaultCoord,
  106. bool centre = true);
  107. #endif
  108. // wxUSE_TEXTDLG
  109. #endif // _WX_TEXTDLGG_H_