Mark msysGit as obsolete
[msysgit.git] / mingw / lib / tk8.5 / ttk / scale.tcl
blob23d08ed94fc82650679ca604283d821ae75d75fb
1 # scale.tcl - Copyright (C) 2004 Pat Thoyts <patthoyts@users.sourceforge.net>
3 # Bindings for the TScale widget
5 namespace eval ttk::scale {
6 variable State
7 array set State {
8 dragging 0
12 bind TScale <ButtonPress-1> { ttk::scale::Press %W %x %y }
13 bind TScale <B1-Motion> { ttk::scale::Drag %W %x %y }
14 bind TScale <ButtonRelease-1> { ttk::scale::Release %W %x %y }
16 bind TScale <ButtonPress-2> { ttk::scale::Jump %W %x %y }
17 bind TScale <B2-Motion> { ttk::scale::Drag %W %x %y }
18 bind TScale <ButtonRelease-2> { ttk::scale::Release %W %x %y }
20 bind TScale <ButtonPress-3> { ttk::scale::Jump %W %x %y }
21 bind TScale <B3-Motion> { ttk::scale::Drag %W %x %y }
22 bind TScale <ButtonRelease-3> { ttk::scale::Release %W %x %y }
24 bind TScale <Left> { ttk::scale::Increment %W -1 }
25 bind TScale <Up> { ttk::scale::Increment %W -1 }
26 bind TScale <Right> { ttk::scale::Increment %W 1 }
27 bind TScale <Down> { ttk::scale::Increment %W 1 }
28 bind TScale <Control-Left> { ttk::scale::Increment %W -10 }
29 bind TScale <Control-Up> { ttk::scale::Increment %W -10 }
30 bind TScale <Control-Right> { ttk::scale::Increment %W 10 }
31 bind TScale <Control-Down> { ttk::scale::Increment %W 10 }
32 bind TScale <Home> { %W set [%W cget -from] }
33 bind TScale <End> { %W set [%W cget -to] }
35 proc ttk::scale::Press {w x y} {
36 variable State
37 set State(dragging) 0
39 switch -glob -- [$w identify $x $y] {
40 *track -
41 *trough {
42 set inc [expr {([$w get $x $y] <= [$w get]) ? -1 : 1}]
43 ttk::Repeatedly Increment $w $inc
45 *slider {
46 set State(dragging) 1
47 set State(initial) [$w get]
52 # scale::Jump -- ButtonPress-2/3 binding for scale acts like
53 # Press except that clicking in the trough jumps to the
54 # clicked position.
55 proc ttk::scale::Jump {w x y} {
56 variable State
57 set State(dragging) 0
59 switch -glob -- [$w identify $x $y] {
60 *track -
61 *trough {
62 $w set [$w get $x $y]
63 set State(dragging) 1
64 set State(initial) [$w get]
66 *slider {
67 Press $w $x $y
72 proc ttk::scale::Drag {w x y} {
73 variable State
74 if {$State(dragging)} {
75 $w set [$w get $x $y]
79 proc ttk::scale::Release {w x y} {
80 variable State
81 set State(dragging) 0
82 ttk::CancelRepeat
85 proc ttk::scale::Increment {w delta} {
86 if {![winfo exists $w]} return
87 $w set [expr {[$w get] + $delta}]