Changeset 1614 for trunk/gui/scripts
- Timestamp:
- Nov 16, 2009, 3:02:37 PM (15 years ago)
- Location:
- trunk/gui/scripts
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/tooltip.tcl
r1418 r1614 53 53 54 54 bind RapptureTooltip <Enter> \ 55 55 [list ::Rappture::Tooltip::tooltip pending %W] 56 56 bind RapptureTooltip <Leave> \ 57 57 [list ::Rappture::Tooltip::tooltip cancel] 58 58 bind RapptureTooltip <ButtonPress> \ 59 59 [list ::Rappture::Tooltip::tooltip cancel] 60 60 bind RapptureTooltip <KeyPress> \ 61 61 [list ::Rappture::Tooltip::tooltip cancel] 62 62 } 63 63 … … 77 77 78 78 itk_component add icon { 79 79 label $itk_interior.icon -anchor n 80 80 } 81 81 82 82 itk_component add text { 83 83 label $itk_interior.text -justify left 84 84 } { 85 86 85 usual 86 keep -wraplength 87 87 } 88 88 pack $itk_component(text) -expand yes -fill both -ipadx 4 -ipady 4 … … 109 109 110 110 if {[regexp {^@([0-9]+),([0-9]+)$} $where match x y]} { 111 112 111 set xpos $x 112 set ypos $y 113 113 } elseif {[regexp {^(.*)([-+])([0-9]+),([-+]?)([0-9]+)$} $where match win signx x signy y]} { 114 115 116 114 if {$signy == ""} { set signy $signx } 115 set xpos [expr {[winfo rootx $win] + $x}] 116 set ypos [expr {[winfo rooty $win] + $y}] 117 117 } elseif {[winfo exists $where]} { 118 119 120 } else { 121 118 set xpos [expr {[winfo rootx $where]+10}] 119 set ypos [expr {[winfo rooty $where]+[winfo height $where]}] 120 } else { 121 error "bad position \"$where\": should be widget+x,y, or @x,y" 122 122 } 123 123 124 124 if {[string index $itk_option(-message) 0] == "@"} { 125 126 127 128 129 130 } else { 131 125 set cmd [string range $itk_option(-message) 1 end] 126 if {[catch $cmd mesg] != 0} { 127 bgerror $mesg 128 return 129 } 130 } else { 131 set mesg $itk_option(-message) 132 132 } 133 133 134 134 # if there's no message to show, forget it 135 135 if {[string length $mesg] == 0} { 136 136 return 137 137 } 138 138 … … 140 140 set pos 0 141 141 ::for {set i 0} {$pos >= 0 && $i < 20} {incr i} { 142 143 142 incr pos 143 set pos [string first \n $mesg $pos] 144 144 } 145 145 if {$pos > 0} { 146 146 set mesg "[string range $mesg 0 $pos]..." 147 147 } 148 148 if {[string length $mesg] > 1000} { 149 149 set mesg "[string range $mesg 0 1500]..." 150 150 } 151 151 $itk_component(text) configure -text $mesg … … 156 156 update idletasks 157 157 if {$signx == "+"} { 158 159 160 161 162 } else { 163 164 165 166 158 if {$xpos+[winfo reqwidth $hull] > [winfo screenwidth $hull]} { 159 set xpos [expr {[winfo screenwidth $hull]-[winfo reqwidth $hull]}] 160 } 161 if {$xpos < 0} { set xpos 0 } 162 } else { 163 if {$xpos-[winfo reqwidth $hull] < 0} { 164 set xpos [expr {[winfo screenwidth $hull]-[winfo reqwidth $hull]}] 165 } 166 set xpos [expr {[winfo screenwidth $hull]-$xpos}] 167 167 } 168 168 169 169 if {$signy == "+"} { 170 171 172 173 174 } else { 175 176 177 178 170 if {$ypos+[winfo reqheight $hull] > [winfo screenheight $hull]} { 171 set ypos [expr {[winfo screenheight $hull]-[winfo reqheight $hull]}] 172 } 173 if {$ypos < 0} { set ypos 0 } 174 } else { 175 if {$ypos-[winfo reqheight $hull] < 0} { 176 set ypos [expr {[winfo screenheight $hull]-[winfo reqheight $hull]}] 177 } 178 set ypos [expr {[winfo screenheight $hull]-$ypos}] 179 179 } 180 180 … … 187 187 set py [winfo pointery $hull] 188 188 if {$px >= $xpos && $px <= $xpos+[winfo reqwidth $hull] 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 189 && $py >= $ypos && $py <= $ypos+[winfo reqheight $hull]} { 190 191 if {$px > [winfo screenwidth $hull]/2} { 192 set signx "-" 193 set xpos [expr {[winfo screenwidth $hull]-$px+4}] 194 } else { 195 set signx "+" 196 set xpos [expr {$px+4}] 197 } 198 if {$py > [winfo screenheight $hull]/2} { 199 set signy "-" 200 set ypos [expr {[winfo screenheight $hull]-$py+4}] 201 } else { 202 set signy "+" 203 set ypos [expr {$py+4}] 204 } 205 205 } 206 206 … … 242 242 set i [lsearch $btags RapptureTooltip] 243 243 if {$i < 0} { 244 245 246 247 244 set i [lsearch $btags [winfo class $widget]] 245 if {$i < 0} {set i 0} 246 set btags [linsert $btags $i RapptureTooltip] 247 bindtags $widget $btags 248 248 } 249 249 } … … 258 258 itcl::body Rappture::Tooltip::text {widget args} { 259 259 if {[llength $args] == 0} { 260 261 262 263 260 if {[info exists catalog($widget)]} { 261 return $catalog($widget) 262 } 263 return "" 264 264 } elseif {[llength $args] == 1} { 265 266 267 } else { 268 265 set str [lindex $args 0] 266 set catalog($widget) $str 267 } else { 268 error "wrong # args: should be \"text widget ?str?\"" 269 269 } 270 270 } … … 283 283 itcl::body Rappture::Tooltip::tooltip {option args} { 284 284 switch -- $option { 285 286 287 288 289 290 291 292 293 return;# No tooltip for widget.294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 285 pending { 286 if {[llength $args] < 1 || [llength $args] > 2} { 287 error "wrong # args: should be \"tooltip pending widget ?@x,y?\"" 288 } 289 set widget [lindex $args 0] 290 set loc [lindex $args 1] 291 292 if {![info exists catalog($widget)]} { 293 return; # No tooltip for widget. 294 } 295 if {$pending != ""} { 296 after cancel $pending 297 } 298 set pending [after 750 [itcl::code tooltip show $widget $loc]] 299 } 300 show { 301 if {[llength $args] < 1 || [llength $args] > 2} { 302 error "wrong # args: should be \"tooltip show tag loc\"" 303 } 304 set tag [lindex $args 0] 305 set loc [lindex $args 1] 306 307 # tag name may be .g-axis -- get widget ".g" part 308 set widget $tag 309 if {[regexp {^(\.[^-]+)-[^\.]+$} $widget match wname]} { 310 set widget $wname 311 } 312 313 if {[winfo exists $widget] && [info exists catalog($tag)]} { 314 .rappturetooltip configure -message $catalog($tag) 315 if {[string index $loc 0] == "@"} { 316 .rappturetooltip show $loc 317 } elseif {[regexp {^[-+]} $loc]} { 318 .rappturetooltip show $widget$loc 319 } else { 320 .rappturetooltip show $widget 321 } 322 } 323 } 324 cancel { 325 if {$pending != ""} { 326 after cancel $pending 327 set pending "" 328 } 329 .rappturetooltip hide 330 } 331 default { 332 error "bad option \"$option\": should be show, pending, cancel" 333 } 334 334 } 335 335 } … … 345 345 itcl::body Rappture::Tooltip::cue {option args} { 346 346 if {"hide" == $option} { 347 348 347 grab release .rappturetoolcue 348 .rappturetoolcue hide 349 349 } elseif {[regexp {^@[0-9]+,[0-9]+$} $option] || [winfo exists $option]} { 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 } else { 381 350 if {[llength $args] != 1} { 351 error "wrong # args: should be \"cue location message\"" 352 } 353 set loc $option 354 set mesg [lindex $args 0] 355 356 .rappturetoolcue configure -message $mesg 357 .rappturetoolcue show $loc 358 359 # 360 # Add a binding to all widgets so that any keypress will 361 # take this cue down. 362 # 363 set cmd [bind all <KeyPress>] 364 if {![regexp {Rappture::Tooltip::cue} $cmd]} { 365 bind all <KeyPress> "+[list ::Rappture::Tooltip::cue hide]" 366 bind all <KeyPress-Return> "+ " 367 } 368 369 # 370 # If nobody has the pointer, then grab it. Otherwise, 371 # we assume the pop-up editor or someone like that has 372 # the grab, so we don't need to impose a grab here. 373 # 374 if {"" == [grab current]} { 375 update 376 while {[catch {grab set -global .rappturetoolcue}]} { 377 after 100 378 } 379 } 380 } else { 381 error "bad option \"$option\": should be hide, a widget name, or @x,y" 382 382 } 383 383 } … … 388 388 itcl::configbody Rappture::Tooltip::icon { 389 389 if {"" == $itk_option(-icon)} { 390 391 392 } else { 393 394 395 390 $itk_component(icon) configure -image "" 391 pack forget $itk_component(icon) 392 } else { 393 $itk_component(icon) configure -image $itk_option(-icon) 394 pack $itk_component(icon) -before $itk_component(text) \ 395 -side left -fill y 396 396 } 397 397 } -
trunk/gui/scripts/xyresult.tcl
r1606 r1614 488 488 # if we haven't created the popup yet, do it now 489 489 Rappture::Balloon $popup \ 490 490 -title "[Rappture::filexfer::label downloadWord] as..." 491 491 set inner [$popup component inner] 492 492 label $inner.summary -text "" -anchor w … … 559 559 } 560 560 image { 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 561 set popup .xyprintdownload 562 if { ![winfo exists $popup] } { 563 # Create a popup for the print dialog 564 Rappture::Balloon $popup -title "Save as image..." 565 set inner [$popup component inner] 566 # Create the print dialog widget and add it to the 567 # the balloon popup. 568 Rappture::XyPrint $inner.print 569 $popup configure \ 570 -deactivatecommand [list $inner.print reset] 571 blt::table $inner 0,0 $inner.print -fill both 572 } 573 update 574 # Activate the popup and call for the output. 575 foreach { widget toolName plotName } $args break 576 $popup activate $widget left 577 set inner [$popup component inner] 578 set output [$inner.print print $itk_component(plot) \ 579 $toolName $plotName] 580 $popup deactivate 581 581 return $output 582 582 } … … 721 721 set elem "elem[incr count]" 722 722 set _elem2curve($elem) $curve 723 723 lappend label2elem($label) $elem 724 724 $g element create $elem -x $xv -y $yv \ 725 725 -symbol $sym -pixels $pixels -linewidth $lwidth \ 726 726 -label $label \ 727 727 -color $color -dashes $dashes \ 728 728 -mapx $mapx -mapy $mapy … … 732 732 # Fix duplicate labels by appending the simulation number 733 733 foreach label [array names label2elem] { 734 735 736 737 738 739 740 741 742 743 744 } 734 if { [llength $label2elem($label)] == 1 } { 735 continue 736 } 737 foreach elem $label2elem($label) { 738 set curve $_elem2curve($elem) 739 scan [$curve hints xmlobj] "::libraryObj%d" suffix 740 incr suffix 741 set elabel [format "%s \#%d" $label $suffix] 742 $g element configure $elem -label $elabel 743 } 744 } 745 745 746 746 foreach curve $_clist { … … 827 827 set logmin [expr {floor(log10(abs($min)))}] 828 828 set logmax [expr {ceil(log10(abs($max)))}] 829 829 if 0 { 830 830 if {[string match y* $axis]} { 831 831 # add a little padding … … 835 835 set logmax [expr {$logmax+0.05*$delta}] 836 836 } 837 837 } 838 838 } 839 839 if {$logmin < -300} { … … 856 856 set max $_limits(${axis}lin-max) 857 857 858 858 if 0 { 859 859 if {[string match y* $axis]} { 860 860 # add a little padding … … 863 863 set max [expr {$max+0.05*$delta}] 864 864 } 865 865 } 866 866 } 867 867 if {$min < $max} {
Note: See TracChangeset
for help on using the changeset viewer.