Skip to content

Commit 1560534

Browse files
author
oberdorfer
committed
ttk style related mod's done
1 parent 197e6b9 commit 1560534

File tree

1 file changed

+48
-14
lines changed

1 file changed

+48
-14
lines changed

notebook.tcl

Lines changed: 48 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# ---------------------------------------------------------------------------
22
# notebook.tcl
33
# This file is part of Unifix BWidget Toolkit
4-
# $Id: notebook.tcl,v 1.26 2009/08/04 16:39:06 oehhar Exp $
4+
# $Id: notebook.tcl,v 1.27 2009/09/08 20:50:46 oberdorfer Exp $
55
# ---------------------------------------------------------------------------
66
# Index of commands:
77
# - NoteBook::create
@@ -31,6 +31,7 @@
3131
# - NoteBook::_draw_arrows
3232
# - NoteBook::_draw_area
3333
# - NoteBook::_resize
34+
# - NoteBook::_themechanged
3435
# ---------------------------------------------------------------------------
3536

3637
namespace eval NoteBook {
@@ -44,11 +45,11 @@ namespace eval NoteBook {
4445
{-leavecmd String "" 0}
4546
{-image TkResource "" 0 label}
4647
{-text String "" 0}
47-
{-foreground String "" 0}
48-
{-background String "" 0}
49-
{-activeforeground String "" 0}
50-
{-activebackground String "" 0}
51-
{-disabledforeground String "" 0}
48+
{-foreground Color "SystemWindowText" 0}
49+
{-background Color "SystemWindowFrame" 0}
50+
{-activebackground Color "SystemHighlight" 0}
51+
{-activeforeground Color "SystemHighlightText" 0}
52+
{-disabledforeground Color "SystemDisabledText" 0}
5253
}
5354
}
5455

@@ -65,13 +66,14 @@ namespace eval NoteBook {
6566
-repeatdelay -borderwidth} \
6667
initialize {-borderwidth 1}
6768

68-
Widget::declare NoteBook {
69-
{-foreground TkResource "" 0 button}
70-
{-background TkResource "" 0 button}
71-
{-activebackground TkResource "" 0 button}
72-
{-activeforeground TkResource "" 0 button}
73-
{-disabledforeground TkResource "" 0 button}
74-
{-font TkResource "" 0 button}
69+
Widget::declare NoteBook {
70+
{-foreground Color "SystemWindowText" 0}
71+
{-background Color "SystemWindowFrame" 0}
72+
{-activebackground Color "SystemHighlight" 0}
73+
{-activeforeground Color "SystemHighlightText" 0}
74+
{-disabledforeground Color "SystemDisabledText" 0}
75+
{-font String "TkTextFont" 0}
76+
7577
{-side Enum top 0 {top bottom}}
7678
{-homogeneous Boolean 0 0}
7779
{-borderwidth Int 1 0 "%d >= 1 && %d <= 2"}
@@ -98,6 +100,10 @@ namespace eval NoteBook {
98100

99101
bind NoteBook <Configure> [list NoteBook::_resize %W]
100102
bind NoteBook <Destroy> [list NoteBook::_destroy %W]
103+
104+
if {[lsearch [bindtags .] NBThemeChanged] < 0} {
105+
bindtags . [linsert [bindtags .] 1 NBThemeChanged]
106+
}
101107
}
102108

103109

@@ -113,7 +119,6 @@ proc NoteBook::create { path args } {
113119
set data(base) 0
114120
set data(select) ""
115121
set data(pages) {}
116-
set data(pages) {}
117122
set data(cpt) 0
118123
set data(realized) 0
119124
set data(wpage) 0
@@ -142,6 +147,9 @@ proc NoteBook::create { path args } {
142147
}
143148
bindtags $path.c $bindings
144149

150+
bind NBThemeChanged <<ThemeChanged>> \
151+
"+ [namespace current]::_themechanged $path"
152+
145153
# Create the arrow button
146154
eval [list ArrowButton::create $path.c.fg] [Widget::subcget $path .c.fg] \
147155
[list -highlightthickness 0 -type button -dir left \
@@ -1164,3 +1172,29 @@ proc NoteBook::_set_help { path page } {
11641172
proc NoteBook::_get_page_name { path {item current} {tagindex end-1} } {
11651173
return [string range [lindex [$path.c gettags $item] $tagindex] 2 end]
11661174
}
1175+
1176+
# ----------------------------------------------------------------------------
1177+
# Command NoteBook::_themechanged
1178+
# ----------------------------------------------------------------------------
1179+
proc NoteBook::_themechanged { path } {
1180+
1181+
if { ![winfo exists $path] } { return }
1182+
BWidget::set_themedefaults
1183+
1184+
$path configure \
1185+
-foreground $BWidget::colors(SystemWindowText) \
1186+
-background $BWidget::colors(SystemWindowFrame) \
1187+
-activebackground $BWidget::colors(SystemHighlight) \
1188+
-activeforeground $BWidget::colors(SystemHighlightText) \
1189+
-disabledforeground $BWidget::colors(SystemDisabledText)
1190+
1191+
# make sure, existing items appear in the same color as well:
1192+
foreach page [$path pages] {
1193+
$path itemconfigure $page \
1194+
-foreground $BWidget::colors(SystemWindowText) \
1195+
-background $BWidget::colors(SystemWindowFrame) \
1196+
-activebackground $BWidget::colors(SystemHighlight) \
1197+
-activeforeground $BWidget::colors(SystemHighlightText) \
1198+
-disabledforeground $BWidget::colors(SystemDisabledText)
1199+
}
1200+
}

0 commit comments

Comments
 (0)