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.

109 lines
4.2KB

  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_SHAPEBUTTON_JUCEHEADER__
  19. #define __JUCE_SHAPEBUTTON_JUCEHEADER__
  20. #include "juce_Button.h"
  21. //==============================================================================
  22. /**
  23. A button that contains a filled shape.
  24. @see Button, ImageButton, TextButton, ArrowButton
  25. */
  26. class JUCE_API ShapeButton : public Button
  27. {
  28. public:
  29. //==============================================================================
  30. /** Creates a ShapeButton.
  31. @param name a name to give the component - see Component::setName()
  32. @param normalColour the colour to fill the shape with when the mouse isn't over
  33. @param overColour the colour to use when the mouse is over the shape
  34. @param downColour the colour to use when the button is in the pressed-down state
  35. */
  36. ShapeButton (const String& name,
  37. const Colour& normalColour,
  38. const Colour& overColour,
  39. const Colour& downColour);
  40. /** Destructor. */
  41. ~ShapeButton();
  42. //==============================================================================
  43. /** Sets the shape to use.
  44. @param newShape the shape to use
  45. @param resizeNowToFitThisShape if true, the button will be resized to fit the shape's bounds
  46. @param maintainShapeProportions if true, the shape's proportions will be kept fixed when
  47. the button is resized
  48. @param hasDropShadow if true, the button will be given a drop-shadow effect
  49. */
  50. void setShape (const Path& newShape,
  51. bool resizeNowToFitThisShape,
  52. bool maintainShapeProportions,
  53. bool hasDropShadow);
  54. /** Set the colours to use for drawing the shape.
  55. @param normalColour the colour to fill the shape with when the mouse isn't over
  56. @param overColour the colour to use when the mouse is over the shape
  57. @param downColour the colour to use when the button is in the pressed-down state
  58. */
  59. void setColours (const Colour& normalColour,
  60. const Colour& overColour,
  61. const Colour& downColour);
  62. /** Sets up an outline to draw around the shape.
  63. @param outlineColour the colour to use
  64. @param outlineStrokeWidth the thickness of line to draw
  65. */
  66. void setOutline (const Colour& outlineColour,
  67. float outlineStrokeWidth);
  68. protected:
  69. /** @internal */
  70. void paintButton (Graphics& g,
  71. bool isMouseOverButton,
  72. bool isButtonDown);
  73. private:
  74. //==============================================================================
  75. Colour normalColour, overColour, downColour, outlineColour;
  76. DropShadowEffect shadow;
  77. Path shape;
  78. bool maintainShapeProportions;
  79. float outlineWidth;
  80. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ShapeButton);
  81. };
  82. #endif // __JUCE_SHAPEBUTTON_JUCEHEADER__