-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathMyValidator.h
102 lines (79 loc) · 2.54 KB
/
MyValidator.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// $Id: MyValidator.h 175 2009-02-22 04:11:02Z felfert $
//
// Copyright (C) 2006 The OpenNX Team
// Author: Fritz Elfert
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU Library General Public License as
// published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc.,
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
#ifndef _MYVALIDATOR_H_
#define _MYVALIDATOR_H_
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma interface "MyValidator.h"
#endif
#include "wx/validate.h"
class KeyTypeCallback
{
public:
virtual ~KeyTypeCallback() {};
virtual void KeyTyped() = 0;
};
class MyValidator : public wxValidator
{
DECLARE_DYNAMIC_CLASS(MyValidator)
public:
typedef enum {
MYVAL_ANY,
MYVAL_NUMERIC,
MYVAL_HEX,
MYVAL_HOST,
MYVAL_FILENAME,
} MyValidatorType;
MyValidator() { };
MyValidator(bool*);
MyValidator(int*);
MyValidator(wxString*);
MyValidator(wxArrayInt*);
MyValidator(const MyValidator&);
MyValidator(MyValidatorType, bool*);
MyValidator(MyValidatorType, int*);
MyValidator(MyValidatorType, wxString*);
MyValidator(MyValidatorType, wxArrayInt*);
MyValidator(MyValidatorType, const MyValidator&);
virtual wxObject *Clone() const { return new MyValidator(*this); }
bool Copy(const MyValidator& val);
// Called when the value in the window must be validated.
// This function can pop up an error message.
virtual bool Validate(wxWindow * WXUNUSED(parent)) { return TRUE; }
// Called to transfer data to the window
virtual bool TransferToWindow();
// Called to transfer data to the window
virtual bool TransferFromWindow();
void SetKeyTyped(KeyTypeCallback *);
virtual ~MyValidator();
void OnChar(wxKeyEvent& event);
DECLARE_EVENT_TABLE()
protected:
void Init();
bool* m_pBool;
int* m_pInt;
wxString* m_pString;
wxArrayInt* m_pArrayInt;
KeyTypeCallback *m_ktc;
private:
MyValidatorType m_type;
};
#endif
// _MYVALIDATOR_H_