comctl32/button: Implement BCM_SETSPLITINFO.

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-01 15:19:38 +03:00 committed by Alexandre Julliard
parent 202a1c1ef0
commit 82d39e1817
1 changed files with 46 additions and 0 deletions

View File

@ -86,6 +86,9 @@ typedef struct _BUTTON_INFO
INT note_length;
DWORD image_type; /* IMAGE_BITMAP or IMAGE_ICON */
BUTTON_IMAGELIST imagelist;
UINT split_style;
HIMAGELIST glyph; /* this is a font character code when split_style doesn't have BCSS_IMAGE */
SIZE glyph_size;
RECT text_margin;
union
{
@ -243,6 +246,21 @@ static inline WCHAR *get_button_text( const BUTTON_INFO *infoPtr )
return buffer;
}
/* get the default glyph size for split buttons */
static LONG get_default_glyph_size(const BUTTON_INFO *infoPtr)
{
if (infoPtr->split_style & BCSS_IMAGE)
{
/* Size it to fit, including the left and right edges */
int w, h;
if (!ImageList_GetIconSize(infoPtr->glyph, &w, &h)) w = 0;
return w + GetSystemMetrics(SM_CXEDGE) * 2;
}
/* The glyph size relies on the default menu font's cell height */
return GetSystemMetrics(SM_CYMENUCHECK);
}
static void init_custom_draw(NMCUSTOMDRAW *nmcd, const BUTTON_INFO *infoPtr, HDC hdc, const RECT *rc)
{
nmcd->hdr.hwndFrom = infoPtr->hwnd;
@ -834,6 +852,34 @@ static LRESULT CALLBACK BUTTON_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, L
return TRUE;
}
case BCM_SETSPLITINFO:
{
BUTTON_SPLITINFO *info = (BUTTON_SPLITINFO*)lParam;
if (!info) return TRUE;
if (info->mask & (BCSIF_GLYPH | BCSIF_IMAGE))
{
infoPtr->split_style &= ~BCSS_IMAGE;
if (!(info->mask & BCSIF_GLYPH))
infoPtr->split_style |= BCSS_IMAGE;
infoPtr->glyph = info->himlGlyph;
infoPtr->glyph_size.cx = infoPtr->glyph_size.cy = 0;
}
if (info->mask & BCSIF_STYLE)
infoPtr->split_style = info->uSplitStyle;
if (info->mask & BCSIF_SIZE)
infoPtr->glyph_size = info->size;
/* Calculate fitting value for cx if invalid (cy is untouched) */
if (infoPtr->glyph_size.cx <= 0)
infoPtr->glyph_size.cx = get_default_glyph_size(infoPtr);
/* Windows doesn't invalidate or redraw it, so we don't, either */
return TRUE;
}
case BM_GETCHECK:
return infoPtr->state & 3;