juce_ToggleButton.cpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. ToggleButton::ToggleButton()
  18. : Button (String::empty)
  19. {
  20. setClickingTogglesState (true);
  21. }
  22. ToggleButton::ToggleButton (const String& buttonText)
  23. : Button (buttonText)
  24. {
  25. setClickingTogglesState (true);
  26. }
  27. ToggleButton::~ToggleButton()
  28. {
  29. }
  30. void ToggleButton::paintButton (Graphics& g, bool isMouseOverButton, bool isButtonDown)
  31. {
  32. getLookAndFeel().drawToggleButton (g, *this, isMouseOverButton, isButtonDown);
  33. }
  34. void ToggleButton::changeWidthToFitText()
  35. {
  36. getLookAndFeel().changeToggleButtonWidthToFitText (*this);
  37. }
  38. void ToggleButton::colourChanged()
  39. {
  40. repaint();
  41. }