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.

101 lines
4.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_TOOLBARBUTTON_JUCEHEADER__
  19. #define __JUCE_TOOLBARBUTTON_JUCEHEADER__
  20. #include "../widgets/juce_ToolbarItemComponent.h"
  21. //==============================================================================
  22. /**
  23. A type of button designed to go on a toolbar.
  24. This simple button can have two Drawable objects specified - one for normal
  25. use and another one (optionally) for the button's "on" state if it's a
  26. toggle button.
  27. @see Toolbar, ToolbarItemFactory, ToolbarItemComponent, Drawable, Button
  28. */
  29. class JUCE_API ToolbarButton : public ToolbarItemComponent
  30. {
  31. public:
  32. //==============================================================================
  33. /** Creates a ToolbarButton.
  34. @param itemId the ID for this toolbar item type. This is passed through to the
  35. ToolbarItemComponent constructor
  36. @param labelText the text to display on the button (if the toolbar is using a style
  37. that shows text labels). This is passed through to the
  38. ToolbarItemComponent constructor
  39. @param normalImage a drawable object that the button should use as its icon. The object
  40. that is passed-in here will be kept by this object and will be
  41. deleted when no longer needed or when this button is deleted.
  42. @param toggledOnImage a drawable object that the button can use as its icon if the button
  43. is in a toggled-on state (see the Button::getToggleState() method). If
  44. 0 is passed-in here, then the normal image will be used instead, regardless
  45. of the toggle state. The object that is passed-in here will be kept by
  46. this object and will be deleted when no longer needed or when this button
  47. is deleted.
  48. */
  49. ToolbarButton (int itemId,
  50. const String& labelText,
  51. Drawable* normalImage,
  52. Drawable* toggledOnImage);
  53. /** Destructor. */
  54. ~ToolbarButton();
  55. //==============================================================================
  56. /** @internal */
  57. bool getToolbarItemSizes (int toolbarDepth, bool isToolbarVertical, int& preferredSize,
  58. int& minSize, int& maxSize);
  59. /** @internal */
  60. void paintButtonArea (Graphics&, int width, int height, bool isMouseOver, bool isMouseDown);
  61. /** @internal */
  62. void contentAreaChanged (const Rectangle<int>&);
  63. /** @internal */
  64. void buttonStateChanged();
  65. /** @internal */
  66. void resized();
  67. /** @internal */
  68. void enablementChanged();
  69. private:
  70. //==============================================================================
  71. ScopedPointer<Drawable> normalImage, toggledOnImage;
  72. Drawable* currentImage;
  73. void updateDrawable();
  74. Drawable* getImageToUse() const;
  75. void setCurrentImage (Drawable*);
  76. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ToolbarButton);
  77. };
  78. #endif // __JUCE_TOOLBARBUTTON_JUCEHEADER__