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.

101 lines
4.1KB

  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. @param buttonName the text to put in the button (the component's name is also
  31. initially set to this string, but these can be changed later
  32. using the setName() and setButtonText() methods)
  33. @param toolTip an optional string to use as a toolip
  34. @see Button
  35. */
  36. TextButton (const String& buttonName = String::empty,
  37. const String& toolTip = String::empty);
  38. /** Destructor. */
  39. ~TextButton();
  40. //==============================================================================
  41. /** A set of colour IDs to use to change the colour of various aspects of the button.
  42. These constants can be used either via the Component::setColour(), or LookAndFeel::setColour()
  43. methods.
  44. @see Component::setColour, Component::findColour, LookAndFeel::setColour, LookAndFeel::findColour
  45. */
  46. enum ColourIds
  47. {
  48. buttonColourId = 0x1000100, /**< The colour used to fill the button shape (when the button is toggled
  49. 'off'). The look-and-feel class might re-interpret this to add
  50. effects, etc. */
  51. buttonOnColourId = 0x1000101, /**< The colour used to fill the button shape (when the button is toggled
  52. 'on'). The look-and-feel class might re-interpret this to add
  53. effects, etc. */
  54. textColourOffId = 0x1000102, /**< The colour to use for the button's text when the button's toggle state is "off". */
  55. textColourOnId = 0x1000103 /**< The colour to use for the button's text.when the button's toggle state is "on". */
  56. };
  57. //==============================================================================
  58. /** Resizes the button to fit neatly around its current text.
  59. If newHeight is >= 0, the button's height will be changed to this
  60. value. If it's less than zero, its height will be unaffected.
  61. */
  62. void changeWidthToFitText (int newHeight = -1);
  63. /** This can be overridden to use different fonts than the default one.
  64. Note that you'll need to set the font's size appropriately, too.
  65. */
  66. virtual Font getFont();
  67. protected:
  68. /** @internal */
  69. void paintButton (Graphics&, bool isMouseOverButton, bool isButtonDown) override;
  70. /** @internal */
  71. void colourChanged() override;
  72. private:
  73. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TextButton)
  74. };
  75. #endif // JUCE_TEXTBUTTON_H_INCLUDED