summaryrefslogtreecommitdiffstats
path: root/library/panedwindow.tcl
blob: 58218c14d0dff2dca8d78d03bede29fa5ec82b6c (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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# panedwindow.tcl --
#
# This file defines the default bindings for Tk panedwindow widgets and
# provides procedures that help in implementing those bindings.
#
# RCS: @(#) $Id: panedwindow.tcl,v 1.2 2002/02/22 14:07:01 dkf Exp $
#

bind PanedWindow <Button-1> { ::tk::panedwindow::MarkSash %W %x %y 1 }
bind PanedWindow <Button-2> { ::tk::panedwindow::MarkSash %W %x %y 0 }

bind PanedWindow <B1-Motion> { ::tk::panedwindow::DragSash %W %x %y 1 }
bind PanedWindow <B2-Motion> { ::tk::panedwindow::DragSash %W %x %y 0 }

bind PanedWindow <ButtonRelease-1> {::tk::panedwindow::ReleaseSash %W %x %y 1}
bind PanedWindow <ButtonRelease-2> {::tk::panedwindow::ReleaseSash %W %x %y 0}

bind PanedWindow <Motion> { ::tk::panedwindow::Motion %W %x %y }

bind PanedWindow <Leave> { ::tk::panedwindow::Leave %W }

# Initialize namespace
namespace eval ::tk::panedwindow {}

# ::tk::panedwindow::MarkSash --
#
#   ADD COMMENTS HERE
#
# Arguments:
#   args	comments
# Results:
#   Returns ...
#
proc ::tk::panedwindow::MarkSash {w x y proxy} {
    set what [$w identify $x $y]
    if { [llength $what] == 2 } {
	foreach {index which} $what break
	if { !$::tk_strictMotif || [string equal $which "handle"] } {
	    if {!$proxy} { $w sash mark $index $x $y }
	    set ::tk::Priv(sash) $index
	}
    }
}

# ::tk::panedwindow::DragSash --
#
#   ADD COMMENTS HERE
#
# Arguments:
#   args	comments
# Results:
#   Returns ...
#
proc ::tk::panedwindow::DragSash {w x y proxy} {
    if { [info exists ::tk::Priv(sash)] } {
	if {$proxy} {
	    $w proxy place $x $y
	} else {
	    $w sash dragto $::tk::Priv(sash) $x $y
	    $w sash mark $::tk::Priv(sash) $x $y
	}
    }
}

# ::tk::panedwindow::ReleaseSash --
#
#   ADD COMMENTS HERE
#
# Arguments:
#   args	comments
# Results:
#   Returns ...
#
proc ::tk::panedwindow::ReleaseSash {w x y proxy} {
    if { [info exists ::tk::Priv(sash)] } {
	if {$proxy} {
	    foreach {x y} [$w proxy coord] break
	    $w sash place $::tk::Priv(sash) $x $y
	    unset ::tk::Priv(sash)
	    $w proxy forget
	} else {
	    unset ::tk::Priv(sash)
	}
    }
}

# ::tk::panedwindow::Motion --
#
#   ADD COMMENTS HERE
#
# Arguments:
#   args	comments
# Results:
#   Returns ...
#
proc ::tk::panedwindow::Motion {w x y} {
    variable ::tk::Priv
    set id [$w identify $x $y]
    if { [llength $id] == 2 } {
	if { !$::tk_strictMotif || [string equal [lindex $id 1] "handle"] } {
	    if { ![info exists Priv(panecursor)] } {
		set Priv(panecursor) [$w cget -cursor]
	    }
	    if { [string equal [$w cget -sashcursor] ""] } {
		if { [string equal [$w cget -orient] "horizontal"] } {
		    $w configure -cursor sb_h_double_arrow
		} else {
		    $w configure -cursor sb_v_double_arrow
		}
	    } else {
		$w configure -cursor [$w cget -sashcursor]
	    }
	    return
	}
    }
    if { [info exists Priv(panecursor)] } {
	$w configure -cursor $Priv(panecursor)
	unset Priv(panecursor)
    }
}

# ::tk::panedwindow::Leave --
#
#   ADD COMMENTS HERE
#
# Arguments:
#   args	comments
# Results:
#   Returns ...
#
proc ::tk::panedwindow::Leave {w} {
    if { [info exists ::tk::Priv(panecursor)] } {
        $w configure -cursor $::tk::Priv(panecursor)
        unset ::tk::Priv(panecursor)
    }
}