1
1
# ---------------------------------------------------------------------------
2
2
# notebook.tcl
3
3
# 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 $
5
5
# ---------------------------------------------------------------------------
6
6
# Index of commands:
7
7
# - NoteBook::create
31
31
# - NoteBook::_draw_arrows
32
32
# - NoteBook::_draw_area
33
33
# - NoteBook::_resize
34
+ # - NoteBook::_themechanged
34
35
# ---------------------------------------------------------------------------
35
36
36
37
namespace eval NoteBook {
@@ -44,11 +45,11 @@ namespace eval NoteBook {
44
45
{-leavecmd String " " 0}
45
46
{-image TkResource " " 0 label}
46
47
{-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}
52
53
}
53
54
}
54
55
@@ -65,13 +66,14 @@ namespace eval NoteBook {
65
66
-repeatdelay -borderwidth} \
66
67
initialize {-borderwidth 1}
67
68
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
+
75
77
{-side Enum top 0 {top bottom}}
76
78
{-homogeneous Boolean 0 0}
77
79
{-borderwidth Int 1 0 " %d >= 1 && %d <= 2" }
@@ -98,6 +100,10 @@ namespace eval NoteBook {
98
100
99
101
bind NoteBook <Configure> [list NoteBook::_resize %W]
100
102
bind NoteBook <Destroy> [list NoteBook::_destroy %W]
103
+
104
+ if {[lsearch [bindtags .] NBThemeChanged] < 0} {
105
+ bindtags . [linsert [bindtags .] 1 NBThemeChanged]
106
+ }
101
107
}
102
108
103
109
@@ -113,7 +119,6 @@ proc NoteBook::create { path args } {
113
119
set data(base) 0
114
120
set data(select) " "
115
121
set data(pages) {}
116
- set data(pages) {}
117
122
set data(cpt) 0
118
123
set data(realized) 0
119
124
set data(wpage) 0
@@ -142,6 +147,9 @@ proc NoteBook::create { path args } {
142
147
}
143
148
bindtags $path .c $bindings
144
149
150
+ bind NBThemeChanged <<ThemeChanged>> \
151
+ " + [ namespace current] ::_themechanged $path "
152
+
145
153
# Create the arrow button
146
154
eval [list ArrowButton::create $path .c.fg] [Widget::subcget $path .c.fg] \
147
155
[list -highlightthickness 0 -type button -dir left \
@@ -1164,3 +1172,29 @@ proc NoteBook::_set_help { path page } {
1164
1172
proc NoteBook::_get_page_name { path {item current} {tagindex end-1} } {
1165
1173
return [string range [lindex [$path .c gettags $item ] $tagindex ] 2 end]
1166
1174
}
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