Commit eb79ebe5 authored by Zhiyi Zhang's avatar Zhiyi Zhang Committed by Alexandre Julliard

comctl32/button: Support text margin rendering.

parent c9aa8dab
...@@ -1027,6 +1027,17 @@ static SIZE BUTTON_GetImageSize(const BUTTON_INFO *infoPtr) ...@@ -1027,6 +1027,17 @@ static SIZE BUTTON_GetImageSize(const BUTTON_INFO *infoPtr)
return size; 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 * BUTTON_CalcLayoutRects
* *
...@@ -1054,7 +1065,8 @@ static UINT BUTTON_CalcLayoutRects(const BUTTON_INFO *infoPtr, HDC hdc, RECT *la ...@@ -1054,7 +1065,8 @@ static UINT BUTTON_CalcLayoutRects(const BUTTON_INFO *infoPtr, HDC hdc, RECT *la
UINT dtStyle = BUTTON_BStoDT(style, ex_style); UINT dtStyle = BUTTON_BStoDT(style, ex_style);
RECT labelRect, imageRect, imageRectWithMargin, textRect; RECT labelRect, imageRect, imageRectWithMargin, textRect;
LONG imageMarginWidth, imageMarginHeight; LONG imageMarginWidth, imageMarginHeight;
RECT emptyMargin = {0}, oneMargin = {1, 1, 1, 1}; const RECT *textMargin = BUTTON_GetTextMargin(infoPtr);
RECT emptyMargin = {0};
LONG maxTextWidth; LONG maxTextWidth;
/* Calculate label rectangle according to label type */ /* Calculate label rectangle according to label type */
...@@ -1118,7 +1130,7 @@ static UINT BUTTON_CalcLayoutRects(const BUTTON_INFO *infoPtr, HDC hdc, RECT *la ...@@ -1118,7 +1130,7 @@ static UINT BUTTON_CalcLayoutRects(const BUTTON_INFO *infoPtr, HDC hdc, RECT *la
BUTTON_PositionRect(split_style, &boundingImageRect, &imageRect, BUTTON_PositionRect(split_style, &boundingImageRect, &imageRect,
infoPtr->imagelist.himl ? &infoPtr->imagelist.margin : &emptyMargin); infoPtr->imagelist.himl ? &infoPtr->imagelist.margin : &emptyMargin);
/* Text doesn't use imagelist align */ /* Text doesn't use imagelist align */
BUTTON_PositionRect(style, &boundingTextRect, &textRect, &oneMargin); BUTTON_PositionRect(style, &boundingTextRect, &textRect, textMargin);
} }
else else
{ {
...@@ -1143,17 +1155,17 @@ static UINT BUTTON_CalcLayoutRects(const BUTTON_INFO *infoPtr, HDC hdc, RECT *la ...@@ -1143,17 +1155,17 @@ static UINT BUTTON_CalcLayoutRects(const BUTTON_INFO *infoPtr, HDC hdc, RECT *la
/* Get text rect */ /* Get text rect */
SubtractRect(&boundingTextRect, &labelRect, &boundingImageRect); SubtractRect(&boundingTextRect, &labelRect, &boundingImageRect);
/* Text doesn't use imagelist align */ /* Text doesn't use imagelist align */
BUTTON_PositionRect(style, &boundingTextRect, &textRect, &oneMargin); BUTTON_PositionRect(style, &boundingTextRect, &textRect, textMargin);
} }
} }
/* Show text only */ /* Show text only */
else else
{ {
if (get_button_type(style) != BS_GROUPBOX) if (get_button_type(style) != BS_GROUPBOX)
BUTTON_PositionRect(style, labelRc, &textRect, &oneMargin); BUTTON_PositionRect(style, labelRc, &textRect, textMargin);
else else
/* GroupBox is always top aligned */ /* 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; labelRect = textRect;
SetRectEmpty(&imageRect); SetRectEmpty(&imageRect);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment