summaryrefslogtreecommitdiffstats
path: root/library/demos
diff options
context:
space:
mode:
authordas <das>2009-07-15 21:50:52 (GMT)
committerdas <das>2009-07-15 21:50:52 (GMT)
commit4f610a5f0cbcaef99f4dc717059838c3d387e158 (patch)
tree09fb6b0c78bc456f1a2fbd028bddfc8eeede3a3c /library/demos
parentebfe03eb0a8d627c9967d64a70f41571e3c07fa1 (diff)
downloadtk-4f610a5f0cbcaef99f4dc717059838c3d387e158.zip
tk-4f610a5f0cbcaef99f4dc717059838c3d387e158.tar.gz
tk-4f610a5f0cbcaef99f4dc717059838c3d387e158.tar.bz2
* library/demos/mclist.tcl: use native sort arrows with aqua theme.
Diffstat (limited to 'library/demos')
-rw-r--r--library/demos/mclist.tcl22
1 files changed, 18 insertions, 4 deletions
diff --git a/library/demos/mclist.tcl b/library/demos/mclist.tcl
index 68beb51..ba21c01 100644
--- a/library/demos/mclist.tcl
+++ b/library/demos/mclist.tcl
@@ -3,7 +3,7 @@
# This demonstration script creates a toplevel window containing a Ttk
# tree widget configured as a multi-column listbox.
#
-# RCS: @(#) $Id: mclist.tcl,v 1.5 2009/03/31 14:20:41 dkf Exp $
+# RCS: @(#) $Id: mclist.tcl,v 1.6 2009/07/15 21:50:52 das Exp $
if {![info exists widgetDemo]} {
error "This script should be run from the \"widget\" demo."
@@ -85,6 +85,16 @@ foreach {country capital currency} $data {
## Code to do the sorting of the tree contents when clicked on
proc SortBy {tree col direction} {
+ # Determine currently sorted column and its sort direction
+ foreach c {country capital currency} {
+ set s [$tree heading $c state]
+ if {("selected" in $s || "alternate" in $s) && $col ne $c} {
+ # Sorted column has changed
+ $tree heading $c -image noArrow state {!selected !alternate !user1}
+ set direction [expr {"alternate" in $s}]
+ }
+ }
+
# Build something we can sort
set data {}
foreach row [$tree children {}] {
@@ -99,9 +109,13 @@ proc SortBy {tree col direction} {
$tree move [lindex $info 1] {} [incr r]
}
- foreach c {country capital currency} {$tree heading $c -image noArrow}
-
# Switch the heading so that it will sort in the opposite direction
$tree heading $col -command [list SortBy $tree $col [expr {!$direction}]] \
- -image [expr {$direction?"upArrow":"downArrow"}]
+ state [expr {$direction?"!selected alternate":"selected !alternate"}]
+ if {[ttk::style theme use] eq "aqua"} {
+ # Aqua theme displays native sort arrows when user1 state is set
+ $tree heading $col state "user1"
+ } else {
+ $tree heading $col -image [expr {$direction?"upArrow":"downArrow"}]
+ }
}