]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/input_validators.C
Bugfixes: checkboxes to radiobuttons (from J�rgen S) and remove a little
[lyx.git] / src / frontends / xforms / input_validators.C
index 5555d516d51550903b5d1a0ac30b2901ab9fb559..cc237bf3de7e312d5ae97f86a7538f3cb579f439 100644 (file)
@@ -1,10 +1,10 @@
 /* input_validators.C
  * A collection of input filtering and validating functions for use in
- * XForms popups.  Mainly meant for filtering input boxes although may
+ * XForms dialogs.  Mainly meant for filtering input boxes although may
  * be extended to include other generally useful xforms-specific tools.
  */
 
-#include "config.h"
+#include <config.h>
 #include FORMS_H_LOCATION
 #include "support/lstrings.h"
 #include "input_validators.h"
@@ -14,10 +14,20 @@ extern "C"
 {
 #endif
 
+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;
+}
+
+
 int fl_unsigned_int_filter(FL_OBJECT * /*ob*/,
-                          char const * /*not_used*/,
-                          char const * /*unused*/,
-                          int c)
+                          char const *, char const *, int c)
 {
        if (c == 0 /* final test before handing contents to app */
            || strchr("0123456789", c)) {
@@ -28,6 +38,18 @@ int fl_unsigned_int_filter(FL_OBJECT * /*ob*/,
 }
 
 
+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;
+}
+
+
 int fl_unsigned_float_filter(FL_OBJECT * ob,
                             char const * /*not_used*/,
                             char const * /*unused*/,
@@ -37,8 +59,6 @@ int fl_unsigned_float_filter(FL_OBJECT * ob,
            || strchr("0123456789.", c)) {
                if (isStrDbl(fl_get_input(ob)))
                        return FL_VALID;
-               else
-                       return FL_INVALID|FL_RINGBELL;
        }
        return FL_INVALID|FL_RINGBELL;
 }
@@ -99,7 +119,7 @@ void fl_print_range_filter(FL_OBJECT * ob,
                piece = strip(piece) ;
                piece = frontStrip(piece) ;
                if (!stringOnlyContains (piece, "0123456789-")) {
-                       WriteAlert(_("ERROR!  Unable to print!"),
+                       Alert::alert(_("ERROR!  Unable to print!"),
                                   _("Check 'range of pages'!"));
                        return;
                }