Changeset 43 for trunk/gui/scripts/tooltip.tcl
- Timestamp:
- Aug 16, 2005, 1:12:56 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/tooltip.tcl
r26 r43 93 93 94 94 # ---------------------------------------------------------------------- 95 # USAGE: show @<x>,<y>|<widget>+ <x>,<y>95 # USAGE: show @<x>,<y>|<widget>+/-<x>,<y> 96 96 # 97 97 # Clients use this to pop up the tooltip on the screen. The position 98 # should be either a <widget> name with an optional offset + <x>,<y>98 # should be either a <widget> name with an optional offset +/-<x>,<y> 99 99 # (tooltip pops up beneath widget by default), or a specific root 100 100 # window coordinate of the form @x,y. … … 106 106 itcl::body Rappture::Tooltip::show {where} { 107 107 set hull $itk_component(hull) 108 set signx "+" 109 set signy "+" 108 110 109 111 if {[regexp {^@([0-9]+),([0-9]+)$} $where match x y]} { 110 112 set xpos $x 111 113 set ypos $y 112 } elseif {[regexp {^(.*)\+([0-9]+),([0-9]+)$} $where match win x y]} { 113 set xpos [expr {[winfo rootx $win]+$x}] 114 set ypos [expr {[winfo rooty $win]+$y}] 114 } elseif {[regexp {^(.*)([-+])([0-9]+),([-+]?)([0-9]+)$} $where match win signx x signy y]} { 115 if {$signy == ""} { set signy $signx } 116 set xpos [expr {[winfo rootx $win] + $x}] 117 set ypos [expr {[winfo rooty $win] + $y}] 115 118 } elseif {[winfo exists $where]} { 116 119 set xpos [expr {[winfo rootx $where]+10}] 117 120 set ypos [expr {[winfo rooty $where]+[winfo height $where]}] 118 121 } else { 119 error "bad position \"$where\": should be widget name,+x,y, or @x,y"122 error "bad position \"$where\": should be widget+x,y, or @x,y" 120 123 } 121 124 … … 152 155 # Make sure the tooltip doesn't go off screen. Then, put it up. 153 156 # 154 update 155 if {$xpos+[winfo reqwidth $hull] > [winfo screenwidth $hull]} { 156 set xpos [expr {[winfo screenwidth $hull]-[winfo reqwidth $hull]}] 157 } 158 if {$xpos < 0} { set xpos 0 } 159 160 if {$ypos+[winfo reqheight $hull] > [winfo screenheight $hull]} { 161 set ypos [expr {[winfo screenheight $hull]-[winfo reqheight $hull]}] 162 } 163 if {$ypos < 0} { set ypos 0 } 164 165 wm geometry $hull +$xpos+$ypos 157 update idletasks 158 if {$signx == "+"} { 159 if {$xpos+[winfo reqwidth $hull] > [winfo screenwidth $hull]} { 160 set xpos [expr {[winfo screenwidth $hull]-[winfo reqwidth $hull]}] 161 } 162 if {$xpos < 0} { set xpos 0 } 163 } else { 164 if {$xpos-[winfo reqwidth $hull] < 0} { 165 set xpos [expr {[winfo screenwidth $hull]-[winfo reqwidth $hull]}] 166 } 167 set xpos [expr {[winfo screenwidth $hull]-$xpos}] 168 } 169 170 if {$signy == "+"} { 171 if {$ypos+[winfo reqheight $hull] > [winfo screenheight $hull]} { 172 set ypos [expr {[winfo screenheight $hull]-[winfo reqheight $hull]}] 173 } 174 if {$ypos < 0} { set ypos 0 } 175 } else { 176 if {$ypos-[winfo reqheight $hull] < 0} { 177 set ypos [expr {[winfo screenheight $hull]-[winfo reqheight $hull]}] 178 } 179 set ypos [expr {[winfo screenheight $hull]-$ypos}] 180 } 181 182 wm geometry $hull $signx$xpos$signy$ypos 166 183 update 167 184 … … 264 281 if {[string index $loc 0] == "@"} { 265 282 .rappturetooltip show $loc 266 } elseif {[ string index $loc 0] == "+"} {283 } elseif {[regexp {^[-+]} $loc]} { 267 284 .rappturetooltip show $widget$loc 268 285 } else {
Note: See TracChangeset
for help on using the changeset viewer.