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_TextButton.h 4.3KB

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