Ignore:
Timestamp:
Oct 22, 2010, 4:06:10 PM (14 years ago)
Author:
gah
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/scripts/valueresult.tcl

    r1839 r1929  
    3838    private variable _dobj2desc   ;# maps data object => description
    3939}
    40                                                                                
     40                                                                               
    4141itk::usual ValueResult {
    4242    keep -background -foreground -cursor -font
     
    5252
    5353    itk_component add scroller {
    54         Rappture::Scroller $itk_interior.scroller \
    55             -xscrollmode auto -yscrollmode auto
     54        Rappture::Scroller $itk_interior.scroller \
     55            -xscrollmode auto -yscrollmode auto
    5656    }
    5757    pack $itk_component(scroller) -expand yes -fill both
    5858
    5959    itk_component add html {
    60         Rappture::HTMLviewer $itk_component(scroller).html
     60        Rappture::HTMLviewer $itk_component(scroller).html
    6161    }
    6262    $itk_component(scroller) contents $itk_component(html)
     
    7575itcl::body Rappture::ValueResult::add {dataobj {settings ""}} {
    7676    array set params {
    77         -color ""
    78         -brightness 0
    79         -width ""
    80         -linestyle ""
    81         -raise 0
    82         -description ""
    83         -param ""
     77        -color ""
     78        -brightness 0
     79        -width ""
     80        -linestyle ""
     81        -raise 0
     82        -description ""
     83        -param ""
    8484    }
    8585    foreach {opt val} $settings {
    86         if {![info exists params($opt)]} {
    87             error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]"
    88         }
    89         set params($opt) $val
     86        if {![info exists params($opt)]} {
     87            error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]"
     88        }
     89        set params($opt) $val
    9090    }
    9191    if {$params(-color) == "auto" || $params(-color) == "autoreset"} {
    92         # can't handle -autocolors yet
    93         set params(-color) black
     92        # can't handle -autocolors yet
     93        set params(-color) black
    9494    }
    9595
    9696    if {"" != $dataobj} {
    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         }
     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        }
    112112    }
    113113}
     
    123123    set dlist $_dlist
    124124    foreach obj $dlist {
    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         }
     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        }
    132132    }
    133133    return $dlist
     
    142142itcl::body Rappture::ValueResult::delete {args} {
    143143    if {[llength $args] == 0} {
    144         set args $_dlist
     144        set args $_dlist
    145145    }
    146146
     
    148148    set changed 0
    149149    foreach obj $args {
    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         }
     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        }
    158158    }
    159159
    160160    # if anything changed, then rebuild the plot
    161161    if {$changed} {
    162         $_dispatcher event -idle !rebuild
     162        $_dispatcher event -idle !rebuild
    163163    }
    164164}
     
    189189itcl::body Rappture::ValueResult::download {option args} {
    190190    switch $option {
    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         }
     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        }
    220220    }
    221221}
     
    233233    set obj [lindex $_dlist 0]
    234234    if {"" != $obj} {
    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"
     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"
    240240    }
    241241
    242242    foreach obj $_dlist {
    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>"
     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>"
    267267    }
    268268    append html "</body></html>"
Note: See TracChangeset for help on using the changeset viewer.