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.

77 lines
2.9KB

  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. */
  21. class JUCE_API CaretComponent : public Component,
  22. private Timer
  23. {
  24. public:
  25. //==============================================================================
  26. /** Creates the caret component.
  27. The keyFocusOwner is an optional component which the caret will check, making
  28. itself visible only when the keyFocusOwner has keyboard focus.
  29. */
  30. CaretComponent (Component* keyFocusOwner);
  31. /** Destructor. */
  32. ~CaretComponent();
  33. //==============================================================================
  34. /** Sets the caret's position to place it next to the given character.
  35. The area is the rectangle containing the entire character that the caret is
  36. positioned on, so by default a vertical-line caret may choose to just show itself
  37. at the left of this area. You can override this method to customise its size.
  38. This method will also force the caret to reset its timer and become visible (if
  39. appropriate), so that as it moves, you can see where it is.
  40. */
  41. virtual void setCaretPosition (const Rectangle<int>& characterArea);
  42. /** A set of colour IDs to use to change the colour of various aspects of the caret.
  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. caretColourId = 0x1000204, /**< The colour with which to draw the caret. */
  50. };
  51. //==============================================================================
  52. /** @internal */
  53. void paint (Graphics&) override;
  54. private:
  55. Component* owner;
  56. bool shouldBeShown() const;
  57. void timerCallback() override;
  58. JUCE_DECLARE_NON_COPYABLE (CaretComponent)
  59. };