diff options
Diffstat (limited to 'src/Fl_Value_Input.cxx')
| -rw-r--r-- | src/Fl_Value_Input.cxx | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/Fl_Value_Input.cxx b/src/Fl_Value_Input.cxx index 11241033c..0fefb7694 100644 --- a/src/Fl_Value_Input.cxx +++ b/src/Fl_Value_Input.cxx @@ -1,5 +1,5 @@ // -// "$Id: Fl_Value_Input.cxx,v 1.6.2.5.2.3 2002/02/18 13:25:26 easysw Exp $" +// "$Id: Fl_Value_Input.cxx,v 1.6.2.5.2.4 2002/05/21 11:14:59 easysw Exp $" // // Value input widget for the Fast Light Tool Kit (FLTK). // @@ -23,7 +23,7 @@ // Please report all bugs and problems to "fltk-bugs@fltk.org". // -// Fltk widget for drag-adjusting a floating point value. +// FLTK widget for drag-adjusting a floating point value. // Warning: this works by making a child Fl_Input object, even // though this object is *not* an Fl_Group. May be a kludge? @@ -31,12 +31,18 @@ #include <FL/Fl_Value_Input.H> #include <FL/Fl_Group.H> #include <stdlib.h> +#include <FL/math.h> + +// Some math headers don't seem to define this function... +extern "C" { + double trunc(double); +} void Fl_Value_Input::input_cb(Fl_Widget*, void* v) { Fl_Value_Input& t = *(Fl_Value_Input*)v; double nv; - if (t.step()>=1.0) nv = strtol(t.input.value(), 0, 0); - else nv = strtod(t.input.value(), 0); + if ((trunc(t.step()) - t.step())>0.0) nv = strtod(t.input.value(), 0); + else nv = strtol(t.input.value(), 0, 0); if (nv != t.value() || t.when() & FL_WHEN_NOT_CHANGED) { t.set_value(nv); if (t.when()) { @@ -108,7 +114,7 @@ int Fl_Value_Input::handle(int event) { return input.take_focus(); default: DEFAULT: - input.type(step()>=1.0 ? FL_INT_INPUT : FL_FLOAT_INPUT); + input.type((trunc(step()) - step())>0.0 ? FL_FLOAT_INPUT : FL_INT_INPUT); return input.handle(event); } } @@ -129,5 +135,5 @@ Fl_Value_Input::Fl_Value_Input(int x, int y, int w, int h, const char* l) } // -// End of "$Id: Fl_Value_Input.cxx,v 1.6.2.5.2.3 2002/02/18 13:25:26 easysw Exp $". +// End of "$Id: Fl_Value_Input.cxx,v 1.6.2.5.2.4 2002/05/21 11:14:59 easysw Exp $". // |
