Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
1.9 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Creates a Message box with a question in it and yes/no buttons
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef TOOLTIP_H
  8. #define TOOLTIP_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include <vgui/VGUI.h>
  13. #include <vgui_controls/Controls.h>
  14. #include <utlvector.h>
  15. namespace vgui
  16. {
  17. //-----------------------------------------------------------------------------
  18. // Purpose: Tooltip for a panel - shows text when cursor hovers over a panel
  19. //-----------------------------------------------------------------------------
  20. class BaseTooltip
  21. {
  22. public:
  23. BaseTooltip(Panel *parent, const char *text = NULL);
  24. virtual void SetText(const char *text);
  25. virtual const char *GetText();
  26. virtual void ShowTooltip(Panel *currentPanel);
  27. virtual void HideTooltip();
  28. bool ShouldLayout( void );
  29. virtual void PerformLayout() { return; }
  30. virtual void PositionWindow( Panel *pTipPanel );
  31. void ResetDelay();
  32. void SetTooltipFormatToSingleLine();
  33. void SetTooltipFormatToMultiLine();
  34. void SetTooltipDelay(int tooltipDelayMilliseconds);
  35. int GetTooltipDelay();
  36. void SetEnabled( bool bState );
  37. private:
  38. Panel *m_pParent;
  39. virtual void ApplySchemeSettings(IScheme *pScheme) {};
  40. protected:
  41. CUtlVector<char> m_Text;
  42. int _delay; // delay that counts down
  43. int _tooltipDelay; // delay before tooltip comes up.
  44. bool _makeVisible : 1;
  45. bool _displayOnOneLine : 1;
  46. bool _isDirty : 1;
  47. bool _enabled : 1;
  48. };
  49. class TextTooltip : public BaseTooltip
  50. {
  51. public:
  52. TextTooltip(Panel *parent, const char *text = NULL);
  53. ~TextTooltip();
  54. virtual void SetText(const char *text);
  55. virtual void ShowTooltip(Panel *currentPanel);
  56. virtual void HideTooltip();
  57. virtual void SizeTextWindow();
  58. virtual void PerformLayout();
  59. virtual void ApplySchemeSettings(IScheme *pScheme);
  60. };
  61. };
  62. #endif // TOOLTIP_H