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_ToggleButton.h 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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_TOGGLEBUTTON_H_INCLUDED
  18. #define JUCE_TOGGLEBUTTON_H_INCLUDED
  19. //==============================================================================
  20. /**
  21. A button that can be toggled on/off.
  22. All buttons can be toggle buttons, but this lets you create one of the
  23. standard ones which has a tick-box and a text label next to it.
  24. @see Button, DrawableButton, TextButton
  25. */
  26. class JUCE_API ToggleButton : public Button
  27. {
  28. public:
  29. //==============================================================================
  30. /** Creates a ToggleButton. */
  31. ToggleButton();
  32. /** Creates a ToggleButton.
  33. @param buttonText the text to put in the button (the component's name is also
  34. initially set to this string, but these can be changed later
  35. using the setName() and setButtonText() methods)
  36. */
  37. explicit ToggleButton (const String& buttonText);
  38. /** Destructor. */
  39. ~ToggleButton();
  40. //==============================================================================
  41. /** Resizes the button to fit neatly around its current text.
  42. The button's height won't be affected, only its width.
  43. */
  44. void changeWidthToFitText();
  45. //==============================================================================
  46. /** A set of colour IDs to use to change the colour of various aspects of the button.
  47. These constants can be used either via the Component::setColour(), or LookAndFeel::setColour()
  48. methods.
  49. @see Component::setColour, Component::findColour, LookAndFeel::setColour, LookAndFeel::findColour
  50. */
  51. enum ColourIds
  52. {
  53. textColourId = 0x1006501 /**< The colour to use for the button's text. */
  54. };
  55. protected:
  56. //==============================================================================
  57. /** @internal */
  58. void paintButton (Graphics&, bool isMouseOverButton, bool isButtonDown) override;
  59. /** @internal */
  60. void colourChanged() override;
  61. private:
  62. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ToggleButton)
  63. };
  64. #endif // JUCE_TOGGLEBUTTON_H_INCLUDED