17 namespace eval ::appearance {}
19 proc ::appearance::applyMenuBarColor { menu docked_nb } {
20 if { ! [
info exists ::menuColor(background)] && \
21 ! [
info exists ::menuBarColor(background)] } {
return}
23 if { $docked_nb eq ""} {
24 set varname ::menuBarColor(background)
26 set varname ::menuColor(background)
28 if { [
info exists $varname] } {
29 $menu configure -background [
set $varname]
31 lassign [
lrange [$menu configure -background] 3 end] default currCol
32 if { $default ne $currCol } {
33 $menu configure -background $default
38 proc ::appearance::chooseMenuColor {col_var} {
39 set col [
tk_chooseColor -initialcolor [
set $col_var] -title "Scid"]
45 focus .menuOptions.f.bg
48 proc ::appearance::setNewMenuColors { m configure_cmd } {
49 $m configure {*}$configure_cmd
50 foreach child [
winfo children $m] {
55 proc ::appearance::updateMenuColors {} {
56 foreach {col value} [
array get ::menuDialog_] {
57 lappend configure_cmd "-[
string tolower $col]"
58 lappend configure_cmd $value
61 lappend toplevel_wins "."
62 foreach wnd $toplevel_wins {
73 proc ::appearance::setMenuColors {} {
74 foreach {col value} [
array get ::menuDialog_] {
75 if { $value ne $::menuDialogDefault_($col) } {
76 set ::menuColor($col) $value
78 unset -nocomplain ::menuColor($col)
80 option add *Menu.$col $value
82 foreach {col value} [
array get ::menuBarDialog_] {
83 if { $value ne $::menuDialogDefault_($col) } {
84 set ::menuBarColor($col) $value
86 unset -nocomplain ::menuBarColor($col)
93 catch {grab release $w}
97 proc ::appearance::defaultColors {} {
98 foreach col { background foreground activeBackground activeForeground selectColor disabledForeground } {
99 set config [.menu configure -[
string tolower $col]]
100 set ::menuDialogDefault_($col) [
lindex $config 3]
101 set ::menuDialog_($col) $::menuDialogDefault_($col)
103 set ::menuBarDialog_(background) $::menuDialogDefault_(background)
109 proc ::appearance::menuConfigDialog {} {
111 foreach {col value} [
array get ::menuColor] {
112 set ::menuDialog_($col) $value
114 foreach {col value} [
array get ::menuBarColor] {
115 set ::menuBarDialog_($col) $value
120 wm title $w "Scid: [
tr OptionsMenuColor]"
122 ttk::label $w.status -text ""
123 pack [ttk::frame $w.b] -side bottom -fill x
124 pack [ttk::frame $w.f] \
130 ttk::label $f.mainmenu -text "Menu bar Menu"
131 if { ! $::windowsOS && ! $::macOS} {
132 ttk::button $f.mbg -text $::tr(MenuColorBackground) -command { ::appearance::chooseMenuColor ::menuBarDialog_(background) }
133 grid $f.mainmenu -row $r -column 0 -columnspan 3 -padx 4 -sticky e
134 grid $f.mbg -row $r -column 4 -padx 4
137 ttk::label $f.menuline0 -text "Disabled"
138 grid $f.menuline0 -row $r -column 2 -padx 4
139 ttk::button $f.dfg -text $::tr(MenuColorForeground) -command { ::appearance::chooseMenuColor ::menuDialog_(disabledForeground) }
140 grid $f.dfg -row $r -column 3 -padx 4
142 ttk::button $f.sel -text $::tr(MenuColorSelect) -command { ::appearance::chooseMenuColor ::menuDialog_(selectColor) }
143 grid $f.sel -row $r -column 0 -padx 4
144 ttk::label $f.select -text "x"
145 grid $f.select -row $r -column 1
146 ttk::label $f.menuline1 -text "Menu1"
147 grid $f.menuline1 -row $r -column 2 -padx 4
148 ttk::button $f.fg -text $::tr(MenuColorForeground) -command { ::appearance::chooseMenuColor ::menuDialog_(foreground) }
149 grid $f.fg -row $r -column 3 -padx 4 -pady 5
150 ttk::button $f.bg -text $::tr(MenuColorBackground) -command { ::appearance::chooseMenuColor ::menuDialog_(background) }
151 grid $f.bg -row $r -column 4 -padx 4
153 ttk::label $f.menuline2 -text "Menu2"
154 grid $f.menuline2 -row $r -column 2 -padx 4
155 ttk::button $f.afg -text $::tr(MenuColorForeground) -command { ::appearance::chooseMenuColor ::menuDialog_(activeForeground) }
156 grid $f.afg -row $r -column 3 -padx 4
157 ttk::button $f.abg -text $::tr(MenuColorBackground) -command { ::appearance::chooseMenuColor ::menuDialog_(activeBackground) }
158 grid $f.abg -row $r -column 4 -padx 4 -pady 5
161 ttk::button $w.b.help -image tb_help -command {grab release .menuOptions; helpWindow Appearance }
163 dialogbutton $w.b.ok -text OK -command ::appearance::setMenuColors
164 dialogbutton $w.b.reset -text $::tr(Defaults) -command {
165 ::appearance::defaultColors
166 ::appearance::setMenuColors
168 dialogbutton $w.b.cancel -text $::tr(Cancel) -command "::win::closeWindow $w"
170 bind $w <Return> [list $w.b.ok invoke]
171 bind $w <Escape> [list $w.b.cancel invoke]
172 bind $w.f <Destroy> { unset ::menuDialog_ }
173 bind $w <F1> { grab release .menuOptions; helpWindow Appearance }
182 proc ::appearance::Refresh {} {
185 $w.f.menuline0 configure -background $menuDialog_(background) -foreground $menuDialog_(disabledForeground)
186 $w.f.menuline1 configure -background $menuDialog_(background) -foreground $menuDialog_(foreground)
187 $w.f.menuline2 configure -background $menuDialog_(activeBackground) -foreground $menuDialog_(activeForeground)
188 $w.f.select configure -foreground $menuDialog_(selectColor)
189 $w.f.mainmenu configure -background $::menuBarDialog_(background) -foreground $menuDialog_(foreground)