diff options
Diffstat (limited to 'fluid/widgets/Formula_Input.cxx')
| -rw-r--r-- | fluid/widgets/Formula_Input.cxx | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/fluid/widgets/Formula_Input.cxx b/fluid/widgets/Formula_Input.cxx index 16bc2310a..06f5e3672 100644 --- a/fluid/widgets/Formula_Input.cxx +++ b/fluid/widgets/Formula_Input.cxx @@ -23,8 +23,8 @@ #include <ctype.h> #include <string.h> -using namespace fld; -using namespace fld::widget; + + /** \class fld::widget::Formula_Input The Formula_Input widget is an input field for entering widget coordinates @@ -36,18 +36,18 @@ using namespace fld::widget; /** Create an input field. */ -Formula_Input::Formula_Input(int x, int y, int w, int h, const char *l) +fld::widget::Formula_Input::Formula_Input(int x, int y, int w, int h, const char *l) : Fl_Input(x, y, w, h, l) { Fl_Input::callback((Fl_Callback*)callback_handler_cb); text("0"); } -void Formula_Input::callback_handler_cb(Formula_Input *This, void *v) { +void fld::widget::Formula_Input::callback_handler_cb(Formula_Input *This, void *v) { This->callback_handler(v); } -void Formula_Input::callback_handler(void *v) { +void fld::widget::Formula_Input::callback_handler(void *v) { if (user_callback_) (*user_callback_)(this, v); // do *not* update the value to show the evaluated formula here, because the @@ -63,7 +63,7 @@ void Formula_Input::callback_handler(void *v) { the last character of the variable name when returning. \return the integer value that was found or calculated */ -int Formula_Input::eval_var(uchar *&s) const { +int fld::widget::Formula_Input::eval_var(uchar *&s) const { if (!vars_) return 0; // find the end of the variable name @@ -71,7 +71,8 @@ int Formula_Input::eval_var(uchar *&s) const { while (isalpha(*s)) s++; int n = (int)(s-v); // find the variable in the list - for (Formula_Input_Vars *vars = vars_; vars->name_; vars++) { + Formula_Input_Vars *vars; + for (vars = vars_; vars->name_; vars++) { if (strncmp((char*)v, vars->name_, n)==0 && vars->name_[n]==0) return vars->callback_(this, vars_user_data_); } @@ -85,7 +86,7 @@ int Formula_Input::eval_var(uchar *&s) const { \param prio priority of current operation \return the value so far */ -int Formula_Input::eval(uchar *&s, int prio) const { +int fld::widget::Formula_Input::eval(uchar *&s, int prio) const { int v = 0, sgn = 1; uchar c = *s++; @@ -157,7 +158,7 @@ int Formula_Input::eval(uchar *&s, int prio) const { \param s formula as a C string \return the calculated value */ -int Formula_Input::eval(const char *s) const +int fld::widget::Formula_Input::eval(const char *s) const { // duplicate the text, so we can modify it uchar *buf = (uchar*)fl_strdup(s); @@ -179,14 +180,14 @@ int Formula_Input::eval(const char *s) const /** Evaluate the formula and return the result. */ -int Formula_Input::value() const { +int fld::widget::Formula_Input::value() const { return eval(text()); } /** Set the field to an integer value, replacing previous texts. */ -void Formula_Input::value(int v) { +void fld::widget::Formula_Input::value(int v) { char buf[32]; fl_snprintf(buf, sizeof(buf), "%d", v); text(buf); @@ -195,7 +196,7 @@ void Formula_Input::value(int v) { /** Allow vertical mouse dragging and mouse wheel to interactively change the value. */ -int Formula_Input::handle(int event) { +int fld::widget::Formula_Input::handle(int event) { switch (event) { case FL_MOUSEWHEEL: if (Fl::event_dy()) { @@ -211,7 +212,7 @@ int Formula_Input::handle(int event) { /** Set the list of the available variables \param vars array of variables, last entry `has name_` set to `0` \param user_data is forwarded to the Variable callback */ -void Formula_Input::variables(Formula_Input_Vars *vars, void *user_data) { +void fld::widget::Formula_Input::variables(Formula_Input_Vars *vars, void *user_data) { vars_ = vars; vars_user_data_ = user_data; } |
