summaryrefslogtreecommitdiffstats
path: root/library
diff options
context:
space:
mode:
Diffstat (limited to 'library')
-rw-r--r--library/ttk/altTheme.tcl3
-rw-r--r--library/ttk/classicTheme.tcl3
-rw-r--r--library/ttk/defaults.tcl2
-rw-r--r--library/ttk/range.tcl135
-rw-r--r--library/ttk/ttk.tcl1
-rw-r--r--library/ttk/vistaTheme.tcl32
-rw-r--r--library/ttk/winTheme.tcl2
7 files changed, 178 insertions, 0 deletions
diff --git a/library/ttk/altTheme.tcl b/library/ttk/altTheme.tcl
index d57227c..20bde48 100644
--- a/library/ttk/altTheme.tcl
+++ b/library/ttk/altTheme.tcl
@@ -95,6 +95,9 @@ namespace eval ttk::theme::alt {
ttk::style configure TScale \
-groovewidth 4 -troughrelief sunken \
-sliderwidth raised -borderwidth 2
+ ttk::style configure TRange \
+ -groovewidth 4 -troughrelief sunken \
+ -sliderwidth raised -borderwidth 2
ttk::style configure TProgressbar \
-background $colors(-selectbg) -borderwidth 0
}
diff --git a/library/ttk/classicTheme.tcl b/library/ttk/classicTheme.tcl
index 7e3eff5..5c1f91c 100644
--- a/library/ttk/classicTheme.tcl
+++ b/library/ttk/classicTheme.tcl
@@ -82,6 +82,9 @@ namespace eval ttk::theme::classic {
ttk::style configure TScale -sliderrelief raised
ttk::style map TScale -sliderrelief {{pressed !disabled} sunken}
+
+ ttk::style configure TRange -sliderrelief raised
+ ttk::style map TRange -sliderrelief {{pressed !disabled} sunken}
ttk::style configure TProgressbar -background SteelBlue
ttk::style configure TNotebook.Tab \
diff --git a/library/ttk/defaults.tcl b/library/ttk/defaults.tcl
index 05a46bd..42032b4 100644
--- a/library/ttk/defaults.tcl
+++ b/library/ttk/defaults.tcl
@@ -79,6 +79,8 @@ namespace eval ttk::theme::default {
ttk::style configure TScale \
-sliderrelief raised
+ ttk::style configure TRange \
+ -sliderrelief raised
ttk::style configure TProgressbar \
-background $colors(-selectbg)
diff --git a/library/ttk/range.tcl b/library/ttk/range.tcl
new file mode 100644
index 0000000..1608dfb
--- /dev/null
+++ b/library/ttk/range.tcl
@@ -0,0 +1,135 @@
+# range.tcl - Copyright (C) 2011 Goodwin Lawlor
+#
+# Bindings for the TRange widget
+
+namespace eval ttk::range {
+ variable State
+ array set State {
+ dragging 0
+ }
+}
+
+bind TRange <ButtonPress-1> { ttk::range::Press %W %x %y }
+bind TRange <B1-Motion> { ttk::range::Drag %W %x %y }
+bind TRange <ButtonRelease-1> { ttk::range::Release %W %x %y }
+
+bind TRange <ButtonPress-2> { ttk::range::Jump %W %x %y }
+bind TRange <B2-Motion> { ttk::range::Drag %W %x %y }
+bind TRange <ButtonRelease-2> { ttk::range::Release %W %x %y }
+
+bind TRange <ButtonPress-3> { ttk::range::Jump %W %x %y }
+bind TRange <B3-Motion> { ttk::range::Drag %W %x %y }
+bind TRange <ButtonRelease-3> { ttk::range::Release %W %x %y }
+
+bind TRange <Left> { ttk::range::Increment %W -1 }
+bind TRange <Up> { ttk::range::Increment %W -1 }
+bind TRange <Right> { ttk::range::Increment %W 1 }
+bind TRange <Down> { ttk::range::Increment %W 1 }
+bind TRange <Control-Left> { ttk::range::Increment %W -10 }
+bind TRange <Control-Up> { ttk::range::Increment %W -10 }
+bind TRange <Control-Right> { ttk::range::Increment %W 10 }
+bind TRange <Control-Down> { ttk::range::Increment %W 10 }
+bind TRange <Home> { %W set [%W cget -from] }
+bind TRange <End> { %W set [%W cget -to] }
+
+proc ttk::range::Press {w x y} {
+ variable State
+ set State(dragging) 0
+
+ switch -glob -- [$w identify $x $y] {
+ *track -
+ *trough {
+ set val [$w get $x $y]
+ set min [$w getmin]
+ set max [$w getmax]
+ if {$val < $min} {
+ #increment min
+ ttk::Repeatedly IncrementMin $w -0.1
+ } elseif {$val > $max} {
+ #increment max
+ ttk::Repeatedly IncrementMax $w +0.1
+ } else {
+ set State(dragging) 3
+ set State(initial) [$w get $x $y]
+ }
+ }
+ *minslider {
+ set State(dragging) 1
+ set State(initial) [$w getmin]
+ }
+ *maxslider {
+ # hack to prevent minslider hidding under the maxslider
+ # when both are at the "to" value
+ if {[$w getmin] == [$w cget -to]} {
+ set State(dragging) 1
+ } else {
+ set State(dragging) 2
+ }
+
+ set State(initial) [$w getmax]
+ }
+ }
+}
+
+# range::Jump -- ButtonPress-2/3 binding for range acts like
+# Press except that clicking in the trough jumps to the
+# clicked position.
+proc ttk::range::Jump {w x y} {
+ variable State
+ set State(dragging) 0
+
+ switch -glob -- [$w identify $x $y] {
+ *track -
+ *trough {
+ set val [$w get $x $y]
+ set min [$w getmin]
+ set max [$w getmax]
+ if {$val < $min} {
+ #jump min
+ $w setmin $val
+ set State(initial) [$w get $x $y]
+ } elseif {$val > $max} {
+ #jump max
+ $w setmax $val
+ set State(initial) [$w get $x $y]
+ } else {
+ set State(dragging) 3
+ set State(initial) [$w get $x $y]
+ }
+ }
+ *slider {
+ Press $w $x $y
+ }
+ }
+}
+
+proc ttk::range::Drag {w x y} {
+ variable State
+ if {$State(dragging) eq 1} {
+ $w setmin [$w get $x $y]
+ } elseif {$State(dragging) eq 2} {
+ $w setmax [$w get $x $y]
+ } else {
+ set v [$w get $x $y]
+ set dv [expr $v - $State(initial)]
+ $w setmin [expr [$w getmin] + $dv]
+ $w setmax [expr [$w getmax] + $dv]
+ set State(initial) $v
+ }
+}
+
+proc ttk::range::Release {w x y} {
+ variable State
+ set State(dragging) 0
+ ttk::CancelRepeat
+}
+
+proc ttk::range::IncrementMin {w delta} {
+ if {![winfo exists $w]} return
+ $w setmin [expr {[$w getmin] + $delta}]
+}
+
+proc ttk::range::IncrementMax {w delta} {
+ if {![winfo exists $w]} return
+ $w setmax [expr {[$w getmax] + $delta}]
+}
diff --git a/library/ttk/ttk.tcl b/library/ttk/ttk.tcl
index 7bae211..04ac959 100644
--- a/library/ttk/ttk.tcl
+++ b/library/ttk/ttk.tcl
@@ -109,6 +109,7 @@ source [file join $::ttk::library combobox.tcl] ;# dependency: entry.tcl
source [file join $::ttk::library spinbox.tcl] ;# dependency: entry.tcl
source [file join $::ttk::library treeview.tcl]
source [file join $::ttk::library sizegrip.tcl]
+source [file join $::ttk::library range.tcl]
## Label and Labelframe bindings:
# (not enough to justify their own file...)
diff --git a/library/ttk/vistaTheme.tcl b/library/ttk/vistaTheme.tcl
index 99410cb..749042f 100644
--- a/library/ttk/vistaTheme.tcl
+++ b/library/ttk/vistaTheme.tcl
@@ -215,6 +215,38 @@ namespace eval ttk::theme::vista {
}
}
}
+
+ # Range
+ ttk::style element create Horizontal.Range.minslider vsapi \
+ TRACKBAR 3 {disabled 5 focus 4 pressed 3 active 2 {} 1} \
+ -width 6 -height 12
+ ttk::style element create Horizontal.Range.maxslider vsapi \
+ TRACKBAR 3 {disabled 5 focus 4 pressed 3 active 2 {} 1} \
+ -width 6 -height 12
+ ttk::style layout Horizontal.TRange {
+ Range.focus -expand 1 -sticky nswe -children {
+ Horizontal.Range.trough -expand 1 -sticky nswe -children {
+ Horizontal.Range.track -sticky we
+ Horizontal.Range.minslider -side left -sticky {}
+ Horizontal.Range.maxslider -side right -sticky {}
+ }
+ }
+ }
+ ttk::style element create Vertical.Range.minslider vsapi \
+ TRACKBAR 6 {disabled 5 focus 4 pressed 3 active 2 {} 1} \
+ -width 12 -height 6
+ ttk::style element create Vertical.Range.maxslider vsapi \
+ TRACKBAR 6 {disabled 5 focus 4 pressed 3 active 2 {} 1} \
+ -width 12 -height 6
+ ttk::style layout Vertical.TRange {
+ Range.focus -expand 1 -sticky nswe -children {
+ Vertical.Range.trough -expand 1 -sticky nswe -children {
+ Vertical.Range.track -sticky ns
+ Vertical.Range.maxslider -side top -sticky {}
+ Vertical.Range.minslider -side bottom -sticky {}
+ }
+ }
+ }
# Treeview
ttk::style configure Item -padding {4 0 0 0}
diff --git a/library/ttk/winTheme.tcl b/library/ttk/winTheme.tcl
index 55367bc..909e82f 100644
--- a/library/ttk/winTheme.tcl
+++ b/library/ttk/winTheme.tcl
@@ -62,6 +62,8 @@ namespace eval ttk::theme::winnative {
{disabled flat selected sunken pressed sunken active raised}
ttk::style configure TScale -groovewidth 4
+
+ ttk::style configure TRange groovewidth 4
ttk::style configure TNotebook -tabmargins {2 2 2 0}
ttk::style configure TNotebook.Tab -padding {3 1} -borderwidth 1