]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/input_validators.C
If I ever see another licence blurb again, it'll be too soon...
[lyx.git] / src / frontends / xforms / input_validators.C
1 /**
2  * \file input_validators.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Allan Rae
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "lyx_forms.h"
14 #include "support/lstrings.h"
15 #include "input_validators.h"
16
17 using namespace lyx::support;
18
19 #if defined(__cplusplus)
20 extern "C"
21 {
22 #endif
23
24 int fl_int_filter(FL_OBJECT * ob,
25                   char const *, char const *, int c)
26 {
27         if (c == 0 /* final test before handing contents to app */
28             || strchr("0123456789+-", c)) {
29                 if (isStrInt(fl_get_input(ob)))
30                         return FL_VALID;
31         }
32         return FL_INVALID|FL_RINGBELL;
33 }
34
35
36 int fl_unsigned_int_filter(FL_OBJECT * /*ob*/,
37                            char const *, char const *, int c)
38 {
39         if (c == 0 /* final test before handing contents to app */
40             || strchr("0123456789", c)) {
41                 /* since we only accept numerals then it must be valid */
42                 return FL_VALID;
43         }
44         return FL_INVALID|FL_RINGBELL;
45 }
46
47
48 int fl_float_filter(FL_OBJECT * ob,
49                     char const *, char const *, int c)
50 {
51         if (c == 0 /* final test before handing contents to app */
52             || strchr("0123456789.+-", c)) {
53                 if (isStrDbl(fl_get_input(ob)))
54                         return FL_VALID;
55         }
56         return FL_INVALID|FL_RINGBELL;
57 }
58
59
60 int fl_unsigned_float_filter(FL_OBJECT * ob,
61                              char const * /*not_used*/,
62                              char const * /*unused*/,
63                              int c)
64 {
65         if (c == 0 /* final test before handing contents to app */
66             || strchr("0123456789.", c)) {
67                 if (isStrDbl(fl_get_input(ob)))
68                         return FL_VALID;
69         }
70         return FL_INVALID|FL_RINGBELL;
71 }
72
73
74 int fl_lowercase_filter(FL_OBJECT * /*ob*/,
75                         char const * /*not_used*/,
76                         char const * /*unused*/,
77                         int c)
78 {
79         if (c == 0 /* final test before handing contents to app */
80             || strchr("abcdefghijklmnopqrstuvwxyz0123456789", c)) {
81                 /* since we only accept numerals then it must be valid */
82                 return FL_VALID;
83         }
84         return FL_INVALID|FL_RINGBELL;
85 }
86
87
88 #if defined(__cplusplus)
89 }
90 #endif