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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2017 - ROLI Ltd.
  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 5 End-User License
  8. Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
  9. 27th April 2017).
  10. End User License Agreement: www.juce.com/juce-5-licence
  11. Privacy Policy: www.juce.com/juce-5-privacy-policy
  12. Or: You may also use this code under the terms of the GPL v3 (see
  13. www.gnu.org/licenses).
  14. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  15. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  16. DISCLAIMED.
  17. ==============================================================================
  18. */
  19. namespace juce
  20. {
  21. //==============================================================================
  22. /**
  23. A button that uses the standard lozenge-shaped background with a line of
  24. text on it.
  25. @see Button, DrawableButton
  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 toolip
  44. */
  45. TextButton (const String& buttonName, const String& toolTip);
  46. /** Destructor. */
  47. ~TextButton();
  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 isMouseOverButton, bool isButtonDown) override;
  81. /** @internal */
  82. void colourChanged() override;
  83. private:
  84. #if JUCE_CATCH_DEPRECATED_CODE_MISUSE
  85. // Note that this method has been removed - instead, see LookAndFeel::getTextButtonFont()
  86. virtual int getFont() { return 0; }
  87. #endif
  88. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TextButton)
  89. };
  90. } // namespace juce