ExCtrls/TButtonEx: Fix wordwrapped custom-drawn caption not being centered.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7985 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2021-03-28 18:00:00 +00:00
parent 8f8e736b98
commit c0acf0abb4
3 changed files with 12 additions and 1 deletions

View File

@ -65,6 +65,9 @@
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths> </SearchPaths>
<Linking> <Linking>
<Debugging>
<DebugInfoType Value="dsDwarf2Set"/>
</Debugging>
<Options> <Options>
<Win32> <Win32>
<GraphicApplication Value="True"/> <GraphicApplication Value="True"/>

View File

@ -42,6 +42,7 @@
</Item5> </Item5>
</Files> </Files>
<CompatibilityMode Value="True"/> <CompatibilityMode Value="True"/>
<LazDoc Paths="fpdoc"/>
<RequiredPkgs Count="2"> <RequiredPkgs Count="2">
<Item1> <Item1>
<PackageName Value="LazControls"/> <PackageName Value="LazControls"/>

View File

@ -418,6 +418,7 @@ var
i: integer; i: integer;
txtSize: TSize; txtSize: TSize;
txtPt: TPoint; txtPt: TPoint;
ts: TTextStyle;
begin begin
if (csDestroying in ComponentState) or not HandleAllocated then if (csDestroying in ComponentState) or not HandleAllocated then
exit; exit;
@ -526,7 +527,13 @@ begin
end; end;
txtPt.Y := (Height - txtSize.CY + 1) div 2; txtPt.Y := (Height - txtSize.CY + 1) div 2;
R := Rect(txtPt.X, txtPt.Y, txtPt.X + txtSize.CX, txtPt.Y + txtSize.CY); R := Rect(txtPt.X, txtPt.Y, txtPt.X + txtSize.CX, txtPt.Y + txtSize.CY);
DrawText(lCanvas.Handle, PChar(Caption), -1, R, flags);
ts := lCanvas.TextStyle;
ts.Alignment := lAlignment;
ts.Layout := tlCenter;
ts.SingleLine := not FWordWrap;
ts.Wordbreak := FWordWrap;
lCanvas.TextRect(R, txtPt.X, txtPt.Y, Caption, ts);
// Draw focus rectangle // Draw focus rectangle
if FShowFocusRect and Focused then if FShowFocusRect and Focused then