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