Commit 37f0823e authored by wp's avatar wp
Browse files

LCL: Fix TBitBtn ignoring the Margin property on Windows (issue #34379)

git-svn-id: trunk@59270 -
parent efd092f5
......@@ -291,10 +291,12 @@ var
RGBA: PRGBAQuad;
AlphaDraw: Boolean;
ASpacing: Integer;
lMargin: Integer;
begin
// gather info about bitbtn
BitBtnHandle := BitBtn.Handle;
ASpacing := BitBtn.Spacing;
if BitBtn.Margin = -1 then lMargin := 0 else lMargin := BitBtn.Margin;
if BitBtn.CanShowGlyph(True) then
begin
......@@ -321,9 +323,9 @@ begin
blGlyphLeft, blGlyphRight:
begin
if ASpacing = -1 then
newWidth := BitBtn.Width - 10
newWidth := BitBtn.Width
else
newWidth := TextSize.cx + srcWidth + ASpacing;
newWidth := TextSize.cx + srcWidth + ASpacing + lMargin;
newHeight := TextSize.cy;
if newHeight < srcHeight then
newHeight := srcHeight;
......@@ -332,20 +334,28 @@ begin
case BitBtnLayout of
blGlyphLeft:
begin
XDestBitmap := 0;
XDestBitmap := lMargin;
XDestText := srcWidth;
if ASpacing = -1 then
inc(XDestText, (newWidth - srcWidth - TextSize.cx) div 2)
else
inc(XDestText, ASpacing);
if ASpacing = -1 then begin
if BitBtn.Margin = -1 then begin
XDestBitmap := (BitBtn.Width - (srcWidth + TextSize.cx)) div 3;
XDestText := 2*XDestBitmap + srcWidth;
end else
inc(XDestText, (newWidth - srcWidth - TextSize.cx + lMargin) div 2);
end else
inc(XDestText, ASpacing + lMargin);
end;
blGlyphRight:
begin
XDestBitmap := newWidth - srcWidth;
XDestBitmap := newWidth - srcWidth - lMargin;
XDestText := XDestBitmap - TextSize.cx;
if ASpacing = -1 then
dec(XDestText, (newWidth - srcWidth - TextSize.cx) div 2)
else
if ASpacing = -1 then begin
if BitBtn.Margin = -1 then begin
XDestText := (BitBtn.Width - (srcWidth + TextSize.cx)) div 3;
XDestBitmap := 2 * XDestText + TextSize.cx;
end else
dec(XDestText, (newWidth - srcWidth - TextSize.cx - lMargin) div 2)
end else
dec(XDestText, ASpacing);
end;
end;
......@@ -356,28 +366,36 @@ begin
if newWidth < srcWidth then
newWidth := srcWidth;
if ASpacing = -1 then
newHeight := BitBtn.Height - 10
newHeight := BitBtn.Height
else
newHeight := TextSize.cy + srcHeight + ASpacing;
newHeight := TextSize.cy + srcHeight + ASpacing + lMargin;
XDestBitmap := (newWidth - srcWidth) shr 1;
XDestText := (newWidth - TextSize.cx) shr 1;
case BitBtnLayout of
blGlyphTop:
begin
YDestBitmap := 0;
YDestBitmap := lMargin;
YDestText := srcHeight;
if ASpacing = -1 then
inc(YDestText, (newHeight - srcHeight - TextSize.cy) div 2)
else
inc(YDestText, ASpacing);
if ASpacing = -1 then begin
if BitBtn.Margin = -1 then begin
YDestBitmap := (BitBtn.Height - (srcHeight + TextSize.cy)) div 3;
YDestText := 2*YDestBitmap + srcHeight;
end else
inc(YDestText, (newHeight - srcHeight - TextSize.cy + lMargin) div 2)
end else
inc(YDestText, ASpacing + lMargin);
end;
blGlyphBottom:
begin
YDestBitmap := newHeight - srcHeight;
YDestBitmap := newHeight - srcHeight - lMargin;
YDestText := YDestBitmap - TextSize.cy;
if ASpacing = -1 then
dec(YDestText, (newHeight - srcHeight - TextSize.cy) div 2)
else
if ASpacing = -1 then begin
if BitBtn.Margin = -1 then begin
YDestText := (BitBtn.Height - (srcHeight + TextSize.cy)) div 3;
YDestBitmap := 2 * YDestText + TextSize.cy;
end else
dec(YDestText, (newHeight - srcHeight - TextSize.cy - lMargin) div 2)
end else
dec(YDestText, ASpacing);
end;
end;
......@@ -416,11 +434,14 @@ begin
ButtonImageList.himl := ImageList_Create(newWidth, newHeight, ILC_COLORDDB or ILC_MASK, 5, 0)
else
ButtonImageList.himl := ImageList_Create(newWidth, newHeight, ILC_COLORDDB or ILC_MASK, 1, 0);
ButtonImageList.margin.left := 5;
ButtonImageList.margin.right := 5;
ButtonImageList.margin.top := 5;
ButtonImageList.margin.bottom := 5;
ButtonImageList.uAlign := BUTTON_IMAGELIST_ALIGN_CENTER;
ButtonImageList.margin.left := 0; //5;
ButtonImageList.margin.right := 0; //5;
ButtonImageList.margin.top := 0; //5;
ButtonImageList.margin.bottom := 0; //5;
if (BitBtn.Margin = -1) then
ButtonImageList.uAlign := BUTTON_IMAGELIST_ALIGN_CENTER
else
ButtonImageList.uAlign := ord(BitBtnLayout);
// if themes are enabled then we need to fill all state bitmaps,
// else fill only current state bitmap
if ThemeServices.ThemesEnabled then
......
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