Add remaining files
[juce-lv2.git] / juce / source / src / gui / components / buttons / juce_ToolbarButton.h
blob423f73f1d390d32f8c30328e105e324aed59f3f6
1 /*
2 ==============================================================================
4 This file is part of the JUCE library - "Jules' Utility Class Extensions"
5 Copyright 2004-11 by Raw Material Software Ltd.
7 ------------------------------------------------------------------------------
9 JUCE can be redistributed and/or modified under the terms of the GNU General
10 Public License (Version 2), as published by the Free Software Foundation.
11 A copy of the license is included in the JUCE distribution, or can be found
12 online at www.gnu.org/licenses.
14 JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 ------------------------------------------------------------------------------
20 To release a closed-source product which uses JUCE, commercial licenses are
21 available: visit www.rawmaterialsoftware.com/juce for more information.
23 ==============================================================================
26 #ifndef __JUCE_TOOLBARBUTTON_JUCEHEADER__
27 #define __JUCE_TOOLBARBUTTON_JUCEHEADER__
29 #include "../controls/juce_ToolbarItemComponent.h"
32 //==============================================================================
33 /**
34 A type of button designed to go on a toolbar.
36 This simple button can have two Drawable objects specified - one for normal
37 use and another one (optionally) for the button's "on" state if it's a
38 toggle button.
40 @see Toolbar, ToolbarItemFactory, ToolbarItemComponent, Drawable, Button
42 class JUCE_API ToolbarButton : public ToolbarItemComponent
44 public:
45 //==============================================================================
46 /** Creates a ToolbarButton.
48 @param itemId the ID for this toolbar item type. This is passed through to the
49 ToolbarItemComponent constructor
50 @param labelText the text to display on the button (if the toolbar is using a style
51 that shows text labels). This is passed through to the
52 ToolbarItemComponent constructor
53 @param normalImage a drawable object that the button should use as its icon. The object
54 that is passed-in here will be kept by this object and will be
55 deleted when no longer needed or when this button is deleted.
56 @param toggledOnImage a drawable object that the button can use as its icon if the button
57 is in a toggled-on state (see the Button::getToggleState() method). If
58 0 is passed-in here, then the normal image will be used instead, regardless
59 of the toggle state. The object that is passed-in here will be kept by
60 this object and will be deleted when no longer needed or when this button
61 is deleted.
63 ToolbarButton (int itemId,
64 const String& labelText,
65 Drawable* normalImage,
66 Drawable* toggledOnImage);
68 /** Destructor. */
69 ~ToolbarButton();
72 //==============================================================================
73 /** @internal */
74 bool getToolbarItemSizes (int toolbarDepth, bool isToolbarVertical, int& preferredSize,
75 int& minSize, int& maxSize);
76 /** @internal */
77 void paintButtonArea (Graphics& g, int width, int height, bool isMouseOver, bool isMouseDown);
78 /** @internal */
79 void contentAreaChanged (const Rectangle<int>& newBounds);
80 /** @internal */
81 void buttonStateChanged();
82 /** @internal */
83 void resized();
84 /** @internal */
85 void enablementChanged();
87 private:
88 //==============================================================================
89 ScopedPointer<Drawable> normalImage, toggledOnImage;
90 Drawable* currentImage;
92 void updateDrawable();
94 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ToolbarButton);
98 #endif // __JUCE_TOOLBARBUTTON_JUCEHEADER__