Opkman: ShowHintFrm: memo height was incorrectly calculated under GTK.

git-svn-id: trunk@56838 -
This commit is contained in:
balazs 2017-12-24 13:15:23 +00:00
parent 6e53952a43
commit bed7ec4fc7
4 changed files with 52 additions and 53 deletions

View File

@ -112,8 +112,8 @@ begin
CH := LCLIntf.GetSystemMetrics(SM_CYCAPTION);
R.Left := Left;
R.Top := Top;
R.Right := Left + Width + 10;
R.Bottom := Top + Height + CH + 10;
R.Right := Left + Width + 15;
R.Bottom := Top + Height + CH + 15;
P.X := 0;
P.Y := 0;
GetCursorPos(P);
@ -170,21 +170,20 @@ begin
CurFrame.Align := alTop;
CurFrame.Init;
CurFrame.pnPackageName.Caption := ' ' + LazPackage.Name;
CurFrame.mDescription.Text := Trim(LazPackage.Description);
CurFrame.mLicense.Text := Trim(LazPackage.License);
FFrames.Add(CurFrame);
if FFrames.Count > 1 then
CurFrame.pnBase.BorderSpacing.Bottom := 5;
CurFrame.Parent := sbLazPackages;
CurFrame.CalcHeight(CurFrame.mLicense);
CurFrame.CalcHeight(CurFrame.mDescription);
CurFrame.Height := CurFrame.pnPackageName.Height + CurFrame.mDescription.Height + CurFrame.mLicense.Height;
CurFrame.CalcHeight(CurFrame.mDescription, Trim(LazPackage.Description));
CurFrame.CalcHeight(CurFrame.mLicense, Trim(LazPackage.License));
CurFrame.Height := CurFrame.pnPackageName.Height + CurFrame.pnDescription.Height + CurFrame.pnLicense.Height +
CurFrame.BorderSpacing.Top + CurFrame.pnBase.BorderSpacing.Bottom;
TotHeight := TotHeight + CurFrame.Height;
CurFrame.Visible := True;
end;
Node := VisualTree.VST.GetNextSibling(Node);
end;
if (TotHeight < 50) or (TotHeight > 325) then
if (TotHeight < 51) or (TotHeight > 325) then
TotHeight := 325;
Self.Height := TotHeight;
end;

View File

@ -1,17 +1,17 @@
object frShowHint: TfrShowHint
Left = 0
Height = 156
Height = 198
Top = 0
Width = 559
AutoSize = True
ClientHeight = 156
ClientHeight = 198
ClientWidth = 559
TabOrder = 0
DesignLeft = 388
DesignTop = 227
object pnBase: TPanel
Left = 10
Height = 136
Height = 178
Top = 10
Width = 539
Align = alClient
@ -20,18 +20,17 @@ object frShowHint: TfrShowHint
BorderSpacing.Right = 10
BorderSpacing.Bottom = 10
BevelInner = bvLowered
ClientHeight = 136
ClientHeight = 178
ClientWidth = 539
TabOrder = 0
object pnDescription: TPanel
Left = 2
Height = 55
Height = 73
Top = 24
Width = 535
Align = alTop
AutoSize = True
BevelOuter = bvNone
ClientHeight = 55
ClientHeight = 73
ClientWidth = 535
ParentFont = False
TabOrder = 0
@ -43,8 +42,8 @@ object frShowHint: TfrShowHint
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Side = asrBottom
Left = 20
Height = 31
Top = 17
Height = 51
Top = 19
Width = 508
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 20
@ -52,8 +51,12 @@ object frShowHint: TfrShowHint
BorderSpacing.Right = 7
BorderSpacing.Bottom = 7
BorderStyle = bsNone
Lines.Strings = (
'aaaaaaaaaa'
'bbbbbbbb'
)
ReadOnly = True
ScrollBars = ssVertical
ScrollBars = ssAutoVertical
TabOrder = 0
end
object lbDescription: TLabel
@ -61,9 +64,10 @@ object frShowHint: TfrShowHint
AnchorSideTop.Control = pnDescription
Left = 2
Height = 15
Top = 0
Top = 2
Width = 67
BorderSpacing.Left = 2
BorderSpacing.Top = 2
Caption = 'Description:'
Font.Style = [fsBold]
ParentColor = False
@ -72,13 +76,12 @@ object frShowHint: TfrShowHint
end
object pnLicense: TPanel
Left = 2
Height = 55
Top = 79
Height = 79
Top = 97
Width = 535
Align = alTop
AutoSize = True
BevelOuter = bvNone
ClientHeight = 55
ClientHeight = 79
ClientWidth = 535
ParentFont = False
TabOrder = 1
@ -90,17 +93,16 @@ object frShowHint: TfrShowHint
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Side = asrBottom
Left = 20
Height = 31
Top = 17
Height = 51
Top = 19
Width = 508
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 20
BorderSpacing.Top = 2
BorderSpacing.Right = 7
BorderSpacing.Bottom = 7
BorderStyle = bsNone
ReadOnly = True
ScrollBars = ssVertical
ScrollBars = ssAutoVertical
TabOrder = 0
end
object lbLicense: TLabel
@ -108,9 +110,10 @@ object frShowHint: TfrShowHint
AnchorSideTop.Control = pnLicense
Left = 2
Height = 15
Top = 0
Top = 2
Width = 44
BorderSpacing.Left = 2
BorderSpacing.Top = 2
Caption = 'License:'
Font.Style = [fsBold]
ParentColor = False

View File

@ -47,7 +47,7 @@ type
private
public
procedure Init;
procedure CalcHeight(AMemo: TMemo);
procedure CalcHeight(AMemo: TMemo; AText: String);
end;
implementation
@ -64,7 +64,7 @@ begin
Self.DoubleBuffered := True;
mDescription.DoubleBuffered := True;
mLicense.DoubleBuffered := True;
if Options.HintFormOptionColors.Count = 3 then
if Options.HintFormOptionColors.Count = HintColCnt then
begin
pnPackageName.Color := StringToColor(Options.HintFormOptionColors[0]);
pnDescription.Color := StringToColor(Options.HintFormOptionColors[1]);
@ -74,29 +74,26 @@ begin
end;
end;
procedure TfrShowHint.CalcHeight(AMemo: TMemo);
procedure TfrShowHint.CalcHeight(AMemo: TMemo; AText: String);
var
LH: Integer;
DC: HDC;
SaveFont : HFont;
Metrics : TTextMetric;
R: TRect;
Increase: Integer;
LC: Integer;
MH: Integer;
LH: Integer;
begin
DC := GetDC(AMemo.Handle);
SaveFont := SelectObject(DC, AMemo.Font.Handle);
GetTextMetrics(DC, Metrics);
SelectObject(DC, SaveFont);
ReleaseDC(AMemo.Handle, DC);
LH := Metrics.tmHeight;
R := Rect(0, 0, AMemo.Width, 0);
TPanel(AMemo.Parent).Font.Assign(AMemo.Font);
DrawText(TPanel(AMemo.Parent).Canvas.Handle, PChar(AText), -1, R, DT_CALCRECT or DT_LEFT or DT_WORDBREAK or DT_NOPREFIX);
Increase := AMemo.Height;
LC := AMemo.Lines.Count;
if LC < 2 then
LC := 2;
if LC > 6 then
LC := 6;
AMemo.Height := LC * LH + 8;
Increase := AMemo.Height - Increase;
MH := R.Bottom - R.Top;
if MH < 35 then
MH := 35;
if MH > 100 then
MH := 100;
Increase := MH - Increase;
AMemo.Height := MH;
AMemo.Parent.Height := AMemo.Parent.Height + Increase + 2;
AMemo.Text := AText;
end;
end.

View File

@ -1693,6 +1693,10 @@ begin
if (ssShift in Shift) and PtInRect(ContRect, P) and (Level > 0) then
begin
P := FVST.ClientToScreen(P);
if FShowHintFrm.Visible then
FShowHintFrm.MoveFormTo(P.X, P.Y)
else
FShowHintFrm.ShowFormAt(P.X, P.Y);
case Level of
2: FHoverNode := FHoverNode^.Parent;
3: FHoverNode := FHoverNode^.Parent^.Parent;
@ -1702,10 +1706,6 @@ begin
FShowHintFrm.UpdateInfo(FHoverNode);
FHoverNodeOld := FHoverNode;
end;
if FShowHintFrm.Visible then
FShowHintFrm.MoveFormTo(P.X, P.Y)
else
FShowHintFrm.ShowFormAt(P.X, P.Y);
end
end;
2: Exit;