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.

104 lines
4.4KB

  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_TEXTBUTTON_JUCEHEADER__
  19. #define __JUCE_TEXTBUTTON_JUCEHEADER__
  20. #include "juce_Button.h"
  21. //==============================================================================
  22. /**
  23. A button that uses the standard lozenge-shaped background with a line of
  24. text on it.
  25. @see Button, DrawableButton
  26. */
  27. class JUCE_API TextButton : public Button
  28. {
  29. public:
  30. //==============================================================================
  31. /** Creates a TextButton.
  32. @param buttonName the text to put in the button (the component's name is also
  33. initially set to this string, but these can be changed later
  34. using the setName() and setButtonText() methods)
  35. @param toolTip an optional string to use as a toolip
  36. @see Button
  37. */
  38. TextButton (const String& buttonName = String::empty,
  39. const String& toolTip = String::empty);
  40. /** Destructor. */
  41. ~TextButton();
  42. //==============================================================================
  43. /** A set of colour IDs to use to change the colour of various aspects of the button.
  44. These constants can be used either via the Component::setColour(), or LookAndFeel::setColour()
  45. methods.
  46. @see Component::setColour, Component::findColour, LookAndFeel::setColour, LookAndFeel::findColour
  47. */
  48. enum ColourIds
  49. {
  50. buttonColourId = 0x1000100, /**< The colour used to fill the button shape (when the button is toggled
  51. 'off'). The look-and-feel class might re-interpret this to add
  52. effects, etc. */
  53. buttonOnColourId = 0x1000101, /**< The colour used to fill the button shape (when the button is toggled
  54. 'on'). The look-and-feel class might re-interpret this to add
  55. effects, etc. */
  56. textColourOffId = 0x1000102, /**< The colour to use for the button's text when the button's toggle state is "off". */
  57. textColourOnId = 0x1000103 /**< The colour to use for the button's text.when the button's toggle state is "on". */
  58. };
  59. //==============================================================================
  60. /** Resizes the button to fit neatly around its current text.
  61. If newHeight is >= 0, the button's height will be changed to this
  62. value. If it's less than zero, its height will be unaffected.
  63. */
  64. void changeWidthToFitText (int newHeight = -1);
  65. /** This can be overridden to use different fonts than the default one.
  66. Note that you'll need to set the font's size appropriately, too.
  67. */
  68. virtual Font getFont();
  69. protected:
  70. /** @internal */
  71. void paintButton (Graphics& g, bool isMouseOverButton, bool isButtonDown);
  72. /** @internal */
  73. void colourChanged();
  74. private:
  75. JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TextButton);
  76. };
  77. #endif // __JUCE_TEXTBUTTON_JUCEHEADER__