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

This commit is contained in:
wp_xyz 2022-02-07 12:59:12 +01:00
parent 932d36f20e
commit 89bd5e8943

View File

@ -711,19 +711,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;
@ -732,13 +732,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;