valgen.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/valgen.h
  3. // Purpose: wxGenericValidator class
  4. // Author: Kevin Smith
  5. // Created: Jan 22 1999
  6. // Copyright: (c) 1999 Julian Smart (assigned from Kevin)
  7. // Licence: wxWindows licence
  8. /////////////////////////////////////////////////////////////////////////////
  9. #ifndef _WX_VALGENH__
  10. #define _WX_VALGENH__
  11. #include "wx/validate.h"
  12. #if wxUSE_VALIDATORS
  13. class WXDLLIMPEXP_FWD_BASE wxDateTime;
  14. class WXDLLIMPEXP_FWD_BASE wxFileName;
  15. // ----------------------------------------------------------------------------
  16. // wxGenericValidator performs data transfer between many standard controls and
  17. // variables of the type corresponding to their values.
  18. //
  19. // It doesn't do any validation so its name is a slight misnomer.
  20. // ----------------------------------------------------------------------------
  21. class WXDLLIMPEXP_CORE wxGenericValidator: public wxValidator
  22. {
  23. public:
  24. // Different constructors: each of them creates a validator which can only
  25. // be used with some controls, the comments before each constructor
  26. // indicate which ones:
  27. // wxCheckBox, wxRadioButton, wx(Bitmap)ToggleButton
  28. wxGenericValidator(bool* val);
  29. // wxChoice, wxGauge, wxRadioBox, wxScrollBar, wxSlider, wxSpinButton
  30. wxGenericValidator(int* val);
  31. // wxComboBox, wxTextCtrl, wxButton, wxStaticText (read-only)
  32. wxGenericValidator(wxString* val);
  33. // wxListBox, wxCheckListBox
  34. wxGenericValidator(wxArrayInt* val);
  35. #if wxUSE_DATETIME
  36. // wxDatePickerCtrl
  37. wxGenericValidator(wxDateTime* val);
  38. #endif // wxUSE_DATETIME
  39. // wxTextCtrl
  40. wxGenericValidator(wxFileName* val);
  41. // wxTextCtrl
  42. wxGenericValidator(float* val);
  43. // wxTextCtrl
  44. wxGenericValidator(double* val);
  45. wxGenericValidator(const wxGenericValidator& copyFrom);
  46. virtual ~wxGenericValidator(){}
  47. // Make a clone of this validator (or return NULL) - currently necessary
  48. // if you're passing a reference to a validator.
  49. // Another possibility is to always pass a pointer to a new validator
  50. // (so the calling code can use a copy constructor of the relevant class).
  51. virtual wxObject *Clone() const { return new wxGenericValidator(*this); }
  52. bool Copy(const wxGenericValidator& val);
  53. // Called when the value in the window must be validated: this is not used
  54. // by this class
  55. virtual bool Validate(wxWindow * WXUNUSED(parent)) { return true; }
  56. // Called to transfer data to the window
  57. virtual bool TransferToWindow();
  58. // Called to transfer data to the window
  59. virtual bool TransferFromWindow();
  60. protected:
  61. void Initialize();
  62. bool* m_pBool;
  63. int* m_pInt;
  64. wxString* m_pString;
  65. wxArrayInt* m_pArrayInt;
  66. #if wxUSE_DATETIME
  67. wxDateTime* m_pDateTime;
  68. #endif // wxUSE_DATETIME
  69. wxFileName* m_pFileName;
  70. float* m_pFloat;
  71. double* m_pDouble;
  72. private:
  73. DECLARE_CLASS(wxGenericValidator)
  74. wxDECLARE_NO_ASSIGN_CLASS(wxGenericValidator);
  75. };
  76. #endif // wxUSE_VALIDATORS
  77. #endif // _WX_VALGENH__