summaryrefslogtreecommitdiffstats
path: root/win/tkWinX.c
diff options
context:
space:
mode:
authormdejong <mdejong>2004-09-21 19:13:38 (GMT)
committermdejong <mdejong>2004-09-21 19:13:38 (GMT)
commita25c5763f281dd91e24bcdff1ef95473cca5eb0f (patch)
tree98ecad90de0c4147910bd99028f9dfa862606dad /win/tkWinX.c
parentde82f6faac81acdc141df0474176f05fe79cd24e (diff)
downloadtk-a25c5763f281dd91e24bcdff1ef95473cca5eb0f.zip
tk-a25c5763f281dd91e24bcdff1ef95473cca5eb0f.tar.gz
tk-a25c5763f281dd91e24bcdff1ef95473cca5eb0f.tar.bz2
* generic/tkInt.decls: Add decl for TkWinGetPlatformTheme.
It is only defined under Win32. * generic/tkIntPlatDecls.h: Regen. * generic/tkStubInit.c: Regen. * win/tkWinInt.h: Define TK_THEME_WIN_CLASSIC and TK_THEME_WIN_XP. * win/tkWinMenu.c (DrawMenuEntryAccelerator, DrawMenuEntryLabel): Draw a disabled 3D text highlight for the accelerator only with the Win95/98 look. Same goes for the menu entry text. * win/tkWinX.c (TkWinGetPlatformId, TkWinGetPlatformTheme): Automatically detect the Windows theme in use and return either TK_THEME_WIN_CLASSIC or TK_THEME_WIN_XP when the TkWinGetPlatformTheme function is invoked. [Patch 866194]
Diffstat (limited to 'win/tkWinX.c')
-rw-r--r--win/tkWinX.c57
1 files changed, 56 insertions, 1 deletions
diff --git a/win/tkWinX.c b/win/tkWinX.c
index 60c9f3f..082bfe1 100644
--- a/win/tkWinX.c
+++ b/win/tkWinX.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkWinX.c,v 1.31 2004/07/05 21:21:53 dkf Exp $
+ * RCS: @(#) $Id: tkWinX.c,v 1.32 2004/09/21 19:13:58 mdejong Exp $
*/
#include "tkWinInt.h"
@@ -90,6 +90,7 @@ static HINSTANCE tkInstance = NULL; /* Application instance handle. */
static int childClassInitialized; /* Registered child class? */
static WNDCLASS childClass; /* Window class for child windows. */
static int tkPlatformId = 0; /* version of Windows platform */
+static int tkWinTheme = 0; /* See TkWinGetPlatformTheme */
static Tcl_Encoding keyInputEncoding = NULL;/* The current character
* encoding for keyboard input */
static int keyInputCharset = -1; /* The Win32 CHARSET for the keyboard
@@ -361,6 +362,33 @@ TkWinGetPlatformId()
os.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&os);
tkPlatformId = os.dwPlatformId;
+
+ /* Set tkWinTheme to be TK_THEME_WIN_XP or TK_THEME_WIN_CLASSIC.
+ * The TK_THEME_WIN_CLASSIC could be set even when running
+ * under XP if the windows classic theme was selected. */
+ if ((os.dwPlatformId == VER_PLATFORM_WIN32_NT) &&
+ (os.dwMajorVersion == 5 && os.dwMinorVersion == 1)) {
+ HKEY hKey;
+ LPCSTR szSubKey = TEXT("Control Panel\\Appearance");
+ LPCSTR szCurrent = TEXT("Current");
+ DWORD dwSize = 200;
+ char pBuffer[200];
+ memset(pBuffer, 0, dwSize);
+ if (RegOpenKeyEx(HKEY_CURRENT_USER, szSubKey, 0L,
+ KEY_READ, &hKey) != ERROR_SUCCESS) {
+ tkWinTheme = TK_THEME_WIN_XP;
+ } else {
+ RegQueryValueEx(hKey, szCurrent, NULL, NULL, pBuffer, &dwSize);
+ RegCloseKey(hKey);
+ if (strcmp(pBuffer, "Windows Standard") == 0) {
+ tkWinTheme = TK_THEME_WIN_CLASSIC;
+ } else {
+ tkWinTheme = TK_THEME_WIN_XP;
+ }
+ }
+ } else {
+ tkWinTheme = TK_THEME_WIN_CLASSIC;
+ }
}
return tkPlatformId;
}
@@ -368,6 +396,33 @@ TkWinGetPlatformId()
/*
*----------------------------------------------------------------------
*
+ * TkWinGetPlatformTheme --
+ *
+ * Return the Windows drawing style we should be using.
+ *
+ * Results:
+ * The return value is one of:
+ * TK_THEME_WIN_CLASSIC 95/98/NT or XP in classic mode
+ * TK_THEME_WIN_XP XP not in classic mode
+ *
+ * Side effects:
+ * Could invoke TkWinGetPlatformId.
+ *
+ *----------------------------------------------------------------------
+ */
+
+int
+TkWinGetPlatformTheme()
+{
+ if (tkPlatformId == 0) {
+ TkWinGetPlatformId();
+ }
+ return tkWinTheme;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* TkGetDefaultScreenName --
*
* Returns the name of the screen that Tk should use during