Browse Source

Path label hint popup uses the same font as the underlying label

Source commit: 8b72ac109be65db03e41c2fd542c364ff2cee2cc
Martin Prikryl 9 years ago
parent
commit
15ee674b7d
3 changed files with 15 additions and 6 deletions
  1. 2 2
      source/packages/my/PathLabel.pas
  2. 12 4
      source/windows/GUITools.cpp
  3. 1 0
      source/windows/GUITools.h

+ 2 - 2
source/packages/my/PathLabel.pas

@@ -173,8 +173,8 @@ procedure TCustomPathLabel.CMHintShow(var Message: TMessage);
 begin
   with TCMHintShow(Message).HintInfo^ do
   begin
-    HintPos.X := ClientOrigin.X + IndentHorizontal - 3;
-    HintPos.Y := ClientOrigin.Y + IndentVertical - 3;
+    HintPos.X := ClientOrigin.X + IndentHorizontal;
+    HintPos.Y := ClientOrigin.Y + IndentVertical;
     if UseHotTrack then Inc(HintPos.Y, Height);
   end;
 end; { CMHintShow }

+ 12 - 4
source/windows/GUITools.cpp

@@ -1166,6 +1166,11 @@ bool __fastcall TScreenTipHintWindow::UseBoldShortHint(TControl * HintControl)
     (dynamic_cast<TTBPopupWindow *>(HintControl) != NULL);
 }
 //---------------------------------------------------------------------------
+bool __fastcall TScreenTipHintWindow::IsPathLabel(TControl * HintControl)
+{
+  return (dynamic_cast<TPathLabel *>(HintControl) != NULL);
+}
+//---------------------------------------------------------------------------
 bool __fastcall TScreenTipHintWindow::IsHintPopup(TControl * HintControl, const UnicodeString & Hint)
 {
   TLabel * HintLabel = dynamic_cast<TLabel *>(HintControl);
@@ -1176,7 +1181,7 @@ int __fastcall TScreenTipHintWindow::GetMargin(TControl * HintControl, const Uni
 {
   int Result;
 
-  if (IsHintPopup(HintControl, Hint))
+  if (IsHintPopup(HintControl, Hint) || IsPathLabel(HintControl))
   {
     Result = 3;
   }
@@ -1192,11 +1197,10 @@ int __fastcall TScreenTipHintWindow::GetMargin(TControl * HintControl, const Uni
 //---------------------------------------------------------------------------
 TFont * __fastcall TScreenTipHintWindow::GetFont(TControl * HintControl, const UnicodeString & Hint)
 {
-  bool HintPopup = IsHintPopup(HintControl, Hint);
   TFont * Result;
-  if (HintPopup)
+  if (IsHintPopup(HintControl, Hint) || IsPathLabel(HintControl))
   {
-    Result = dynamic_cast<TLabel *>(HintControl)->Font;
+    Result = reinterpret_cast<TLabel *>(dynamic_cast<TCustomLabel *>(HintControl))->Font;
   }
   else
   {
@@ -1300,6 +1304,10 @@ void __fastcall TScreenTipHintWindow::ActivateHintData(const TRect & ARect, cons
   {
     Rect.SetLocation(FHintControl->ClientToScreen(TPoint(-FMargin, -FMargin)));
   }
+  if (IsPathLabel(FHintControl))
+  {
+    Rect.Offset(-FMargin, -FMargin);
+  }
 
   THintWindow::ActivateHintData(Rect, FShortHint, AData);
 }

+ 1 - 0
source/windows/GUITools.h

@@ -143,6 +143,7 @@ private:
   UnicodeString __fastcall GetLongHintIfAny(const UnicodeString & AHint);
   static int __fastcall GetTextFlags(TControl * Control);
   bool __fastcall IsHintPopup(TControl * HintControl, const UnicodeString & Hint);
+  bool __fastcall IsPathLabel(TControl * HintControl);
   bool __fastcall UseBoldShortHint(TControl * HintControl);
   int __fastcall GetMargin(TControl * HintControl, const UnicodeString & Hint);
   TFont * __fastcall GetFont(TControl * HintControl, const UnicodeString & Hint);