blob: 12f707c63b9d6894dc6bfc0a6065c26489e771c4 (
plain)
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
|
#include <limits.h>
#include "int_validator.h"
#include "int_validator.moc"
IntValidator::IntValidator( TQWidget *parent, const char *name ) :
TQValidator( parent, name )
{
#ifdef INT_MIN
v_bottom = INT_MIN;
#else
v_bottom = ~INT_MAX;
#endif
v_top = INT_MIN;
}
IntValidator::IntValidator( int bottom, int top, TQWidget *parent, const char *name ) :
TQValidator( parent, name )
{
v_bottom = bottom;
v_top = top;
}
IntValidator::~IntValidator() {}
TQValidator::State
IntValidator::validate( TQString &input, int & ) const
{
if( input.isEmpty() ) {
return TQValidator::Valid;
} else {
bool ok;
int value = input.toInt( &ok );
if( !ok )
return TQValidator::Invalid;
if( value < v_bottom || value > v_top )
return TQValidator::Valid;
return TQValidator::Acceptable;
}
}
void
IntValidator::setRange( int b, int t )
{
v_bottom = b;
v_top = t;
}
|