Update tk to version 8.5.9
[msysgit.git] / mingw / lib / tk8.5 / ttk / ttk.tcl
blob6740d174048b738af62368ecb8fa76dc9d0fd36c
2 # $Id: ttk.tcl,v 1.8.2.2 2010/08/26 02:06:10 hobbs Exp $
4 # Ttk widget set initialization script.
7 ### Source library scripts.
10 namespace eval ::ttk {
11 variable library
12 if {![info exists library]} {
13 set library [file dirname [info script]]
17 source [file join $::ttk::library fonts.tcl]
18 source [file join $::ttk::library cursors.tcl]
19 source [file join $::ttk::library utils.tcl]
21 ## ttk::deprecated $old $new --
22 # Define $old command as a deprecated alias for $new command
23 # $old and $new must be fully namespace-qualified.
25 proc ttk::deprecated {old new} {
26 interp alias {} $old {} ttk::do'deprecate $old $new
28 ## do'deprecate --
29 # Implementation procedure for deprecated commands --
30 # issue a warning (once), then re-alias old to new.
32 proc ttk::do'deprecate {old new args} {
33 deprecated'warning $old $new
34 interp alias {} $old {} $new
35 uplevel 1 [linsert $args 0 $new]
38 ## deprecated'warning --
39 # Gripe about use of deprecated commands.
41 proc ttk::deprecated'warning {old new} {
42 puts stderr "$old deprecated -- use $new instead"
45 ### Backward-compatibility.
48 # Make [package require tile] an effective no-op;
49 # see SF#3016598 for discussion.
51 package ifneeded tile 0.8.6 { package provide tile 0.8.6 }
53 # ttk::panedwindow used to be named ttk::paned. Keep the alias for now.
55 ::ttk::deprecated ::ttk::paned ::ttk::panedwindow
57 ### ::ttk::ThemeChanged --
58 # Called from [::ttk::style theme use].
59 # Sends a <<ThemeChanged>> virtual event to all widgets.
61 proc ::ttk::ThemeChanged {} {
62 set Q .
63 while {[llength $Q]} {
64 set QN [list]
65 foreach w $Q {
66 event generate $w <<ThemeChanged>>
67 foreach child [winfo children $w] {
68 lappend QN $child
71 set Q $QN
75 ### Public API.
78 proc ::ttk::themes {{ptn *}} {
79 set themes [list]
81 foreach pkg [lsearch -inline -all -glob [package names] ttk::theme::$ptn] {
82 lappend themes [namespace tail $pkg]
85 return $themes
88 ## ttk::setTheme $theme --
89 # Set the current theme to $theme, loading it if necessary.
91 proc ::ttk::setTheme {theme} {
92 variable currentTheme ;# @@@ Temp -- [::ttk::style theme use] doesn't work
93 if {$theme ni [::ttk::style theme names]} {
94 package require ttk::theme::$theme
96 ::ttk::style theme use $theme
97 set currentTheme $theme
100 ### Load widget bindings.
102 source [file join $::ttk::library button.tcl]
103 source [file join $::ttk::library menubutton.tcl]
104 source [file join $::ttk::library scrollbar.tcl]
105 source [file join $::ttk::library scale.tcl]
106 source [file join $::ttk::library progress.tcl]
107 source [file join $::ttk::library notebook.tcl]
108 source [file join $::ttk::library panedwindow.tcl]
109 source [file join $::ttk::library entry.tcl]
110 source [file join $::ttk::library combobox.tcl] ;# dependency: entry.tcl
111 source [file join $::ttk::library spinbox.tcl] ;# dependency: entry.tcl
112 source [file join $::ttk::library treeview.tcl]
113 source [file join $::ttk::library sizegrip.tcl]
115 ## Label and Labelframe bindings:
116 # (not enough to justify their own file...)
118 bind TLabelframe <<Invoke>> { tk::TabToWindow [tk_focusNext %W] }
119 bind TLabel <<Invoke>> { tk::TabToWindow [tk_focusNext %W] }
121 ### Load settings for built-in themes:
123 proc ttk::LoadThemes {} {
124 variable library
126 # "default" always present:
127 uplevel #0 [list source [file join $library defaults.tcl]]
129 set builtinThemes [style theme names]
130 foreach {theme scripts} {
131 classic classicTheme.tcl
132 alt altTheme.tcl
133 clam clamTheme.tcl
134 winnative winTheme.tcl
135 xpnative {xpTheme.tcl vistaTheme.tcl}
136 aqua aquaTheme.tcl
138 if {[lsearch -exact $builtinThemes $theme] >= 0} {
139 foreach script $scripts {
140 uplevel #0 [list source [file join $library $script]]
146 ttk::LoadThemes; rename ::ttk::LoadThemes {}
148 ### Select platform-specific default theme:
150 # Notes:
151 # + On OSX, aqua theme is the default
152 # + On Windows, xpnative takes precedence over winnative if available.
153 # + On X11, users can use the X resource database to
154 # specify a preferred theme (*TkTheme: themeName);
155 # otherwise "default" is used.
158 proc ttk::DefaultTheme {} {
159 set preferred [list aqua vista xpnative winnative]
161 set userTheme [option get . tkTheme TkTheme]
162 if {$userTheme ne {} && ![catch {
163 uplevel #0 [list package require ttk::theme::$userTheme]
164 }]} {
165 return $userTheme
168 foreach theme $preferred {
169 if {[package provide ttk::theme::$theme] ne ""} {
170 return $theme
173 return "default"
176 ttk::setTheme [ttk::DefaultTheme] ; rename ttk::DefaultTheme {}
178 #*EOF*