richtooltip.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/richtooltip.h
  3. // Purpose: Declaration of wxRichToolTip class.
  4. // Author: Vadim Zeitlin
  5. // Created: 2011-10-07
  6. // Copyright: (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
  7. // Licence: wxWindows licence
  8. ///////////////////////////////////////////////////////////////////////////////
  9. #ifndef _WX_RICHTOOLTIP_H_
  10. #define _WX_RICHTOOLTIP_H_
  11. #include "wx/defs.h"
  12. #if wxUSE_RICHTOOLTIP
  13. #include "wx/colour.h"
  14. class WXDLLIMPEXP_FWD_CORE wxFont;
  15. class WXDLLIMPEXP_FWD_CORE wxIcon;
  16. class WXDLLIMPEXP_FWD_CORE wxWindow;
  17. class wxRichToolTipImpl;
  18. // This enum describes the kind of the tip shown which combines both the tip
  19. // position and appearance because the two are related (when the tip is
  20. // positioned asymmetrically, a right handed triangle is used but an
  21. // equilateral one when it's in the middle of a side).
  22. //
  23. // Automatic selects the tip appearance best suited for the current platform
  24. // and the position best suited for the window the tooltip is shown for, i.e.
  25. // chosen in such a way that the tooltip is always fully on screen.
  26. //
  27. // Other values describe the position of the tooltip itself, not the window it
  28. // relates to. E.g. wxTipKind_Top places the tip on the top of the tooltip and
  29. // so the tooltip itself is located beneath its associated window.
  30. enum wxTipKind
  31. {
  32. wxTipKind_None,
  33. wxTipKind_TopLeft,
  34. wxTipKind_Top,
  35. wxTipKind_TopRight,
  36. wxTipKind_BottomLeft,
  37. wxTipKind_Bottom,
  38. wxTipKind_BottomRight,
  39. wxTipKind_Auto
  40. };
  41. // ----------------------------------------------------------------------------
  42. // wxRichToolTip: a customizable but not necessarily native tooltip.
  43. // ----------------------------------------------------------------------------
  44. // Notice that this class does not inherit from wxWindow.
  45. class WXDLLIMPEXP_ADV wxRichToolTip
  46. {
  47. public:
  48. // Ctor must specify the tooltip title and main message, additional
  49. // attributes can be set later.
  50. wxRichToolTip(const wxString& title, const wxString& message);
  51. // Set the background colour: if two colours are specified, the background
  52. // is drawn using a gradient from top to bottom, otherwise a single solid
  53. // colour is used.
  54. void SetBackgroundColour(const wxColour& col,
  55. const wxColour& colEnd = wxColour());
  56. // Set the small icon to show: either one of the standard information/
  57. // warning/error ones (the question icon doesn't make sense for a tooltip)
  58. // or a custom icon.
  59. void SetIcon(int icon = wxICON_INFORMATION);
  60. void SetIcon(const wxIcon& icon);
  61. // Set timeout after which the tooltip should disappear, in milliseconds.
  62. // By default the tooltip is hidden after system-dependent interval of time
  63. // elapses but this method can be used to change this or also disable
  64. // hiding the tooltip automatically entirely by passing 0 in this parameter
  65. // (but doing this can result in native version not being used).
  66. // Optionally specify a show delay.
  67. void SetTimeout(unsigned milliseconds, unsigned millisecondsShowdelay = 0);
  68. // Choose the tip kind, possibly none. By default the tip is positioned
  69. // automatically, as if wxTipKind_Auto was used.
  70. void SetTipKind(wxTipKind tipKind);
  71. // Set the title text font. By default it's emphasized using the font style
  72. // or colour appropriate for the current platform.
  73. void SetTitleFont(const wxFont& font);
  74. // Show the tooltip for the given window and optionally a specified area.
  75. void ShowFor(wxWindow* win, const wxRect* rect = NULL);
  76. // Non-virtual dtor as this class is not supposed to be derived from.
  77. ~wxRichToolTip();
  78. private:
  79. wxRichToolTipImpl* const m_impl;
  80. wxDECLARE_NO_COPY_CLASS(wxRichToolTip);
  81. };
  82. #endif // wxUSE_RICHTOOLTIP
  83. #endif // _WX_RICHTOOLTIP_H_