Domingo Alvarez Duarte wrote:
> It seems a bit logical to have methods to get/set value on then with th
> respective type, this way we save a lot of work for the users that doesn't
> need to make conversions to and from then.
This certainly sounds reasonable ;)
Since the Fl_Int_Input and Fl_Float_Input classes are implemented
as .H files only, I'd offer that the methods be made available
in Fl_Input_, since there's no reason floats and ints shouldn't
be accessible to the float, int, and string version of the widget.
For the 'get' methods, I strongly suggest we provide a way
for FLTK to return an error if the value in the widget cannot
be converted.
One way could be to add a fail() method the caller can check, eg:
Fl_Input *in;
[..]
int val = in->value_int(); // get value as an integer
if ( in->fail() ) { // check for conversion error
printf("'%s' is not an integer.", in->value());
}
Regarding naming for the new methods: I don't think we can use
the name "value()" for the int/float methods because C++ doesn't
allow overloading by return type alone (the set method would work,
but get method wouldn't).
So I think we need some new name like value_int() and value_float(),
or some such. And if so, possibly for consistency we should have
value_str()..?
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk