2000-06-12 11:55:12 +00:00
|
|
|
/* input_validators.C
|
|
|
|
* A collection of input filtering and validating functions for use in
|
2001-04-03 14:30:58 +00:00
|
|
|
* XForms dialogs. Mainly meant for filtering input boxes although may
|
2000-06-12 11:55:12 +00:00
|
|
|
* be extended to include other generally useful xforms-specific tools.
|
|
|
|
*/
|
|
|
|
|
2001-03-15 13:37:04 +00:00
|
|
|
#include <config.h>
|
2002-03-11 17:00:41 +00:00
|
|
|
|
|
|
|
|
2003-05-14 09:17:22 +00:00
|
|
|
#include "lyx_forms.h"
|
2000-12-06 22:24:17 +00:00
|
|
|
#include "support/lstrings.h"
|
2000-06-12 11:55:12 +00:00
|
|
|
#include "input_validators.h"
|
|
|
|
|
2003-06-30 23:56:22 +00:00
|
|
|
using namespace lyx::support;
|
|
|
|
|
2000-06-12 11:55:12 +00:00
|
|
|
#if defined(__cplusplus)
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#endif
|
|
|
|
|
2001-07-28 12:24:16 +00:00
|
|
|
int fl_int_filter(FL_OBJECT * ob,
|
|
|
|
char const *, char const *, int c)
|
|
|
|
{
|
|
|
|
if (c == 0 /* final test before handing contents to app */
|
|
|
|
|| strchr("0123456789+-", c)) {
|
|
|
|
if (isStrInt(fl_get_input(ob)))
|
|
|
|
return FL_VALID;
|
|
|
|
}
|
|
|
|
return FL_INVALID|FL_RINGBELL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-01-08 09:37:13 +00:00
|
|
|
int fl_unsigned_int_filter(FL_OBJECT * /*ob*/,
|
2001-07-28 12:24:16 +00:00
|
|
|
char const *, char const *, int c)
|
2000-06-12 11:55:12 +00:00
|
|
|
{
|
2000-06-13 17:10:47 +00:00
|
|
|
if (c == 0 /* final test before handing contents to app */
|
2000-06-12 11:55:12 +00:00
|
|
|
|| strchr("0123456789", c)) {
|
2000-06-13 17:10:47 +00:00
|
|
|
/* since we only accept numerals then it must be valid */
|
2000-11-03 09:47:02 +00:00
|
|
|
return FL_VALID;
|
|
|
|
}
|
|
|
|
return FL_INVALID|FL_RINGBELL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-07-28 12:24:16 +00:00
|
|
|
int fl_float_filter(FL_OBJECT * ob,
|
|
|
|
char const *, char const *, int c)
|
|
|
|
{
|
|
|
|
if (c == 0 /* final test before handing contents to app */
|
|
|
|
|| strchr("0123456789.+-", c)) {
|
|
|
|
if (isStrDbl(fl_get_input(ob)))
|
|
|
|
return FL_VALID;
|
|
|
|
}
|
|
|
|
return FL_INVALID|FL_RINGBELL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-12-06 22:24:17 +00:00
|
|
|
int fl_unsigned_float_filter(FL_OBJECT * ob,
|
2001-01-08 09:37:13 +00:00
|
|
|
char const * /*not_used*/,
|
|
|
|
char const * /*unused*/,
|
2000-12-06 22:24:17 +00:00
|
|
|
int c)
|
|
|
|
{
|
|
|
|
if (c == 0 /* final test before handing contents to app */
|
|
|
|
|| strchr("0123456789.", c)) {
|
2001-01-08 09:37:13 +00:00
|
|
|
if (isStrDbl(fl_get_input(ob)))
|
2000-12-06 22:24:17 +00:00
|
|
|
return FL_VALID;
|
|
|
|
}
|
|
|
|
return FL_INVALID|FL_RINGBELL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-01-08 09:37:13 +00:00
|
|
|
int fl_lowercase_filter(FL_OBJECT * /*ob*/,
|
|
|
|
char const * /*not_used*/,
|
|
|
|
char const * /*unused*/,
|
2000-11-03 09:47:02 +00:00
|
|
|
int c)
|
|
|
|
{
|
|
|
|
if (c == 0 /* final test before handing contents to app */
|
2000-11-08 09:39:46 +00:00
|
|
|
|| strchr("abcdefghijklmnopqrstuvwxyz0123456789", c)) {
|
2000-11-03 09:47:02 +00:00
|
|
|
/* since we only accept numerals then it must be valid */
|
2000-06-12 11:55:12 +00:00
|
|
|
return FL_VALID;
|
|
|
|
}
|
|
|
|
return FL_INVALID|FL_RINGBELL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(__cplusplus)
|
|
|
|
}
|
|
|
|
#endif
|