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.

128 lines
4.5KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2022 - Raw Material Software Limited
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. By using JUCE, you agree to the terms of both the JUCE 7 End-User License
  8. Agreement and JUCE Privacy Policy.
  9. End User License Agreement: www.juce.com/juce-7-licence
  10. Privacy Policy: www.juce.com/juce-privacy-policy
  11. Or: You may also use this code under the terms of the GPL v3 (see
  12. www.gnu.org/licenses).
  13. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  14. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  15. DISCLAIMED.
  16. ==============================================================================
  17. */
  18. namespace juce
  19. {
  20. //==============================================================================
  21. /**
  22. A button showing an underlined weblink, that will launch the link
  23. when it's clicked.
  24. @see Button
  25. @tags{GUI}
  26. */
  27. class JUCE_API HyperlinkButton : public Button
  28. {
  29. public:
  30. //==============================================================================
  31. /** Creates a HyperlinkButton.
  32. @param linkText the text that will be displayed in the button - this is
  33. also set as the Component's name, but the text can be
  34. changed later with the Button::setButtonText() method
  35. @param linkURL the URL to launch when the user clicks the button
  36. */
  37. HyperlinkButton (const String& linkText,
  38. const URL& linkURL);
  39. /** Creates a HyperlinkButton. */
  40. HyperlinkButton();
  41. /** Destructor. */
  42. ~HyperlinkButton() override;
  43. //==============================================================================
  44. /** Changes the font to use for the text.
  45. If resizeToMatchComponentHeight is true, the font's height will be adjusted
  46. to match the size of the component.
  47. */
  48. void setFont (const Font& newFont,
  49. bool resizeToMatchComponentHeight,
  50. Justification justificationType = Justification::horizontallyCentred);
  51. //==============================================================================
  52. /** A set of colour IDs to use to change the colour of various aspects of the link.
  53. These constants can be used either via the Component::setColour(), or LookAndFeel::setColour()
  54. methods.
  55. @see Component::setColour, Component::findColour, LookAndFeel::setColour, LookAndFeel::findColour
  56. */
  57. enum ColourIds
  58. {
  59. textColourId = 0x1001f00, /**< The colour to use for the URL text. */
  60. };
  61. //==============================================================================
  62. /** Changes the URL that the button will trigger. */
  63. void setURL (const URL& newURL) noexcept;
  64. /** Returns the URL that the button will trigger. */
  65. const URL& getURL() const noexcept { return url; }
  66. //==============================================================================
  67. /** Resizes the button horizontally to fit snugly around the text.
  68. This won't affect the button's height.
  69. */
  70. void changeWidthToFitText();
  71. //==============================================================================
  72. /** Sets the style of justification to be used for positioning the text.
  73. (The default is Justification::centred)
  74. */
  75. void setJustificationType (Justification justification);
  76. /** Returns the type of justification, as set in setJustificationType(). */
  77. Justification getJustificationType() const noexcept { return justification; }
  78. protected:
  79. //==============================================================================
  80. /** @internal */
  81. void clicked() override;
  82. /** @internal */
  83. void colourChanged() override;
  84. /** @internal */
  85. void paintButton (Graphics&, bool, bool) override;
  86. private:
  87. //==============================================================================
  88. using Button::clicked;
  89. Font getFontToUse() const;
  90. //==============================================================================
  91. URL url;
  92. Font font;
  93. bool resizeFont;
  94. Justification justification;
  95. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (HyperlinkButton)
  96. };
  97. } // namespace juce