summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--win/tkWin.h17
-rw-r--r--win/tkWinFont.c39
3 files changed, 48 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index 790565f..7bec35f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2007-12-10 Pat Thoyts <patthoyts@users.sourceforge.net>
+ * win/tkWin.h: We must specify the lowest Windows version we
+ intend to support. In particular the SystemParametersInfo API
+ doesn't like to receive structures that are larger than it expects
+ which affects the font assignements. Set to Win98 support.
+
+ * win/tkWinFont.c: Handle failure to read the system parameters.
+ This causes ttk/fonts.tcl to set any missing named fonts.
+
* win/ttkWinMonitor.c: Only tkWin.h should include windows.h
* win/ttkWinTheme.c: unless we have an explicit override of
* tin/ttkWinXPTheme.c: the WINVER macro.
diff --git a/win/tkWin.h b/win/tkWin.h
index 08d6d64..bd1c931 100644
--- a/win/tkWin.h
+++ b/win/tkWin.h
@@ -9,12 +9,27 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWin.h,v 1.13 2005/01/16 00:23:11 chengyemao Exp $
+ * RCS: @(#) $Id: tkWin.h,v 1.14 2007/12/10 12:10:09 patthoyts Exp $
*/
#ifndef _TKWIN
#define _TKWIN
+/*
+ * We must specify the lower version we intend to support. In particular
+ * the SystemParametersInfo API doesn't like to receive structures that
+ * are larger than it expects which affects the font assignements.
+ *
+ * WINVER = 0x0410 means Windows 98 and above
+ */
+
+#ifndef WINVER
+#define WINVER 0x0410
+#endif
+#ifndef _WIN32_WINDOWS
+#define _WIN32_WINDOWS 0x0410
+#endif
+
#ifndef _TK
#include <tk.h>
#endif
diff --git a/win/tkWinFont.c b/win/tkWinFont.c
index aae69a8..383cdf3 100644
--- a/win/tkWinFont.c
+++ b/win/tkWinFont.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinFont.c,v 1.36 2007/11/17 21:55:09 patthoyts Exp $
+ * RCS: @(#) $Id: tkWinFont.c,v 1.37 2007/12/10 12:10:10 patthoyts Exp $
*/
#include "tkWinInt.h"
@@ -336,7 +336,7 @@ CreateNamedSystemLogFont(
Tcl_Interp *interp,
Tk_Window tkwin,
CONST char* name,
- LOGFONT* logFontPtr)
+ LOGFONTA* logFontPtr)
{
HFONT hFont;
int r;
@@ -406,30 +406,39 @@ TkWinSetupSystemFonts(TkMainInfo *mainPtr)
((TkWindow *) tkwin)->mainPtr = mainPtr;
}
- ncMetrics.cbSize = sizeof(ncMetrics);
- SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(ncMetrics),
- &ncMetrics, 0);
+ /*
+ * If this API call fails then we will fallback to setting these
+ * named fonts from script in ttk/fonts.tcl. So far I've only
+ * seen it fail when WINVER has been defined for a higher platform than
+ * we are running on. (ie: WINVER=0x0600 and running on XP).
+ */
- CreateNamedSystemLogFont(interp, tkwin, "TkDefaultFont",
+ ZeroMemory(&ncMetrics, sizeof(ncMetrics));
+ ncMetrics.cbSize = sizeof(ncMetrics);
+ if (SystemParametersInfo(SPI_GETNONCLIENTMETRICS,
+ sizeof(ncMetrics), &ncMetrics, 0)) {
+ CreateNamedSystemLogFont(interp, tkwin, "TkDefaultFont",
&ncMetrics.lfMessageFont);
- CreateNamedSystemLogFont(interp, tkwin, "TkHeadingFont",
+ CreateNamedSystemLogFont(interp, tkwin, "TkHeadingFont",
&ncMetrics.lfMessageFont);
- CreateNamedSystemLogFont(interp, tkwin, "TkTextFont",
+ CreateNamedSystemLogFont(interp, tkwin, "TkTextFont",
&ncMetrics.lfMessageFont);
- CreateNamedSystemLogFont(interp, tkwin, "TkMenuFont",
+ CreateNamedSystemLogFont(interp, tkwin, "TkMenuFont",
&ncMetrics.lfMenuFont);
- CreateNamedSystemLogFont(interp, tkwin, "TkTooltipFont",
+ CreateNamedSystemLogFont(interp, tkwin, "TkTooltipFont",
&ncMetrics.lfStatusFont);
- CreateNamedSystemLogFont(interp, tkwin, "TkCaptionFont",
+ CreateNamedSystemLogFont(interp, tkwin, "TkCaptionFont",
&ncMetrics.lfCaptionFont);
- CreateNamedSystemLogFont(interp, tkwin, "TkSmallCaptionFont",
+ CreateNamedSystemLogFont(interp, tkwin, "TkSmallCaptionFont",
&ncMetrics.lfSmCaptionFont);
+ }
iconMetrics.cbSize = sizeof(iconMetrics);
- SystemParametersInfo(SPI_GETICONMETRICS, sizeof(iconMetrics),
- &iconMetrics, 0);
- CreateNamedSystemLogFont(interp, tkwin, "TkIconFont",
+ if (SystemParametersInfo(SPI_GETICONMETRICS, sizeof(iconMetrics),
+ &iconMetrics, 0)) {
+ CreateNamedSystemLogFont(interp, tkwin, "TkIconFont",
&iconMetrics.lfFont);
+ }
hFont = (HFONT)GetStockObject(ANSI_FIXED_FONT);
CreateNamedSystemFont(interp, tkwin, "TkFixedFont", hFont);