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.

84 lines
3.3KB

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