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.

103 lines
4.2KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2013 - Raw Material Software Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. #ifndef __JUCE_TEXTBUTTON_JUCEHEADER__
  18. #define __JUCE_TEXTBUTTON_JUCEHEADER__
  19. #include "juce_Button.h"
  20. //==============================================================================
  21. /**
  22. A button that uses the standard lozenge-shaped background with a line of
  23. text on it.
  24. @see Button, DrawableButton
  25. */
  26. class JUCE_API TextButton : public Button
  27. {
  28. public:
  29. //==============================================================================
  30. /** Creates a TextButton.
  31. @param buttonName the text to put in the button (the component's name is also
  32. initially set to this string, but these can be changed later
  33. using the setName() and setButtonText() methods)
  34. @param toolTip an optional string to use as a toolip
  35. @see Button
  36. */
  37. TextButton (const String& buttonName = String::empty,
  38. const String& toolTip = String::empty);
  39. /** Destructor. */
  40. ~TextButton();
  41. //==============================================================================
  42. /** A set of colour IDs to use to change the colour of various aspects of the button.
  43. These constants can be used either via the Component::setColour(), or LookAndFeel::setColour()
  44. methods.
  45. @see Component::setColour, Component::findColour, LookAndFeel::setColour, LookAndFeel::findColour
  46. */
  47. enum ColourIds
  48. {
  49. buttonColourId = 0x1000100, /**< The colour used to fill the button shape (when the button is toggled
  50. 'off'). The look-and-feel class might re-interpret this to add
  51. effects, etc. */
  52. buttonOnColourId = 0x1000101, /**< The colour used to fill the button shape (when the button is toggled
  53. 'on'). The look-and-feel class might re-interpret this to add
  54. effects, etc. */
  55. textColourOffId = 0x1000102, /**< The colour to use for the button's text when the button's toggle state is "off". */
  56. textColourOnId = 0x1000103 /**< The colour to use for the button's text.when the button's toggle state is "on". */
  57. };
  58. //==============================================================================
  59. /** Resizes the button to fit neatly around its current text.
  60. If newHeight is >= 0, the button's height will be changed to this
  61. value. If it's less than zero, its height will be unaffected.
  62. */
  63. void changeWidthToFitText (int newHeight = -1);
  64. /** This can be overridden to use different fonts than the default one.
  65. Note that you'll need to set the font's size appropriately, too.
  66. */
  67. virtual Font getFont();
  68. protected:
  69. /** @internal */
  70. void paintButton (Graphics& g, bool isMouseOverButton, bool isButtonDown);
  71. /** @internal */
  72. void colourChanged();
  73. private:
  74. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TextButton)
  75. };
  76. #endif // __JUCE_TEXTBUTTON_JUCEHEADER__