From 82d39e181778f165a973c90a8e80c261a3926a20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Iv=C4=83ncescu?= Date: Mon, 1 Apr 2019 15:19:38 +0300 Subject: [PATCH] comctl32/button: Implement BCM_SETSPLITINFO. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Gabriel Ivăncescu Signed-off-by: Nikolay Sivov Signed-off-by: Alexandre Julliard --- dlls/comctl32/button.c | 46 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/dlls/comctl32/button.c b/dlls/comctl32/button.c index 38c7d4c257d..4b8a8f43cd4 100644 --- a/dlls/comctl32/button.c +++ b/dlls/comctl32/button.c @@ -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;