- Make button text centre correctly when dropdown arrow is present

- Centre dropdown arrow
This commit is contained in:
Robert Shearman 2003-06-13 16:30:24 +00:00 committed by Alexandre Julliard
parent 0fc0ddb62d
commit 7614f27f3b
1 changed files with 11 additions and 6 deletions

View File

@ -179,6 +179,7 @@ typedef struct
#define TOP_BORDER 2 #define TOP_BORDER 2
#define BOTTOM_BORDER 2 #define BOTTOM_BORDER 2
#define DDARROW_WIDTH 11 #define DDARROW_WIDTH 11
#define ARROW_HEIGHT 3
#define TOOLBAR_GetInfoPtr(hwnd) ((TOOLBAR_INFO *)GetWindowLongA(hwnd,0)) #define TOOLBAR_GetInfoPtr(hwnd) ((TOOLBAR_INFO *)GetWindowLongA(hwnd,0))
#define TOOLBAR_HasText(x, y) (TOOLBAR_GetText(x, y) ? TRUE : FALSE) #define TOOLBAR_HasText(x, y) (TOOLBAR_GetText(x, y) ? TRUE : FALSE)
@ -502,7 +503,7 @@ TOOLBAR_DrawArrow (HDC hdc, INT left, INT top, INT colorRef)
if (!(hPen = CreatePen( PS_SOLID, 1, GetSysColor( colorRef )))) return; if (!(hPen = CreatePen( PS_SOLID, 1, GetSysColor( colorRef )))) return;
hOldPen = SelectObject ( hdc, hPen ); hOldPen = SelectObject ( hdc, hPen );
x = left + 2; x = left + 2;
y = top + 8; y = top;
MoveToEx (hdc, x, y, NULL); MoveToEx (hdc, x, y, NULL);
LineTo (hdc, x+5, y++); x++; LineTo (hdc, x+5, y++); x++;
MoveToEx (hdc, x, y, NULL); MoveToEx (hdc, x, y, NULL);
@ -642,7 +643,6 @@ TOOLBAR_DrawButton (HWND hwnd, TBUTTON_INFO *btnPtr, HDC hdc)
CopyRect (&rcFill, &rc); CopyRect (&rcFill, &rc);
CopyRect (&rcArrow, &rc); CopyRect (&rcArrow, &rc);
CopyRect(&rcBitmap, &rc); CopyRect(&rcBitmap, &rc);
CopyRect(&rcText, &rc);
/* get a pointer to the text */ /* get a pointer to the text */
lpText = TOOLBAR_GetText(infoPtr, btnPtr); lpText = TOOLBAR_GetText(infoPtr, btnPtr);
@ -656,6 +656,11 @@ TOOLBAR_DrawButton (HWND hwnd, TBUTTON_INFO *btnPtr, HDC hdc)
rcArrow.left = rc.right; rcArrow.left = rc.right;
} }
/* copy text rect after adjusting for drop-down arrow
* so that text is centred in the rectangle not containing
* the arrow */
CopyRect(&rcText, &rc);
/* Center the bitmap horizontally and vertically */ /* Center the bitmap horizontally and vertically */
if (dwStyle & TBSTYLE_LIST) if (dwStyle & TBSTYLE_LIST)
rcBitmap.left += 3; rcBitmap.left += 3;
@ -794,8 +799,8 @@ TOOLBAR_DrawButton (HWND hwnd, TBUTTON_INFO *btnPtr, HDC hdc)
if (hasDropDownArrow) if (hasDropDownArrow)
{ {
TOOLBAR_DrawArrow(hdc, rcArrow.left+1, rcArrow.top+1, COLOR_3DHIGHLIGHT); TOOLBAR_DrawArrow(hdc, rcArrow.left+1, rcArrow.top+1 + (rcArrow.bottom - rcArrow.top - ARROW_HEIGHT) / 2, COLOR_3DHIGHLIGHT);
TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top, COLOR_3DSHADOW); TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top + (rcArrow.bottom - rcArrow.top - ARROW_HEIGHT) / 2, COLOR_3DSHADOW);
} }
if (!TOOLBAR_DrawImageList (infoPtr, btnPtr, himlDis, if (!TOOLBAR_DrawImageList (infoPtr, btnPtr, himlDis,
@ -827,7 +832,7 @@ TOOLBAR_DrawButton (HWND hwnd, TBUTTON_INFO *btnPtr, HDC hdc)
} }
if (hasDropDownArrow) if (hasDropDownArrow)
TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top, COLOR_WINDOWFRAME); TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top + (rcArrow.bottom - rcArrow.top - ARROW_HEIGHT) / 2, COLOR_WINDOWFRAME);
TOOLBAR_DrawImageList (infoPtr, btnPtr, himlDef, TOOLBAR_DrawImageList (infoPtr, btnPtr, himlDef,
hdc, rcBitmap.left+offset, rcBitmap.top+offset, hdc, rcBitmap.left+offset, rcBitmap.top+offset,
@ -940,7 +945,7 @@ TOOLBAR_DrawButton (HWND hwnd, TBUTTON_INFO *btnPtr, HDC hdc)
if (!(infoPtr->dwItemCDFlag & TBCDRF_NOEDGES)) if (!(infoPtr->dwItemCDFlag & TBCDRF_NOEDGES))
DrawEdge (hdc, &rcArrow, EDGE_RAISED, DrawEdge (hdc, &rcArrow, EDGE_RAISED,
BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST); BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top, COLOR_WINDOWFRAME); TOOLBAR_DrawArrow(hdc, rcArrow.left, rcArrow.top + (rcArrow.bottom - rcArrow.top - ARROW_HEIGHT) / 2, COLOR_WINDOWFRAME);
} }
TOOLBAR_DrawImageList (infoPtr, btnPtr, himlDef, TOOLBAR_DrawImageList (infoPtr, btnPtr, himlDef,