summaryrefslogtreecommitdiff
path: root/src/Fl_Value_Input.cxx
diff options
context:
space:
mode:
authorMichael R Sweet <michael.r.sweet@gmail.com>2002-05-21 11:14:59 +0000
committerMichael R Sweet <michael.r.sweet@gmail.com>2002-05-21 11:14:59 +0000
commit23cfc372a0dab95c688190f49614c1b9090cc435 (patch)
treea68cce3f557d44c3a09a497f3f102ed30ee10ce3 /src/Fl_Value_Input.cxx
parent0104b4abc53eaf2d77c7407a01d09a886885d92e (diff)
Fix links inside PRE
Make style data const in Fl_Text_Display. Use INT input only when step() is an integral value. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@2246 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/Fl_Value_Input.cxx')
-rw-r--r--src/Fl_Value_Input.cxx18
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 $".
//