summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpatthoyts <patthoyts@users.sourceforge.net>2008-12-05 11:11:58 (GMT)
committerpatthoyts <patthoyts@users.sourceforge.net>2008-12-05 11:11:58 (GMT)
commitf6cf2b9418bcce56c89cf0efd5898654fb97a883 (patch)
treeaf22b463f856458435174e7d6c4ad80587a248cc
parentfc57686bf62443a7e6aa417dc6e3c81d245bfcfa (diff)
downloadtk-f6cf2b9418bcce56c89cf0efd5898654fb97a883.zip
tk-f6cf2b9418bcce56c89cf0efd5898654fb97a883.tar.gz
tk-f6cf2b9418bcce56c89cf0efd5898654fb97a883.tar.bz2
Added vista theme to iron out the visual differences between vista and XP.
-rw-r--r--ChangeLog7
-rw-r--r--library/ttk/ttk.tcl16
-rw-r--r--library/ttk/vistaTheme.tcl204
-rw-r--r--library/ttk/xpTheme.tcl47
-rw-r--r--win/ttkWinXPTheme.c21
5 files changed, 240 insertions, 55 deletions
diff --git a/ChangeLog b/ChangeLog
index 4f1cb2b..cad8740 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008-12-05 Pat Thoyts <patthoyts@users.sourceforge.net>
+
+ * library/ttk/ttk.tcl: Added vista theme to iron out the visual
+ * library/ttk/vistaTheme.tcl: differences between vista and XP.
+ * library/ttk/xpTheme.tcl:
+ * win/ttkWinXPTheme.c:
+
2008-12-05 Donal K. Fellows <dkf@users.sf.net>
* generic/tkCanvPs.c (Tk_PostscriptFont): Ensure that font sizes can
diff --git a/library/ttk/ttk.tcl b/library/ttk/ttk.tcl
index 8bc1478..6b859b6 100644
--- a/library/ttk/ttk.tcl
+++ b/library/ttk/ttk.tcl
@@ -1,5 +1,5 @@
#
-# $Id: ttk.tcl,v 1.9 2008/11/01 15:34:24 patthoyts Exp $
+# $Id: ttk.tcl,v 1.10 2008/12/05 11:11:58 patthoyts Exp $
#
# Ttk widget set initialization script.
#
@@ -124,16 +124,18 @@ proc ttk::LoadThemes {} {
uplevel #0 [list source [file join $library defaults.tcl]]
set builtinThemes [style theme names]
- foreach {theme script} {
+ foreach {theme scripts} {
classic classicTheme.tcl
alt altTheme.tcl
clam clamTheme.tcl
winnative winTheme.tcl
- xpnative xpTheme.tcl
+ xpnative {xpTheme.tcl vistaTheme.tcl}
aqua aquaTheme.tcl
} {
if {[lsearch -exact $builtinThemes $theme] >= 0} {
- uplevel #0 [list source [file join $library $script]]
+ foreach script $scripts {
+ uplevel #0 [list source [file join $library $script]]
+ }
}
}
}
@@ -151,17 +153,17 @@ ttk::LoadThemes; rename ::ttk::LoadThemes {}
#
proc ttk::DefaultTheme {} {
- set preferred [list aqua xpnative winnative]
+ set preferred [list aqua vista xpnative winnative]
set userTheme [option get . tkTheme TkTheme]
- if {$userTheme != {} && ![catch {
+ if {$userTheme ne {} && ![catch {
uplevel #0 [list package require ttk::theme::$userTheme]
}]} {
return $userTheme
}
foreach theme $preferred {
- if {[package provide ttk::theme::$theme] != ""} {
+ if {[package provide ttk::theme::$theme] ne ""} {
return $theme
}
}
diff --git a/library/ttk/vistaTheme.tcl b/library/ttk/vistaTheme.tcl
new file mode 100644
index 0000000..d8f9cbc
--- /dev/null
+++ b/library/ttk/vistaTheme.tcl
@@ -0,0 +1,204 @@
+#
+# Settings for Microsoft Windows Vista and Server 2008
+#
+
+# The Vista theme can only be defined on Windows Vista and above. The theme
+# is created in C due to the need to assign a theme-enabled function for
+# detecting when themeing is disabled. On systems that cannot support the
+# Vista theme, there will be no such theme created and we must not
+# evaluate this script.
+
+if {"vista" ni [ttk::style theme names]} {
+ return
+}
+
+namespace eval ttk::theme::vista {
+
+ ttk::style theme settings vista {
+
+ ttk::style configure . \
+ -background SystemButtonFace \
+ -foreground SystemWindowText \
+ -selectforeground SystemHighlightText \
+ -selectbackground SystemHighlight \
+ -font TkDefaultFont \
+ ;
+
+ ttk::style map "." \
+ -foreground [list disabled SystemGrayText] \
+ ;
+
+ ttk::style configure TButton -anchor center -padding {1 1} -width -11
+ ttk::style configure TRadiobutton -padding 2
+ ttk::style configure TCheckbutton -padding 2
+ ttk::style configure TMenubutton -padding {8 4}
+
+ ttk::style configure TNotebook -tabmargins {2 2 2 0}
+ ttk::style map TNotebook.Tab \
+ -expand [list selected {2 2 2 2}]
+
+ # Treeview:
+ ttk::style configure Heading -font TkHeadingFont
+ ttk::style configure Treeview -background SystemWindow
+ ttk::style map Treeview \
+ -background [list selected SystemHighlight] \
+ -foreground [list selected SystemHighlightText] ;
+
+ # Label and Toolbutton
+ ttk::style configure TLabelframe.Label -foreground "#0046d5"
+
+ ttk::style configure Toolbutton -padding {4 4}
+
+ # Combobox
+ ttk::style configure TCombobox -padding 2
+ ttk::style element create Combobox.field vsapi \
+ COMBOBOX 2 {{} 1}
+ ttk::style element create Combobox.border vsapi \
+ COMBOBOX 4 {disabled 4 focus 3 active 2 hover 2 {} 1}
+ ttk::style element create Combobox.rightdownarrow vsapi \
+ COMBOBOX 6 {disabled 4 pressed 3 active 2 {} 1}
+ ttk::style layout TCombobox {
+ Combobox.border -sticky nswe -border 0 -children {
+ Combobox.rightdownarrow -side right -sticky ns
+ Combobox.padding -expand 1 -sticky nswe -children {
+ Combobox.focus -expand 1 -sticky nswe -children {
+ Combobox.textarea -sticky nswe
+ }
+ }
+ }
+ }
+ # Vista.Combobox droplist frame
+ ttk::style element create ComboboxPopdownFrame.background vsapi\
+ LISTBOX 3 {disabled 4 active 3 focus 2 {} 1}
+ ttk::style layout ComboboxPopdownFrame {
+ ComboboxPopdownFrame.background -sticky news -border 1 -children {
+ ComboboxPopdownFrame.padding -sticky news
+ }
+ }
+ ttk::style map TCombobox \
+ -selectbackground [list !focus SystemWindow] \
+ -selectforeground [list !focus SystemWindowText] \
+ -foreground [list {readonly focus} SystemHighlightText] \
+ -focusfill [list {readonly focus} SystemHighlight] \
+ ;
+
+ # Entry
+ ttk::style configure TEntry -padding {1 1 1 1} ;# Needs lookup
+ ttk::style element create Entry.field vsapi \
+ EDIT 6 {disabled 4 focus 3 hover 2 {} 1} -padding {2 2 2 2}
+ ttk::style element create Entry.background vsapi \
+ EDIT 3 {disabled 3 readonly 3 focus 4 hover 2 {} 1}
+ ttk::style layout TEntry {
+ Entry.field -sticky news -border 0 -children {
+ Entry.background -sticky news -children {
+ Entry.padding -sticky news -children {
+ Entry.textarea -sticky news
+ }
+ }
+ }
+ }
+ ttk::style map TEntry \
+ -selectbackground [list !focus SystemWindow] \
+ -selectforeground [list !focus SystemWindowText] \
+ ;
+
+ # Spinbox
+ ttk::style configure TSpinbox -padding 0 ;#{2 0 15 1}
+ ttk::style element create Spinbox.field vsapi \
+ EDIT 9 {disabled 4 focus 3 hover 2 {} 1} -padding {1 1 1 2}
+ ttk::style element create Spinbox.background vsapi \
+ EDIT 3 {disabled 3 readonly 3 focus 4 hover 2 {} 1}
+ ttk::style element create Spinbox.innerbg vsapi \
+ EDIT 3 {disabled 3 readonly 3 focus 4 hover 2 {} 1}\
+ -padding {2 0 15 1}
+ ttk::style element create Spinbox.uparrow vsapi \
+ SPIN 1 {disabled 4 pressed 3 active 2 {} 1} \
+ -height 5 -width 8
+ ttk::style element create Spinbox.downarrow vsapi \
+ SPIN 2 {disabled 4 pressed 3 active 2 {} 1} \
+ -height 5 -width 8
+ ttk::style layout TSpinbox {
+ Spinbox.field -sticky nswe -children {
+ Spinbox.background -sticky news -children {
+ Spinbox.padding -sticky news -children {
+ Spinbox.innerbg -sticky news -children {
+ Spinbox.textarea -expand 1 -sticky {}
+ }
+ }
+ Spinbox.uparrow -side top -sticky ens
+ Spinbox.downarrow -side bottom -sticky ens
+ }
+ }
+ }
+ ttk::style map TSpinbox \
+ -selectbackground [list !focus SystemWindow] \
+ -selectforeground [list !focus SystemWindowText] \
+ ;
+
+
+ # SCROLLBAR elements (Vista includes a state for 'hover')
+ ttk::style element create Vertical.Scrollbar.uparrow vsapi \
+ SCROLLBAR 1 {disabled 4 pressed 3 active 2 hover 17 {} 1}
+ ttk::style element create Vertical.Scrollbar.downarrow vsapi \
+ SCROLLBAR 1 {disabled 8 pressed 7 active 6 hover 18 {} 5}
+ ttk::style element create Vertical.Scrollbar.trough vsapi \
+ SCROLLBAR 7 {disabled 4 pressed 3 active 2 hover 5 {} 1}
+ ttk::style element create Vertical.Scrollbar.thumb vsapi \
+ SCROLLBAR 3 {disabled 4 pressed 3 active 2 hover 5 {} 1}
+ ttk::style element create Vertical.Scrollbar.grip vsapi \
+ SCROLLBAR 9 {disabled 4 pressed 3 active 2 hover 5 {} 1}
+ ttk::style element create Horizontal.Scrollbar.leftarrow vsapi \
+ SCROLLBAR 1 {disabled 12 pressed 11 active 10 hover 19 {} 9}
+ ttk::style element create Horizontal.Scrollbar.rightarrow vsapi \
+ SCROLLBAR 1 {disabled 16 pressed 15 active 14 hover 20 {} 13}
+ ttk::style element create Horizontal.Scrollbar.trough vsapi \
+ SCROLLBAR 5 {disabled 4 pressed 3 active 2 hover 5 {} 1}
+ ttk::style element create Horizontal.Scrollbar.thumb vsapi \
+ SCROLLBAR 2 {disabled 4 pressed 3 active 2 hover 5 {} 1}
+ ttk::style element create Horizontal.Scrollbar.grip vsapi \
+ SCROLLBAR 8 {disabled 4 pressed 3 active 2 hover 5 {} 1}
+
+ # Progressbar
+ ttk::style element create Horizontal.Progressbar.pbar vsapi \
+ PROGRESS 3 {{} 1} -padding 8
+ ttk::style layout Horizontal.TProgressbar {
+ Horizontal.Progressbar.trough -sticky nswe -children {
+ Horizontal.Progressbar.pbar -side left -sticky ns
+ }
+ }
+ ttk::style element create Vertical.Progressbar.pbar vsapi \
+ PROGRESS 3 {{} 1} -padding 8
+ ttk::style layout Vertical.TProgressbar {
+ Vertical.Progressbar.trough -sticky nswe -children {
+ Vertical.Progressbar.pbar -side bottom -sticky we
+ }
+ }
+
+ # Scale
+ ttk::style element create Horizontal.Scale.slider vsapi \
+ TRACKBAR 3 {disabled 5 focus 4 pressed 3 active 2 {} 1} \
+ -width 6 -height 12
+ ttk::style layout Horizontal.TScale {
+ Scale.focus -expand 1 -sticky nswe -children {
+ Horizontal.Scale.trough -expand 1 -sticky nswe -children {
+ Horizontal.Scale.track -sticky we
+ Horizontal.Scale.slider -side left -sticky {}
+ }
+ }
+ }
+ ttk::style element create Vertical.Scale.slider vsapi \
+ TRACKBAR 6 {disabled 5 focus 4 pressed 3 active 2 {} 1} \
+ -width 12 -height 6
+ ttk::style layout Vertical.TScale {
+ Scale.focus -expand 1 -sticky nswe -children {
+ Vertical.Scale.trough -expand 1 -sticky nswe -children {
+ Vertical.Scale.track -sticky ns
+ Vertical.Scale.slider -side top -sticky {}
+ }
+ }
+ }
+
+
+ package provide ttk::theme::vista 1.0
+ }
+} \ No newline at end of file
diff --git a/library/ttk/xpTheme.tcl b/library/ttk/xpTheme.tcl
index 07df1d9..d786841 100644
--- a/library/ttk/xpTheme.tcl
+++ b/library/ttk/xpTheme.tcl
@@ -1,5 +1,5 @@
#
-# $Id: xpTheme.tcl,v 1.11 2008/11/29 00:43:48 patthoyts Exp $
+# $Id: xpTheme.tcl,v 1.12 2008/12/05 11:11:58 patthoyts Exp $
#
# Settings for 'xpnative' theme
#
@@ -60,50 +60,5 @@ namespace eval ttk::theme::xpnative {
ttk::style configure Toolbutton -padding {4 4}
- # Vista requires some style modifications. There are some
- # additional or different elements in use.
- if {[tk windowingsystem] eq "win32"
- && [info exists tcl_platform(osVersion)]
- && $tcl_platform(osVersion) >= 6.0} {
-
- ttk::style element create Combobox.field vsapi \
- COMBOBOX 2 {{} 1}
- ttk::style element create Combobox.border vsapi \
- COMBOBOX 4 {disabled 4 focus 3 active 2 {} 1}
- ttk::style element create Combobox.rightdownarrow vsapi \
- COMBOBOX 6 {disabled 4 pressed 3 active 2 {} 1}
- ttk::style layout TCombobox {
- Combobox.border -sticky nswe -border 0 -children {
- Combobox.rightdownarrow -side right -sticky ns
- Combobox.padding -expand 1 -sticky nswe -children {
- Combobox.focus -expand 1 -sticky nswe -children {
- Combobox.textarea -sticky nswe
- }
- }
- }
- }
- ttk::style element create ComboboxPopdownFrame.background vsapi\
- COMBOBOX 2
- ttk::style layout ComboboxPopdownFrame {
- ComboboxPopdownFrame.background -sticky news -border 1 -children {
- ComboboxPopdownFrame.padding -sticky news
- }
- }
-
- # EDIT EP_EDITBORDER_HVSCROLL
- ttk::style configure TSpinbox -padding {2 0 15 1}
- ttk::style element create Vista.Spinbox.field vsapi \
- EDIT 9 {disabled 4 focus 3 active 2 {} 1} \
- -padding {1 1 1 2}
- ttk::style layout TSpinbox {
- Vista.Spinbox.field -sticky nswe -children {
- Spinbox.padding -sticky nswe -children {
- Spinbox.textarea -expand 1 -sticky {}
- }
- Spinbox.uparrow -side top -sticky ens
- Spinbox.downarrow -side bottom -sticky ens
- }
- }
- }
}
}
diff --git a/win/ttkWinXPTheme.c b/win/ttkWinXPTheme.c
index 27416e0..2f5648f 100644
--- a/win/ttkWinXPTheme.c
+++ b/win/ttkWinXPTheme.c
@@ -1,5 +1,5 @@
/*
- * $Id: ttkWinXPTheme.c,v 1.21 2008/11/01 15:34:24 patthoyts Exp $
+ * $Id: ttkWinXPTheme.c,v 1.22 2008/12/05 11:11:58 patthoyts Exp $
*
* Tk theme engine which uses the Windows XP "Visual Styles" API
* Adapted from Georgios Petasis' XP theme patch.
@@ -258,6 +258,7 @@ static Ttk_StateTable combobox_statemap[] = {
{ CBXS_DISABLED, TTK_STATE_DISABLED, 0 },
{ CBXS_PRESSED, TTK_STATE_PRESSED, 0 },
{ CBXS_HOT, TTK_STATE_ACTIVE, 0 },
+ { CBXS_HOT, TTK_STATE_HOVER, 0 },
{ CBXS_NORMAL, 0, 0 }
};
@@ -1175,8 +1176,12 @@ MODULE_SCOPE int TtkXPTheme_Init(Tcl_Interp *interp, HWND hwnd)
XPThemeData *themeData;
XPThemeProcs *procs;
HINSTANCE hlibrary;
- Ttk_Theme themePtr, parentPtr;
+ Ttk_Theme themePtr, parentPtr, vistaPtr;
ElementInfo *infoPtr;
+ OSVERSIONINFO os;
+
+ os.dwOSVersionInfoSize = sizeof(os);
+ GetVersionEx(&os);
procs = LoadXPThemeProcs(&hlibrary);
if (!procs)
@@ -1205,6 +1210,18 @@ MODULE_SCOPE int TtkXPTheme_Init(Tcl_Interp *interp, HWND hwnd)
Ttk_RegisterElementFactory(interp, "vsapi", Ttk_CreateVsapiElement, themeData);
/*
+ * Create the vista theme on suitable platform versions and set the theme
+ * enable function. The theme itself is defined in script.
+ */
+
+ if (os.dwPlatformId == VER_PLATFORM_WIN32_NT && os.dwMajorVersion > 5) {
+ vistaPtr = Ttk_CreateTheme(interp, "vista", themePtr);
+ if (vistaPtr) {
+ Ttk_SetThemeEnabledProc(vistaPtr, XPThemeEnabled, themeData);
+ }
+ }
+
+ /*
* New elements:
*/
for (infoPtr = ElementInfoTable; infoPtr->elementName != 0; ++infoPtr) {