Use floor() instead of trunc() when checking if step() is an integer
(it is equivalent to trunc() for positive numbers) Fix order of subtraction so that the test actually works right. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@2247 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
23cfc372a0
commit
dc560e83e3
@ -1,5 +1,5 @@
|
||||
//
|
||||
// "$Id: Fl_Value_Input.cxx,v 1.6.2.5.2.4 2002/05/21 11:14:59 easysw Exp $"
|
||||
// "$Id: Fl_Value_Input.cxx,v 1.6.2.5.2.5 2002/05/21 16:50:48 easysw Exp $"
|
||||
//
|
||||
// Value input widget for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
@ -33,15 +33,11 @@
|
||||
#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 ((trunc(t.step()) - t.step())>0.0) nv = strtod(t.input.value(), 0);
|
||||
if ((t.step() - floor(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);
|
||||
@ -114,7 +110,7 @@ int Fl_Value_Input::handle(int event) {
|
||||
return input.take_focus();
|
||||
default:
|
||||
DEFAULT:
|
||||
input.type((trunc(step()) - step())>0.0 ? FL_FLOAT_INPUT : FL_INT_INPUT);
|
||||
input.type((step() - floor(step()))>0.0 ? FL_FLOAT_INPUT : FL_INT_INPUT);
|
||||
return input.handle(event);
|
||||
}
|
||||
}
|
||||
@ -135,5 +131,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.4 2002/05/21 11:14:59 easysw Exp $".
|
||||
// End of "$Id: Fl_Value_Input.cxx,v 1.6.2.5.2.5 2002/05/21 16:50:48 easysw Exp $".
|
||||
//
|
||||
|
Loading…
x
Reference in New Issue
Block a user