Commit 5c5a0608 authored by Robert Shearman's avatar Robert Shearman Committed by Alexandre Julliard

- Clean up the mask drawing code.

- Improve bitmap not found message.
parent f3b681a2
......@@ -407,7 +407,7 @@ TOOLBAR_GetImageListForDrawing (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr, IMA
if (!TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) {
if (btnPtr->iBitmap == I_IMAGENONE) return NULL;
ERR("index %d,%d is not valid, max %d\n",
ERR("bitmap for ID %d, index %d is not valid, number of bitmaps in imagelist: %d\n",
HIWORD(btnPtr->iBitmap), LOWORD(btnPtr->iBitmap), infoPtr->nNumBitmaps);
return NULL;
}
......@@ -641,15 +641,8 @@ TOOLBAR_DrawPattern (LPRECT lpRect, NMTBCUSTOMDRAW *tbcd)
}
static void TOOLBAR_DrawMasked(TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
HDC hdc, INT x, INT y)
static void TOOLBAR_DrawMasked(HIMAGELIST himl, int index, HDC hdc, INT x, INT y, UINT draw_flags)
{
int index;
HIMAGELIST himl =
TOOLBAR_GetImageListForDrawing(infoPtr, btnPtr, IMAGE_LIST_DEFAULT, &index);
if (himl)
{
INT cx, cy;
HBITMAP hbmMask, hbmImage;
HDC hdcMask, hdcImage;
......@@ -662,7 +655,7 @@ static void TOOLBAR_DrawMasked(TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
GetDeviceCaps(hdc,BITSPIXEL), NULL);
SelectObject(hdcImage, hbmImage);
ImageList_DrawEx(himl, index, hdcImage, 0, 0, cx, cy,
RGB(0xff, 0xff, 0xff), RGB(0,0,0), ILD_NORMAL);
RGB(0xff, 0xff, 0xff), RGB(0,0,0), draw_flags);
/* Create Mask */
hdcMask = CreateCompatibleDC(0);
......@@ -688,7 +681,6 @@ static void TOOLBAR_DrawMasked(TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
DeleteDC(hdcImage);
DeleteObject (hbmMask);
DeleteDC(hdcMask);
}
}
......@@ -721,8 +713,11 @@ TOOLBAR_DrawImage(TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr, INT left, INT top
{
himl = TOOLBAR_GetImageListForDrawing(infoPtr, btnPtr, IMAGE_LIST_DISABLED, &index);
if (!himl)
{
himl = TOOLBAR_GetImageListForDrawing(infoPtr, btnPtr, IMAGE_LIST_DEFAULT, &index);
draw_masked = TRUE;
}
}
else if ((tbcd->nmcd.uItemState & CDIS_HOT) && (infoPtr->dwStyle & TBSTYLE_FLAT))
{
/* if hot, attempt to draw with hot image list, if fails,
......@@ -734,6 +729,9 @@ TOOLBAR_DrawImage(TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr, INT left, INT top
else
himl = TOOLBAR_GetImageListForDrawing(infoPtr, btnPtr, IMAGE_LIST_DEFAULT, &index);
if (!himl)
return;
if (!(infoPtr->dwItemCDFlag & TBCDRF_NOOFFSET) &&
(tbcd->nmcd.uItemState & (CDIS_SELECTED | CDIS_CHECKED)))
offset = 1;
......@@ -746,8 +744,8 @@ TOOLBAR_DrawImage(TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr, INT left, INT top
index, himl, left, top, offset);
if (draw_masked)
TOOLBAR_DrawMasked (infoPtr, btnPtr, tbcd->nmcd.hdc, left + offset, top + offset);
else if (himl)
TOOLBAR_DrawMasked (himl, index, tbcd->nmcd.hdc, left + offset, top + offset, draw_flags);
else
ImageList_Draw (himl, index, tbcd->nmcd.hdc, left + offset, top + offset, draw_flags);
}
......@@ -5313,6 +5311,8 @@ TOOLBAR_LButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
NMTOOLBARA nmtb;
BOOL bDragKeyPressed;
TRACE("\n");
if (infoPtr->dwStyle & TBSTYLE_ALTDRAG)
bDragKeyPressed = (GetKeyState(VK_MENU) < 0);
else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment