TvPlanIt: Fix painting of text in VpNavBar on Cocoa.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8839 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2023-06-16 10:43:39 +00:00
parent 7940c5f9df
commit 839adfaf80
2 changed files with 9 additions and 6 deletions

View File

@ -500,7 +500,7 @@ uses
VpNavBarPainter;
const
DEFAULT_ITEMSPACING = 8;
DEFAULT_ITEMSPACING = 12;
{$IFNDEF PAINTER}
{DrawNavTab - returns the usable text area inside the tab rect.}

View File

@ -591,8 +591,9 @@ begin
AItem.LabelRect := R;
bkMode := SetBkMode(Canvas.Handle, TRANSPARENT);
AHeight:= DrawText(Canvas.Handle, PChar(s), Length(s), R, DT_CENTER or DT_VCENTER or DT_WORDBREAK);
DrawText(Canvas.Handle, PChar(s), Length(s), R, DT_CENTER or DT_VCENTER or DT_WORDBREAK);
SetBkMode(Canvas.Handle, bkMode);
AHeight := HeightOf(R);
end else
begin
R.Top := CurPos;
@ -611,7 +612,6 @@ begin
AItem.DisplayName := s;
DrawText(Canvas.Handle, PChar(s), Length(s), R, DT_LEFT or DT_CALCRECT);
txtWidth := WidthOf(R);
AHeight := HeightOf(R);
R.Right := R.Left + txtWidth + 1;
{$IFDEF MSWINDOWS}
OffsetRect(R, 0, -1); // Better centering of text
@ -623,6 +623,7 @@ begin
// AHeight := DrawText(Canvas.Handle, PChar(s), Length(s), R, DT_LEFT or DT_VCENTER);
SetBkMode(Canvas.Handle, bkMode);
AHeight := HeightOf(R);
if AHeight < FSmallImagesSize then
AHeight := FSmallImagesSize;
end;
@ -634,7 +635,7 @@ end;
function TVpNavBarPainter.DrawLargeIcon(Canvas: TCanvas; AItem: TVpNavBtnItem;
CurPos: Integer): Boolean;
const
MARGIN = 2;
MARGIN = 1;
var
W, H: Integer;
R: TRect;
@ -1098,7 +1099,8 @@ begin
Right := 1;
Bottom := 1;
end;
SH := DrawText(Canvas.Handle, 'W W', 3, TestRect, DT_SINGLELINE or DT_CALCRECT);
DrawText(Canvas.Handle, 'W W', 3, TestRect, DT_SINGLELINE or DT_CALCRECT);
SH := HeightOf(TestRect);
{get double line height}
with TestRect do begin
@ -1107,7 +1109,8 @@ begin
Right := 1;
Bottom := 1;
end;
DH := DrawText(Canvas.Handle, 'W W', 3, TestRect, DT_WORDBREAK or DT_CALCRECT);
DrawText(Canvas.Handle, 'W W', 3, TestRect, DT_WORDBREAK or DT_CALCRECT);
DH := HeightOf(TestRect);
{see if the text can fit within the existing rect without growing}
TestRect := Rect;