| | |
| | |
| | |
| |
|
| | namespace eval ttk::notebook { |
| | variable TLNotebooks |
| | } |
| |
|
| | bind TNotebook <Button-1> { ttk::notebook::Press %W %x %y } |
| | bind TNotebook <Right> { ttk::notebook::CycleTab %W 1; break } |
| | bind TNotebook <Left> { ttk::notebook::CycleTab %W -1; break } |
| | bind TNotebook <Control-Tab> { ttk::notebook::CycleTab %W 1; break } |
| | bind TNotebook <Control-Shift-Tab> { ttk::notebook::CycleTab %W -1; break } |
| | catch { |
| | bind TNotebook <Control-ISO_Left_Tab> { ttk::notebook::CycleTab %W -1; break } |
| | } |
| | bind TNotebook <Destroy> { ttk::notebook::Cleanup %W } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | proc ttk::notebook::ActivateTab {w tab} { |
| | set oldtab [$w select] |
| | $w select $tab |
| | set newtab [$w select] |
| |
|
| | if {[focus] eq $w} { return } |
| | if {$newtab eq $oldtab} { focus $w ; return } |
| |
|
| | update idletasks |
| | if {[set f [ttk::focusFirst $newtab]] ne ""} { |
| | ttk::traverseTo $f |
| | } else { |
| | focus $w |
| | } |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | proc ttk::notebook::Press {w x y} { |
| | set index [$w index @$x,$y] |
| | if {$index ne ""} { |
| | ActivateTab $w $index |
| | } |
| | } |
| |
|
| | |
| | |
| | |
| | proc ttk::notebook::CycleTab {w dir} { |
| | set current [$w index current] |
| | if {$current >= 0} { |
| | set tabCount [$w index end] |
| | set select [expr {($current + $dir) % $tabCount}] |
| | set step [expr {$dir > 0 ? 1 : -1}] |
| | while {[$w tab $select -state] ne "normal" && ($select != $current)} { |
| | set select [expr {($select + $step) % $tabCount}] |
| | } |
| | if {$select != $current} { |
| | ActivateTab $w $select |
| | } |
| | } |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | proc ttk::notebook::MnemonicTab {nb key} { |
| | set key [string toupper $key] |
| | foreach tab [$nb tabs] { |
| | set label [$nb tab $tab -text] |
| | set underline [$nb tab $tab -underline] |
| | if {$underline >= 0} { |
| | set mnemonic [string toupper [string index $label $underline]] |
| | if {$mnemonic ne "" && $mnemonic eq $key} { |
| | return $tab |
| | } |
| | } |
| | } |
| | return "" |
| | } |
| |
|
| | |
| | |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | proc ttk::notebook::enableTraversal {nb} { |
| | variable TLNotebooks |
| |
|
| | set top [winfo toplevel $nb] |
| |
|
| | if {![info exists TLNotebooks($top)]} { |
| | |
| | |
| | bind $top <Control-Next> {+ttk::notebook::TLCycleTab %W 1} |
| | bind $top <Control-Prior> {+ttk::notebook::TLCycleTab %W -1} |
| | bind $top <Control-Tab> {+ttk::notebook::TLCycleTab %W 1} |
| | bind $top <Control-Shift-Tab> {+ttk::notebook::TLCycleTab %W -1} |
| | catch { |
| | bind $top <Control-ISO_Left_Tab> {+ttk::notebook::TLCycleTab %W -1} |
| | } |
| | if {[tk windowingsystem] eq "aqua"} { |
| | bind $top <Option-Key> \ |
| | +[list ttk::notebook::MnemonicActivation $top %K] |
| | } else { |
| | bind $top <Alt-Key> \ |
| | +[list ttk::notebook::MnemonicActivation $top %K] |
| | } |
| | bind $top <Destroy> {+ttk::notebook::TLCleanup %W} |
| | } |
| |
|
| | lappend TLNotebooks($top) $nb |
| | } |
| |
|
| | |
| | |
| | proc ttk::notebook::TLCleanup {w} { |
| | variable TLNotebooks |
| | if {$w eq [winfo toplevel $w]} { |
| | unset -nocomplain -please TLNotebooks($w) |
| | } |
| | } |
| |
|
| | |
| | |
| | proc ttk::notebook::Cleanup {nb} { |
| | variable TLNotebooks |
| | set top [winfo toplevel $nb] |
| | if {[info exists TLNotebooks($top)]} { |
| | set index [lsearch -exact $TLNotebooks($top) $nb] |
| | set TLNotebooks($top) [lreplace $TLNotebooks($top) $index $index] |
| | } |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | proc ttk::notebook::EnclosingNotebook {w} { |
| | variable TLNotebooks |
| |
|
| | set top [winfo toplevel $w] |
| | if {![info exists TLNotebooks($top)]} { return } |
| |
|
| | while {$w ne $top && $w ne ""} { |
| | if {[lsearch -exact $TLNotebooks($top) $w] >= 0} { |
| | return $w |
| | } |
| | set w [winfo parent $w] |
| | } |
| | return "" |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | proc ttk::notebook::TLCycleTab {w dir} { |
| | set nb [EnclosingNotebook $w] |
| | if {$nb ne ""} { |
| | CycleTab $nb $dir |
| | return -code break |
| | } |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | proc ttk::notebook::MnemonicActivation {top key} { |
| | variable TLNotebooks |
| | foreach nb $TLNotebooks($top) { |
| | if {[set tab [MnemonicTab $nb $key]] ne ""} { |
| | ActivateTab $nb [$nb index $tab] |
| | return -code break |
| | } |
| | } |
| | } |
| |
|