Skip to content

Commit 725bd10

Browse files
author
oberdorfer
committed
theme related mod's done
1 parent 50993a0 commit 725bd10

File tree

8 files changed

+242
-119
lines changed

8 files changed

+242
-119
lines changed

entry.tcl

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# ------------------------------------------------------------------------------
22
# entry.tcl
33
# This file is part of Unifix BWidget Toolkit
4-
# $Id: entry.tcl,v 1.22 2009/06/10 08:48:06 oehhar Exp $
4+
# $Id: entry.tcl,v 1.23 2009/09/06 21:13:55 oberdorfer Exp $
55
# ------------------------------------------------------------------------------
66
# Index of commands:
77
# - Entry::create
@@ -27,8 +27,11 @@ namespace eval Entry {
2727
-disabledforeground -disabledbackground }
2828

2929
set declare [list \
30-
[list -background TkResource "" 0 entry] \
31-
[list -foreground TkResource "" 0 entry] \
30+
[list -background Color "SystemWindow" 0] \
31+
[list -foreground Color "SystemWindowText" 0] \
32+
[list -disabledbackground Color "SystemButtonFace" 0] \
33+
[list -disabledforeground Color "SystemDisabledText" 0] \
34+
[list -highlightcolor Color "SystemHighlight" 0] \
3235
[list -state Enum normal 0 [list normal disabled]] \
3336
[list -text String "" 0] \
3437
[list -textvariable String "" 0] \
@@ -41,17 +44,6 @@ namespace eval Entry {
4144
[list -bd Synonym -borderwidth] \
4245
]
4346

44-
if {![package vsatisfies [package provide Tk] 8.4]} {
45-
## If we're not running version 8.4 or higher, get our
46-
## disabled resources from the button widget.
47-
lappend declare [list -disabledforeground TkResource "" 0 button]
48-
lappend declare [list -disabledbackground TkResource "" 0 \
49-
{button -background}]
50-
} else {
51-
lappend declare [list -disabledforeground TkResource "" 0 entry]
52-
lappend declare [list -disabledbackground TkResource "" 0 entry]
53-
}
54-
5547
Widget::declare Entry $declare
5648
Widget::addmap Entry "" :cmd { -textvariable {} }
5749

@@ -78,6 +70,10 @@ namespace eval Entry {
7870
bind BwEntry <Return> [list Entry::invoke %W]
7971
bind BwEntry <Destroy> [list Entry::_destroy %W]
8072
bind BwDisabledEntry <Destroy> [list Entry::_destroy %W]
73+
74+
if {[lsearch [bindtags .] EntryThemeChanged] < 0} {
75+
bindtags . [linsert [bindtags .] 1 EntryThemeChanged]
76+
}
8177
}
8278

8379

@@ -134,6 +130,9 @@ proc Entry::create { path args } {
134130
DropSite::setdrop $path $path Entry::_over_cmd Entry::_drop_cmd 1
135131
DynamicHelp::sethelp $path $path 1
136132

133+
bind EntryThemeChanged <<ThemeChanged>> \
134+
"+ [namespace current]::_themechanged $path"
135+
137136
Widget::create Entry $path
138137
proc ::$path { cmd args } \
139138
"return \[Entry::_path_command [list $path] \$cmd \$args\]"
@@ -470,3 +469,20 @@ proc Entry::_destroy { path } {
470469
Widget::destroy $path
471470
unset data
472471
}
472+
473+
# ----------------------------------------------------------------------------
474+
# Command ListBox::_themechanged
475+
# ----------------------------------------------------------------------------
476+
proc Entry::_themechanged { path } {
477+
478+
if { ![winfo exists $path] } { return }
479+
BWidget::set_themedefaults
480+
$path configure \
481+
-foreground $BWidget::colors(SystemWindowText) \
482+
-background $BWidget::colors(SystemWindow) \
483+
-selectforeground $BWidget::colors(SystemHighlightText) \
484+
-selectbackground $BWidget::colors(SystemHighlight) \
485+
-disabledbackground $BWidget::colors(SystemButtonFace) \
486+
-disabledforeground $BWidget::colors(SystemDisabledText) \
487+
-highlightcolor $BWidget::colors(SystemHighlight)
488+
}

font.tcl

Lines changed: 92 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# ----------------------------------------------------------------------------
22
# font.tcl
33
# This file is part of Unifix BWidget Toolkit
4+
# $Id: font.tcl,v 1.17 2009/09/06 21:14:46 oberdorfer Exp $
45
# ----------------------------------------------------------------------------
56
# Index of commands:
67
# - SelectFont::create
@@ -12,6 +13,7 @@
1213
# - SelectFont::_update
1314
# - SelectFont::_getfont
1415
# - SelectFont::_init
16+
# - SelectFont::_themechanged
1517
# ----------------------------------------------------------------------------
1618

1719
namespace eval SelectFont {
@@ -20,8 +22,10 @@ namespace eval SelectFont {
2022
Widget::declare SelectFont {
2123
{-title String "Font selection" 0}
2224
{-parent String "" 0}
23-
{-background TkResource "" 0 frame}
24-
25+
{-foreground Color "SystemWindowText" 0}
26+
{-background Color "SystemWindow" 0}
27+
{-selectbackground Color "SystemHighlight" 0}
28+
{-selectforeground Color "SystemHighlightText" 0}
2529
{-type Enum dialog 0 {dialog toolbar}}
2630
{-font TkResource "" 0 label}
2731
{-initialcolor String "" 0}
@@ -105,6 +109,10 @@ namespace eval SelectFont {
105109
presetall $presetAll \
106110
]
107111

112+
if {[lsearch [bindtags .] SelectFontThemeChanged] < 0} {
113+
bindtags . [linsert [bindtags .] 1 SelectFontThemeChanged]
114+
}
115+
108116
variable _widget
109117
}
110118

@@ -128,20 +136,31 @@ proc SelectFont::create { path args } {
128136
set bg [Widget::getoption "$path#SelectFont" -background]
129137
set _styles [Widget::getoption "$path#SelectFont" -styles]
130138
if { [Widget::getoption "$path#SelectFont" -type] == "dialog" } {
139+
131140
Dialog::create $path -modal local -anchor e -default 0 -cancel 1 \
132-
-background $bg \
133-
-title [Widget::getoption "$path#SelectFont" -title] \
134-
-parent [Widget::getoption "$path#SelectFont" -parent]
141+
-title [Widget::getoption "$path#SelectFont" -title] \
142+
-parent [Widget::getoption "$path#SelectFont" -parent]
143+
144+
$path configure -background $bg
135145

136146
set frame [Dialog::getframe $path]
137-
set topf [frame $frame.topf -relief flat -borderwidth 0 -background $bg]
147+
148+
set topf [frame \
149+
$frame.topf -relief flat -borderwidth 0 \
150+
-background $bg]
138151

139152
set labf1 [LabelFrame::create $topf.labf1 -text "Font" -name font \
140153
-side top -anchor w -relief flat -background $bg]
141154
set sw [ScrolledWindow::create [LabelFrame::getframe $labf1].sw \
142155
-background $bg]
143156
set lbf [listbox $sw.lb \
144-
-height 5 -width 25 -exportselection false -selectmode browse]
157+
-height 5 -width 25 \
158+
-exportselection false -selectmode browse \
159+
-foreground $BWidget::colors(SystemWindowText) \
160+
-background $BWidget::colors(SystemWindow) \
161+
-selectforeground $BWidget::colors(SystemHighlightText) \
162+
-selectbackground $BWidget::colors(SystemHighlight)]
163+
145164
ScrolledWindow::setwidget $sw $lbf
146165
LabelFrame::configure $labf1 -focus $lbf
147166
if { [Widget::getoption "$path#SelectFont" -querysystem] } {
@@ -165,7 +184,13 @@ proc SelectFont::create { path args } {
165184
set sw [ScrolledWindow::create [LabelFrame::getframe $labf2].sw \
166185
-scrollbar vertical -background $bg]
167186
set lbs [listbox $sw.lb \
168-
-height 5 -width 6 -exportselection false -selectmode browse]
187+
-height 5 -width 6 -exportselection false \
188+
-selectmode browse \
189+
-foreground $BWidget::colors(SystemWindowText) \
190+
-background $BWidget::colors(SystemWindow) \
191+
-selectforeground $BWidget::colors(SystemHighlightText) \
192+
-selectbackground $BWidget::colors(SystemHighlight)]
193+
169194
ScrolledWindow::setwidget $sw $lbs
170195
LabelFrame::configure $labf2 -focus $lbs
171196
eval [list $lbs insert end] $_sizes
@@ -186,12 +211,20 @@ proc SelectFont::create { path args } {
186211
if { $name == "" } {
187212
set name [string toupper $name 0]
188213
}
189-
checkbutton $subf.$st -text $name \
190-
-variable SelectFont::$path\($st\) \
191-
-background $bg \
192-
-command [list SelectFont::_update $path]
214+
215+
if { [BWidget::using ttk] } {
216+
ttk::checkbutton $subf.$st -text $name \
217+
-variable SelectFont::$path\($st\) \
218+
-command [list SelectFont::_update $path]
219+
} else {
220+
checkbutton $subf.$st -text $name \
221+
-variable SelectFont::$path\($st\) \
222+
-background $bg \
223+
-command [list SelectFont::_update $path]
224+
}
225+
193226
bind $subf.$st <Return> break
194-
pack $subf.$st -anchor w
227+
pack $subf.$st -anchor w -padx 5
195228
}
196229
LabelFrame::configure $labf3 -focus $subf.[lindex $_styles 0]
197230

@@ -204,11 +237,13 @@ proc SelectFont::create { path args } {
204237
set botf [frame $frame.botf -width 100 -height 50 \
205238
-bg white -bd 0 -relief flat \
206239
-highlightthickness 1 -takefocus 0 \
207-
-highlightbackground black \
208-
-highlightcolor black]
240+
-background $BWidget::colors(SystemWindow) \
241+
-highlightbackground $BWidget::colors(SystemWindowText) \
242+
-highlightcolor $BWidget::colors(SystemWindowText)]
209243

210244
set lab [label $botf.label \
211-
-background white -foreground black \
245+
-foreground $BWidget::colors(SystemWindowText) \
246+
-background $BWidget::colors(SystemWindow) \
212247
-borderwidth 0 -takefocus 0 -highlightthickness 0 \
213248
-text [Widget::getoption "$path#SelectFont" -sampletext]]
214249
place $lab -relx 0.5 -rely 0.5 -anchor c
@@ -217,19 +252,21 @@ proc SelectFont::create { path args } {
217252

218253
if { [Widget::getoption "$path#SelectFont" -initialcolor] != ""} {
219254
set thecolor [Widget::getoption "$path#SelectFont" -initialcolor]
220-
set colf [frame $frame.colf]
221-
222-
set frc [frame $colf.frame -width 50 -height 20 -bg $thecolor -bd 0 -relief flat\
255+
256+
set colf [frame $frame.colf]
257+
set frc [frame $colf.frame -width 50 -height 20 -bg $thecolor -bd 0 -relief flat\
223258
-highlightthickness 1 -takefocus 0 \
224259
-highlightbackground black \
225260
-highlightcolor black]
226-
227-
set script "set [list SelectFont::${path}(fontcolor)] \[tk_chooseColor -parent $colf.button -initialcolor \[set [list SelectFont::${path}(fontcolor)]\]\];\
228-
SelectFont::_update [list $path]"
229-
230-
set but [button $colf.button -command $script \
231-
-text "Color..."]
261+
262+
set script "set [list SelectFont::${path}(fontcolor)] \
263+
\[SelectColor::dialog $colf.coldlg -parent $colf.button \
264+
-color \[set [list SelectFont::${path}(fontcolor)]\]\]; \
265+
SelectFont::_update [list $path]"
232266

267+
set but [Button $colf.button -command $script \
268+
-text "Color..."]
269+
233270
$lab configure -foreground $thecolor
234271
$frc configure -bg $thecolor
235272

@@ -265,7 +302,7 @@ proc SelectFont::create { path args } {
265302
set fams "preset"
266303
append fams [Widget::getoption "$path#SelectFont" -families]
267304
}
268-
if {[Widget::theme]} {
305+
if { [BWidget::using ttk] } {
269306
ttk::frame $path
270307
set lbf [ttk::combobox $path.font \
271308
-takefocus 0 -exportselection 0 \
@@ -287,25 +324,27 @@ proc SelectFont::create { path args } {
287324
-values $_families($fams) \
288325
-textvariable SelectFont::$path\(family\) \
289326
-editable 0 \
290-
-modifycmd [list SelectFont::_update $path]]
327+
-modifycmd [list SelectFont::_update $path] \
328+
-hottrack 1]
291329
set lbs [ComboBox::create $path.size \
292330
-highlightthickness 0 -takefocus 0 -background $bg \
293331
-width 4 \
294332
-values $_sizes \
295333
-textvariable SelectFont::$path\(size\) \
296334
-editable 0 \
297-
-modifycmd [list SelectFont::_update $path]]
335+
-modifycmd [list SelectFont::_update $path] \
336+
-hottrack 1]
298337
}
299338
bind $path <Destroy> [list SelectFont::_destroy $path]
300339
pack $lbf -side left -anchor w
301340
pack $lbs -side left -anchor w -padx 4
302341
foreach st $_styles {
303-
if {$::Widget::_theme} {
342+
if { [BWidget::using ttk] } {
304343
ttk::checkbutton $path.$st -takefocus 0 \
305-
-style BWSlim.Toolbutton \
306344
-image [Bitmap::get $st] \
307345
-variable SelectFont::${path}($st) \
308-
-command [list SelectFont::_update $path]
346+
-command [list SelectFont::_update $path] \
347+
-style "BWSlimCB.Toolbutton"
309348
} else {
310349
button $path.$st \
311350
-highlightthickness 0 -takefocus 0 -padx 0 -pady 0 \
@@ -320,6 +359,9 @@ proc SelectFont::create { path args } {
320359
set data(lbs) $lbs
321360
_getfont $path
322361

362+
bind SelectFontThemeChanged <<ThemeChanged>> \
363+
"+ [namespace current]::_themechanged $path"
364+
323365
return [Widget::create SelectFont $path]
324366
}
325367

@@ -357,12 +399,14 @@ proc SelectFont::configure { path args } {
357399
}
358400
}
359401
toolbar {
360-
$path configure -background $bg
361-
ComboBox::configure $path.font -background $bg
362-
ComboBox::configure $path.size -background $bg
363-
foreach st $_styles {
364-
$path.$st configure -background $bg
365-
}
402+
if { ![BWidget::using ttk] } {
403+
$path:cmd configure -background $bg
404+
ComboBox::configure $path.font -background $bg
405+
ComboBox::configure $path.size -background $bg
406+
foreach st $_styles {
407+
$path.$st configure -background $bg
408+
}
409+
}
366410
}
367411
}
368412
}
@@ -545,7 +589,7 @@ proc SelectFont::_getfont { path } {
545589
} else {
546590
set data(family) $font(-family)
547591
set data(size) $font(-size)
548-
if {![Widget::theme]} {
592+
if { ![BWidget::using ttk] } {
549593
foreach st $_styles {
550594
$path.$st configure \
551595
-relief [expr {$data($st) ? "sunken":"raised"}]
@@ -564,3 +608,13 @@ proc SelectFont::_destroy { path } {
564608
unset data
565609
Widget::destroy "$path#SelectFont"
566610
}
611+
612+
# ----------------------------------------------------------------------------
613+
# Command SelectFont::_themechanged
614+
# ----------------------------------------------------------------------------
615+
proc SelectFont::_themechanged { path } {
616+
if { ![winfo exists $path] } { return }
617+
BWidget::set_themedefaults
618+
$path configure -background $BWidget::colors(SystemWindowFrame)
619+
}
620+

label.tcl

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# ------------------------------------------------------------------------------
22
# label.tcl
33
# This file is part of Unifix BWidget Toolkit
4-
# $Id: label.tcl,v 1.10 2003/10/20 21:23:52 damonc Exp $
4+
# $Id: label.tcl,v 1.11 2009/09/06 21:15:25 oberdorfer Exp $
55
# ------------------------------------------------------------------------------
66
# Index of commands:
77
# - Label::create
@@ -25,10 +25,10 @@ namespace eval Label {
2525
{-textvariable String "" 0}
2626
{-underline Int -1 0 "%d >= -1"}
2727
{-focus String "" 0}
28-
{-foreground TkResource "" 0 label}
29-
{-disabledforeground TkResource "" 0 button}
28+
{-foreground Color "SystemWindow" 0}
29+
{-background Color "SystemWindowFrame" 0}
30+
{-disabledforeground Color "SystemDisabledText" 0}
3031
{-state Enum normal 0 {normal disabled}}
31-
3232
{-fg Synonym -foreground}
3333
}
3434

@@ -56,7 +56,10 @@ namespace eval Label {
5656
proc Label::create { path args } {
5757
array set maps [list Label {} .l {}]
5858
array set maps [Widget::parseArgs Label $args]
59-
frame $path -class Label -borderwidth 0 -highlightthickness 0 -relief flat
59+
60+
BWidget::wrap frame $path \
61+
-class Label -borderwidth 0 -highlightthickness 0 -relief flat
62+
6063
Widget::initFromODB Label $path $maps(Label)
6164

6265
eval [list label $path.l] $maps(.l)

0 commit comments

Comments
 (0)