Changeset 3511
- Timestamp:
- Mar 16, 2013, 9:31:43 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/numberentry.tcl
r3330 r3511 48 48 set _owner $owner 49 49 set _path $path 50 50 51 51 # 52 52 # Figure out what sort of control to create … … 54 54 set presets "" 55 55 foreach pre [$_owner xml children -type preset $path] { 56 lappend presets \57 [$_owner xml get $path.$pre.value] \58 [$_owner xml get $path.$pre.label]59 } 60 56 set value [string trim [$_owner xml get $path.$pre.value]] 57 set label [$_owner xml get $path.$pre.label] 58 lappend presets $value $label 59 } 60 61 61 set class Rappture::Gauge 62 set units [ $_owner xml get $path.units]62 set units [string trim [$_owner xml get $path.units]] 63 63 if {$units != ""} { 64 64 set desc [Rappture::Units::description $units] … … 67 67 } 68 68 } 69 69 70 70 # 71 71 # Create the widget and configure it properly based on other … … 77 77 pack $itk_component(gauge) -expand yes -fill both 78 78 bind $itk_component(gauge) <<Value>> [itcl::code $this _newValue] 79 80 set min [$_owner xml get $path.min] 81 if {$min ne ""} { $itk_component(gauge) configure -minvalue $min } 82 83 set max [$_owner xml get $path.max] 84 if {$max ne ""} { $itk_component(gauge) configure -maxvalue $max } 79 80 set min [string trim [$_owner xml get $path.min]] 81 if {$min ne ""} { 82 $itk_component(gauge) configure -minvalue $min 83 } 84 85 set max [string trim [$_owner xml get $path.max]] 86 if {$max ne ""} { 87 $itk_component(gauge) configure -maxvalue $max 88 } 85 89 86 90 if {$class == "Rappture::Gauge" && $min ne "" && $max ne ""} { 87 set color [ $_owner xml get $path.about.color]91 set color [string trim [$_owner xml get $path.about.color]] 88 92 if {$color == ""} { 89 93 # deprecated. Color should be in "about" 90 set color [ $_owner xml get $path.color]94 set color [string trim [$_owner xml get $path.color]] 91 95 } 92 96 if {$color != ""} { … … 100 104 } 101 105 $itk_component(gauge) configure \ 102 -spectrum [Rappture::Spectrum :: #auto $color -units $units]106 -spectrum [Rappture::Spectrum ::\#auto $color -units $units] 103 107 } 104 108 } 105 109 106 110 # if the control has an icon, plug it in 107 set str [ $_owner xml get $path.about.icon]111 set str [string trim [$_owner xml get $path.about.icon]] 108 112 if {$str ne ""} { 109 113 $itk_component(gauge) configure -image [image create photo -data $str] 110 114 } 111 112 115 eval itk_initialize $args 113 116 … … 115 118 # Assign the default value to this widget, if there is one. 116 119 # 117 set str [$_owner xml get $path.default] 118 if {$str ne ""} { $itk_component(gauge) value $str } 120 set str [string trim [$_owner xml get $path.default]] 121 if {$str ne ""} { 122 $itk_component(gauge) value $str 123 } 119 124 } 120 125 … … 180 185 set str [$_owner xml get $_path.about.description] 181 186 182 set units [ $_owner xml get $_path.units]183 set min [ $_owner xml get $_path.min]184 set max [ $_owner xml get $_path.max]187 set units [string trim [$_owner xml get $_path.units]] 188 set min [string trim [$_owner xml get $_path.min]] 189 set max [string trim [$_owner xml get $_path.max]] 185 190 186 191 if {$units != "" || $min != "" || $max != ""} { -
trunk/lang/tcl/src/RpUnitsTclInterface.cc
r3177 r3511 38 38 */ 39 39 40 #include <algorithm> 41 #include <functional> 42 #include <cctype> 43 44 // Trim from start 45 static inline std::string <rim(std::string &s) 46 { 47 s.erase(s.begin(), 48 std::find_if(s.begin(), s.end(), 49 std::not1(std::ptr_fun<int, int>(std::isspace)))); 50 return s; 51 } 52 53 // Trim from end 54 static inline std::string &rtrim(std::string &s) 55 { 56 s.erase(std::find_if(s.rbegin(), s.rend(), 57 std::not1(std::ptr_fun<int, int>(std::isspace))).base(), s.end()); 58 return s; 59 } 60 61 // Trim from both ends 62 static inline std::string &trim(std::string &s) 63 { 64 return ltrim(rtrim(s)); 65 } 66 40 67 extern "C" int 41 68 RpUnits_Init(Tcl_Interp *interp) … … 71 98 * provided in -context option. 72 99 */ 100 73 101 74 102 int … … 208 236 // or if we should use those provided in -context option 209 237 238 239 // Trim away white space from the value. 240 trim(inValue); 241 210 242 double value; 211 value = strtod(inValue.c_str(), &endptr);243 value = strtod(inValue.c_str(), &endptr); 212 244 if (endptr == inValue.c_str()) { 213 245 // there was no numeric value that could be pulled from inValue
Note: See TracChangeset
for help on using the changeset viewer.