Zhiyi Zhang : comctl32/button: Support text margin rendering.
Module: wine Branch: master Commit: eb79ebe50c123b68989209546d6109e182901aed URL: https://source.winehq.org/git/wine.git/?a=commit;h=eb79ebe50c123b68989209546... Author: Zhiyi Zhang <zzhang(a)codeweavers.com> Date: Wed Sep 5 22:59:13 2018 +0800 comctl32/button: Support text margin rendering. Signed-off-by: Zhiyi Zhang <zzhang(a)codeweavers.com> Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/comctl32/button.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/dlls/comctl32/button.c b/dlls/comctl32/button.c index 5fdfe7f..a9ca619 100644 --- a/dlls/comctl32/button.c +++ b/dlls/comctl32/button.c @@ -1027,6 +1027,17 @@ static SIZE BUTTON_GetImageSize(const BUTTON_INFO *infoPtr) return size; } +static const RECT *BUTTON_GetTextMargin(const BUTTON_INFO *infoPtr) +{ + static const RECT oneMargin = {1, 1, 1, 1}; + + /* Use text margin only when showing both image and text, and image is not imagelist */ + if (show_image_and_text(infoPtr) && !infoPtr->imagelist.himl) + return &infoPtr->text_margin; + else + return &oneMargin; +} + /********************************************************************** * BUTTON_CalcLayoutRects * @@ -1054,7 +1065,8 @@ static UINT BUTTON_CalcLayoutRects(const BUTTON_INFO *infoPtr, HDC hdc, RECT *la UINT dtStyle = BUTTON_BStoDT(style, ex_style); RECT labelRect, imageRect, imageRectWithMargin, textRect; LONG imageMarginWidth, imageMarginHeight; - RECT emptyMargin = {0}, oneMargin = {1, 1, 1, 1}; + const RECT *textMargin = BUTTON_GetTextMargin(infoPtr); + RECT emptyMargin = {0}; LONG maxTextWidth; /* Calculate label rectangle according to label type */ @@ -1118,7 +1130,7 @@ static UINT BUTTON_CalcLayoutRects(const BUTTON_INFO *infoPtr, HDC hdc, RECT *la BUTTON_PositionRect(split_style, &boundingImageRect, &imageRect, infoPtr->imagelist.himl ? &infoPtr->imagelist.margin : &emptyMargin); /* Text doesn't use imagelist align */ - BUTTON_PositionRect(style, &boundingTextRect, &textRect, &oneMargin); + BUTTON_PositionRect(style, &boundingTextRect, &textRect, textMargin); } else { @@ -1143,17 +1155,17 @@ static UINT BUTTON_CalcLayoutRects(const BUTTON_INFO *infoPtr, HDC hdc, RECT *la /* Get text rect */ SubtractRect(&boundingTextRect, &labelRect, &boundingImageRect); /* Text doesn't use imagelist align */ - BUTTON_PositionRect(style, &boundingTextRect, &textRect, &oneMargin); + BUTTON_PositionRect(style, &boundingTextRect, &textRect, textMargin); } } /* Show text only */ else { if (get_button_type(style) != BS_GROUPBOX) - BUTTON_PositionRect(style, labelRc, &textRect, &oneMargin); + BUTTON_PositionRect(style, labelRc, &textRect, textMargin); else /* GroupBox is always top aligned */ - BUTTON_PositionRect((style & ~BS_VCENTER) | BS_TOP, labelRc, &textRect, &oneMargin); + BUTTON_PositionRect((style & ~BS_VCENTER) | BS_TOP, labelRc, &textRect, textMargin); labelRect = textRect; SetRectEmpty(&imageRect); }
participants (1)
-
Alexandre Julliard