# TH bindings (created by makebeth) for Scrollbar widgets

bind Scrollbar <Button-3> {th_toggle_menus %W}
bind Scrollbar <Control-p> {tkScrollByUnits %W hv -1}
bind Scrollbar <Control-n> {tkScrollByUnits %W hv  1}
bind Scrollbar <Meta-quoteleft> {tkScrollByPages %W hv -1}
bind Scrollbar <Control-quoteleft> {tkScrollByPages %W hv  1}
bind Scrollbar <Control-a> {tkScrollToPos %W 0}
bind Scrollbar <Control-e> {tkScrollToPos %W 1}
bind Scrollbar <Control-space> {set TH(Mark,%W) [lindex [%W get] 0]}
bind Scrollbar <Control-x> {th_[winfo class %W]_exchange_mark %W}
bind Scrollbar <Meta-g> {th_goto %W}
bind Scrollbar <Control-g> {th_cancel_all %W}



proc th_Scrollbar_menus {w} {
  th_Misc_menus $w
set code {

menubutton %W_mb.mb_browse -m %W_mb.mb_browse.m -text Browse -u 0
pack %W_mb.mb_browse -in %W_mb -side left
menu %W_mb.mb_browse.m
%W_mb.mb_browse.m add cascade -l Goto -u 0 -m %W_mb.mb_browse.m.goto
menu %W_mb.mb_browse.m.goto
%W_mb.mb_browse.m.goto add cascade -l Character -u 0 -m %W_mb.mb_browse.m.goto.character
menu %W_mb.mb_browse.m.goto.character
%W_mb.mb_browse.m.goto.character add command -l {Previous} -u 0 -acc {<Control-p>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  tkScrollByUnits %W hv -1}}
%W_mb.mb_browse.m.goto.character add command -l {Next} -u 0 -acc {<Control-n>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  tkScrollByUnits %W hv  1}}
%W_mb.mb_browse.m add cascade -l Scroll -u 0 -m %W_mb.mb_browse.m.scroll
menu %W_mb.mb_browse.m.scroll
%W_mb.mb_browse.m.scroll add cascade -l Page -u 0 -m %W_mb.mb_browse.m.scroll.page
menu %W_mb.mb_browse.m.scroll.page
%W_mb.mb_browse.m.scroll.page add command -l {Up} -u 0 -acc {<Meta-quoteleft>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  tkScrollByPages %W hv -1}}
%W_mb.mb_browse.m.scroll.page add command -l {Down} -u 0 -acc {<Control-quoteleft>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  tkScrollByPages %W hv  1}}
%W_mb.mb_browse.m.goto add cascade -l Edge -u 0 -m %W_mb.mb_browse.m.goto.edge
menu %W_mb.mb_browse.m.goto.edge
%W_mb.mb_browse.m.goto.edge add command -l {Left} -u 0 -acc {<Control-a>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  tkScrollToPos %W 0}}
%W_mb.mb_browse.m.goto.edge add command -l {Right} -u 0 -acc {<Control-e>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  tkScrollToPos %W 1}}
%W_mb.mb_browse.m add command -l {Anchor} -u 0 -acc {<Control-space>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  set TH(Mark,%W) [lindex [%W get] 0]}}
%W_mb.mb_browse.m.goto add command -l {Anchor} -u 0 -acc {<Control-x>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_[winfo class %W]_exchange_mark %W}}
%W_mb.mb_browse.m.goto add command -l {Specify an Index} -u 11 -acc {<Meta-g>} -co {if {![winfo exists %W]} {destroy %W_mb} else {
  th_goto %W}}


}

global TH
regsub -all "%W_mb" $code $TH(Menubar,$w) new_code
regsub -all %W $new_code $w code
eval $code
}


