Changeset 1929 for trunk/gui/scripts/valueresult.tcl
- Timestamp:
- Oct 22, 2010, 4:06:10 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/valueresult.tcl
r1839 r1929 38 38 private variable _dobj2desc ;# maps data object => description 39 39 } 40 40 41 41 itk::usual ValueResult { 42 42 keep -background -foreground -cursor -font … … 52 52 53 53 itk_component add scroller { 54 55 54 Rappture::Scroller $itk_interior.scroller \ 55 -xscrollmode auto -yscrollmode auto 56 56 } 57 57 pack $itk_component(scroller) -expand yes -fill both 58 58 59 59 itk_component add html { 60 60 Rappture::HTMLviewer $itk_component(scroller).html 61 61 } 62 62 $itk_component(scroller) contents $itk_component(html) … … 75 75 itcl::body Rappture::ValueResult::add {dataobj {settings ""}} { 76 76 array set params { 77 78 79 80 81 82 83 77 -color "" 78 -brightness 0 79 -width "" 80 -linestyle "" 81 -raise 0 82 -description "" 83 -param "" 84 84 } 85 85 foreach {opt val} $settings { 86 87 88 89 86 if {![info exists params($opt)]} { 87 error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]" 88 } 89 set params($opt) $val 90 90 } 91 91 if {$params(-color) == "auto" || $params(-color) == "autoreset"} { 92 93 92 # can't handle -autocolors yet 93 set params(-color) black 94 94 } 95 95 96 96 if {"" != $dataobj} { 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 97 # find the value and assign it with the proper coloring 98 if {"" != $params(-color) && "" != $params(-brightness) 99 && $params(-brightness) != 0} { 100 set params(-color) [Rappture::color::brightness \ 101 $params(-color) $params(-brightness)] 102 } 103 104 set pos [lsearch -exact $dataobj $_dlist] 105 if {$pos < 0} { 106 lappend _dlist $dataobj 107 set _dobj2color($dataobj) $params(-color) 108 set _dobj2raise($dataobj) $params(-raise) 109 set _dobj2desc($dataobj) $params(-description) 110 $_dispatcher event -idle !rebuild 111 } 112 112 } 113 113 } … … 123 123 set dlist $_dlist 124 124 foreach obj $dlist { 125 126 127 128 129 130 131 125 if {[info exists _dobj2raise($obj)] && $_dobj2raise($obj)} { 126 set i [lsearch -exact $dlist $obj] 127 if {$i >= 0} { 128 set dlist [lreplace $dlist $i $i] 129 lappend dlist $obj 130 } 131 } 132 132 } 133 133 return $dlist … … 142 142 itcl::body Rappture::ValueResult::delete {args} { 143 143 if {[llength $args] == 0} { 144 144 set args $_dlist 145 145 } 146 146 … … 148 148 set changed 0 149 149 foreach obj $args { 150 151 152 153 154 155 156 157 150 set pos [lsearch -exact $_dlist $obj] 151 if {$pos >= 0} { 152 set _dlist [lreplace $_dlist $pos $pos] 153 catch {unset _dobj2color($obj)} 154 catch {unset _dobj2raise($obj)} 155 catch {unset _dobj2desc($obj)} 156 set changed 1 157 } 158 158 } 159 159 160 160 # if anything changed, then rebuild the plot 161 161 if {$changed} { 162 162 $_dispatcher event -idle !rebuild 163 163 } 164 164 } … … 189 189 itcl::body Rappture::ValueResult::download {option args} { 190 190 switch $option { 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 191 coming { 192 # nothing to do 193 } 194 controls { 195 # no controls for this download yet 196 return "" 197 } 198 now { 199 if {[llength $_dlist] == 1} { 200 set lstr [$_dlist get about.label] 201 set mesg "$lstr [$_dlist get current]" 202 } else { 203 set mesg "" 204 foreach obj $_dlist { 205 set lstr [$obj get about.label] 206 append mesg "$lstr [$obj get current]\n" 207 if {[string length $_dobj2desc($obj)] > 0} { 208 foreach line [split $_dobj2desc($obj) \n] { 209 append mesg " * $line\n" 210 } 211 append mesg "\n" 212 } 213 } 214 } 215 return [list .txt $mesg] 216 } 217 default { 218 error "bad option \"$option\": should be coming, controls, now" 219 } 220 220 } 221 221 } … … 233 233 set obj [lindex $_dlist 0] 234 234 if {"" != $obj} { 235 236 237 238 239 235 set label [$obj get about.label] 236 if {"" != $label && [string index $label end] != ":"} { 237 append label ":" 238 } 239 append html "<h3>$label</h3>\n" 240 240 } 241 241 242 242 foreach obj $_dlist { 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 243 if {$_dobj2raise($obj)} { 244 set bold0 "<b>" 245 set bold1 "</b>" 246 set bg "background:#ffffcc; border:1px solid #cccccc;" 247 } else { 248 set bold0 "" 249 set bold1 "" 250 set bg "" 251 } 252 if {$_dobj2color($obj) != ""} { 253 set color0 "<font style=\"color: $_dobj2color($obj)\">" 254 set color1 "</font>" 255 } else { 256 set color0 "" 257 set color1 "" 258 } 259 260 append html "<div style=\"margin:8px; padding:4px; $bg\">${bold0}${color0}[$obj get current]${color1}${bold1}" 261 if {$_dobj2raise($obj) && [string length $_dobj2desc($obj)] > 0} { 262 foreach line [split $_dobj2desc($obj) \n] { 263 append html "<li style=\"margin-left:12px;\">$line</li>\n" 264 } 265 } 266 append html "</div>" 267 267 } 268 268 append html "</body></html>"
Note: See TracChangeset
for help on using the changeset viewer.