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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE 6 technical preview.
  4. Copyright (c) 2020 - Raw Material Software Limited
  5. You may use this code under the terms of the GPL v3
  6. (see www.gnu.org/licenses).
  7. For this technical preview, this file is not subject to commercial licensing.
  8. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  9. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  10. DISCLAIMED.
  11. ==============================================================================
  12. */
  13. namespace juce
  14. {
  15. //==============================================================================
  16. /**
  17. A button that uses the standard lozenge-shaped background with a line of
  18. text on it.
  19. @see Button, DrawableButton
  20. @tags{GUI}
  21. */
  22. class JUCE_API TextButton : public Button
  23. {
  24. public:
  25. //==============================================================================
  26. /** Creates a TextButton. */
  27. TextButton();
  28. /** Creates a TextButton.
  29. @param buttonName the text to put in the button (the component's name is also
  30. initially set to this string, but these can be changed later
  31. using the setName() and setButtonText() methods)
  32. */
  33. explicit TextButton (const String& buttonName);
  34. /** Creates a TextButton.
  35. @param buttonName the text to put in the button (the component's name is also
  36. initially set to this string, but these can be changed later
  37. using the setName() and setButtonText() methods)
  38. @param toolTip an optional string to use as a tooltip
  39. */
  40. TextButton (const String& buttonName, const String& toolTip);
  41. /** Destructor. */
  42. ~TextButton() override;
  43. //==============================================================================
  44. /** A set of colour IDs to use to change the colour of various aspects of the button.
  45. These constants can be used either via the Component::setColour(), or LookAndFeel::setColour()
  46. methods.
  47. @see Component::setColour, Component::findColour, LookAndFeel::setColour, LookAndFeel::findColour
  48. */
  49. enum ColourIds
  50. {
  51. buttonColourId = 0x1000100, /**< The colour used to fill the button shape (when the button is toggled
  52. 'off'). The look-and-feel class might re-interpret this to add
  53. effects, etc. */
  54. buttonOnColourId = 0x1000101, /**< The colour used to fill the button shape (when the button is toggled
  55. 'on'). The look-and-feel class might re-interpret this to add
  56. effects, etc. */
  57. textColourOffId = 0x1000102, /**< The colour to use for the button's text when the button's toggle state is "off". */
  58. textColourOnId = 0x1000103 /**< The colour to use for the button's text.when the button's toggle state is "on". */
  59. };
  60. //==============================================================================
  61. /** Changes this button's width to fit neatly around its current text, without
  62. changing its height.
  63. */
  64. void changeWidthToFitText();
  65. /** Resizes the button's width to fit neatly around its current text, and gives it
  66. the specified height.
  67. */
  68. void changeWidthToFitText (int newHeight);
  69. /** Returns the width that the LookAndFeel suggests would be best for this button if it
  70. had the given height.
  71. */
  72. int getBestWidthForHeight (int buttonHeight);
  73. //==============================================================================
  74. /** @internal */
  75. void paintButton (Graphics&, bool, bool) override;
  76. /** @internal */
  77. void colourChanged() override;
  78. private:
  79. #if JUCE_CATCH_DEPRECATED_CODE_MISUSE
  80. // Note that this method has been removed - instead, see LookAndFeel::getTextButtonFont()
  81. virtual int getFont() { return 0; }
  82. #endif
  83. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TextButton)
  84. };
  85. } // namespace juce