The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
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.

82 lines
2.5KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE 6 technical preview.
  4. Copyright (c) 2020 - Raw Material Software Limited
  5. You may use this code under the terms of the GPL v3
  6. (see www.gnu.org/licenses).
  7. For this technical preview, this file is not subject to commercial licensing.
  8. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  9. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  10. DISCLAIMED.
  11. ==============================================================================
  12. */
  13. namespace juce
  14. {
  15. //==============================================================================
  16. /**
  17. Components that want to use pop-up tooltips should implement this interface.
  18. A TooltipWindow will wait for the mouse to hover over a component that
  19. implements the TooltipClient interface, and when it finds one, it will display
  20. the tooltip returned by its getTooltip() method.
  21. @see TooltipWindow, SettableTooltipClient
  22. @tags{GUI}
  23. */
  24. class JUCE_API TooltipClient
  25. {
  26. public:
  27. /** Destructor. */
  28. virtual ~TooltipClient() = default;
  29. /** Returns the string that this object wants to show as its tooltip. */
  30. virtual String getTooltip() = 0;
  31. };
  32. //==============================================================================
  33. /**
  34. An implementation of TooltipClient that stores the tooltip string and a method
  35. for changing it.
  36. This makes it easy to add a tooltip to a custom component, by simply adding this
  37. as a base class and calling setTooltip().
  38. Many of the JUCE widgets already use this as a base class to implement their
  39. tooltips.
  40. @see TooltipClient, TooltipWindow
  41. @tags{GUI}
  42. */
  43. class JUCE_API SettableTooltipClient : public TooltipClient
  44. {
  45. public:
  46. //==============================================================================
  47. /** Destructor. */
  48. ~SettableTooltipClient() override = default;
  49. //==============================================================================
  50. /** Assigns a new tooltip to this object. */
  51. virtual void setTooltip (const String& newTooltip) { tooltipString = newTooltip; }
  52. /** Returns the tooltip assigned to this object. */
  53. String getTooltip() override { return tooltipString; }
  54. protected:
  55. SettableTooltipClient() = default;
  56. private:
  57. String tooltipString;
  58. };
  59. } // namespace juce