]> 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 1e48205e6425db2efc60f7bdd921f9717dfd6587..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_unsigned_int_filter(FL_OBJECT * ob,
-                          char const * not_used,
-                          char const * unused,
-                          int c)
+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 *, char const *, int c)
 {
        if (c == 0 /* final test before handing contents to app */
            || strchr("0123456789", c)) {
@@ -28,25 +38,35 @@ 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,
+                            char const * /*not_used*/,
+                            char const * /*unused*/,
                             int c)
 {
        if (c == 0 /* final test before handing contents to app */
            || strchr("0123456789.", c)) {
-               if ( isStrDbl(fl_get_input(ob)) )
+               if (isStrDbl(fl_get_input(ob)))
                        return FL_VALID;
-               else
-                       return FL_INVALID|FL_RINGBELL;
        }
        return FL_INVALID|FL_RINGBELL;
 }
 
 
-int fl_lowercase_filter(FL_OBJECT * ob,
-                       char const * not_used,
-                       char const * unused,
+int fl_lowercase_filter(FL_OBJECT * /*ob*/,
+                       char const * /*not_used*/,
+                       char const * /*unused*/,
                        int c)
 {
        if (c == 0 /* final test before handing contents to app */
@@ -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;
                }