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.

114 lines
4.8KB

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