diff options
author | dgp <dgp@users.sourceforge.net> | 2007-06-12 16:22:40 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2007-06-12 16:22:40 (GMT) |
commit | e533770d061a74bb7d2e59f1fd3347fb70782bb9 (patch) | |
tree | 9ece99851b1a6a191cc4e20fd532a1ac6abb094d /win | |
parent | c1154a9f8c1aca618e8369de987fbe28a0d7f3b9 (diff) | |
download | tk-e533770d061a74bb7d2e59f1fd3347fb70782bb9.zip tk-e533770d061a74bb7d2e59f1fd3347fb70782bb9.tar.gz tk-e533770d061a74bb7d2e59f1fd3347fb70782bb9.tar.bz2 |
merge updates from HEAD
Diffstat (limited to 'win')
-rw-r--r-- | win/tkWinMenu.c | 31 | ||||
-rw-r--r-- | win/tkWinWm.c | 20 |
2 files changed, 30 insertions, 21 deletions
diff --git a/win/tkWinMenu.c b/win/tkWinMenu.c index 5852d58..5d5f6fd 100644 --- a/win/tkWinMenu.c +++ b/win/tkWinMenu.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: tkWinMenu.c,v 1.56 2007/05/05 07:33:08 dkf Exp $ + * RCS: @(#) $Id: tkWinMenu.c,v 1.56.2.1 2007/06/12 16:22:45 dgp Exp $ */ #define OEMRESOURCE @@ -1100,35 +1100,34 @@ TkWinHandleMenuEvent( break; case WM_MENUCHAR: { - unsigned char menuChar = (unsigned char) LOWORD(*pwParam); - hashEntryPtr = Tcl_FindHashEntry(&tsdPtr->winMenuTable, (char *) *plParam); if (hashEntryPtr != NULL) { int i, len, underline; Tcl_Obj *labelPtr; + Tcl_UniChar *wlabel, menuChar; *plResult = 0; menuPtr = (TkMenu *) Tcl_GetHashValue(hashEntryPtr); + /* + * Assume we have something directly convertable to Tcl_UniChar. + * True at least for wide systems. + */ + menuChar = Tcl_UniCharToUpper((Tcl_UniChar) LOWORD(*pwParam)); + for (i = 0; i < menuPtr->numEntries; i++) { underline = menuPtr->entries[i]->underline; labelPtr = menuPtr->entries[i]->labelPtr; if ((underline >= 0) && (labelPtr != NULL)) { /* - * Do the unicode call just to prevent overruns. + * Ensure we don't exceed the label length, then check */ - - Tcl_GetUnicodeFromObj(labelPtr, &len); - if (underline < len) { - char *label = Tcl_GetString(labelPtr); - char underlined = *Tcl_UtfAtIndex(label, underline); - - if (CharUpper((LPTSTR) menuChar) == - CharUpper((LPTSTR) underlined)) { - *plResult = (2 << 16) | i; - returnResult = 1; - break; - } + wlabel = Tcl_GetUnicodeFromObj(labelPtr, &len); + if ((underline < len) && (menuChar == + Tcl_UniCharToUpper(wlabel[underline]))) { + *plResult = (2 << 16) | i; + returnResult = 1; + break; } } } diff --git a/win/tkWinWm.c b/win/tkWinWm.c index e089985..2b6fde3 100644 --- a/win/tkWinWm.c +++ b/win/tkWinWm.c @@ -12,7 +12,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkWinWm.c,v 1.116 2007/05/04 21:29:23 patthoyts Exp $ + * RCS: @(#) $Id: tkWinWm.c,v 1.116.2.1 2007/06/12 16:22:45 dgp Exp $ */ #include "tkWinInt.h" @@ -4327,7 +4327,8 @@ WmIconphotoCmd( TkWindow *useWinPtr = winPtr; /* window to apply to (NULL if -default) */ Tk_PhotoHandle photo; Tk_PhotoImageBlock block; - int i, width, height, startObj = 3; + int i, width, height, idx, bufferSize, startObj = 3; + unsigned char *bgraPixelPtr; BlockOfIconImagesPtr lpIR; WinIconPtr titlebaricon = NULL; HICON hIcon; @@ -4380,11 +4381,20 @@ WmIconphotoCmd( Tk_PhotoGetImage(photo, &block); /* - * Encode the image data into an HICON. + * Convert the image data into BGRA format (RGBQUAD) and then + * encode the image data into an HICON. */ - + bufferSize = height * width * block.pixelSize; + bgraPixelPtr = ckalloc(bufferSize); + for (idx = 0 ; idx < bufferSize ; idx += 4) { + bgraPixelPtr[idx] = block.pixelPtr[idx+2]; + bgraPixelPtr[idx+1] = block.pixelPtr[idx+1]; + bgraPixelPtr[idx+2] = block.pixelPtr[idx+0]; + bgraPixelPtr[idx+3] = block.pixelPtr[idx+3]; + } hIcon = CreateIcon(Tk_GetHINSTANCE(), width, height, 1, 32, - NULL, (BYTE *) block.pixelPtr); + NULL, (BYTE *) bgraPixelPtr); + ckfree(bgraPixelPtr); if (hIcon == NULL) { /* * XXX should free up created icons. |