]> git.saurik.com Git - wxWidgets.git/blob - include/wx/valgen.h
Added generic MVC hookup code.
[wxWidgets.git] / include / wx / valgen.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: valgen.h
3 // Purpose: wxGenericValidator class
4 // Author: Kevin Smith
5 // Modified by:
6 // Created: Jan 22 1999
7 // RCS-ID:
8 // Copyright: (c) 1999 Julian Smart (assigned from Kevin)
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_VALGENH__
13 #define _WX_VALGENH__
14
15 #include "wx/validate.h"
16
17 #if wxUSE_VALIDATORS
18
19 class WXDLLEXPORT wxGenericValidator: public wxValidator
20 {
21 DECLARE_CLASS(wxGenericValidator)
22 public:
23 wxGenericValidator(bool* val);
24 wxGenericValidator(int* val);
25 wxGenericValidator(wxString* val);
26 wxGenericValidator(wxArrayInt* val);
27 wxGenericValidator(const wxGenericValidator& copyFrom);
28
29 ~wxGenericValidator(){}
30
31 // Make a clone of this validator (or return NULL) - currently necessary
32 // if you're passing a reference to a validator.
33 // Another possibility is to always pass a pointer to a new validator
34 // (so the calling code can use a copy constructor of the relevant class).
35 virtual wxObject *Clone() const { return new wxGenericValidator(*this); }
36 bool Copy(const wxGenericValidator& val);
37
38 // Called when the value in the window must be validated.
39 // This function can pop up an error message.
40 virtual bool Validate(wxWindow * WXUNUSED(parent)) { return true; }
41
42 // Called to transfer data to the window
43 virtual bool TransferToWindow();
44
45 // Called to transfer data to the window
46 virtual bool TransferFromWindow();
47
48 protected:
49 void Initialize();
50
51 bool* m_pBool;
52 int* m_pInt;
53 wxString* m_pString;
54 wxArrayInt* m_pArrayInt;
55
56 private:
57 // Cannot use
58 // DECLARE_NO_COPY_CLASS(wxGenericValidator)
59 // because copy constructor is explicitly declared above;
60 // but no copy assignment operator is defined, so declare
61 // it private to prevent the compiler from defining it:
62 wxGenericValidator& operator=(const wxGenericValidator&);
63 };
64
65 #endif
66 // wxUSE_VALIDATORS
67
68 #endif
69 // _WX_VALGENH__