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