Skip to content

Commit 842cc18

Browse files
author
oberdorfer
committed
theme related mod's done
1 parent 412aa14 commit 842cc18

File tree

9 files changed

+194
-333
lines changed

9 files changed

+194
-333
lines changed

panelframe.tcl

Lines changed: 1 addition & 240 deletions
Large diffs are not rendered by default.

progressbar.tcl

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
# ----------------------------------------------------------------------------
22
# progressbar.tcl
33
# This file is part of Unifix BWidget Toolkit
4+
# $Id: progressbar.tcl,v 1.14 2009/09/06 21:37:18 oberdorfer Exp $
45
# ----------------------------------------------------------------------------
56
# Index of commands:
67
# - ProgressBar::create
78
# - ProgressBar::configure
89
# - ProgressBar::cget
910
# - ProgressBar::_destroy
1011
# - ProgressBar::_modify
12+
# - ProgressBar::_themechanged
1113
# ----------------------------------------------------------------------------
14+
# to-do: johann: -troughcolor has no effect ?!
1215

1316
namespace eval ProgressBar {
1417
Widget::define ProgressBar progressbar
@@ -17,10 +20,10 @@ namespace eval ProgressBar {
1720
{-type Enum normal 0
1821
{normal incremental infinite nonincremental_infinite}}
1922
{-maximum Int 100 0 "%d > 0"}
20-
{-background TkResource "" 0 frame}
21-
{-foreground TkResource "blue" 0 label}
23+
{-background Color "SystemWindowFrame" 0}
24+
{-foreground Color "SystemHighlight" 0}
25+
{-troughcolor Color "SystemScrollbar" 0}
2226
{-borderwidth TkResource 2 0 frame}
23-
{-troughcolor TkResource "" 0 scrollbar}
2427
{-relief TkResource sunken 0 label}
2528
{-orient Enum horizontal 1 {horizontal vertical}}
2629
{-variable String "" 0}
@@ -37,6 +40,10 @@ namespace eval ProgressBar {
3740
-troughcolor -background -borderwidth {} -relief {}
3841
}
3942

43+
if {[lsearch [bindtags .] ProgressBarThemeChanged] < 0} {
44+
bindtags . [linsert [bindtags .] 1 ProgressBarThemeChanged]
45+
}
46+
4047
variable _widget
4148
}
4249

@@ -49,6 +56,7 @@ proc ProgressBar::create { path args } {
4956

5057
array set maps [list ProgressBar {} :cmd {} .bar {}]
5158
array set maps [Widget::parseArgs ProgressBar $args]
59+
5260
eval frame $path $maps(:cmd) -class ProgressBar -bd 0 \
5361
-highlightthickness 0 -relief flat
5462
Widget::initFromODB ProgressBar $path $maps(ProgressBar)
@@ -74,6 +82,9 @@ proc ProgressBar::create { path args } {
7482
bind $path.bar <Destroy> [list ProgressBar::_destroy $path]
7583
bind $path.bar <Configure> [list ProgressBar::_modify $path]
7684

85+
bind ProgressBarThemeChanged <<ThemeChanged>> \
86+
"+ [namespace current]::_themechanged $path"
87+
7788
return [Widget::create ProgressBar $path]
7889
}
7990

@@ -118,6 +129,11 @@ proc ProgressBar::configure { path args } {
118129
set fg [Widget::cget $path -foreground]
119130
$path.bar itemconfigure rect -fill $fg -outline $fg
120131
}
132+
if { [Widget::hasChangedX $path -background] } {
133+
set bg [Widget::cget $path -background]
134+
$path.bar configure -background $bg
135+
}
136+
121137
return $res
122138
}
123139

@@ -206,3 +222,18 @@ proc ProgressBar::_destroy { path } {
206222
unset _widget($path,dir)
207223
Widget::destroy $path
208224
}
225+
226+
227+
# ----------------------------------------------------------------------------
228+
# Command ProgressBar::_themechanged
229+
# ----------------------------------------------------------------------------
230+
proc ProgressBar::_themechanged { path } {
231+
232+
if { ![winfo exists $path] } { return }
233+
BWidget::set_themedefaults
234+
235+
$path configure \
236+
-background $BWidget::colors(SystemWindowFrame) \
237+
-foreground $BWidget::colors(SystemHighlight)
238+
}
239+

scrollframe.tcl

Lines changed: 45 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# ----------------------------------------------------------------------------
22
# scrollframe.tcl
33
# This file is part of Unifix BWidget Toolkit
4-
# $Id: scrollframe.tcl,v 1.11 2009/07/17 15:29:51 oehhar Exp $
4+
# $Id: scrollframe.tcl,v 1.12 2009/09/06 21:38:51 oberdorfer Exp $
55
# ----------------------------------------------------------------------------
66
# Index of commands:
77
# - ScrollableFrame::create
@@ -12,55 +12,41 @@
1212
# - ScrollableFrame::xview
1313
# - ScrollableFrame::yview
1414
# - ScrollableFrame::_resize
15+
# - ScrollableFrame::_themechanged
1516
# ----------------------------------------------------------------------------
1617

1718
namespace eval ScrollableFrame {
1819
Widget::define ScrollableFrame scrollframe
1920

20-
# If themed, there is no background and -bg option
21-
if {[Widget::theme]} {
22-
Widget::declare ScrollableFrame {
23-
{-width Int 0 0 {}}
24-
{-height Int 0 0 {}}
25-
{-areawidth Int 0 0 {}}
26-
{-areaheight Int 0 0 {}}
27-
{-constrainedwidth Boolean 0 0}
28-
{-constrainedheight Boolean 0 0}
29-
{-xscrollcommand TkResource "" 0 canvas}
30-
{-yscrollcommand TkResource "" 0 canvas}
31-
{-xscrollincrement TkResource "" 0 canvas}
32-
{-yscrollincrement TkResource "" 0 canvas}
33-
}
34-
} else {
35-
Widget::declare ScrollableFrame {
36-
{-background TkResource "" 0 frame}
37-
{-width Int 0 0 {}}
38-
{-height Int 0 0 {}}
39-
{-areawidth Int 0 0 {}}
40-
{-areaheight Int 0 0 {}}
41-
{-constrainedwidth Boolean 0 0}
42-
{-constrainedheight Boolean 0 0}
43-
{-xscrollcommand TkResource "" 0 canvas}
44-
{-yscrollcommand TkResource "" 0 canvas}
45-
{-xscrollincrement TkResource "" 0 canvas}
46-
{-yscrollincrement TkResource "" 0 canvas}
47-
{-bg Synonym -background}
48-
}
21+
Widget::declare ScrollableFrame {
22+
{-background Color "SystemWindow" 0}
23+
{-width Int 0 0 {}}
24+
{-height Int 0 0 {}}
25+
{-areawidth Int 0 0 {}}
26+
{-areaheight Int 0 0 {}}
27+
{-constrainedwidth Boolean 0 0}
28+
{-constrainedheight Boolean 0 0}
29+
{-xscrollcommand TkResource "" 0 canvas}
30+
{-yscrollcommand TkResource "" 0 canvas}
31+
{-xscrollincrement TkResource "" 0 canvas}
32+
{-yscrollincrement TkResource "" 0 canvas}
33+
{-bg Synonym -background}
4934
}
5035

5136
Widget::addmap ScrollableFrame "" :cmd {
5237
-width {} -height {}
5338
-xscrollcommand {} -yscrollcommand {}
5439
-xscrollincrement {} -yscrollincrement {}
5540
}
56-
if { ! [Widget::theme]} {
57-
Widget::addmap ScrollableFrame "" .frame {-background {}}
58-
}
5941

6042
variable _widget
6143

6244
bind BwScrollableFrame <Configure> [list ScrollableFrame::_resize %W]
6345
bind BwScrollableFrame <Destroy> [list Widget::destroy %W]
46+
47+
if {[lsearch [bindtags .] ScrollableFrameThemeChanged] < 0} {
48+
bindtags . [linsert [bindtags .] 1 ScrollableFrameThemeChanged]
49+
}
6450
}
6551

6652

@@ -70,21 +56,15 @@ namespace eval ScrollableFrame {
7056
proc ScrollableFrame::create { path args } {
7157
Widget::init ScrollableFrame $path $args
7258

59+
set bg [Widget::cget $path -background]
60+
7361
set canvas [eval [list canvas $path] [Widget::subcget $path :cmd] \
74-
-highlightthickness 0 -borderwidth 0 -relief flat]
75-
76-
if {[Widget::theme]} {
77-
set frame [eval [list ttk::frame $path.frame] \
78-
[Widget::subcget $path .frame]]
79-
set bg [ttk::style lookup TFrame -background]
80-
} else {
81-
set frame [eval [list frame $path.frame] \
82-
[Widget::subcget $path .frame] \
83-
-highlightthickness 0 -borderwidth 0 -relief flat]
84-
set bg [$frame cget -background]
85-
}
86-
# Give canvas frame (or theme) background
87-
$canvas configure -background $bg
62+
-highlightthickness 0 -borderwidth 0 -relief flat \
63+
-bg $bg]
64+
65+
set frame [eval [list frame $path.frame] \
66+
-highlightthickness 0 -borderwidth 0 -relief flat \
67+
-background $bg]
8868

8969
$canvas create window 0 0 -anchor nw -window $frame -tags win \
9070
-width [Widget::cget $path -areawidth] \
@@ -102,6 +82,9 @@ proc ScrollableFrame::create { path args } {
10282

10383
bindtags $path [list $path BwScrollableFrame [winfo toplevel $path] all]
10484

85+
bind ScrollableFrameThemeChanged <<ThemeChanged>> \
86+
"+ [namespace current]::_themechanged $path"
87+
10588
return [Widget::create ScrollableFrame $path]
10689
}
10790

@@ -113,6 +96,11 @@ proc ScrollableFrame::configure { path args } {
11396
set res [Widget::configure $path $args]
11497
set upd 0
11598

99+
if { [Widget::hasChanged $path -background bg] } {
100+
$path:cmd configure -background $bg
101+
$path.frame configure -background $bg
102+
}
103+
116104
set modcw [Widget::hasChanged $path -constrainedwidth cw]
117105
set modw [Widget::hasChanged $path -areawidth w]
118106
if { $modcw || (!$cw && $modw) } {
@@ -260,3 +248,13 @@ proc ScrollableFrame::_frameConfigure {canvas {unmap 0}} {
260248

261249
$canvas:cmd configure -scrollregion [list 0 0 $width $height]
262250
}
251+
252+
# ----------------------------------------------------------------------------
253+
# Command ScrollableFrame::_themechanged
254+
# ----------------------------------------------------------------------------
255+
proc ScrollableFrame::_themechanged { path } {
256+
257+
if { ![winfo exists $path] } { return }
258+
BWidget::set_themedefaults
259+
$path configure -background $BWidget::colors(SystemWindow)
260+
}

scrollview.tcl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# ------------------------------------------------------------------------------
22
# scrollview.tcl
33
# This file is part of Unifix BWidget Toolkit
4-
# $Id: scrollview.tcl,v 1.7 2003/11/05 18:04:29 hobbs Exp $
4+
# $Id: scrollview.tcl,v 1.71 2009/09/06 21:39:24 oberdorfer Exp $
55
# ------------------------------------------------------------------------------
66
# Index of commands:
77
# - ScrolledWindow::create
@@ -25,8 +25,8 @@ namespace eval ScrollView {
2525
Widget::declare ScrollView {
2626
{-width TkResource 30 0 canvas}
2727
{-height TkResource 30 0 canvas}
28-
{-background TkResource "" 0 canvas}
29-
{-foreground String black 0}
28+
{-foreground Color "SystemWindow" 0}
29+
{-background Color "SystemWindowFrame" 0}
3030
{-fill String "" 0}
3131
{-relief TkResource flat 0 canvas}
3232
{-borderwidth TkResource 0 0 canvas}
@@ -49,7 +49,8 @@ namespace eval ScrollView {
4949
# ------------------------------------------------------------------------------
5050
proc ScrollView::create { path args } {
5151
Widget::init ScrollView $path $args
52-
eval [list canvas $path] [Widget::subcget $path :cmd] -highlightthickness 0
52+
eval [list canvas $path] \
53+
[Widget::subcget $path :cmd] -highlightthickness 0
5354

5455
Widget::create ScrollView $path
5556

scrollw.tcl

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
# -----------------------------------------------------------------------------
22
# scrollw.tcl
33
# This file is part of Unifix BWidget Toolkit
4-
# $Id: scrollw.tcl,v 1.13 2009/06/29 13:28:24 oehhar Exp $
4+
# $Id: scrollw.tcl,v 1.14 2009/09/06 21:40:13 oberdorfer Exp $
55
# -----------------------------------------------------------------------------
66
# Index of commands:
77
# - ScrolledWindow::create
88
# - ScrolledWindow::getframe
99
# - ScrolledWindow::setwidget
1010
# - ScrolledWindow::configure
1111
# - ScrolledWindow::cget
12-
# - ScrolledWindow::_set_hframe
12+
# - ScrolledWindow::_set_hscroll
1313
# - ScrolledWindow::_set_vscroll
1414
# - ScrolledWindow::_setData
15-
# - ScrolledWindow::_setSBSize
1615
# - ScrolledWindow::_realize
16+
# - ScrolledWindow::_themechanged
1717
# -----------------------------------------------------------------------------
1818

1919
namespace eval ScrolledWindow {
2020
Widget::define ScrolledWindow scrollw
2121

2222
Widget::declare ScrolledWindow {
23-
{-background TkResource "" 0 button}
23+
{-background Color "SystemWindowFrame" 0}
2424
{-scrollbar Enum both 0 {none both vertical horizontal}}
2525
{-auto Enum both 0 {none both vertical horizontal}}
2626
{-sides Enum se 0 {ne en nw wn se es sw ws}}
@@ -34,6 +34,10 @@ namespace eval ScrolledWindow {
3434
}
3535

3636
Widget::addmap ScrolledWindow "" :cmd {-relief {} -borderwidth {}}
37+
38+
if {[lsearch [bindtags .] ScrolledWindowThemeChanged] < 0} {
39+
bindtags . [linsert [bindtags .] 1 ScrolledWindowThemeChanged]
40+
}
3741
}
3842

3943

@@ -50,18 +54,27 @@ proc ScrolledWindow::create { path args } {
5054
set sw [eval [list frame $path \
5155
-relief flat -borderwidth 0 -background $bg \
5256
-highlightthickness 0 -takefocus 0] \
53-
[Widget::subcget $path :cmd]]
57+
[Widget::subcget $path :cmd]]
58+
59+
if { [BWidget::using ttk] &&
60+
![string equal [tk windowingsystem] "aqua"]} {
61+
62+
ttk::scrollbar $path.vscroll -orient vertical
63+
ttk::scrollbar $path.hscroll -orient horizontal
64+
65+
} else {
5466

55-
scrollbar $path.hscroll \
67+
scrollbar $path.hscroll \
5668
-highlightthickness 0 -takefocus 0 \
5769
-orient horiz \
5870
-relief sunken \
5971
-bg $bg
60-
scrollbar $path.vscroll \
72+
scrollbar $path.vscroll \
6173
-highlightthickness 0 -takefocus 0 \
6274
-orient vert \
6375
-relief sunken \
6476
-bg $bg
77+
}
6578

6679
set data(realized) 0
6780

@@ -77,11 +90,12 @@ proc ScrolledWindow::create { path args } {
7790
set data(hsb,packed) 0
7891
set data(vsb,packed) 0
7992
}
80-
if {$sbsize} {
81-
$path.vscroll configure -width $sbsize
82-
$path.hscroll configure -width $sbsize
83-
} else {
84-
set sbsize [$path.vscroll cget -width]
93+
94+
if { ![BWidget::using ttk] } {
95+
if {$sbsize} {
96+
$path.vscroll configure -width $sbsize
97+
$path.hscroll configure -width $sbsize
98+
}
8599
}
86100
set data(ipad) [Widget::cget $path -ipad]
87101

@@ -100,6 +114,9 @@ proc ScrolledWindow::create { path args } {
100114
bind $path <Configure> [list ScrolledWindow::_realize $path]
101115
bind $path <Destroy> [list ScrolledWindow::_destroy $path]
102116

117+
bind ScrolledWindowThemeChanged <<ThemeChanged>> \
118+
"+ [namespace current]::_themechanged $path"
119+
103120
return [Widget::create ScrolledWindow $path]
104121
}
105122

@@ -142,9 +159,9 @@ proc ScrolledWindow::configure { path args } {
142159

143160
set res [Widget::configure $path $args]
144161
if { [Widget::hasChanged $path -background bg] } {
145-
$path configure -background $bg
146-
catch {$path.hscroll configure -background $bg}
147-
catch {$path.vscroll configure -background $bg}
162+
$path:cmd configure -background $bg
163+
catch { $path.hscroll configure -background $bg }
164+
catch { $path.vscroll configure -background $bg }
148165
}
149166

150167
if {[Widget::hasChanged $path -scrollbar scrollbar] | \
@@ -280,3 +297,13 @@ proc ScrolledWindow::_realize { path } {
280297
proc ScrolledWindow::_destroy { path } {
281298
Widget::destroy $path
282299
}
300+
301+
# ----------------------------------------------------------------------------
302+
# Command ScrolledWindow::_themechanged
303+
# ----------------------------------------------------------------------------
304+
proc ScrolledWindow::_themechanged { path } {
305+
306+
if { ![winfo exists $path] } { return }
307+
BWidget::set_themedefaults
308+
$path configure -background $BWidget::colors(SystemWindowFrame)
309+
}

0 commit comments

Comments
 (0)