Commit 88ebde86 authored by Francois Gouget's avatar Francois Gouget Committed by Alexandre Julliard

Modified the bitmap centering algorithm to take the button's border

into account.
parent 6bac4f2c
...@@ -305,14 +305,14 @@ TOOLBAR_DrawButton (HWND hwnd, TBUTTON_INFO *btnPtr, HDC hdc) ...@@ -305,14 +305,14 @@ TOOLBAR_DrawButton (HWND hwnd, TBUTTON_INFO *btnPtr, HDC hdc)
DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
BOOL hasDropDownArrow = TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle) && BOOL hasDropDownArrow = TOOLBAR_HasDropDownArrows(infoPtr->dwExStyle) &&
(btnPtr->fsStyle & TBSTYLE_DROPDOWN); (btnPtr->fsStyle & TBSTYLE_DROPDOWN);
RECT rc, rcArrow; RECT rc, rcArrow, rcBitmap;
INT xOffset = (infoPtr->nButtonWidth / 2) - (infoPtr->nBitmapWidth / 2);
if (btnPtr->fsState & TBSTATE_HIDDEN) if (btnPtr->fsState & TBSTATE_HIDDEN)
return; return;
rc = btnPtr->rect; rc = btnPtr->rect;
CopyRect (&rcArrow, &rc); CopyRect (&rcArrow, &rc);
CopyRect(&rcBitmap, &rc);
FillRect( hdc, &rc, GetSysColorBrush(COLOR_BTNFACE)); FillRect( hdc, &rc, GetSysColorBrush(COLOR_BTNFACE));
...@@ -325,6 +325,10 @@ TOOLBAR_DrawButton (HWND hwnd, TBUTTON_INFO *btnPtr, HDC hdc) ...@@ -325,6 +325,10 @@ TOOLBAR_DrawButton (HWND hwnd, TBUTTON_INFO *btnPtr, HDC hdc)
rcArrow.left = rc.right; rcArrow.left = rc.right;
} }
/* Take the border into account and center the bitmap horizontally */
rcBitmap.left+=(infoPtr->nButtonWidth - infoPtr->nBitmapWidth - 1-2) / 2;
rcBitmap.top+=1;
TRACE("iBitmap: %d\n", btnPtr->iBitmap); TRACE("iBitmap: %d\n", btnPtr->iBitmap);
/* separator */ /* separator */
...@@ -359,9 +363,9 @@ TOOLBAR_DrawButton (HWND hwnd, TBUTTON_INFO *btnPtr, HDC hdc) ...@@ -359,9 +363,9 @@ TOOLBAR_DrawButton (HWND hwnd, TBUTTON_INFO *btnPtr, HDC hdc)
if (infoPtr->himlDis && if (infoPtr->himlDis &&
TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap))
ImageList_Draw (infoPtr->himlDis, btnPtr->iBitmap, hdc, ImageList_Draw (infoPtr->himlDis, btnPtr->iBitmap, hdc,
rc.left + xOffset + 1, rc.top + 1, ILD_NORMAL); rcBitmap.left, rcBitmap.top, ILD_NORMAL);
else else
TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rc.left + xOffset + 1, rc.top + 1); TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rcBitmap.left, rcBitmap.top);
TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle); TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
return; return;
...@@ -387,7 +391,7 @@ TOOLBAR_DrawButton (HWND hwnd, TBUTTON_INFO *btnPtr, HDC hdc) ...@@ -387,7 +391,7 @@ TOOLBAR_DrawButton (HWND hwnd, TBUTTON_INFO *btnPtr, HDC hdc)
if (TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) if (TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap))
ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc, ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
rc.left + xOffset + 2, rc.top + 2, ILD_NORMAL); rcBitmap.left + 1, rcBitmap.top + 1, ILD_NORMAL);
TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle); TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
return; return;
...@@ -407,8 +411,7 @@ TOOLBAR_DrawButton (HWND hwnd, TBUTTON_INFO *btnPtr, HDC hdc) ...@@ -407,8 +411,7 @@ TOOLBAR_DrawButton (HWND hwnd, TBUTTON_INFO *btnPtr, HDC hdc)
if (TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) if (TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap))
ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc, ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
rc.left + xOffset, rc.top + 2, ILD_NORMAL); rcBitmap.left + 1, rcBitmap.top + 1, ILD_NORMAL);
TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle); TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
return; return;
} }
...@@ -419,7 +422,7 @@ TOOLBAR_DrawButton (HWND hwnd, TBUTTON_INFO *btnPtr, HDC hdc) ...@@ -419,7 +422,7 @@ TOOLBAR_DrawButton (HWND hwnd, TBUTTON_INFO *btnPtr, HDC hdc)
BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST); BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
TOOLBAR_DrawPattern (hdc, &rc); TOOLBAR_DrawPattern (hdc, &rc);
TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rc.left + xOffset + 1, rc.top + 1); TOOLBAR_DrawMasked (infoPtr, btnPtr, hdc, rcBitmap.left, rcBitmap.top);
TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle); TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
return; return;
} }
...@@ -446,10 +449,10 @@ TOOLBAR_DrawButton (HWND hwnd, TBUTTON_INFO *btnPtr, HDC hdc) ...@@ -446,10 +449,10 @@ TOOLBAR_DrawButton (HWND hwnd, TBUTTON_INFO *btnPtr, HDC hdc)
if (btnPtr->bHot && infoPtr->himlHot && if (btnPtr->bHot && infoPtr->himlHot &&
TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap))
ImageList_Draw (infoPtr->himlHot, btnPtr->iBitmap, hdc, ImageList_Draw (infoPtr->himlHot, btnPtr->iBitmap, hdc,
rc.left + xOffset + 2, rc.top + 2, ILD_NORMAL); rcBitmap.left + 1, rcBitmap.top + 1, ILD_NORMAL);
else if (TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) else if (TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap))
ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc, ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
rc.left + xOffset + 2, rc.top + 2, ILD_NORMAL); rcBitmap.left + 1, rcBitmap.top + 1, ILD_NORMAL);
} }
else else
{ {
...@@ -465,7 +468,7 @@ TOOLBAR_DrawButton (HWND hwnd, TBUTTON_INFO *btnPtr, HDC hdc) ...@@ -465,7 +468,7 @@ TOOLBAR_DrawButton (HWND hwnd, TBUTTON_INFO *btnPtr, HDC hdc)
if (TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap)) if (TOOLBAR_IsValidBitmapIndex(infoPtr,btnPtr->iBitmap))
ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc, ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
rc.left + xOffset + 1, rc.top + 1, ILD_NORMAL); rcBitmap.left, rcBitmap.top, ILD_NORMAL);
} }
TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle); TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState, dwStyle);
......
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