]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/input_validators.C
Yet more dialog tweaking from Rob.
[lyx.git] / src / frontends / xforms / input_validators.C
index e511e10e59cce3400867108b64041bd5411ac540..3cb159ba213457fd7caefa6b2ba382b44d08187e 100644 (file)
@@ -5,6 +5,11 @@
  */
 
 #include <config.h>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
 #include FORMS_H_LOCATION
 #include "support/lstrings.h"
 #include "input_validators.h"
@@ -14,10 +19,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 +43,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 +64,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;
 }
@@ -82,7 +107,7 @@ void fl_print_range_filter(FL_OBJECT * ob,
                   That might be acceptable if there was a "to_page"
                   entry however if you start making a page range in the "from"
                   field you can do it all in the "from" field.  That is, a
-                  range in the "from" field immmediately blanks the "to" 
+                  range in the "from" field immmediately blanks the "to"
                   field. */
        }
        return FL_INVALID|FL_RINGBELL;
@@ -91,15 +116,14 @@ void fl_print_range_filter(FL_OBJECT * ob,
           code below. */
 
        string pages = subst(fl_get_input(fd_form_print->input_pages), ';',',');
-       pages = subst(pages, '+',',');
-       pages = frontStrip(strip(pages)) ;
+       pages = trim(subst(pages, '+', ','));
+
        while (!pages.empty()) { // a page range was given
                string piece ;
                pages = split (pages, piece, ',') ;
-               piece = strip(piece) ;
-               piece = frontStrip(piece) ;
+               piece = trim(piece);
                if (!stringOnlyContains (piece, "0123456789-")) {
-                       WriteAlert(_("ERROR!  Unable to print!"),
+                       Alert::alert(_("ERROR!  Unable to print!"),
                                   _("Check 'range of pages'!"));
                        return;
                }
@@ -114,7 +138,7 @@ void fl_print_range_filter(FL_OBJECT * ob,
                }
        }
 }
-#endif 
+#endif
 
 #if defined(__cplusplus)
 }