valgen.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: valgen.h
  3. // Purpose: interface of wxGenericValidator
  4. // Author: wxWidgets team
  5. // Licence: wxWindows licence
  6. /////////////////////////////////////////////////////////////////////////////
  7. /**
  8. @class wxGenericValidator
  9. wxGenericValidator performs data transfer (but not validation or filtering)
  10. for many type of controls.
  11. wxGenericValidator supports:
  12. - wxButton, wxRadioButton, wxToggleButton, wxBitmapToggleButton, wxSpinButton
  13. - wxCheckBox, wxRadioBox, wxComboBox, wxListBox, wxCheckListBox
  14. - wxGauge, wxSlider, wxScrollBar, wxChoice, wxStaticText
  15. - wxSpinCtrl, wxTextCtrl
  16. It checks the type of the window and uses an appropriate type for it.
  17. For example, wxButton and wxTextCtrl transfer data to and from a
  18. wxString variable; wxListBox uses a wxArrayInt; wxCheckBox uses a boolean.
  19. For more information, please see @ref overview_validator.
  20. @library{wxcore}
  21. @category{validator}
  22. @see @ref overview_validator, wxValidator, wxTextValidator,
  23. wxIntegerValidator, wxFloatingPointValidator
  24. */
  25. class wxGenericValidator : public wxValidator
  26. {
  27. public:
  28. /**
  29. Copy constructor.
  30. @param validator
  31. Validator to copy.
  32. */
  33. wxGenericValidator(const wxGenericValidator& validator);
  34. /**
  35. Constructor taking a bool pointer. This will be used for wxCheckBox,
  36. wxRadioButton, wxToggleButton and wxBitmapToggleButton.
  37. @param valPtr
  38. A pointer to a variable that contains the value. This variable
  39. should have a lifetime equal to or longer than the validator
  40. lifetime (which is usually determined by the lifetime of the
  41. window).
  42. */
  43. wxGenericValidator(bool* valPtr);
  44. /**
  45. Constructor taking a wxString pointer. This will be used for wxButton,
  46. wxComboBox, wxStaticText, wxTextCtrl.
  47. @param valPtr
  48. A pointer to a variable that contains the value. This variable
  49. should have a lifetime equal to or longer than the validator
  50. lifetime (which is usually determined by the lifetime of the
  51. window).
  52. */
  53. wxGenericValidator(wxString* valPtr);
  54. /**
  55. Constructor taking an integer pointer. This will be used for wxChoice,
  56. wxGauge, wxScrollBar, wxRadioBox, wxSlider, wxSpinButton and
  57. wxSpinCtrl.
  58. @param valPtr
  59. A pointer to a variable that contains the value. This variable
  60. should have a lifetime equal to or longer than the validator
  61. lifetime (which is usually determined by the lifetime of the
  62. window).
  63. */
  64. wxGenericValidator(int* valPtr);
  65. /**
  66. Constructor taking a wxArrayInt pointer. This will be used for
  67. wxListBox, wxCheckListBox.
  68. @param valPtr
  69. A pointer to a variable that contains the value. This variable
  70. should have a lifetime equal to or longer than the validator
  71. lifetime (which is usually determined by the lifetime of the
  72. window).
  73. */
  74. wxGenericValidator(wxArrayInt* valPtr);
  75. /**
  76. Constructor taking a wxDateTime pointer. This will be used for
  77. wxDatePickerCtrl.
  78. @param valPtr
  79. A pointer to a variable that contains the value. This variable
  80. should have a lifetime equal to or longer than the validator
  81. lifetime (which is usually determined by the lifetime of the
  82. window).
  83. */
  84. wxGenericValidator(wxDateTime* valPtr);
  85. /**
  86. Constructor taking a wxFileName pointer. This will be used for
  87. wxTextCtrl.
  88. @param valPtr
  89. A pointer to a variable that contains the value. This variable
  90. should have a lifetime equal to or longer than the validator
  91. lifetime (which is usually determined by the lifetime of the
  92. window).
  93. @since 2.9.3
  94. */
  95. wxGenericValidator(wxFileName* valPtr);
  96. /**
  97. Constructor taking a float pointer. This will be used for
  98. wxTextCtrl.
  99. @param valPtr
  100. A pointer to a variable that contains the value. This variable
  101. should have a lifetime equal to or longer than the validator
  102. lifetime (which is usually determined by the lifetime of the
  103. window).
  104. @since 2.9.3
  105. */
  106. wxGenericValidator(float* valPtr);
  107. /**
  108. Constructor taking a double pointer. This will be used for
  109. wxTextCtrl.
  110. @param valPtr
  111. A pointer to a variable that contains the value. This variable
  112. should have a lifetime equal to or longer than the validator
  113. lifetime (which is usually determined by the lifetime of the
  114. window).
  115. @since 2.9.3
  116. */
  117. wxGenericValidator(double* valPtr);
  118. /**
  119. Destructor.
  120. */
  121. virtual ~wxGenericValidator();
  122. /**
  123. Clones the generic validator using the copy constructor.
  124. */
  125. virtual wxObject* Clone() const;
  126. /**
  127. Transfers the value from the window to the appropriate data type.
  128. */
  129. virtual bool TransferFromWindow();
  130. /**
  131. Transfers the value to the window.
  132. */
  133. virtual bool TransferToWindow();
  134. };