comctl32/button: Implement BCM_GETIDEALSIZE for split buttons.

Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Gabriel Ivăncescu 2019-04-03 20:06:32 +03:00 committed by Alexandre Julliard
parent 09bdf5d07d
commit 9c62f7e42b
1 changed files with 22 additions and 2 deletions

View File

@ -197,6 +197,7 @@ typedef BOOL (*pfGetIdealSize)(BUTTON_INFO *infoPtr, SIZE *size);
static BOOL PB_GetIdealSize(BUTTON_INFO *infoPtr, SIZE *size);
static BOOL CB_GetIdealSize(BUTTON_INFO *infoPtr, SIZE *size);
static BOOL GB_GetIdealSize(BUTTON_INFO *infoPtr, SIZE *size);
static BOOL SB_GetIdealSize(BUTTON_INFO *infoPtr, SIZE *size);
static const pfGetIdealSize btnGetIdealSizeFunc[MAX_BTN_TYPE] = {
PB_GetIdealSize, /* BS_PUSHBUTTON */
@ -211,9 +212,9 @@ static const pfGetIdealSize btnGetIdealSizeFunc[MAX_BTN_TYPE] = {
CB_GetIdealSize, /* BS_AUTORADIOBUTTON */
GB_GetIdealSize, /* BS_PUSHBOX */
GB_GetIdealSize, /* BS_OWNERDRAW */
SB_GetIdealSize, /* BS_SPLITBUTTON */
SB_GetIdealSize, /* BS_DEFSPLITBUTTON */
/* GetIdealSize() for following types are unimplemented, use BS_PUSHBUTTON's for now */
PB_GetIdealSize, /* BS_SPLITBUTTON */
PB_GetIdealSize, /* BS_DEFSPLITBUTTON */
PB_GetIdealSize, /* BS_COMMANDLINK */
PB_GetIdealSize /* BS_DEFCOMMANDLINK */
};
@ -1347,6 +1348,25 @@ static BOOL PB_GetIdealSize(BUTTON_INFO *infoPtr, SIZE *size)
return TRUE;
}
static BOOL SB_GetIdealSize(BUTTON_INFO *infoPtr, SIZE *size)
{
LONG extra_width = infoPtr->glyph_size.cx * 2 + GetSystemMetrics(SM_CXEDGE);
SIZE label_size;
if (SendMessageW(infoPtr->hwnd, WM_GETTEXTLENGTH, 0, 0) == 0)
{
BUTTON_GetClientRectSize(infoPtr, size);
size->cx = max(size->cx, extra_width);
}
else
{
BUTTON_GetLabelIdealSize(infoPtr, size->cx, &label_size);
size->cx = label_size.cx + ((size->cx == 0) ? extra_width : 0);
size->cy = label_size.cy;
}
return TRUE;
}
/**********************************************************************
* BUTTON_CalcLayoutRects
*