Cafu Engine
valTextNumber.hpp
1 /*
2 Cafu Engine, http://www.cafu.de/
3 Copyright (c) Carsten Fuchs and other contributors.
4 This project is licensed under the terms of the MIT license.
5 */
6 
7 #ifndef CAFU_WX_CAWE_TESTVAL_HPP_INCLUDED
8 #define CAFU_WX_CAWE_TESTVAL_HPP_INCLUDED
9 
10 #include "wx/defs.h"
11 #include "wx/textctrl.h"
12 #include "wx/validate.h"
13 
14 
15 class textNumberValidator : public wxValidator
16 {
17  DECLARE_CLASS(textNumberValidator)
18 
19  public:
20 
21  textNumberValidator(double* val, double minvalue = 0.0, double maxvalue = 0.0);
22  textNumberValidator(int* val, int minvalue = 0, int maxvalue = 0);
23 
25 
27 
28  virtual wxObject *Clone() const;
29  bool Copy(const textNumberValidator& val);
30 
31  virtual bool Validate(wxWindow *parent);
32 
33  virtual bool TransferToWindow();
34  virtual bool TransferFromWindow();
35 
36  // Filter keystrokes
37  void OnChar(wxKeyEvent& event);
38 
39  DECLARE_EVENT_TABLE()
40 
41 
42  protected:
43 
44  double* m_doubleValue;
45  double m_doubleMin;
46  double m_doubleMax;
47 
48  int* m_intValue;
49  int m_intMin;
50  int m_intMax;
51 
52  bool m_isDouble;
53 
54  bool CheckValidator() const
55  {
56  wxCHECK_MSG( m_validatorWindow, false,
57  _T("No window associated with validator") );
58  wxCHECK_MSG( m_validatorWindow->IsKindOf(CLASSINFO(wxTextCtrl)), false,
59  _T("wxTextValidator is only for wxTextCtrl's") );
60 // wxCHECK_MSG( m_stringValue, false,
61  // _T("No variable storage for validator") );
62 
63  return true;
64  }
65 };
66 
67 #endif
Definition: valTextNumber.hpp:15