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.

83 lines
3.1KB

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