1# 2# Bindings for ttk::panedwindow widget. 3# 4 5namespace eval ttk::panedwindow { 6 variable State 7 array set State { 8 pressed 0 9 pressX - 10 pressY - 11 sash - 12 sashPos - 13 } 14} 15 16## Bindings: 17# 18bind TPanedwindow <ButtonPress-1> { ttk::panedwindow::Press %W %x %y } 19bind TPanedwindow <B1-Motion> { ttk::panedwindow::Drag %W %x %y } 20bind TPanedwindow <ButtonRelease-1> { ttk::panedwindow::Release %W %x %y } 21 22bind TPanedwindow <Motion> { ttk::panedwindow::SetCursor %W %x %y } 23bind TPanedwindow <Enter> { ttk::panedwindow::SetCursor %W %x %y } 24bind TPanedwindow <Leave> { ttk::panedwindow::ResetCursor %W } 25# See <<NOTE-PW-LEAVE-NOTIFYINFERIOR>> 26bind TPanedwindow <<EnteredChild>> { ttk::panedwindow::ResetCursor %W } 27 28## Sash movement: 29# 30proc ttk::panedwindow::Press {w x y} { 31 variable State 32 33 set sash [$w identify $x $y] 34 if {$sash eq ""} { 35 set State(pressed) 0 36 return 37 } 38 set State(pressed) 1 39 set State(pressX) $x 40 set State(pressY) $y 41 set State(sash) $sash 42 set State(sashPos) [$w sashpos $sash] 43} 44 45proc ttk::panedwindow::Drag {w x y} { 46 variable State 47 if {!$State(pressed)} { return } 48 switch -- [$w cget -orient] { 49 horizontal { set delta [expr {$x - $State(pressX)}] } 50 vertical { set delta [expr {$y - $State(pressY)}] } 51 } 52 $w sashpos $State(sash) [expr {$State(sashPos) + $delta}] 53} 54 55proc ttk::panedwindow::Release {w x y} { 56 variable State 57 set State(pressed) 0 58 SetCursor $w $x $y 59} 60 61## Cursor management: 62# 63proc ttk::panedwindow::ResetCursor {w} { 64 variable State 65 if {!$State(pressed)} { 66 ttk::setCursor $w {} 67 } 68} 69 70proc ttk::panedwindow::SetCursor {w x y} { 71 set cursor "" 72 if {[llength [$w identify $x $y]]} { 73 # Assume we're over a sash. 74 switch -- [$w cget -orient] { 75 horizontal { set cursor hresize } 76 vertical { set cursor vresize } 77 } 78 } 79 ttk::setCursor $w $cursor 80} 81 82#*EOF* 83