LCL/SpeedButton: Draw centered multi-line caption. Issue #39632

(cherry picked from commit 89bd5e8943)
This commit is contained in:
wp_xyz 2022-02-07 12:59:12 +01:00 committed by Maxim Ganetsky
parent 587c6d56c5
commit fc869b0bdc

View File

@ -710,19 +710,19 @@ begin
blGlyphRight : begin
Offset.X:= ClientSize.cx - M - GlyphWidth;
Offset.Y:= (ClientSize.cy - GlyphHeight) div 2;
OffsetCap.X:= Offset.X - S - TextSize.cx;
OffsetCap.X:= M;
OffsetCap.Y:= (ClientSize.cy - TextSize.cy) div 2;
end;
blGlyphTop : begin
Offset.X:= (ClientSize.cx - GlyphWidth) div 2;
Offset.Y:= M;
OffsetCap.X:= (ClientSize.cx - TextSize.cx) div 2;
OffsetCap.X:= 0;
OffsetCap.Y:= Offset.Y + GlyphHeight + S;
end;
blGlyphBottom : begin
Offset.X:= (ClientSize.cx - GlyphWidth) div 2;
Offset.Y:= ClientSize.cy - M - GlyphHeight;
OffsetCap.X:= (ClientSize.cx - TextSize.cx) div 2;
OffsetCap.X:= 0;
OffsetCap.Y:= Offset.Y - S - TextSize.cy;
end;
end;
@ -731,13 +731,15 @@ begin
if FShowCaption and (Caption <> '') then
begin
with PaintRect, OffsetCap do
with PaintRect do
begin
Left := Left + X;
Top := Top + Y;
Left := Left + OffsetCap.X;
Top := Top + OffsetCap.Y;
if CurLayout = blGlyphRight then
Right := ClientSize.cx - M - GlyphWidth - S;
end;
TextFlags := DT_LEFT or DT_TOP;
TextFlags := DT_LEFT or DT_TOP or DT_CENTER or DT_NOCLIP;
if UseRightToLeftReading then
TextFlags := TextFlags or DT_RTLREADING;