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.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. A button showing an underlined weblink, that will launch the link
  18. when it's clicked.
  19. @see Button
  20. @tags{GUI}
  21. */
  22. class JUCE_API HyperlinkButton : public Button
  23. {
  24. public:
  25. //==============================================================================
  26. /** Creates a HyperlinkButton.
  27. @param linkText the text that will be displayed in the button - this is
  28. also set as the Component's name, but the text can be
  29. changed later with the Button::setButtonText() method
  30. @param linkURL the URL to launch when the user clicks the button
  31. */
  32. HyperlinkButton (const String& linkText,
  33. const URL& linkURL);
  34. /** Creates a HyperlinkButton. */
  35. HyperlinkButton();
  36. /** Destructor. */
  37. ~HyperlinkButton() override;
  38. //==============================================================================
  39. /** Changes the font to use for the text.
  40. If resizeToMatchComponentHeight is true, the font's height will be adjusted
  41. to match the size of the component.
  42. */
  43. void setFont (const Font& newFont,
  44. bool resizeToMatchComponentHeight,
  45. Justification justificationType = Justification::horizontallyCentred);
  46. //==============================================================================
  47. /** A set of colour IDs to use to change the colour of various aspects of the link.
  48. These constants can be used either via the Component::setColour(), or LookAndFeel::setColour()
  49. methods.
  50. @see Component::setColour, Component::findColour, LookAndFeel::setColour, LookAndFeel::findColour
  51. */
  52. enum ColourIds
  53. {
  54. textColourId = 0x1001f00, /**< The colour to use for the URL text. */
  55. };
  56. //==============================================================================
  57. /** Changes the URL that the button will trigger. */
  58. void setURL (const URL& newURL) noexcept;
  59. /** Returns the URL that the button will trigger. */
  60. const URL& getURL() const noexcept { return url; }
  61. //==============================================================================
  62. /** Resizes the button horizontally to fit snugly around the text.
  63. This won't affect the button's height.
  64. */
  65. void changeWidthToFitText();
  66. //==============================================================================
  67. /** Sets the style of justification to be used for positioning the text.
  68. (The default is Justification::centred)
  69. */
  70. void setJustificationType (Justification justification);
  71. /** Returns the type of justification, as set in setJustificationType(). */
  72. Justification getJustificationType() const noexcept { return justification; }
  73. protected:
  74. //==============================================================================
  75. /** @internal */
  76. void clicked() override;
  77. /** @internal */
  78. void colourChanged() override;
  79. /** @internal */
  80. void paintButton (Graphics&, bool, bool) override;
  81. private:
  82. //==============================================================================
  83. using Button::clicked;
  84. Font getFontToUse() const;
  85. //==============================================================================
  86. URL url;
  87. Font font;
  88. bool resizeFont;
  89. Justification justification;
  90. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (HyperlinkButton)
  91. };
  92. } // namespace juce