| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| proc ::tk::TearOffMenu {w {x 0} {y 0}} { |
| |
| |
| |
| |
| |
| |
| |
|
|
| if {$x == 0} { |
| set x [winfo rootx $w] |
| } |
| if {$y == 0} { |
| set y [winfo rooty $w] |
| if {[tk windowingsystem] eq "aqua"} { |
| |
| catch {incr y [expr {[$w yposition 1] - 16}]} |
| |
| if {$y < 22} {set y 22} |
| } |
| } |
|
|
| set parent [winfo parent $w] |
| while {[winfo toplevel $parent] ne $parent \ |
| || [winfo class $parent] eq "Menu"} { |
| set parent [winfo parent $parent] |
| } |
| if {$parent eq "."} { |
| set parent "" |
| } |
| for {set i 1} 1 {incr i} { |
| set menu $parent.tearoff$i |
| if {![winfo exists $menu]} { |
| break |
| } |
| } |
|
|
| $w clone $menu tearoff |
|
|
| |
| |
| |
|
|
| set parent [winfo parent $w] |
| if {[$menu cget -title] ne ""} { |
| wm title $menu [$menu cget -title] |
| } else { |
| switch -- [winfo class $parent] { |
| Menubutton { |
| wm title $menu [$parent cget -text] |
| } |
| Menu { |
| wm title $menu [$parent entrycget active -label] |
| } |
| } |
| } |
|
|
| if {[tk windowingsystem] eq "win32"} { |
| |
| set parent [winfo toplevel $parent] |
| while {[winfo class $parent] eq "Menu"} { |
| set parent [winfo toplevel [winfo parent $parent]] |
| } |
| wm transient $menu [winfo toplevel $parent] |
| wm attributes $menu -toolwindow 1 |
| } |
|
|
| $menu post $x $y |
|
|
| if {[winfo exists $menu] == 0} { |
| return "" |
| } |
|
|
| |
| |
| |
|
|
| bind $menu <Enter> { |
| set tk::Priv(focus) %W |
| } |
|
|
| |
| |
|
|
| set cmd [$w cget -tearoffcommand] |
| if {$cmd ne ""} { |
| uplevel #0 $cmd [list $w $menu] |
| } |
| return $menu |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| proc ::tk::MenuDup {src dst type} { |
| set cmd [list menu $dst -type $type] |
| foreach option [$src configure] { |
| if {[llength $option] == 2} { |
| continue |
| } |
| if {[lindex $option 0] eq "-type"} { |
| continue |
| } |
| lappend cmd [lindex $option 0] [lindex $option 4] |
| } |
| eval $cmd |
| set last [$src index last] |
| if {$last eq "none" || $last < 0} { |
| return |
| } |
| for {set i [$src cget -tearoff]} {$i <= $last} {incr i} { |
| set cmd [list $dst add [$src type $i]] |
| foreach option [$src entryconfigure $i] { |
| lappend cmd [lindex $option 0] [lindex $option 4] |
| } |
| eval $cmd |
| } |
|
|
| |
|
|
| set tags [bindtags $src] |
| set srcLen [string length $src] |
|
|
| |
|
|
| while {[set index [string first $src $tags]] >= 0} { |
| if {$index > 0} { |
| append x [string range $tags 0 $index-1]$dst |
| } |
| set tags [string range $tags $index+$srcLen end] |
| } |
| append x $tags |
|
|
| bindtags $dst $x |
|
|
| foreach event [bind $src] { |
| unset x |
| set script [bind $src $event] |
| set eventLen [string length $event] |
|
|
| |
|
|
| while {[set index [string first $event $script]] >= 0} { |
| if {$index > 0} { |
| append x [string range $script 0 $index-1] |
| } |
| append x $dst |
| set script [string range $script $index+$eventLen end] |
| } |
| append x $script |
|
|
| bind $dst $event $x |
| } |
| } |
|
|