Update tk to version 8.5.11
[msysgit.git] / mingw / lib / tk8.5 / ttk / ttk.tcl
blob7bae211d2058b977e6637c5640a5821a03339dd7
2 # Ttk widget set initialization script.
5 ### Source library scripts.
8 namespace eval ::ttk {
9 variable library
10 if {![info exists library]} {
11 set library [file dirname [info script]]
15 source [file join $::ttk::library fonts.tcl]
16 source [file join $::ttk::library cursors.tcl]
17 source [file join $::ttk::library utils.tcl]
19 ## ttk::deprecated $old $new --
20 # Define $old command as a deprecated alias for $new command
21 # $old and $new must be fully namespace-qualified.
23 proc ttk::deprecated {old new} {
24 interp alias {} $old {} ttk::do'deprecate $old $new
26 ## do'deprecate --
27 # Implementation procedure for deprecated commands --
28 # issue a warning (once), then re-alias old to new.
30 proc ttk::do'deprecate {old new args} {
31 deprecated'warning $old $new
32 interp alias {} $old {} $new
33 uplevel 1 [linsert $args 0 $new]
36 ## deprecated'warning --
37 # Gripe about use of deprecated commands.
39 proc ttk::deprecated'warning {old new} {
40 puts stderr "$old deprecated -- use $new instead"
43 ### Backward-compatibility.
46 # Make [package require tile] an effective no-op;
47 # see SF#3016598 for discussion.
49 package ifneeded tile 0.8.6 { package provide tile 0.8.6 }
51 # ttk::panedwindow used to be named ttk::paned. Keep the alias for now.
53 ::ttk::deprecated ::ttk::paned ::ttk::panedwindow
55 ### ::ttk::ThemeChanged --
56 # Called from [::ttk::style theme use].
57 # Sends a <<ThemeChanged>> virtual event to all widgets.
59 proc ::ttk::ThemeChanged {} {
60 set Q .
61 while {[llength $Q]} {
62 set QN [list]
63 foreach w $Q {
64 event generate $w <<ThemeChanged>>
65 foreach child [winfo children $w] {
66 lappend QN $child
69 set Q $QN
73 ### Public API.
76 proc ::ttk::themes {{ptn *}} {
77 set themes [list]
79 foreach pkg [lsearch -inline -all -glob [package names] ttk::theme::$ptn] {
80 lappend themes [namespace tail $pkg]
83 return $themes
86 ## ttk::setTheme $theme --
87 # Set the current theme to $theme, loading it if necessary.
89 proc ::ttk::setTheme {theme} {
90 variable currentTheme ;# @@@ Temp -- [::ttk::style theme use] doesn't work
91 if {$theme ni [::ttk::style theme names]} {
92 package require ttk::theme::$theme
94 ::ttk::style theme use $theme
95 set currentTheme $theme
98 ### Load widget bindings.
100 source [file join $::ttk::library button.tcl]
101 source [file join $::ttk::library menubutton.tcl]
102 source [file join $::ttk::library scrollbar.tcl]
103 source [file join $::ttk::library scale.tcl]
104 source [file join $::ttk::library progress.tcl]
105 source [file join $::ttk::library notebook.tcl]
106 source [file join $::ttk::library panedwindow.tcl]
107 source [file join $::ttk::library entry.tcl]
108 source [file join $::ttk::library combobox.tcl] ;# dependency: entry.tcl
109 source [file join $::ttk::library spinbox.tcl] ;# dependency: entry.tcl
110 source [file join $::ttk::library treeview.tcl]
111 source [file join $::ttk::library sizegrip.tcl]
113 ## Label and Labelframe bindings:
114 # (not enough to justify their own file...)
116 bind TLabelframe <<Invoke>> { tk::TabToWindow [tk_focusNext %W] }
117 bind TLabel <<Invoke>> { tk::TabToWindow [tk_focusNext %W] }
119 ### Load settings for built-in themes:
121 proc ttk::LoadThemes {} {
122 variable library
124 # "default" always present:
125 uplevel #0 [list source [file join $library defaults.tcl]]
127 set builtinThemes [style theme names]
128 foreach {theme scripts} {
129 classic classicTheme.tcl
130 alt altTheme.tcl
131 clam clamTheme.tcl
132 winnative winTheme.tcl
133 xpnative {xpTheme.tcl vistaTheme.tcl}
134 aqua aquaTheme.tcl
136 if {[lsearch -exact $builtinThemes $theme] >= 0} {
137 foreach script $scripts {
138 uplevel #0 [list source [file join $library $script]]
144 ttk::LoadThemes; rename ::ttk::LoadThemes {}
146 ### Select platform-specific default theme:
148 # Notes:
149 # + On OSX, aqua theme is the default
150 # + On Windows, xpnative takes precedence over winnative if available.
151 # + On X11, users can use the X resource database to
152 # specify a preferred theme (*TkTheme: themeName);
153 # otherwise "default" is used.
156 proc ttk::DefaultTheme {} {
157 set preferred [list aqua vista xpnative winnative]
159 set userTheme [option get . tkTheme TkTheme]
160 if {$userTheme ne {} && ![catch {
161 uplevel #0 [list package require ttk::theme::$userTheme]
162 }]} {
163 return $userTheme
166 foreach theme $preferred {
167 if {[package provide ttk::theme::$theme] ne ""} {
168 return $theme
171 return "default"
174 ttk::setTheme [ttk::DefaultTheme] ; rename ttk::DefaultTheme {}
176 #*EOF*