1
0
Эх сурвалжийг харах

Generalizing HasLabelHintPopup

Source commit: c09baaab29d74b6bfd6b3df25a7fb158976b9525
Martin Prikryl 7 жил өмнө
parent
commit
7d405b5fc0

+ 4 - 10
source/windows/GUITools.cpp

@@ -1426,17 +1426,11 @@ 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);
-  return (HintLabel != NULL) && HasLabelHintPopup(HintLabel, Hint);
-}
-//---------------------------------------------------------------------------
 int __fastcall TScreenTipHintWindow::GetMargin(TControl * HintControl, const UnicodeString & Hint)
 {
   int Result;
 
-  if (IsHintPopup(HintControl, Hint) || IsPathLabel(HintControl))
+  if (HasLabelHintPopup(HintControl, Hint) || IsPathLabel(HintControl))
   {
     Result = 3;
   }
@@ -1453,7 +1447,7 @@ int __fastcall TScreenTipHintWindow::GetMargin(TControl * HintControl, const Uni
 TFont * __fastcall TScreenTipHintWindow::GetFont(TControl * HintControl, const UnicodeString & Hint)
 {
   TFont * Result;
-  if (IsHintPopup(HintControl, Hint) || IsPathLabel(HintControl))
+  if (HasLabelHintPopup(HintControl, Hint) || IsPathLabel(HintControl))
   {
     Result = reinterpret_cast<TLabel *>(dynamic_cast<TCustomLabel *>(HintControl))->Font;
   }
@@ -1498,7 +1492,7 @@ TRect __fastcall TScreenTipHintWindow::CalcHintRect(int MaxWidth, const UnicodeS
     MaxWidth *= 2;
   }
 
-  bool HintPopup = IsHintPopup(HintControl, AHint);
+  bool HintPopup = HasLabelHintPopup(HintControl, AHint);
   if (HintPopup)
   {
     MaxWidth = HintControl->Width;
@@ -1551,7 +1545,7 @@ void __fastcall TScreenTipHintWindow::ActivateHintData(const TRect & ARect, cons
   FLongHint = GetLongHintIfAny(AHint);
   FHintControl = GetHintControl(AData);
   FMargin = GetMargin(FHintControl, AHint);
-  FHintPopup = IsHintPopup(FHintControl, AHint);
+  FHintPopup = HasLabelHintPopup(FHintControl, AHint);
 
   Canvas->Font->Assign(GetFont(FHintControl, AHint));
 

+ 0 - 1
source/windows/GUITools.h

@@ -144,7 +144,6 @@ 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);

+ 1 - 2
source/windows/TerminalManager.cpp

@@ -745,8 +745,7 @@ void __fastcall TTerminalManager::ApplicationShowHint(UnicodeString & HintStr,
   bool & /*CanShow*/, THintInfo & HintInfo)
 {
   HintInfo.HintData = HintInfo.HintControl;
-  TLabel * HintLabel = dynamic_cast<TLabel *>(HintInfo.HintControl);
-  if ((HintLabel != NULL) && HasLabelHintPopup(HintLabel, HintStr))
+  if (HasLabelHintPopup(HintInfo.HintControl, HintStr))
   {
     // Hack for transfer setting labels.
     // Should be converted to something like HintLabel()

+ 3 - 2
source/windows/VCLCommon.cpp

@@ -2263,9 +2263,10 @@ void __fastcall SetLabelHintPopup(TLabel * Label, const UnicodeString & Hint)
   Label->ShowHint = (Rect.Bottom > Label->Height);
 }
 //---------------------------------------------------------------------------
-bool __fastcall HasLabelHintPopup(TLabel * Label, const UnicodeString & HintStr)
+bool __fastcall HasLabelHintPopup(TControl * Control, const UnicodeString & HintStr)
 {
-  return (Label->Caption == HintStr);
+  TLabel * HintLabel = dynamic_cast<TLabel *>(Control);
+  return (HintLabel != NULL) && (HintLabel->Caption == HintStr);
 }
 //---------------------------------------------------------------------------
 Forms::TMonitor *  __fastcall FormMonitor(TCustomForm * Form)

+ 1 - 1
source/windows/VCLCommon.h

@@ -28,7 +28,7 @@ void __fastcall LinkAppLabel(TStaticText * StaticText);
 void __fastcall HintLabel(TStaticText * StaticText, UnicodeString Hint = L"");
 void __fastcall HotTrackLabel(TLabel * Label);
 void __fastcall SetLabelHintPopup(TLabel * Label, const UnicodeString & Hint);
-bool __fastcall HasLabelHintPopup(TLabel * Label, const UnicodeString & HintStr);
+bool __fastcall HasLabelHintPopup(TControl * Control, const UnicodeString & HintStr);
 void __fastcall FixComboBoxResizeBug(TCustomComboBox * ComboBox);
 void __fastcall ShowAsModal(TForm * Form, void *& Storage, bool BringToFront = true);
 void __fastcall HideAsModal(TForm * Form, void *& Storage);