- if (str.empty()) {
- fl_set_input(input, "");
- int unitpos = 1; // xforms has Fortran-style indexing
- for(int i = 0; i < fl_get_choice_maxitems(choice); ++i) {
- string const text = fl_get_choice_item_text(choice,i+1);
- if (default_unit ==
- lowercase(strip(frontStrip(text)))) {
- unitpos = i+1;
- break;
- }
- }
- fl_set_choice(choice, unitpos);
- return;
- }
-
- // The unit is presumed to begin at the first char a-z
- // or with the char '%'
- string const tmp = lowercase(strip(frontStrip(str)));
-
- string::const_iterator p = tmp.begin();
- for (; p != tmp.end(); ++p) {
- if ((*p >= 'a' && *p <= 'z') || *p == '%')
- break;
- }
-
- string len = "0";
- int unitpos = 1; // xforms has Fortran-style indexing
-
- if (p == tmp.end()) {
- if (isStrDbl(tmp))
- len = tmp;
-
- } else {
- string tmplen = string(tmp.begin(), p);
- if (isStrDbl(tmplen))
- len = tmplen;
- string unit = string(p, tmp.end());
- unit = subst(unit, "%", "%%");
-
- for(int i = 0; i < fl_get_choice_maxitems(choice); ++i) {
- string const text = fl_get_choice_item_text(choice,i+1);
- if (unit == lowercase(strip(frontStrip(text)))) {
- unitpos = i+1;
- break;
- }
- }
- }
-
- fl_set_input(input, len.c_str());
- fl_set_choice(choice, unitpos);
-}
-#else
-void updateWidgetsFromLengthString(FL_OBJECT * input, FL_OBJECT * choice,
- string const & str,
- string const & default_unit)
-{