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