summaryrefslogtreecommitdiffstats
path: root/win/tkWinMenu.c
diff options
context:
space:
mode:
authorpatthoyts <patthoyts@users.sourceforge.net>2009-02-23 10:37:38 (GMT)
committerpatthoyts <patthoyts@users.sourceforge.net>2009-02-23 10:37:38 (GMT)
commitf3e184518b3f37077274cd6308f1751d4ecd30d6 (patch)
treeb6560ab03aea7291c9e247fdef443cd48bd36e6c /win/tkWinMenu.c
parent5f6476a428fc30fda30e4fda02662e190aa73ada (diff)
downloadtk-f3e184518b3f37077274cd6308f1751d4ecd30d6.zip
tk-f3e184518b3f37077274cd6308f1751d4ecd30d6.tar.gz
tk-f3e184518b3f37077274cd6308f1751d4ecd30d6.tar.bz2
[Patch 2507419] fix menu image display issue on windows
Diffstat (limited to 'win/tkWinMenu.c')
-rw-r--r--win/tkWinMenu.c85
1 files changed, 56 insertions, 29 deletions
diff --git a/win/tkWinMenu.c b/win/tkWinMenu.c
index 2e077b8..004cd14 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.59 2007/12/13 15:28:56 dgp Exp $
+ * RCS: @(#) $Id: tkWinMenu.c,v 1.59.2.1 2009/02/23 10:37:38 patthoyts Exp $
*/
#define OEMRESOURCE
@@ -35,9 +35,6 @@
#define ALIGN_BITMAP_TOP 0x00000004
#define ALIGN_BITMAP_BOTTOM 0x00000008
-#ifndef TPM_NOANIMATION
-#define TPM_NOANIMATION 0x4000L
-#endif
/*
* Platform-specific menu flags:
@@ -715,12 +712,11 @@ TkpPostMenu(
int x, int y)
{
HMENU winMenuHdl = (HMENU) menuPtr->platformData;
- int i, result, flags;
+ int result, flags;
RECT noGoawayRect;
POINT point;
Tk_Window parentWindow = Tk_Parent(menuPtr->tkwin);
int oldServiceMode = Tcl_GetServiceMode();
- TkMenuEntry *mePtr;
ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
@@ -783,18 +779,6 @@ TkpPostMenu(
}
}
- /*
- * Disable menu animation if an image is present, as clipping isn't
- * handled correctly with temp DCs. [Bug 1329198]
- */
- for (i = 0; i < menuPtr->numEntries; i++) {
- mePtr = menuPtr->entries[i];
- if (mePtr->image != NULL) {
- flags |= TPM_NOANIMATION;
- break;
- }
- }
-
TrackPopupMenu(winMenuHdl, flags, x, y, 0,
tsdPtr->menuHWND, &noGoawayRect);
Tcl_SetServiceMode(oldServiceMode);
@@ -2429,7 +2413,7 @@ TkpConfigureMenuEntry(
void
TkpDrawMenuEntry(
TkMenuEntry *mePtr, /* The entry to draw */
- Drawable d, /* What to draw into */
+ Drawable menuDrawable, /* Menu to draw into */
Tk_Font tkfont, /* Precalculated font for menu */
const Tk_FontMetrics *menuMetricsPtr,
/* Precalculated metrics for menu */
@@ -2448,8 +2432,38 @@ TkpDrawMenuEntry(
const Tk_FontMetrics *fmPtr;
Tk_FontMetrics entryMetrics;
int padY = (menuPtr->menuType == MENUBAR) ? 3 : 0;
- int adjustedY = y + padY;
+ int adjustedX, adjustedY;
int adjustedHeight = height - 2 * padY;
+ TkWinDrawable memWinDraw;
+ TkWinDCState dcState;
+ HBITMAP oldBitmap;
+ Drawable d;
+ HDC memDc, menuDc;
+
+ /*
+ * If the menu entry includes an image then draw the entry into a
+ * compatible bitmap first. This avoids problems with clipping on
+ * animated menus. [Bug 1329198]
+ */
+
+ if (mePtr->image != NULL) {
+ menuDc = TkWinGetDrawableDC(menuPtr->display, menuDrawable, &dcState);
+
+ memDc = CreateCompatibleDC(menuDc);
+ oldBitmap = SelectObject(memDc,
+ CreateCompatibleBitmap(menuDc, width, height) );
+
+ memWinDraw.type = TWD_WINDC;
+ memWinDraw.winDC.hdc = memDc;
+ d = (Drawable)&memWinDraw;
+ adjustedX = 0;
+ adjustedY = padY;
+
+ } else {
+ d = menuDrawable;
+ adjustedX = x;
+ adjustedY = y + padY;
+ }
/*
* Choose the gc for drawing the foreground part of the entry.
@@ -2521,26 +2535,39 @@ TkpDrawMenuEntry(
*/
DrawMenuEntryBackground(menuPtr, mePtr, d, activeBorder,
- bgBorder, x, y, width, height);
+ bgBorder, adjustedX, adjustedY-padY, width, height);
if (mePtr->type == SEPARATOR_ENTRY) {
DrawMenuSeparator(menuPtr, mePtr, d, gc, tkfont,
- fmPtr, x, adjustedY, width, adjustedHeight);
+ fmPtr, adjustedX, adjustedY, width, adjustedHeight);
} else if (mePtr->type == TEAROFF_ENTRY) {
- DrawTearoffEntry(menuPtr, mePtr, d, gc, tkfont, fmPtr, x, adjustedY,
- width, adjustedHeight);
+ DrawTearoffEntry(menuPtr, mePtr, d, gc, tkfont, fmPtr,
+ adjustedX, adjustedY, width, adjustedHeight);
} else {
- DrawMenuEntryLabel(menuPtr, mePtr, d, gc, tkfont, fmPtr, x, adjustedY,
- width, adjustedHeight);
+ DrawMenuEntryLabel(menuPtr, mePtr, d, gc, tkfont, fmPtr,
+ adjustedX, adjustedY, width, adjustedHeight);
DrawMenuEntryAccelerator(menuPtr, mePtr, d, gc, tkfont, fmPtr,
- activeBorder, x, adjustedY, width, adjustedHeight);
+ activeBorder, adjustedX, adjustedY, width, adjustedHeight);
DrawMenuEntryArrow(menuPtr, mePtr, d, gc,
- activeBorder, x, adjustedY, width, adjustedHeight, drawArrow);
+ activeBorder, adjustedX, adjustedY, width, adjustedHeight,
+ drawArrow);
if (!mePtr->hideMargin) {
DrawMenuEntryIndicator(menuPtr, mePtr, d, gc, indicatorGC, tkfont,
- fmPtr, x, adjustedY, width, adjustedHeight);
+ fmPtr, adjustedX, adjustedY, width, adjustedHeight);
}
}
+
+ /*
+ * Copy the entry contents from the temporary bitmap to the menu.
+ */
+
+ if (mePtr->image != NULL) {
+ BitBlt(menuDc, x, y, width, height, memDc, 0, 0, SRCCOPY);
+ DeleteObject(SelectObject(memDc, oldBitmap));
+ DeleteDC(memDc);
+
+ TkWinReleaseDrawableDC(menuDrawable, menuDc, &dcState);
+ }
}
/*