summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Melcher <github@matthiasm.com>2023-11-06 19:09:48 +0100
committerMatthias Melcher <github@matthiasm.com>2023-11-07 14:28:22 +0100
commitd7768b76d042eaa6cdce97976e96315d0bceccb2 (patch)
tree92b8c751fa1affc7f5fdb10d980bd4ea4ba1e36e /src
parent8b31954d6698bded12d6252b1bbc46c6eece7f73 (diff)
FLUID: Adds template for tutorial.
Tutorial still to be written. Also adds convenience methods to Fl_Input_ for getting and setting numeric values.
Diffstat (limited to 'src')
-rw-r--r--src/Fl_Input_.cxx48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/Fl_Input_.cxx b/src/Fl_Input_.cxx
index 4fc429aa3..52fa8cb84 100644
--- a/src/Fl_Input_.cxx
+++ b/src/Fl_Input_.cxx
@@ -1463,6 +1463,54 @@ int Fl_Input_::value(const char* str) {
}
/**
+ Changes the widget text to a signed integer number.
+
+ \param [in] v the new value
+ \return non-zero if the new value is different than the current one
+ \see Fl_Input_::value(const char* str), Fl_Input_::ivalue()
+ */
+int Fl_Input_::value(int v) {
+ char buf[64];
+ snprintf(buf, sizeof(buf)-1, "%d", v);
+ return value(buf);
+}
+
+/**
+ Changes the widget text to a floating point number ("%g").
+
+ \param [in] v the new value
+ \return non-zero if the new value is different than the current one
+ \see Fl_Input_::value(const char* str), Fl_Input_::ivalue()
+ */
+int Fl_Input_::value(double v) {
+ char buf[64];
+ snprintf(buf, sizeof(buf)-1, "%g", v);
+ return value(buf);
+}
+
+/**
+ Returns the widget text interpreted as a signed integer.
+
+ \return signed integer value
+ \see Fl_Input_::dvalue()
+ \see Fl_Input_::value(int)
+ */
+int Fl_Input_::ivalue() const {
+ return atoi(value());
+}
+
+/**
+ Returns the widget text interpreted as a floating point number.
+
+ \return double precision floating point value
+ \see Fl_Input_::ivalue()
+ \see Fl_Input_::value(double)
+ */
+int Fl_Input_::dvalue() const {
+ return atof(value());
+}
+
+/**
Changes the size of the widget.
This call updates the text layout so that the cursor is visible.
\param [in] X, Y, W, H new size of the widget