You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
994 B
54 lines
994 B
15 years ago
|
#include <limits.h>
|
||
|
|
||
|
#include "int_validator.h"
|
||
|
#include "int_validator.moc"
|
||
|
|
||
14 years ago
|
IntValidator::IntValidator( TQWidget *parent, const char *name ) :
|
||
|
TQValidator( TQT_TQOBJECT(parent), name )
|
||
15 years ago
|
{
|
||
|
#ifdef INT_MIN
|
||
|
v_bottom = INT_MIN;
|
||
|
#else
|
||
|
v_bottom = ~INT_MAX;
|
||
|
#endif
|
||
|
v_top = INT_MIN;
|
||
|
}
|
||
|
|
||
14 years ago
|
IntValidator::IntValidator( int bottom, int top, TQWidget *parent, const char *name ) :
|
||
|
TQValidator( TQT_TQOBJECT(parent), name )
|
||
15 years ago
|
{
|
||
|
v_bottom = bottom;
|
||
|
v_top = top;
|
||
|
}
|
||
|
|
||
|
IntValidator::~IntValidator() {}
|
||
|
|
||
15 years ago
|
TQValidator::State
|
||
|
IntValidator::validate( TQString &input, int & ) const
|
||
15 years ago
|
{
|
||
|
if( input.isEmpty() ) {
|
||
15 years ago
|
return TQValidator::Valid;
|
||
15 years ago
|
} else {
|
||
|
bool ok;
|
||
|
|
||
|
int value = input.toInt( &ok );
|
||
|
|
||
|
if( !ok )
|
||
15 years ago
|
return TQValidator::Invalid;
|
||
15 years ago
|
|
||
|
if( value < v_bottom || value > v_top )
|
||
15 years ago
|
return TQValidator::Valid;
|
||
15 years ago
|
|
||
15 years ago
|
return TQValidator::Acceptable;
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
|
void
|
||
|
IntValidator::setRange( int b, int t )
|
||
|
{
|
||
|
v_bottom = b;
|
||
|
v_top = t;
|
||
|
}
|
||
|
|
||
|
|