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.

98 lines
3.8KB

  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_BOOLEANPROPERTYCOMPONENT_JUCEHEADER__
  19. #define __JUCE_BOOLEANPROPERTYCOMPONENT_JUCEHEADER__
  20. #include "juce_PropertyComponent.h"
  21. #include "../buttons/juce_ToggleButton.h"
  22. //==============================================================================
  23. /**
  24. A PropertyComponent that contains an on/off toggle button.
  25. This type of property component can be used if you have a boolean value to
  26. toggle on/off.
  27. @see PropertyComponent
  28. */
  29. class JUCE_API BooleanPropertyComponent : public PropertyComponent,
  30. private ButtonListener // (can't use Button::Listener due to idiotic VC2005 bug)
  31. {
  32. protected:
  33. //==============================================================================
  34. /** Creates a button component.
  35. If you use this constructor, you must override the getState() and setState()
  36. methods.
  37. @param propertyName the property name to be passed to the PropertyComponent
  38. @param buttonTextWhenTrue the text shown in the button when the value is true
  39. @param buttonTextWhenFalse the text shown in the button when the value is false
  40. */
  41. BooleanPropertyComponent (const String& propertyName,
  42. const String& buttonTextWhenTrue,
  43. const String& buttonTextWhenFalse);
  44. public:
  45. /** Creates a button component.
  46. @param valueToControl a Value object that this property should refer to.
  47. @param propertyName the property name to be passed to the PropertyComponent
  48. @param buttonText the text shown in the ToggleButton component
  49. */
  50. BooleanPropertyComponent (const Value& valueToControl,
  51. const String& propertyName,
  52. const String& buttonText);
  53. /** Destructor. */
  54. ~BooleanPropertyComponent();
  55. //==============================================================================
  56. /** Called to change the state of the boolean value. */
  57. virtual void setState (bool newState);
  58. /** Must return the current value of the property. */
  59. virtual bool getState() const;
  60. //==============================================================================
  61. /** @internal */
  62. void paint (Graphics& g);
  63. /** @internal */
  64. void refresh();
  65. /** @internal */
  66. void buttonClicked (Button*);
  67. private:
  68. ToggleButton button;
  69. String onText, offText;
  70. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (BooleanPropertyComponent);
  71. };
  72. #endif // __JUCE_BOOLEANPROPERTYCOMPONENT_JUCEHEADER__