diff options
-rw-r--r-- | ChangeLog | 17 | ||||
-rw-r--r-- | generic/tkInt.decls | 6 | ||||
-rw-r--r-- | generic/tkIntPlatDecls.h | 12 | ||||
-rw-r--r-- | generic/tkStubInit.c | 3 | ||||
-rw-r--r-- | win/tkWinInt.h | 8 | ||||
-rw-r--r-- | win/tkWinMenu.c | 57 | ||||
-rw-r--r-- | win/tkWinX.c | 57 |
7 files changed, 130 insertions, 30 deletions
@@ -1,5 +1,22 @@ 2004-09-21 Mo DeJong <mdejong@users.sourceforge.net> + * 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] + +2004-09-21 Mo DeJong <mdejong@users.sourceforge.net> + * win/tkWinWm.c: Rework WS_EX_LAYERED and LWA_ALPHA defines so that compiling with mingw works again. diff --git a/generic/tkInt.decls b/generic/tkInt.decls index 12a560d..f88b670 100644 --- a/generic/tkInt.decls +++ b/generic/tkInt.decls @@ -9,7 +9,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: tkInt.decls,v 1.36 2004/08/19 14:41:52 dkf Exp $ +# RCS: @(#) $Id: tkInt.decls,v 1.37 2004/09/21 19:13:56 mdejong Exp $ library tk @@ -855,6 +855,10 @@ declare 34 win { void TkWinSetHINSTANCE (HINSTANCE hInstance) } +declare 35 win { + int TkWinGetPlatformTheme (void) +} + ######################## # Mac OS X specific functions diff --git a/generic/tkIntPlatDecls.h b/generic/tkIntPlatDecls.h index ebed2ae..e83cf84 100644 --- a/generic/tkIntPlatDecls.h +++ b/generic/tkIntPlatDecls.h @@ -9,7 +9,7 @@ * Copyright (c) 1998-1999 by Scriptics Corporation. * All rights reserved. * - * RCS: @(#) $Id: tkIntPlatDecls.h,v 1.17 2004/03/17 18:15:43 das Exp $ + * RCS: @(#) $Id: tkIntPlatDecls.h,v 1.18 2004/09/21 19:13:57 mdejong Exp $ */ #ifndef _TKINTPLATDECLS @@ -225,6 +225,11 @@ EXTERN int TkWinGetPlatformId _ANSI_ARGS_((void)); /* 34 */ EXTERN void TkWinSetHINSTANCE _ANSI_ARGS_((HINSTANCE hInstance)); #endif +#ifndef TkWinGetPlatformTheme_TCL_DECLARED +#define TkWinGetPlatformTheme_TCL_DECLARED +/* 35 */ +EXTERN int TkWinGetPlatformTheme _ANSI_ARGS_((void)); +#endif #endif /* __WIN32__ */ #ifdef MAC_OSX_TK #ifndef TkGenerateActivateEvents_TCL_DECLARED @@ -605,6 +610,7 @@ typedef struct TkIntPlatStubs { Tcl_Obj * (*tkWinGetMenuSystemDefault) _ANSI_ARGS_((Tk_Window tkwin, CONST char * dbName, CONST char * className)); /* 32 */ int (*tkWinGetPlatformId) _ANSI_ARGS_((void)); /* 33 */ void (*tkWinSetHINSTANCE) _ANSI_ARGS_((HINSTANCE hInstance)); /* 34 */ + int (*tkWinGetPlatformTheme) _ANSI_ARGS_((void)); /* 35 */ #endif /* __WIN32__ */ #ifdef MAC_OSX_TK void (*tkGenerateActivateEvents) _ANSI_ARGS_((TkWindow * winPtr, int active)); /* 0 */ @@ -831,6 +837,10 @@ extern TkIntPlatStubs *tkIntPlatStubsPtr; #define TkWinSetHINSTANCE \ (tkIntPlatStubsPtr->tkWinSetHINSTANCE) /* 34 */ #endif +#ifndef TkWinGetPlatformTheme +#define TkWinGetPlatformTheme \ + (tkIntPlatStubsPtr->tkWinGetPlatformTheme) /* 35 */ +#endif #endif /* __WIN32__ */ #ifdef MAC_OSX_TK #ifndef TkGenerateActivateEvents diff --git a/generic/tkStubInit.c b/generic/tkStubInit.c index 8ba750d..bc3761f 100644 --- a/generic/tkStubInit.c +++ b/generic/tkStubInit.c @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkStubInit.c,v 1.45 2004/08/19 14:43:43 dkf Exp $ + * RCS: @(#) $Id: tkStubInit.c,v 1.46 2004/09/21 19:13:57 mdejong Exp $ */ #include "tkInt.h" @@ -335,6 +335,7 @@ TkIntPlatStubs tkIntPlatStubs = { TkWinGetMenuSystemDefault, /* 32 */ TkWinGetPlatformId, /* 33 */ TkWinSetHINSTANCE, /* 34 */ + TkWinGetPlatformTheme, /* 35 */ #endif /* __WIN32__ */ #ifdef MAC_OSX_TK TkGenerateActivateEvents, /* 0 */ diff --git a/win/tkWinInt.h b/win/tkWinInt.h index 948bb94..0d14a0d 100644 --- a/win/tkWinInt.h +++ b/win/tkWinInt.h @@ -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: tkWinInt.h,v 1.17 2004/09/17 23:26:21 hobbs Exp $ + * RCS: @(#) $Id: tkWinInt.h,v 1.18 2004/09/21 19:13:58 mdejong Exp $ */ #ifndef _TKWININT @@ -210,5 +210,11 @@ EXTERN TkWinProcs *tkWinProcs; extern Tcl_Encoding TkWinGetKeyInputEncoding _ANSI_ARGS_((void)); extern Tcl_Encoding TkWinGetUnicodeEncoding _ANSI_ARGS_((void)); +/* + * Values returned by TkWinGetPlatformTheme. + */ +#define TK_THEME_WIN_CLASSIC 1 +#define TK_THEME_WIN_XP 2 + #endif /* _TKWININT */ diff --git a/win/tkWinMenu.c b/win/tkWinMenu.c index ad55904..677b090 100644 --- a/win/tkWinMenu.c +++ b/win/tkWinMenu.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkWinMenu.c,v 1.35 2004/09/03 14:09:05 dkf Exp $ + * RCS: @(#) $Id: tkWinMenu.c,v 1.36 2004/09/21 19:13:58 mdejong Exp $ */ #define OEMRESOURCE @@ -1602,15 +1602,17 @@ DrawMenuEntryIndicator(menuPtr, mePtr, d, gc, indicatorGC, tkfont, fmPtr, x, * * DrawMenuEntryAccelerator -- * - * This procedure draws the accelerator part of a menu. We - * need to decide what to draw here. Should we replace strings + * This procedure draws the accelerator part of a menu. + * For example, the string "CTRL-Z" could be drawn to + * to the right of the label text for an Undo menu entry. + * Need to decide what to draw here. Should we replace strings * like "Control", "Command", etc? * * Results: * None. * * Side effects: - * Commands are output to X to display the menu in its + * Commands are output to display the menu in its * current mode. * *---------------------------------------------------------------------- @@ -1641,18 +1643,21 @@ DrawMenuEntryAccelerator(menuPtr, mePtr, d, gc, tkfont, fmPtr, baseline = y + (height + fmPtr->ascent - fmPtr->descent) / 2; - if ((mePtr->state == ENTRY_DISABLED) && (menuPtr->disabledFgPtr != NULL) - && (mePtr->accelPtr != NULL)) { - COLORREF oldFgColor = gc->foreground; + /* Draw disabled 3D text highlight only with the Win95/98 look. */ - gc->foreground = GetSysColor(COLOR_3DHILIGHT); - if ((mePtr->accelPtr != NULL) && - ((mePtr->entryFlags & ENTRY_PLATFORM_FLAG1) == 0)) { - Tk_DrawChars(menuPtr->display, d, gc, tkfont, accel, - mePtr->accelLength, leftEdge + 1, baseline + 1); - } + if (TkWinGetPlatformTheme() == TK_THEME_WIN_CLASSIC) { + if ((mePtr->state == ENTRY_DISABLED) && (menuPtr->disabledFgPtr != NULL) + && (mePtr->accelPtr != NULL)) { + COLORREF oldFgColor = gc->foreground; - gc->foreground = oldFgColor; + gc->foreground = GetSysColor(COLOR_3DHILIGHT); + if ((mePtr->accelPtr != NULL) && + ((mePtr->entryFlags & ENTRY_PLATFORM_FLAG1) == 0)) { + Tk_DrawChars(menuPtr->display, d, gc, tkfont, accel, + mePtr->accelLength, leftEdge + 1, baseline + 1); + } + gc->foreground = oldFgColor; + } } if (mePtr->accelPtr != NULL) { @@ -2182,16 +2187,18 @@ DrawMenuEntryLabel( if (mePtr->labelLength > 0) { int baseline = y + (height + fmPtr->ascent - fmPtr->descent) / 2; char *label = Tcl_GetStringFromObj(mePtr->labelPtr, NULL); - /* Win 95/98 systems draw disabled menu text with a - * 3D highlight, unless the menu item is highlighted */ - if ((mePtr->state == ENTRY_DISABLED) && - ((mePtr->entryFlags & ENTRY_PLATFORM_FLAG1) == 0)){ - COLORREF oldFgColor = gc->foreground; - gc->foreground = GetSysColor(COLOR_3DHILIGHT); - Tk_DrawChars(menuPtr->display, d, gc, tkfont, label, - mePtr->labelLength, leftEdge + textXOffset + 1, - baseline + textYOffset + 1); - gc->foreground = oldFgColor; + if (TkWinGetPlatformTheme() == TK_THEME_WIN_CLASSIC) { + /* Win 95/98 systems draw disabled menu text with a + * 3D highlight, unless the menu item is highlighted */ + if ((mePtr->state == ENTRY_DISABLED) && + ((mePtr->entryFlags & ENTRY_PLATFORM_FLAG1) == 0)) { + COLORREF oldFgColor = gc->foreground; + gc->foreground = GetSysColor(COLOR_3DHILIGHT); + Tk_DrawChars(menuPtr->display, d, gc, tkfont, label, + mePtr->labelLength, leftEdge + textXOffset + 1, + baseline + textYOffset + 1); + gc->foreground = oldFgColor; + } } Tk_DrawChars(menuPtr->display, d, gc, tkfont, label, mePtr->labelLength, leftEdge + textXOffset, @@ -2199,7 +2206,7 @@ DrawMenuEntryLabel( DrawMenuUnderline(menuPtr, mePtr, d, gc, tkfont, fmPtr, x + textXOffset, y + textYOffset, width, height); - } + } } if (mePtr->state == ENTRY_DISABLED) { 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 |