The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
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.

91 lines
3.3KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library - "Jules' Utility Class Extensions"
  4. Copyright 2004-11 by Raw Material Software Ltd.
  5. ------------------------------------------------------------------------------
  6. JUCE can be redistributed and/or modified under the terms of the GNU General
  7. Public License (Version 2), as published by the Free Software Foundation.
  8. A copy of the license is included in the JUCE distribution, or can be found
  9. online at www.gnu.org/licenses.
  10. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  13. ------------------------------------------------------------------------------
  14. To release a closed-source product which uses JUCE, commercial licenses are
  15. available: visit www.rawmaterialsoftware.com/juce for more information.
  16. ==============================================================================
  17. */
  18. #ifndef __JUCE_TOGGLEBUTTON_JUCEHEADER__
  19. #define __JUCE_TOGGLEBUTTON_JUCEHEADER__
  20. #include "juce_Button.h"
  21. //==============================================================================
  22. /**
  23. A button that can be toggled on/off.
  24. All buttons can be toggle buttons, but this lets you create one of the
  25. standard ones which has a tick-box and a text label next to it.
  26. @see Button, DrawableButton, TextButton
  27. */
  28. class JUCE_API ToggleButton : public Button
  29. {
  30. public:
  31. //==============================================================================
  32. /** Creates a ToggleButton. */
  33. ToggleButton();
  34. /** Creates a ToggleButton.
  35. @param buttonText 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. */
  39. explicit ToggleButton (const String& buttonText);
  40. /** Destructor. */
  41. ~ToggleButton();
  42. //==============================================================================
  43. /** Resizes the button to fit neatly around its current text.
  44. The button's height won't be affected, only its width.
  45. */
  46. void changeWidthToFitText();
  47. //==============================================================================
  48. /** A set of colour IDs to use to change the colour of various aspects of the button.
  49. These constants can be used either via the Component::setColour(), or LookAndFeel::setColour()
  50. methods.
  51. @see Component::setColour, Component::findColour, LookAndFeel::setColour, LookAndFeel::findColour
  52. */
  53. enum ColourIds
  54. {
  55. textColourId = 0x1006501 /**< The colour to use for the button's text. */
  56. };
  57. protected:
  58. //==============================================================================
  59. /** @internal */
  60. void paintButton (Graphics&, bool isMouseOverButton, bool isButtonDown);
  61. /** @internal */
  62. void colourChanged();
  63. private:
  64. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ToggleButton);
  65. };
  66. #endif // __JUCE_TOGGLEBUTTON_JUCEHEADER__