diff options
Diffstat (limited to 'library/ttk/defaults.tcl')
-rw-r--r-- | library/ttk/defaults.tcl | 153 |
1 files changed, 116 insertions, 37 deletions
diff --git a/library/ttk/defaults.tcl b/library/ttk/defaults.tcl index 66706a3..226bd39 100644 --- a/library/ttk/defaults.tcl +++ b/library/ttk/defaults.tcl @@ -3,11 +3,13 @@ # namespace eval ttk::theme::default { + variable colors array set colors { -frame "#d9d9d9" -foreground "#000000" -window "#ffffff" + -alternate "#e8e8e8" -text "#000000" -activebg "#ececec" -selectbg "#4a6984" @@ -16,10 +18,70 @@ namespace eval ttk::theme::default { -disabledfg "#a3a3a3" -indicator "#4a6984" -disabledindicator "#a3a3a3" - -altindicator "#9fbdd8" - -disabledaltindicator "#c0c0c0" + -pressedindicator "#5895bc" + } + + # On X11, if the user specifies their own choice of colour scheme via + # X resources, then set the colour palette based on the user's choice. + if {[tk windowingsystem] eq "x11"} { + foreach \ + xResourceName { + { background Background } + { foreground Foreground } + { background Background } + { background Background } + { foreground Foreground } + { activeBackground ActiveBackground } + { selectBackground SelectBackground } + { selectForeground SelectForeground } + { troughColor TroughColor } + { disabledForeground DisabledForeground } + { selectBackground SelectBackground } + { disabledForeground DisabledForeground } + { selectBackground SelectBackground } + { windowColor Background } } \ + colorName { + -frame -foreground -window -alternate -text + -activebg -selectbg -selectfg + -darker -disabledfg -indicator + -disabledindicator -pressedindicator -window } { + set color [eval option get . $xResourceName] + if {$color ne ""} { + set colors($colorName) $color + } + } } + # This array is used to match up the tk widget options with + # the corresponding values in the 'colors' array. + # This is used by tk_setPalette to apply the new palette + # to the ttk widgets. + variable colorOptionLookup + array set colorOptionLookup { + background {-frame -window -alternate} + foreground {-foreground -text} + activeBackground -activebg + selectBackground {-selectbg -indicator -pressedindicator} + selectForeground -selectfg + troughColor -darker + disabledForeground {-disabledfg -disabledindicator} + } +} + +# ttk::theme::default::reconfigureDefaultTheme -- +# +# This procedure contains the definition of the 'default' theme itself. +# The theme definition is in a procedure, so it can be re-called when +# required, enabling tk_setPalette to set the colours of the ttk widgets. +# +# Arguments: +# None. + +proc ttk::theme::default::reconfigureDefaultTheme {} { + upvar ttk::theme::default::colors colors + + # The definition of the 'default' theme. + ttk::style theme settings default { ttk::style configure "." \ @@ -31,7 +93,8 @@ namespace eval ttk::theme::default { -selectbackground $colors(-selectbg) \ -selectforeground $colors(-selectfg) \ -insertwidth 1 \ - -indicatordiameter 10 + -insertcolor $colors(-foreground) \ + -focuscolor $colors(-text) ttk::style map "." -background \ [list disabled $colors(-frame) active $colors(-activebg)] @@ -39,52 +102,49 @@ namespace eval ttk::theme::default { [list disabled $colors(-disabledfg)] ttk::style configure TButton \ - -anchor center -padding "3 3" -width -9 \ + -anchor center -padding 2.25p -width -9 \ -relief raised -shiftrelief 1 ttk::style map TButton -relief [list {!disabled pressed} sunken] - ttk::style configure TCheckbutton \ - -indicatorcolor "#ffffff" -indicatorrelief sunken -padding 1 - ttk::style map TCheckbutton -indicatorcolor \ - [list pressed $colors(-activebg) \ - {!disabled alternate} $colors(-altindicator) \ - {disabled alternate} $colors(-disabledaltindicator) \ - {!disabled selected} $colors(-indicator) \ - {disabled selected} $colors(-disabledindicator)] - ttk::style map TCheckbutton -indicatorrelief \ - [list alternate raised] - - ttk::style configure TRadiobutton \ - -indicatorcolor "#ffffff" -indicatorrelief sunken -padding 1 - ttk::style map TRadiobutton -indicatorcolor \ - [list pressed $colors(-activebg) \ - {!disabled alternate} $colors(-altindicator) \ - {disabled alternate} $colors(-disabledaltindicator) \ - {!disabled selected} $colors(-indicator) \ - {disabled selected} $colors(-disabledindicator)] - ttk::style map TRadiobutton -indicatorrelief \ - [list alternate raised] + foreach style {TCheckbutton TRadiobutton} { + ttk::style configure $style \ + -indicatorbackground $colors(-window) \ + -indicatorforeground $colors(-selectfg) \ + -indicatormargin {0 1.5p 3p 1.5p} -padding 0.75p + ttk::style map $style -indicatorbackground \ + [list {alternate disabled} $colors(-disabledindicator) \ + {alternate pressed} $colors(-pressedindicator) \ + alternate $colors(-indicator) \ + {selected disabled} $colors(-disabledindicator) \ + {selected pressed} $colors(-pressedindicator) \ + selected $colors(-indicator) \ + disabled $colors(-frame) \ + pressed $colors(-darker)] + } ttk::style configure TMenubutton \ - -relief raised -indicatorborderwidth 1 -padding "10 3" + -relief raised -arrowsize 3.75p -arrowpadding 2.25p \ + -arrowcolor $colors(-text) -padding {7.5p 2.25p} + ttk::style map TMenubutton \ + -arrowcolor [list disabled $colors(-disabledfg)] ttk::style configure TEntry \ - -fieldbackground white -padding 1 \ + -fieldbackground $colors(-window) -padding 1 \ -focuswidth 2 -focuscolor $colors(-selectbg) ttk::style map TEntry -fieldbackground \ [list readonly $colors(-frame) disabled $colors(-frame)] ttk::style configure TCombobox \ - -arrowsize 12 -arrowcolor black \ - -fieldbackground white -padding 1 \ + -arrowsize 9p -arrowcolor $colors(-text) \ + -fieldbackground $colors(-window) -padding 1 \ -focuswidth 1 -focuscolor $colors(-selectbg) ttk::style map TCombobox -fieldbackground \ [list readonly $colors(-frame) disabled $colors(-frame)] \ -arrowcolor [list disabled $colors(-disabledfg)] ttk::style configure TSpinbox \ - -arrowsize 10 -arrowcolor black \ - -fieldbackground white -padding {2 0 10 0} \ + -arrowsize 7.5p -arrowcolor $colors(-text) \ + -fieldbackground $colors(-window) -padding {1.5p 0 7.5p 0} \ -focuswidth 1 -focuscolor $colors(-selectbg) ttk::style map TSpinbox -fieldbackground \ [list readonly $colors(-frame) disabled $colors(-frame)] \ @@ -94,17 +154,26 @@ namespace eval ttk::theme::default { -relief groove -borderwidth 2 ttk::style configure TScrollbar \ - -width 12 -arrowsize 12 + -width 9p -arrowsize 9p -arrowcolor $colors(-text) ttk::style map TScrollbar \ -arrowcolor [list disabled $colors(-disabledfg)] ttk::style configure TScale \ - -sliderrelief raised -sliderborderwidth 1 + -innercolor $colors(-selectbg) \ + -outercolor $colors(-window) \ + -bordercolor $colors(-darker) \ + -groovewidth 3p + ttk::style map TScale \ + -outercolor [list active $colors(-activebg)] + ttk::style configure TProgressbar \ - -background $colors(-selectbg) + -background $colors(-selectbg) \ + -borderwidth 0 \ + -barsize 22.5p \ + -thickness 3p ttk::style configure TNotebook.Tab \ - -padding {4 2} -background $colors(-darker) + -padding {3p 1.5p} -background $colors(-darker) ttk::style map TNotebook.Tab \ -background [list selected $colors(-frame)] \ -highlight [list selected 1] \ @@ -113,9 +182,17 @@ namespace eval ttk::theme::default { # Treeview. # ttk::style configure Heading -font TkHeadingFont -relief raised + ttk::style configure Item -indicatorsize 9p \ + -indicatormargins {1.5p 1.5p 3p 1.5p} ttk::style configure Treeview \ -background $colors(-window) \ - -foreground $colors(-text) + -stripedbackground $colors(-alternate) \ + -fieldbackground $colors(-window) \ + -foreground $colors(-text) \ + -indent 15p + ttk::setTreeviewRowHeight + ttk::style configure Treeview.Separator \ + -background $colors(-alternate) ttk::style map Treeview \ -background [list disabled $colors(-frame)\ selected $colors(-selectbg)] \ @@ -141,10 +218,12 @@ namespace eval ttk::theme::default { } ttk::style configure Toolbutton \ - -padding 2 -relief flat + -padding 1.5p -relief flat ttk::style map Toolbutton -relief \ [list disabled flat selected sunken pressed sunken active raised] ttk::style map Toolbutton -background \ [list pressed $colors(-darker) active $colors(-activebg)] } } + +ttk::theme::default::reconfigureDefaultTheme |