]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/input_validators.C
(Lars) Remove symbolic links on "make distclean".
[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 "input_validators.h"
14
15 #include "support/lstrings.h"
16
17 #include "lyx_forms.h"
18
19 namespace support = lyx::support;
20 using support::contains;
21 using support::isStrInt;
22 using support::isStrDbl;
23
24 #if defined(__cplusplus)
25 extern "C"
26 {
27 #endif
28
29 int fl_int_filter(FL_OBJECT * ob,
30                   char const *, char const *, int c)
31 {
32         if (c == 0 /* final test before handing contents to app */
33             || contains("0123456789+-", c)) {
34                 if (isStrInt(fl_get_input(ob)))
35                         return FL_VALID;
36         }
37         return FL_INVALID|FL_RINGBELL;
38 }
39
40
41 int fl_unsigned_int_filter(FL_OBJECT * /*ob*/,
42                            char const *, char const *, int c)
43 {
44         if (c == 0 /* final test before handing contents to app */
45             || contains("0123456789", c)) {
46                 /* since we only accept numerals then it must be valid */
47                 return FL_VALID;
48         }
49         return FL_INVALID|FL_RINGBELL;
50 }
51
52
53 int fl_float_filter(FL_OBJECT * ob,
54                     char const *, char const *, int c)
55 {
56         if (c == 0 /* final test before handing contents to app */
57             || contains("0123456789.+-", c)) {
58                 if (isStrDbl(fl_get_input(ob)))
59                         return FL_VALID;
60         }
61         return FL_INVALID|FL_RINGBELL;
62 }
63
64
65 int fl_unsigned_float_filter(FL_OBJECT * ob,
66                              char const * /*not_used*/,
67                              char const * /*unused*/,
68                              int c)
69 {
70         if (c == 0 /* final test before handing contents to app */
71             || contains("0123456789.", c)) {
72                 if (isStrDbl(fl_get_input(ob)))
73                         return FL_VALID;
74         }
75         return FL_INVALID|FL_RINGBELL;
76 }
77
78
79 int fl_lowercase_filter(FL_OBJECT * /*ob*/,
80                         char const * /*not_used*/,
81                         char const * /*unused*/,
82                         int c)
83 {
84         if (c == 0 /* final test before handing contents to app */
85             || contains("abcdefghijklmnopqrstuvwxyz0123456789", c)) {
86                 /* since we only accept numerals then it must be valid */
87                 return FL_VALID;
88         }
89         return FL_INVALID|FL_RINGBELL;
90 }
91
92
93 #if defined(__cplusplus)
94 }
95 #endif