Changeset 1132 for trunk/gui/scripts/xylegend.tcl
- Timestamp:
- Aug 27, 2008, 3:59:56 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/xylegend.tcl
r1130 r1132 29 29 private variable tree_ "" 30 30 private variable diff_ "" 31 private variable focus_ -1 31 32 private variable diffelements_ 32 33 … … 35 36 36 37 public method Activate {} 38 public method Average {} 39 public method Check {} 37 40 public method Deactivate {} 41 public method Delete { args } 42 public method Difference {} 43 public method Editor { option args } 38 44 public method Hide { args } 45 public method Lower { args } 46 public method Raise { args } 47 public method Rename {} 39 48 public method Show { args } 40 49 public method Toggle { args } 41 public method Raise { args }42 public method Lower { args }43 public method Check {}44 public method Difference {}45 public method Delete { args }46 public method Average {}47 50 private method GetData { elem what } 48 51 private method Add { elem label {flags ""}} … … 90 93 -boxcolor grey50 -checkcolor black -activebackground grey90 91 94 $itk_component(legend) column configure "treeView" -justify left \ 92 -weight 1.0 -text "" -pad 0 -borderwidth 0 95 -weight 1.0 -text "" -pad 0 -borderwidth 0 93 96 $itk_component(legend) column configure "show" -style "check" -pad {0 0} \ 94 97 -edit yes … … 110 113 difference "" 111 114 delete "" 115 rename "" 112 116 } 113 117 foreach { but icon} $commands { … … 118 122 -activebackground grey90 119 123 } 120 grid $controls.hide -column 0 -row 0 121 grid $controls.show -column 0 -row 1 124 grid $controls.hide -column 0 -row 0 -sticky w 125 grid $controls.show -column 0 -row 1 -sticky w 122 126 grid $controls.toggle -column 0 -row 2 -sticky w 123 127 grid $controls.raise -column 0 -row 3 -sticky w … … 125 129 grid $controls.difference -column 1 -row 0 -sticky w 126 130 grid $controls.average -column 1 -row 1 -sticky w 127 grid $controls.delete -column 1 -row 2 -sticky w 131 grid $controls.rename -column 1 -row 2 -sticky w 132 grid $controls.delete -column 1 -row 3 -sticky w 128 133 129 134 grid columnconfigure $controls 0 -weight 1 … … 149 154 $itk_component(legend) configure -selectcommand \ 150 155 [itcl::code $this Check] 156 157 itk_component add editor { 158 Rappture::Editor $itk_interior.editor \ 159 -activatecommand [itcl::code $this Editor activate] \ 160 -validatecommand [itcl::code $this Editor validate] \ 161 -applycommand [itcl::code $this Editor apply] 162 } 151 163 Check 152 164 eval itk_initialize $args … … 331 343 itcl::body Rappture::XyLegend::Check {} { 332 344 set nodes [$itk_component(legend) curselection] 333 foreach n { hide show toggle raise lower average difference delete } { 345 foreach n { hide show toggle raise lower 346 rename average difference delete } { 334 347 $itk_component(controls).$n configure -state disabled 335 348 } … … 339 352 break 340 353 } 354 } 355 if { [$itk_component(legend) index focus] != -1 } { 356 $itk_component(controls).rename configure -state normal 341 357 } 342 358 if { [$tree_ degree 0] > 1 && [llength $nodes] > 0 } { … … 542 558 } 543 559 } 560 561 itcl::body Rappture::XyLegend::Rename {} { 562 Editor popup 563 } 564 565 # ---------------------------------------------------------------------- 566 # USAGE: Editor popup 567 # USAGE: Editor activate 568 # USAGE: Editor validate <value> 569 # USAGE: Editor apply <value> 570 # USAGE: Editor menu <rootx> <rooty> 571 # 572 # Used internally to handle the various functions of the pop-up 573 # editor for the value of this gauge. 574 # ---------------------------------------------------------------------- 575 itcl::body Rappture::XyLegend::Editor {option args} { 576 switch -- $option { 577 popup { 578 $itk_component(editor) activate 579 } 580 activate { 581 set focus_ [$itk_component(legend) index focus] 582 if { $focus_ == -1 } { 583 return; 584 } 585 set label [$itk_component(legend) entry cget $focus_ -label] 586 foreach { l r t b } [$itk_component(legend) bbox $focus_] break 587 set info(text) $label 588 set info(x) [expr $l + [winfo rootx $itk_component(legend)]] 589 set info(y) [expr $r + [winfo rooty $itk_component(legend)]] 590 set info(w) [expr $r - $l] 591 set info(h) [expr $b - $t] 592 return [array get info] 593 } 594 validate { 595 if {[llength $args] != 1} { 596 error "wrong # args: should be \"editor validate value\"" 597 } 598 } 599 apply { 600 if {[llength $args] != 1} { 601 error "wrong # args: should be \"editor apply value\"" 602 } 603 set label [lindex $args 0] 604 $itk_component(legend) entry configure $focus_ -label $label 605 } 606 menu { 607 eval tk_popup $itk_component(emenu) $args 608 } 609 default { 610 error "bad option \"$option\": should be popup, activate, validate, apply, and menu" 611 } 612 } 613 }
Note: See TracChangeset
for help on using the changeset viewer.