diff options
author | nijtmans <nijtmans> | 2010-02-16 21:12:56 (GMT) |
---|---|---|
committer | nijtmans <nijtmans> | 2010-02-16 21:12:56 (GMT) |
commit | 98ad94bf967f4567ae47c4b74ffe11cc12f7d22f (patch) | |
tree | b566e3894b84ff71cec41746404929097ffb61c6 /win | |
parent | 759424b1be09259bf20d269efd93af21c5150a01 (diff) | |
download | tk-98ad94bf967f4567ae47c4b74ffe11cc12f7d22f.zip tk-98ad94bf967f4567ae47c4b74ffe11cc12f7d22f.tar.gz tk-98ad94bf967f4567ae47c4b74ffe11cc12f7d22f.tar.bz2 |
tkWindow.c/tkStubInit.c adapted from stub changes in Tcl
tkArgv.c make defaultTable const
tkScrollbar.c Store default for "-with" in static non-const memory
tkWinInt.h make tkWinProcs const, and 5
tkWinX.c procs MODULE_SCOPE
tkWinColor.c make sysColors const
tkWinKey.c make keymap const
tkWinScrlbr.c Simplify copying of "-with" default value.
tkUnixWm.c make TkSetTransientFor static
tests/textImage.test textImage-1.13 depends on hash-order
Diffstat (limited to 'win')
-rw-r--r-- | win/tkWinColor.c | 45 | ||||
-rw-r--r-- | win/tkWinInt.h | 39 | ||||
-rw-r--r-- | win/tkWinKey.c | 4 | ||||
-rw-r--r-- | win/tkWinScrlbr.c | 22 | ||||
-rw-r--r-- | win/tkWinX.c | 62 |
5 files changed, 68 insertions, 104 deletions
diff --git a/win/tkWinColor.c b/win/tkWinColor.c index e0d763f..1b75a94 100644 --- a/win/tkWinColor.c +++ b/win/tkWinColor.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: tkWinColor.c,v 1.13 2009/01/28 20:47:49 nijtmans Exp $ + * RCS: @(#) $Id: tkWinColor.c,v 1.14 2010/02/16 21:12:56 nijtmans Exp $ */ #include "tkWinInt.h" @@ -37,7 +37,7 @@ typedef struct { int index; } SystemColorEntry; -static SystemColorEntry sysColors[] = { +static const SystemColorEntry sysColors[] = { {"3dDarkShadow", COLOR_3DDKSHADOW}, {"3dLight", COLOR_3DLIGHT}, {"ActiveBorder", COLOR_ACTIVEBORDER}, @@ -64,7 +64,6 @@ static SystemColorEntry sysColors[] = { {"Window", COLOR_WINDOW}, {"WindowFrame", COLOR_WINDOWFRAME}, {"WindowText", COLOR_WINDOWTEXT}, - {NULL, 0} }; typedef struct ThreadSpecificData { @@ -104,37 +103,15 @@ FindSystemColor( int *indexPtr) /* Out parameter to store color index. */ { int l, u, r, i; - ThreadSpecificData *tsdPtr = (ThreadSpecificData *) - Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); - - /* - * Count the number of elements in the color array if we haven't done so - * yet. - */ - - if (tsdPtr->ncolors == 0) { - SystemColorEntry *ePtr; - int version; - - version = LOBYTE(LOWORD(GetVersion())); - for (ePtr = sysColors; ePtr->name != NULL; ePtr++) { - if (version < 4) { - if (ePtr->index == COLOR_3DDKSHADOW) { - ePtr->index = COLOR_BTNSHADOW; - } else if (ePtr->index == COLOR_3DLIGHT) { - ePtr->index = COLOR_BTNHIGHLIGHT; - } - } - tsdPtr->ncolors++; - } - } + int index; + int version = LOBYTE(LOWORD(GetVersion())); /* * Perform a binary search on the sorted array of colors. */ l = 0; - u = tsdPtr->ncolors - 1; + u = (sizeof(sysColors) / sizeof(sysColors[0])) - 1; while (l <= u) { i = (l + u) / 2; r = strcasecmp(name, sysColors[i].name); @@ -150,8 +127,16 @@ FindSystemColor( return 0; } - *indexPtr = sysColors[i].index; - colorPtr->pixel = GetSysColor(sysColors[i].index); + index = sysColors[i].index; + if (version < 4) { + if (index == COLOR_3DDKSHADOW) { + index = COLOR_BTNSHADOW; + } else if (index == COLOR_3DLIGHT) { + index = COLOR_BTNHIGHLIGHT; + } + } + *indexPtr = index; + colorPtr->pixel = GetSysColor(index); /* * x257 is (value<<8 + value) to get the properly bit shifted and padded diff --git a/win/tkWinInt.h b/win/tkWinInt.h index 90d68bb..b0fd454 100644 --- a/win/tkWinInt.h +++ b/win/tkWinInt.h @@ -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: tkWinInt.h,v 1.34 2010/01/14 22:05:54 nijtmans Exp $ + * RCS: @(#) $Id: tkWinInt.h,v 1.35 2010/02/16 21:12:56 nijtmans Exp $ */ #ifndef _TKWININT @@ -158,28 +158,28 @@ MODULE_SCOPE int tkpWinBltModes[]; * tkWinX.c:GenerateXEvent and tkWinClipboard.c:UpdateClipboard */ -EXTERN void TkWinUpdatingClipboard(int mode); +MODULE_SCOPE void TkWinUpdatingClipboard(int mode); /* * Used by tkWinDialog.c to associate the right icon with tk_messageBox */ -EXTERN HICON TkWinGetIcon(Tk_Window tkw, DWORD iconsize); +MODULE_SCOPE HICON TkWinGetIcon(Tk_Window tkw, DWORD iconsize); /* * Used by tkWinX.c on for certain system display change messages and cleanup * up containers */ -EXTERN void TkWinDisplayChanged(Display *display); +MODULE_SCOPE void TkWinDisplayChanged(Display *display); MODULE_SCOPE void TkWinCleanupContainerList(void); /* * Used by tkWinWm.c for embedded menu handling. May become public. */ -EXTERN HWND Tk_GetMenuHWND(Tk_Window tkwin); -EXTERN HWND Tk_GetEmbeddedMenuHWND(Tk_Window tkwin); +MODULE_SCOPE HWND Tk_GetMenuHWND(Tk_Window tkwin); +MODULE_SCOPE HWND Tk_GetEmbeddedMenuHWND(Tk_Window tkwin); /* * The following structure keeps track of whether we are using the multi-byte @@ -193,24 +193,19 @@ EXTERN HWND Tk_GetEmbeddedMenuHWND(Tk_Window tkwin); typedef struct TkWinProcs { int useWide; - LRESULT (WINAPI *callWindowProc)(WNDPROC lpPrevWndFunc, HWND hWnd, - UINT Msg, WPARAM wParam, LPARAM lParam); - LRESULT (WINAPI *defWindowProc)(HWND hWnd, UINT Msg, WPARAM wParam, - LPARAM lParam); - ATOM (WINAPI *registerClass)(const WNDCLASS *lpWndClass); - BOOL (WINAPI *setWindowText)(HWND hWnd, LPCTSTR lpString); - HWND (WINAPI *createWindowEx)(DWORD dwExStyle, LPCTSTR lpClassName, - LPCTSTR lpWindowName, DWORD dwStyle, int x, int y, - int nWidth, int nHeight, HWND hWndParent, HMENU hMenu, - HINSTANCE hInstance, LPVOID lpParam); - BOOL (WINAPI *insertMenu)(HMENU hMenu, UINT uPosition, UINT uFlags, - UINT uIDNewItem, LPCTSTR lpNewItem); - int (WINAPI *getWindowText)(HWND hWnd, LPCTSTR lpString, int nMaxCount); - HWND (WINAPI *findWindow)(LPCTSTR lpClassName, LPCTSTR lpWindowName); - int (WINAPI *getClassName)(HWND hwnd, LPTSTR lpClassName, int nMaxCount); + LRESULT (WINAPI *callWindowProc)(WNDPROC, HWND, UINT, WPARAM, LPARAM); + LRESULT (WINAPI *defWindowProc)(HWND, UINT, WPARAM, LPARAM); + ATOM (WINAPI *registerClass)(const WNDCLASS *); + BOOL (WINAPI *setWindowText)(HWND, LPCTSTR); + HWND (WINAPI *createWindowEx)(DWORD, LPCTSTR, LPCTSTR, DWORD, int, int, + int, int, HWND, HMENU, HINSTANCE, LPVOID); + BOOL (WINAPI *insertMenu)(HMENU, UINT, UINT, UINT, LPCTSTR); + int (WINAPI *getWindowText)(HWND, LPCTSTR, int); + HWND (WINAPI *findWindow)(LPCTSTR, LPCTSTR); + int (WINAPI *getClassName)(HWND, LPTSTR, int); } TkWinProcs; -MODULE_SCOPE TkWinProcs *tkWinProcs; +MODULE_SCOPE const TkWinProcs *tkWinProcs; #undef TCL_STORAGE_CLASS #define TCL_STORAGE_CLASS DLLIMPORT diff --git a/win/tkWinKey.c b/win/tkWinKey.c index 8536f9f..b537114 100644 --- a/win/tkWinKey.c +++ b/win/tkWinKey.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: tkWinKey.c,v 1.21 2010/01/13 23:08:11 nijtmans Exp $ + * RCS: @(#) $Id: tkWinKey.c,v 1.22 2010/02/16 21:12:56 nijtmans Exp $ */ #include "tkWinInt.h" @@ -25,7 +25,7 @@ #define MAX_KEYCODE 145 /* VK_SCROLL is the last entry in our table below */ -static KeySym keymap[] = { +static const KeySym keymap[] = { NoSymbol, NoSymbol, NoSymbol, XK_Cancel, NoSymbol, NoSymbol, NoSymbol, NoSymbol, XK_BackSpace, XK_Tab, NoSymbol, NoSymbol, XK_Clear, XK_Return, NoSymbol, diff --git a/win/tkWinScrlbr.c b/win/tkWinScrlbr.c index b87731c..9e848c7 100644 --- a/win/tkWinScrlbr.c +++ b/win/tkWinScrlbr.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: tkWinScrlbr.c,v 1.18 2010/01/13 23:08:11 nijtmans Exp $ + * RCS: @(#) $Id: tkWinScrlbr.c,v 1.19 2010/02/16 21:12:56 nijtmans Exp $ */ #include "tkWinInt.h" @@ -54,18 +54,11 @@ typedef struct WinScrollbar { static int initialized = 0; static int hArrowWidth, hThumb; /* Horizontal control metrics. */ -static int vArrowWidth, vArrowHeight, vThumb; /* Vertical control metrics. */ +static int vArrowHeight, vThumb; /* Vertical control metrics. */ TCL_DECLARE_MUTEX(winScrlbrMutex) /* - * This variable holds the default width for a scrollbar in string form for - * use in a Tk_ConfigSpec. - */ - -static char defWidth[TCL_INTEGER_SPACE]; - -/* * Declarations for functions defined in this file. */ @@ -363,19 +356,22 @@ TkpDestroyScrollbar( void UpdateScrollbarMetrics(void) { - Tk_ConfigSpec *specPtr; + int arrowWidth = GetSystemMetrics(SM_CXVSCROLL); + const Tk_ConfigSpec *specPtr; hArrowWidth = GetSystemMetrics(SM_CXHSCROLL); hThumb = GetSystemMetrics(SM_CXHTHUMB); - vArrowWidth = GetSystemMetrics(SM_CXVSCROLL); vArrowHeight = GetSystemMetrics(SM_CYVSCROLL); vThumb = GetSystemMetrics(SM_CYVTHUMB); - sprintf(defWidth, "%d", vArrowWidth); for (specPtr = tkpScrollbarConfigSpecs; specPtr->type != TK_CONFIG_END; specPtr++) { + /* Make sure that the default value belonging to the "-width" + * option of TkScrollbar points to static non-const space, + * otherwise the following sprintf results in a crash! + */ if (specPtr->offset == Tk_Offset(TkScrollbar, width)) { - specPtr->defValue = defWidth; + sprintf((char *)specPtr->defValue, "%d", arrowWidth); } } } diff --git a/win/tkWinX.c b/win/tkWinX.c index 8b27b1e..312bab0 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.62 2010/01/02 11:07:56 dkf Exp $ + * RCS: @(#) $Id: tkWinX.c,v 1.63 2010/02/16 21:12:56 nijtmans Exp $ */ /* @@ -63,53 +63,41 @@ #define UNICODE_NOCHAR 0xFFFF #endif -static TkWinProcs asciiProcs = { +static const TkWinProcs asciiProcs = { 0, - - (LRESULT (WINAPI *)(WNDPROC lpPrevWndFunc, HWND hWnd, UINT Msg, - WPARAM wParam, LPARAM lParam)) CallWindowProcA, - (LRESULT (WINAPI *)(HWND hWnd, UINT Msg, WPARAM wParam, - LPARAM lParam)) DefWindowProcA, - (ATOM (WINAPI *)(const WNDCLASS *lpWndClass)) RegisterClassA, - (BOOL (WINAPI *)(HWND hWnd, LPCTSTR lpString)) SetWindowTextA, - (HWND (WINAPI *)(DWORD dwExStyle, LPCTSTR lpClassName, - LPCTSTR lpWindowName, DWORD dwStyle, int x, int y, - int nWidth, int nHeight, HWND hWndParent, HMENU hMenu, - HINSTANCE hInstance, LPVOID lpParam)) CreateWindowExA, - (BOOL (WINAPI *)(HMENU hMenu, UINT uPosition, UINT uFlags, - UINT uIDNewItem, LPCTSTR lpNewItem)) InsertMenuA, - (int (WINAPI *)(HWND hWnd, LPCTSTR lpString, int nMaxCount)) GetWindowTextA, - (HWND (WINAPI *)(LPCTSTR lpClassName, LPCTSTR lpWindowName)) FindWindowA, - (int (WINAPI *)(HWND hwnd, LPTSTR lpClassName, int nMaxCount)) GetClassNameA, + (LRESULT (WINAPI *)(WNDPROC, HWND, UINT, WPARAM, LPARAM)) CallWindowProcA, + (LRESULT (WINAPI *)(HWND, UINT, WPARAM, LPARAM)) DefWindowProcA, + (ATOM (WINAPI *)(const WNDCLASS *)) RegisterClassA, + (BOOL (WINAPI *)(HWND, LPCTSTR)) SetWindowTextA, + (HWND (WINAPI *)(DWORD, LPCTSTR, LPCTSTR, DWORD, int, int, + int, int, HWND, HMENU, HINSTANCE, LPVOID)) CreateWindowExA, + (BOOL (WINAPI *)(HMENU, UINT, UINT, UINT, LPCTSTR)) InsertMenuA, + (int (WINAPI *)(HWND, LPCTSTR, int)) GetWindowTextA, + (HWND (WINAPI *)(LPCTSTR, LPCTSTR)) FindWindowA, + (int (WINAPI *)(HWND, LPTSTR, int)) GetClassNameA, }; -static TkWinProcs unicodeProcs = { +static const TkWinProcs unicodeProcs = { 1, - - (LRESULT (WINAPI *)(WNDPROC lpPrevWndFunc, HWND hWnd, UINT Msg, - WPARAM wParam, LPARAM lParam)) CallWindowProcW, - (LRESULT (WINAPI *)(HWND hWnd, UINT Msg, WPARAM wParam, - LPARAM lParam)) DefWindowProcW, - (ATOM (WINAPI *)(const WNDCLASS *lpWndClass)) RegisterClassW, - (BOOL (WINAPI *)(HWND hWnd, LPCTSTR lpString)) SetWindowTextW, - (HWND (WINAPI *)(DWORD dwExStyle, LPCTSTR lpClassName, - LPCTSTR lpWindowName, DWORD dwStyle, int x, int y, - int nWidth, int nHeight, HWND hWndParent, HMENU hMenu, - HINSTANCE hInstance, LPVOID lpParam)) CreateWindowExW, - (BOOL (WINAPI *)(HMENU hMenu, UINT uPosition, UINT uFlags, - UINT uIDNewItem, LPCTSTR lpNewItem)) InsertMenuW, - (int (WINAPI *)(HWND hWnd, LPCTSTR lpString, int nMaxCount)) GetWindowTextW, - (HWND (WINAPI *)(LPCTSTR lpClassName, LPCTSTR lpWindowName)) FindWindowW, - (int (WINAPI *)(HWND hwnd, LPTSTR lpClassName, int nMaxCount)) GetClassNameW, + (LRESULT (WINAPI *)(WNDPROC, HWND, UINT, WPARAM, LPARAM)) CallWindowProcW, + (LRESULT (WINAPI *)(HWND, UINT, WPARAM, LPARAM)) DefWindowProcW, + (ATOM (WINAPI *)(const WNDCLASS *)) RegisterClassW, + (BOOL (WINAPI *)(HWND, LPCTSTR)) SetWindowTextW, + (HWND (WINAPI *)(DWORD, LPCTSTR, LPCTSTR, DWORD, int, int, + int, int, HWND, HMENU, HINSTANCE, LPVOID)) CreateWindowExW, + (BOOL (WINAPI *)(HMENU, UINT, UINT, UINT, LPCTSTR)) InsertMenuW, + (int (WINAPI *)(HWND, LPCTSTR, int)) GetWindowTextW, + (HWND (WINAPI *)(LPCTSTR, LPCTSTR)) FindWindowW, + (int (WINAPI *)(HWND, LPTSTR, int)) GetClassNameW, }; -TkWinProcs *tkWinProcs; +const TkWinProcs *tkWinProcs; /* * Declarations of static variables used in this file. */ -static char winScreenName[] = ":0"; /* Default name of windows display. */ +static const char winScreenName[] = ":0"; /* Default name of windows display. */ static HINSTANCE tkInstance = NULL; /* Application instance handle. */ static int childClassInitialized; /* Registered child class? */ static WNDCLASS childClass; /* Window class for child windows. */ |