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.

110 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 that uses the standard lozenge-shaped background with a line of
  23. text on it.
  24. @see Button, DrawableButton
  25. @tags{GUI}
  26. */
  27. class JUCE_API TextButton : public Button
  28. {
  29. public:
  30. //==============================================================================
  31. /** Creates a TextButton. */
  32. TextButton();
  33. /** Creates a TextButton.
  34. @param buttonName the text to put in the button (the component's name is also
  35. initially set to this string, but these can be changed later
  36. using the setName() and setButtonText() methods)
  37. */
  38. explicit TextButton (const String& buttonName);
  39. /** Creates a TextButton.
  40. @param buttonName the text to put in the button (the component's name is also
  41. initially set to this string, but these can be changed later
  42. using the setName() and setButtonText() methods)
  43. @param toolTip an optional string to use as a tooltip
  44. */
  45. TextButton (const String& buttonName, const String& toolTip);
  46. /** Destructor. */
  47. ~TextButton() override;
  48. //==============================================================================
  49. /** A set of colour IDs to use to change the colour of various aspects of the button.
  50. These constants can be used either via the Component::setColour(), or LookAndFeel::setColour()
  51. methods.
  52. @see Component::setColour, Component::findColour, LookAndFeel::setColour, LookAndFeel::findColour
  53. */
  54. enum ColourIds
  55. {
  56. buttonColourId = 0x1000100, /**< The colour used to fill the button shape (when the button is toggled
  57. 'off'). The look-and-feel class might re-interpret this to add
  58. effects, etc. */
  59. buttonOnColourId = 0x1000101, /**< The colour used to fill the button shape (when the button is toggled
  60. 'on'). The look-and-feel class might re-interpret this to add
  61. effects, etc. */
  62. textColourOffId = 0x1000102, /**< The colour to use for the button's text when the button's toggle state is "off". */
  63. textColourOnId = 0x1000103 /**< The colour to use for the button's text.when the button's toggle state is "on". */
  64. };
  65. //==============================================================================
  66. /** Changes this button's width to fit neatly around its current text, without
  67. changing its height.
  68. */
  69. void changeWidthToFitText();
  70. /** Resizes the button's width to fit neatly around its current text, and gives it
  71. the specified height.
  72. */
  73. void changeWidthToFitText (int newHeight);
  74. /** Returns the width that the LookAndFeel suggests would be best for this button if it
  75. had the given height.
  76. */
  77. int getBestWidthForHeight (int buttonHeight);
  78. //==============================================================================
  79. /** @internal */
  80. void paintButton (Graphics&, bool, bool) override;
  81. /** @internal */
  82. void colourChanged() override;
  83. //==============================================================================
  84. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TextButton)
  85. };
  86. } // namespace juce