Ignore:
Timestamp:
Jun 20, 2010 11:32:36 AM (14 years ago)
Author:
gah
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/blt4/gui/scripts/xylegend.tcl

    r1764 r1767  
    6666    private variable _rename    "";     # Node selected to be renamed.
    6767    private variable _diffelements
     68    private variable _unmapHidden 0
    6869
    6970    constructor {args} { graph }
     
    7475    private method Add { elem label {flags ""}}
    7576    private method Average {}
    76     private method Check {}
     77    private method BuildPopup { popup }
     78    private method Check { menu }
    7779    private method Delete { args }
    7880    private method Difference {}
     
    8284    private method Lower { args }
    8385    private method Raise { args }
     86    private method PopupMenu { x y }
    8487    private method Recolor {}
    8588    private method Rename {}
     
    8790    private method Show { args }
    8891    private method Toggle { args }
     92    private method UnmapHidden {}
    8993}
    9094                                                                               
     
    152156    $m add -text "Show" -command [itcl::code $this Show]
    153157    $m add -text "Toggle" -command [itcl::code $this Toggle]
     158    $m add -text "Unmap Hidden" -command [itcl::code $this UnmapHidden] \
     159        -variable [itcl::scope _unmapHidden] \
     160        -type checkbutton
    154161    $m add -type separator
    155162    $m add -text "Lower" -command [itcl::code $this Lower]
     
    162169    $m add -text "Rename" -command [itcl::code $this Rename]
    163170    $m add -text "Delete" -command [itcl::code $this Delete]
    164 
     171    set _unmapHidden [$graph cget -unmaphiddenelements]
    165172    set _graph $graph
    166173    set cmd [itcl::code $this Toggle current]
     
    181188        "$itk_component(legend) selection clearall"
    182189    $itk_component(legend) configure -selectcommand \
    183         [itcl::code $this Check]
    184 
     190        [itcl::code $this Check $itk_component(controls)]
     191    bind $itk_component(legend) <ButtonRelease-3> \
     192        [itcl::code $this PopupMenu %X %Y]
    185193    itk_component add editor {
    186194        Rappture::Editor $itk_interior.editor \
     
    194202        1,0 $itk_component(scrollbars) -fill both
    195203    blt::table configure $itk_interior r0 -resize none
    196     Check
     204    Check $itk_component(controls)
    197205    eval itk_initialize $args
    198206}
     
    241249    }
    242250    $itk_component(legend) open -recurse root
    243     Check
     251    Check $itk_component(controls)
    244252}
    245253
     
    376384}
    377385
    378 itcl::body Rappture::XyLegend::Check {} {
     386itcl::body Rappture::XyLegend::Check { menu } {
    379387    set nodes [$itk_component(legend) curselection]
    380     foreach n {  Hide Show Toggle Raise Lower Rename Average Difference
    381         Delete Recolor } {
    382         $itk_component(controls) item configure $n -state disabled
    383     }
     388    $menu item configure all -state disabled
     389    $menu item configure "Unmap Hidden" -state normal
    384390    foreach node $nodes {
    385391        if { [$_tree get $node "delete" 0] } {
    386             $itk_component(controls) item configure Delete -state normal
     392            $menu item configure Delete -state normal
    387393            break
    388394        }
     
    390396    if { [$_tree degree 0] > 1  && [llength $nodes] > 0 } {
    391397        foreach n { Raise Lower } {
    392             $itk_component(controls) item configure $n -state normal
     398            $menu item configure $n -state normal
    393399        }
    394400    }
     
    398404        1 {
    399405            foreach n { Hide Show Toggle Rename Recolor } {
    400                 $itk_component(controls) item configure $n -state normal
     406                $menu item configure $n -state normal
    401407            }
    402408        }
    403409        2 {
    404410            foreach n { Hide Show Toggle Difference Average Recolor } {
    405                 $itk_component(controls) item configure $n -state normal
     411                $menu item configure $n -state normal
    406412            }
    407413        }
    408414        default {
    409415            foreach n { Hide Show Toggle Average Recolor } {
    410                 $itk_component(controls) item configure $n -state normal
     416                $menu item configure $n -state normal
    411417            }
    412418        }
     
    557563}
    558564
     565itcl::body Rappture::XyLegend::UnmapHidden {} {
     566    $_graph configure -unmaphiddenelements $_unmapHidden
     567}
     568
    559569itcl::body Rappture::XyLegend::SelectAll { } {
    560570    foreach node [$_tree children 0] {
     
    618628    }
    619629}
     630
     631#
     632# BuildPopup --
     633#
     634#
     635itcl::body Rappture::XyLegend::BuildPopup { popup } {
     636    set m $popup
     637    blt::combomenu $popup \
     638        -yscrollbar $m.ys \
     639        -xscrollbar $m.xs -height { 0 2.5i }
     640    blt::tk::scrollbar $m.xs
     641    blt::tk::scrollbar $m.ys
     642    $m add -text "Hide" -command [itcl::code $this Hide]
     643    $m add -text "Show" -command [itcl::code $this Show]
     644    $m add -text "Toggle" -command [itcl::code $this Toggle]
     645    $m add -text "Unmap Hidden" -command [itcl::code $this UnmapHidden] \
     646        -variable [itcl::scope _unmapHidden] \
     647        -type checkbutton
     648    $m add -type separator
     649    $m add -text "Lower" -command [itcl::code $this Lower]
     650    $m add -text "Raise" -command [itcl::code $this Raise]
     651    $m add -type separator
     652    $m add -text "Average" -command [itcl::code $this Average]
     653    $m add -text "Difference" -command [itcl::code $this Difference]
     654    $m add -type separator
     655    $m add -text "Recolor" -command [itcl::code $this Recolor]
     656    $m add -text "Rename" -command [itcl::code $this Rename]
     657    $m add -text "Delete" -command [itcl::code $this Delete]
     658    set _unmapHidden [$_graph cget -unmaphiddenelements]
     659    set cmd [itcl::code $this Toggle current]
     660    Check $m
     661}
     662
     663#
     664# PopupMenu --
     665#
     666#       Builds the popup associated with the sensor map.  The menu
     667#       is first destroyed if one exists.  This is because the menu
     668#       bindings callbacks are specific to the current map.  Destroying
     669#       the menu automatically removes the bindings and callbacks.
     670#
     671itcl::body Rappture::XyLegend::PopupMenu { x y } {
     672    set m .xylegendpopup
     673    if { [winfo exists $m]  } {
     674        destroy $m
     675    }
     676    BuildPopup $m
     677    blt::ComboMenu::popup $m $x $y
     678}
Note: See TracChangeset for help on using the changeset viewer.