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.

108 lines
3.8KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2015 - ROLI 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. #pragma once
  18. //==============================================================================
  19. /**
  20. A component that draws an outline around itself and has an optional title at
  21. the top, for drawing an outline around a group of controls.
  22. */
  23. class JUCE_API GroupComponent : public Component
  24. {
  25. public:
  26. //==============================================================================
  27. /** Creates a GroupComponent.
  28. @param componentName the name to give the component
  29. @param labelText the text to show at the top of the outline
  30. */
  31. GroupComponent (const String& componentName = String(),
  32. const String& labelText = String());
  33. /** Destructor. */
  34. ~GroupComponent();
  35. //==============================================================================
  36. /** Changes the text that's shown at the top of the component. */
  37. void setText (const String& newText);
  38. /** Returns the currently displayed text label. */
  39. String getText() const;
  40. /** Sets the positioning of the text label.
  41. (The default is Justification::left)
  42. @see getTextLabelPosition
  43. */
  44. void setTextLabelPosition (Justification justification);
  45. /** Returns the current text label position.
  46. @see setTextLabelPosition
  47. */
  48. Justification getTextLabelPosition() const noexcept { return justification; }
  49. //==============================================================================
  50. /** A set of colour IDs to use to change the colour of various aspects of the component.
  51. These constants can be used either via the Component::setColour(), or LookAndFeel::setColour()
  52. methods.
  53. @see Component::setColour, Component::findColour, LookAndFeel::setColour, LookAndFeel::findColour
  54. */
  55. enum ColourIds
  56. {
  57. outlineColourId = 0x1005400, /**< The colour to use for drawing the line around the edge. */
  58. textColourId = 0x1005410 /**< The colour to use to draw the text label. */
  59. };
  60. //==============================================================================
  61. /** This abstract base class is implemented by LookAndFeel classes. */
  62. struct JUCE_API LookAndFeelMethods
  63. {
  64. virtual ~LookAndFeelMethods() {}
  65. virtual void drawGroupComponentOutline (Graphics&, int w, int h, const String& text,
  66. const Justification&, GroupComponent&) = 0;
  67. };
  68. //==============================================================================
  69. /** @internal */
  70. void paint (Graphics&) override;
  71. /** @internal */
  72. void enablementChanged() override;
  73. /** @internal */
  74. void colourChanged() override;
  75. private:
  76. String text;
  77. Justification justification;
  78. JUCE_DECLARE_NON_COPYABLE (GroupComponent)
  79. };