Add remaining files
[juce-lv2.git] / juce / source / src / gui / components / buttons / juce_TextButton.cpp
blobf2dc15df151a578edb3330aacf52ee670f579c61
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 #include "../../../core/juce_StandardHeader.h"
28 BEGIN_JUCE_NAMESPACE
30 #include "juce_TextButton.h"
31 #include "../lookandfeel/juce_LookAndFeel.h"
34 //==============================================================================
35 TextButton::TextButton (const String& name,
36 const String& toolTip)
37 : Button (name)
39 setTooltip (toolTip);
42 TextButton::~TextButton()
46 void TextButton::paintButton (Graphics& g,
47 bool isMouseOverButton,
48 bool isButtonDown)
50 getLookAndFeel().drawButtonBackground (g, *this,
51 findColour (getToggleState() ? buttonOnColourId
52 : buttonColourId),
53 isMouseOverButton,
54 isButtonDown);
56 getLookAndFeel().drawButtonText (g, *this,
57 isMouseOverButton,
58 isButtonDown);
61 void TextButton::colourChanged()
63 repaint();
66 const Font TextButton::getFont()
68 return Font (jmin (15.0f, getHeight() * 0.6f));
71 void TextButton::changeWidthToFitText (const int newHeight)
73 if (newHeight >= 0)
74 setSize (jmax (1, getWidth()), newHeight);
76 setSize (getFont().getStringWidth (getButtonText()) + getHeight(),
77 getHeight());
81 END_JUCE_NAMESPACE