Win32: fixed TBitBtn.Spacing when glyph isn't assigned or size is 0.issue #23255

git-svn-id: trunk@41513 -
This commit is contained in:
zeljko 2013-06-03 13:17:20 +00:00
parent 25446e20d5
commit dbf54a7429

View File

@ -298,15 +298,24 @@ var
var var
RGBA: PRGBAQuad; RGBA: PRGBAQuad;
AlphaDraw: Boolean; AlphaDraw: Boolean;
ASpacing: Integer;
begin begin
// gather info about bitbtn // gather info about bitbtn
BitBtnHandle := BitBtn.Handle; BitBtnHandle := BitBtn.Handle;
ASpacing := BitBtn.Spacing;
{set spacing to LCL's default if bitbtn does not have glyph.issue #23255}
if not BitBtn.CanShowGlyph then
ASpacing := -1;
if BitBtn.CanShowGlyph then if BitBtn.CanShowGlyph then
begin begin
srcWidth := BitBtn.Glyph.Width; srcWidth := BitBtn.Glyph.Width;
srcHeight := BitBtn.Glyph.Height; srcHeight := BitBtn.Glyph.Height;
if BitBtn.NumGlyphs > 1 then if BitBtn.NumGlyphs > 1 then
srcWidth := srcWidth div BitBtn.NumGlyphs; srcWidth := srcWidth div BitBtn.NumGlyphs;
if (srcWidth = 0) or (srcHeight = 0) then
ASpacing := -1;
end else end else
begin begin
srcWidth := 0; srcWidth := 0;
@ -320,10 +329,10 @@ begin
case BitBtnLayout of case BitBtnLayout of
blGlyphLeft, blGlyphRight: blGlyphLeft, blGlyphRight:
begin begin
if BitBtn.Spacing = -1 then if ASpacing = -1 then
newWidth := BitBtn.Width - 10 newWidth := BitBtn.Width - 10
else else
newWidth := TextSize.cx + srcWidth + BitBtn.Spacing; newWidth := TextSize.cx + srcWidth + ASpacing;
newHeight := TextSize.cy; newHeight := TextSize.cy;
if newHeight < srcHeight then if newHeight < srcHeight then
newHeight := srcHeight; newHeight := srcHeight;
@ -334,19 +343,19 @@ begin
begin begin
XDestBitmap := 0; XDestBitmap := 0;
XDestText := srcWidth; XDestText := srcWidth;
if BitBtn.Spacing = -1 then if ASpacing = -1 then
inc(XDestText, (newWidth - srcWidth - TextSize.cx) div 2) inc(XDestText, (newWidth - srcWidth - TextSize.cx) div 2)
else else
inc(XDestText, BitBtn.Spacing); inc(XDestText, ASpacing);
end; end;
blGlyphRight: blGlyphRight:
begin begin
XDestBitmap := newWidth - srcWidth; XDestBitmap := newWidth - srcWidth;
XDestText := XDestBitmap - TextSize.cx; XDestText := XDestBitmap - TextSize.cx;
if BitBtn.Spacing = -1 then if ASpacing = -1 then
dec(XDestText, (newWidth - srcWidth - TextSize.cx) div 2) dec(XDestText, (newWidth - srcWidth - TextSize.cx) div 2)
else else
dec(XDestText, BitBtn.Spacing); dec(XDestText, ASpacing);
end; end;
end; end;
end; end;
@ -355,10 +364,10 @@ begin
newWidth := TextSize.cx; newWidth := TextSize.cx;
if newWidth < srcWidth then if newWidth < srcWidth then
newWidth := srcWidth; newWidth := srcWidth;
if BitBtn.Spacing = -1 then if ASpacing = -1 then
newHeight := BitBtn.Height - 10 newHeight := BitBtn.Height - 10
else else
newHeight := TextSize.cy + srcHeight + BitBtn.Spacing; newHeight := TextSize.cy + srcHeight + ASpacing;
XDestBitmap := (newWidth - srcWidth) shr 1; XDestBitmap := (newWidth - srcWidth) shr 1;
XDestText := (newWidth - TextSize.cx) shr 1; XDestText := (newWidth - TextSize.cx) shr 1;
case BitBtnLayout of case BitBtnLayout of
@ -366,19 +375,19 @@ begin
begin begin
YDestBitmap := 0; YDestBitmap := 0;
YDestText := srcHeight; YDestText := srcHeight;
if BitBtn.Spacing = -1 then if ASpacing = -1 then
inc(YDestText, (newHeight - srcHeight - TextSize.cy) div 2) inc(YDestText, (newHeight - srcHeight - TextSize.cy) div 2)
else else
inc(YDestText, BitBtn.Spacing); inc(YDestText, ASpacing);
end; end;
blGlyphBottom: blGlyphBottom:
begin begin
YDestBitmap := newHeight - srcHeight; YDestBitmap := newHeight - srcHeight;
YDestText := YDestBitmap - TextSize.cy; YDestText := YDestBitmap - TextSize.cy;
if BitBtn.Spacing = -1 then if ASpacing = -1 then
dec(YDestText, (newHeight - srcHeight - TextSize.cy) div 2) dec(YDestText, (newHeight - srcHeight - TextSize.cy) div 2)
else else
dec(YDestText, BitBtn.Spacing); dec(YDestText, ASpacing);
end; end;
end; end;
end; end;