Audio plugin host https://kx.studio/carla
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.

juce_HyperlinkButton.h 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2013 - Raw Material Software Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. #ifndef JUCE_HYPERLINKBUTTON_H_INCLUDED
  18. #define JUCE_HYPERLINKBUTTON_H_INCLUDED
  19. //==============================================================================
  20. /**
  21. A button showing an underlined weblink, that will launch the link
  22. when it's clicked.
  23. @see Button
  24. */
  25. class JUCE_API HyperlinkButton : public Button
  26. {
  27. public:
  28. //==============================================================================
  29. /** Creates a HyperlinkButton.
  30. @param linkText the text that will be displayed in the button - this is
  31. also set as the Component's name, but the text can be
  32. changed later with the Button::getButtonText() method
  33. @param linkURL the URL to launch when the user clicks the button
  34. */
  35. HyperlinkButton (const String& linkText,
  36. const URL& linkURL);
  37. /** Creates a HyperlinkButton. */
  38. HyperlinkButton();
  39. /** Destructor. */
  40. ~HyperlinkButton();
  41. //==============================================================================
  42. /** Changes the font to use for the text.
  43. If resizeToMatchComponentHeight is true, the font's height will be adjusted
  44. to match the size of the component.
  45. */
  46. void setFont (const Font& newFont,
  47. bool resizeToMatchComponentHeight,
  48. Justification justificationType = Justification::horizontallyCentred);
  49. //==============================================================================
  50. /** A set of colour IDs to use to change the colour of various aspects of the link.
  51. These constants can be used either via the Component::setColour(), or LookAndFeel::setColour()
  52. methods.
  53. @see Component::setColour, Component::findColour, LookAndFeel::setColour, LookAndFeel::findColour
  54. */
  55. enum ColourIds
  56. {
  57. textColourId = 0x1001f00, /**< The colour to use for the URL text. */
  58. };
  59. //==============================================================================
  60. /** Changes the URL that the button will trigger. */
  61. void setURL (const URL& newURL) noexcept;
  62. /** Returns the URL that the button will trigger. */
  63. const URL& getURL() const noexcept { return url; }
  64. //==============================================================================
  65. /** Resizes the button horizontally to fit snugly around the text.
  66. This won't affect the button's height.
  67. */
  68. void changeWidthToFitText();
  69. protected:
  70. //==============================================================================
  71. /** @internal */
  72. void clicked() override;
  73. /** @internal */
  74. void colourChanged() override;
  75. /** @internal */
  76. void paintButton (Graphics&, bool isMouseOver, bool isButtonDown) override;
  77. private:
  78. //==============================================================================
  79. URL url;
  80. Font font;
  81. bool resizeFont;
  82. Justification justification;
  83. Font getFontToUse() const;
  84. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (HyperlinkButton)
  85. };
  86. #endif // JUCE_HYPERLINKBUTTON_H_INCLUDED