diff options
Diffstat (limited to 'library/ttk/ttk.tcl')
-rw-r--r-- | library/ttk/ttk.tcl | 73 |
1 files changed, 44 insertions, 29 deletions
diff --git a/library/ttk/ttk.tcl b/library/ttk/ttk.tcl index 5c1b5b2..37a96bc 100644 --- a/library/ttk/ttk.tcl +++ b/library/ttk/ttk.tcl @@ -1,5 +1,5 @@ # -# $Id: ttk.tcl,v 1.3 2006/12/13 05:36:38 jenglish Exp $ +# $Id: ttk.tcl,v 1.4 2006/12/13 17:06:32 jenglish Exp $ # # Ttk widget set initialization script. # @@ -114,44 +114,59 @@ source [file join $::ttk::library dialog.tcl] bind TLabelframe <<Invoke>> { tk::TabToWindow [tk_focusNext %W] } bind TLabel <<Invoke>> { tk::TabToWindow [tk_focusNext %W] } -### Load themes. +### Load settings for built-in themes: # -source [file join $::ttk::library defaults.tcl] -source [file join $::ttk::library classicTheme.tcl] -source [file join $::ttk::library altTheme.tcl] -source [file join $::ttk::library clamTheme.tcl] +proc ttk::LoadThemes {} { + variable library + + # "default" always present: + uplevel #0 [list source [file join $library defaults.tcl]] + + set builtinThemes [style theme names] + foreach {theme script} { + classic classicTheme.tcl + alt altTheme.tcl + clam clamTheme.tcl + winnative winTheme.tcl + xpnative xpTheme.tcl + aqua aquaTheme.tcl + } { + if {[lsearch -exact $builtinThemes $theme] >= 0} { + uplevel #0 [list source [file join $library $script]] + } + } +} + +ttk::LoadThemes; rename ::ttk::LoadThemes {} -### Choose platform-specific default theme. +### Select platform-specific default theme: # -# Notes: -# + xpnative takes precedence over winnative if available. +# Notes: +# + On OSX, aqua theme is the default +# + On Windows, xpnative takes precedence over winnative if available. # + On X11, users can use the X resource database to -# specify a preferred theme (*TkTheme: themeName) +# specify a preferred theme (*TkTheme: themeName); +# otherwise "default" is used. # -set ::ttk::defaultTheme "default" +proc ttk::DefaultTheme {} { + set preferred [list aqua xpnative winnative] -if {[package provide ttk::theme::winnative] != {}} { - source [file join $::ttk::library winTheme.tcl] - set ::ttk::defaultTheme "winnative" -} -if {[package provide ttk::theme::xpnative] != {}} { - source [file join $::ttk::library xpTheme.tcl] - set ::ttk::defaultTheme "xpnative" -} -if {[package provide ttk::theme::aqua] != {}} { - source [file join $::ttk::library aquaTheme.tcl] - set ::ttk::defaultTheme "aqua" -} + set userTheme [option get . tkTheme TkTheme] + if {$userTheme != {} && ![catch { + uplevel #0 [list package require ttk::theme::$userTheme] + }]} { + return $userTheme + } -set ::ttk::userTheme [option get . tkTheme TkTheme] -if {$::ttk::userTheme != {}} { - if {($::ttk::userTheme in [::ttk::style theme names]) - || ![catch {package require ttk::theme::$ttk::userTheme}]} { - set ::ttk::defaultTheme $::ttk::userTheme + foreach theme $preferred { + if {[package provide ttk::theme::$theme] != ""} { + return $theme + } } + return "default" } -::ttk::setTheme $::ttk::defaultTheme +ttk::setTheme [ttk::DefaultTheme] ; rename ttk::DefaultTheme {} #*EOF* |