summaryrefslogtreecommitdiffstats
path: root/library
diff options
context:
space:
mode:
authorjenglish@flightlab.com <jenglish>2008-05-23 20:20:05 (GMT)
committerjenglish@flightlab.com <jenglish>2008-05-23 20:20:05 (GMT)
commit9aa258ce9069619562bacf4e48cdb40b6237ecf4 (patch)
tree38468a3e3f80fe6a337d7e5bef1503a0780d1797 /library
parentb6f3382c7c4fb10658e36e4cc0a69f317c2e796a (diff)
downloadtk-9aa258ce9069619562bacf4e48cdb40b6237ecf4.zip
tk-9aa258ce9069619562bacf4e48cdb40b6237ecf4.tar.gz
tk-9aa258ce9069619562bacf4e48cdb40b6237ecf4.tar.bz2
Batch of ttk::treeview enhancements:
+ Added [$tv identify region], [$tv identify element], and [$tv identify item] subcommands. + Simplified bindings. + Added [$tv tag has] subcommand. + Tag-related display improvements: setting a tag -background or -foreground no longer overrides selection feedback. + Don't need separate 'Item', 'Cell', and 'Row' style settings anymore, only the base "Treeview" style is used.
Diffstat (limited to 'library')
-rw-r--r--library/ttk/altTheme.tcl13
-rw-r--r--library/ttk/aquaTheme.tcl10
-rw-r--r--library/ttk/clamTheme.tcl13
-rw-r--r--library/ttk/classicTheme.tcl10
-rw-r--r--library/ttk/defaults.tcl19
-rw-r--r--library/ttk/treeview.tcl53
-rw-r--r--library/ttk/winTheme.tcl13
-rw-r--r--library/ttk/xpTheme.tcl13
8 files changed, 49 insertions, 95 deletions
diff --git a/library/ttk/altTheme.tcl b/library/ttk/altTheme.tcl
index c92e3d5..e604373 100644
--- a/library/ttk/altTheme.tcl
+++ b/library/ttk/altTheme.tcl
@@ -1,5 +1,5 @@
#
-# $Id: altTheme.tcl,v 1.6 2007/12/13 15:27:07 dgp Exp $
+# $Id: altTheme.tcl,v 1.7 2008/05/23 20:20:05 jenglish Exp $
#
# Ttk widget set: Alternate theme
#
@@ -80,15 +80,8 @@ namespace eval ttk::theme::alt {
# Treeview:
ttk::style configure Heading -font TkHeadingFont -relief raised
- ttk::style configure Row -background $colors(-window)
- ttk::style configure Cell -background $colors(-window)
- ttk::style map Row \
- -background [list selected $colors(-selectbg)] \
- -foreground [list selected $colors(-selectfg)] ;
- ttk::style map Cell \
- -background [list selected $colors(-selectbg)] \
- -foreground [list selected $colors(-selectfg)] ;
- ttk::style map Item \
+ ttk::style configure Treeview -background $colors(-window)
+ ttk::style map Treeview \
-background [list selected $colors(-selectbg)] \
-foreground [list selected $colors(-selectfg)] ;
diff --git a/library/ttk/aquaTheme.tcl b/library/ttk/aquaTheme.tcl
index bc6d4e9..ccb8bd3 100644
--- a/library/ttk/aquaTheme.tcl
+++ b/library/ttk/aquaTheme.tcl
@@ -1,5 +1,5 @@
#
-# $Id: aquaTheme.tcl,v 1.11 2007/12/13 15:27:08 dgp Exp $
+# $Id: aquaTheme.tcl,v 1.12 2008/05/23 20:20:06 jenglish Exp $
#
# Aqua theme (OSX native look and feel)
#
@@ -38,14 +38,10 @@ namespace eval ttk::theme::aqua {
ttk::style configure TCombobox -postoffset {5 -2 -10 0}
# Treeview:
- ttk::style configure Treeview -rowheight 18
ttk::style configure Heading -font TkHeadingFont
- ttk::style map Row -background [list \
+ ttk::style configure Treeview -rowheight 18 -background White
+ ttk::style map Treeview -background [list \
{selected background} "#c3c3c3" selected SystemHighlight] ;
- ttk::style map Cell -foreground [list \
- {selected background} "#000000" selected SystemHighlightText] ;
- ttk::style map Item -foreground [list \
- {selected background} "#000000" selected SystemHighlightText] ;
# Enable animation for ttk::progressbar widget:
ttk::style configure TProgressbar -period 100 -maxphase 255
diff --git a/library/ttk/clamTheme.tcl b/library/ttk/clamTheme.tcl
index c4c8184..799b6ae 100644
--- a/library/ttk/clamTheme.tcl
+++ b/library/ttk/clamTheme.tcl
@@ -1,5 +1,5 @@
#
-# $Id: clamTheme.tcl,v 1.6 2007/12/13 15:27:08 dgp Exp $
+# $Id: clamTheme.tcl,v 1.7 2008/05/23 20:20:06 jenglish Exp $
#
# "Clam" theme.
#
@@ -116,15 +116,8 @@ namespace eval ttk::theme::clam {
# Treeview:
ttk::style configure Heading \
-font TkHeadingFont -relief raised -padding {3}
- ttk::style configure Row -background $colors(-window)
- ttk::style configure Cell -background $colors(-window)
- ttk::style map Row \
- -background [list selected $colors(-selectbg)] \
- -foreground [list selected $colors(-selectfg)] ;
- ttk::style map Cell \
- -background [list selected $colors(-selectbg)] \
- -foreground [list selected $colors(-selectfg)] ;
- ttk::style map Item \
+ ttk::style configure Treeview -background $colors(-window)
+ ttk::style map Treeview \
-background [list selected $colors(-selectbg)] \
-foreground [list selected $colors(-selectfg)] ;
diff --git a/library/ttk/classicTheme.tcl b/library/ttk/classicTheme.tcl
index c96d7ff..48c3df8 100644
--- a/library/ttk/classicTheme.tcl
+++ b/library/ttk/classicTheme.tcl
@@ -1,5 +1,5 @@
#
-# $Id: classicTheme.tcl,v 1.6 2007/12/13 15:27:08 dgp Exp $
+# $Id: classicTheme.tcl,v 1.7 2008/05/23 20:20:06 jenglish Exp $
#
# "classic" Tk theme.
#
@@ -87,12 +87,8 @@ namespace eval ttk::theme::classic {
# Treeview:
ttk::style configure Heading -font TkHeadingFont -relief raised
- ttk::style configure Row -background $colors(-window)
- ttk::style configure Cell -background $colors(-window)
- ttk::style map Row \
- -background [list selected $colors(-selectbg)] \
- -foreground [list selected $colors(-selectfg)] ;
- ttk::style map Cell \
+ ttk::style configure Treeview -background $colors(-window)
+ ttk::style map Treeview \
-background [list selected $colors(-selectbg)] \
-foreground [list selected $colors(-selectfg)] ;
diff --git a/library/ttk/defaults.tcl b/library/ttk/defaults.tcl
index 500562d..dfb6654 100644
--- a/library/ttk/defaults.tcl
+++ b/library/ttk/defaults.tcl
@@ -1,5 +1,5 @@
#
-# $Id: defaults.tcl,v 1.6 2007/12/13 15:27:08 dgp Exp $
+# $Id: defaults.tcl,v 1.7 2008/05/23 20:20:06 jenglish Exp $
#
# Settings for default theme.
#
@@ -8,7 +8,9 @@ namespace eval ttk::theme::default {
variable colors
array set colors {
-frame "#d9d9d9"
+ -foreground "#000000"
-window "#ffffff"
+ -text "#000000"
-activebg "#ececec"
-selectbg "#4a6984"
-selectfg "#ffffff"
@@ -22,7 +24,7 @@ namespace eval ttk::theme::default {
ttk::style configure "." \
-borderwidth 1 \
-background $colors(-frame) \
- -foreground black \
+ -foreground $colors(-foreground) \
-troughcolor $colors(-darker) \
-font TkDefaultFont \
-selectborderwidth 1 \
@@ -85,15 +87,10 @@ namespace eval ttk::theme::default {
# Treeview.
#
ttk::style configure Heading -font TkHeadingFont -relief raised
- ttk::style configure Row -background $colors(-window)
- ttk::style configure Cell -background $colors(-window)
- ttk::style map Row \
- -background [list selected $colors(-selectbg)] \
- -foreground [list selected $colors(-selectfg)] ;
- ttk::style map Cell \
- -background [list selected $colors(-selectbg)] \
- -foreground [list selected $colors(-selectfg)] ;
- ttk::style map Item \
+ ttk::style configure Treeview \
+ -background $colors(-window) \
+ -foreground $colors(-text) ;
+ ttk::style map Treeview \
-background [list selected $colors(-selectbg)] \
-foreground [list selected $colors(-selectfg)] ;
diff --git a/library/ttk/treeview.tcl b/library/ttk/treeview.tcl
index d2a1015..608cdf2 100644
--- a/library/ttk/treeview.tcl
+++ b/library/ttk/treeview.tcl
@@ -1,4 +1,4 @@
-# $Id: treeview.tcl,v 1.5 2008/04/25 19:08:32 jenglish Exp $
+# $Id: treeview.tcl,v 1.6 2008/05/23 20:20:06 jenglish Exp $
#
# ttk::treeview widget bindings and utilities.
#
@@ -21,15 +21,6 @@ namespace eval ttk::treeview {
# For pressmode == "heading"
set State(heading) {}
-
- # Provide [lassign] if not already present
- # (@@@ TODO: check if this is still needed after horrible-identify purge)
- #
- if {![llength [info commands lassign]]} {
- proc lassign {vals args} {
- uplevel 1 [list foreach $args $vals break]
- }
- }
}
### Widget bindings.
@@ -118,10 +109,9 @@ proc ttk::treeview::Motion {w x y} {
set cursor {}
set activeHeading {}
- lassign [$w identify $x $y] what where detail
- switch -- $what {
+ switch -- [$w identify region $x $y] {
separator { set cursor $Cursors(hresize) }
- heading { set activeHeading $where }
+ heading { set activeHeading [$w identify column $x $y] }
}
if {[$w cget -cursor] ne $cursor} {
@@ -170,19 +160,20 @@ proc ttk::treeview::DoubleClick {w x y} {
## Press -- ButtonPress binding.
#
proc ttk::treeview::Press {w x y} {
- lassign [$w identify $x $y] what where detail
- focus $w ;# or: ClickToFocus?
-
- switch -- $what {
+ focus $w
+ switch -- [$w identify region $x $y] {
nothing { }
- heading { heading.press $w $where }
- separator { resize.press $w $x $where }
- cell -
- row -
- item { SelectOp $w $where choose }
- }
- if {$what eq "item" && [string match *indicator $detail]} {
- Toggle $w $where
+ heading { heading.press $w $x $y }
+ separator { resize.press $w $x $y }
+ tree -
+ cell {
+ set item [$w identify item $x $y]
+ SelectOp $w $item choose
+ switch -glob -- [$w identify element $x $y] {
+ *indicator -
+ *disclosure { Toggle $w $item }
+ }
+ }
}
}
@@ -208,10 +199,10 @@ proc ttk::treeview::Release {w x y} {
### Interactive column resizing.
#
-proc ttk::treeview::resize.press {w x column} {
+proc ttk::treeview::resize.press {w x y} {
variable State
set State(pressMode) "resize"
- set State(resizeColumn) $column
+ set State(resizeColumn) [$w identify column $x $y]
}
proc ttk::treeview::resize.drag {w x} {
@@ -226,8 +217,9 @@ proc ttk::treeview::resize.release {w x} {
### Heading activation.
#
-proc ttk::treeview::heading.press {w column} {
+proc ttk::treeview::heading.press {w x y} {
variable State
+ set column [$w identify column $x $y]
set State(pressMode) "heading"
set State(heading) $column
$w heading $column state pressed
@@ -235,8 +227,9 @@ proc ttk::treeview::heading.press {w column} {
proc ttk::treeview::heading.drag {w x y} {
variable State
- lassign [$w identify $x $y] what where detail
- if {$what eq "heading" && $where eq $State(heading)} {
+ if { [$w identify region $x $y] eq "heading"
+ && [$w identify column $x $y] eq $State(heading)
+ } {
$w heading $State(heading) state pressed
} else {
$w heading $State(heading) state !pressed
diff --git a/library/ttk/winTheme.tcl b/library/ttk/winTheme.tcl
index 20f45de..03ca6d2 100644
--- a/library/ttk/winTheme.tcl
+++ b/library/ttk/winTheme.tcl
@@ -1,5 +1,5 @@
#
-# $Id: winTheme.tcl,v 1.6 2007/12/13 15:27:08 dgp Exp $
+# $Id: winTheme.tcl,v 1.7 2008/05/23 20:20:06 jenglish Exp $
#
# Settings for 'winnative' theme.
#
@@ -59,15 +59,8 @@ namespace eval ttk::theme::winnative {
# Treeview:
ttk::style configure Heading -font TkHeadingFont -relief raised
- ttk::style configure Row -background SystemWindow
- ttk::style configure Cell -background SystemWindow
- ttk::style map Row \
- -background [list selected SystemHighlight] \
- -foreground [list selected SystemHighlightText] ;
- ttk::style map Cell \
- -background [list selected SystemHighlight] \
- -foreground [list selected SystemHighlightText] ;
- ttk::style map Item \
+ ttk::style configure Treeview -background SystemWindow
+ ttk::style map Treeview \
-background [list selected SystemHighlight] \
-foreground [list selected SystemHighlightText] ;
diff --git a/library/ttk/xpTheme.tcl b/library/ttk/xpTheme.tcl
index d85d415..691dcea 100644
--- a/library/ttk/xpTheme.tcl
+++ b/library/ttk/xpTheme.tcl
@@ -1,5 +1,5 @@
#
-# $Id: xpTheme.tcl,v 1.8 2008/05/15 23:41:08 patthoyts Exp $
+# $Id: xpTheme.tcl,v 1.9 2008/05/23 20:20:06 jenglish Exp $
#
# Settings for 'xpnative' theme
#
@@ -31,15 +31,8 @@ namespace eval ttk::theme::xpnative {
# Treeview:
ttk::style configure Heading -font TkHeadingFont
- ttk::style configure Row -background SystemWindow
- ttk::style configure Cell -background SystemWindow
- ttk::style map Row \
- -background [list selected SystemHighlight] \
- -foreground [list selected SystemHighlightText] ;
- ttk::style map Cell \
- -background [list selected SystemHighlight] \
- -foreground [list selected SystemHighlightText] ;
- ttk::style map Item \
+ ttk::style configure Treeview -background SystemWindow
+ ttk::style map Treeview \
-background [list selected SystemHighlight] \
-foreground [list selected SystemHighlightText] ;