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.

92 lines
3.2KB

  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. An abstract base class which can be implemented by components that function as
  21. text editors.
  22. This class allows different types of text editor component to provide a uniform
  23. interface, which can be used by things like OS-specific input methods, on-screen
  24. keyboards, etc.
  25. */
  26. class JUCE_API TextInputTarget
  27. {
  28. public:
  29. //==============================================================================
  30. /** */
  31. TextInputTarget() {}
  32. /** Destructor. */
  33. virtual ~TextInputTarget() {}
  34. /** Returns true if this input target is currently accepting input.
  35. For example, a text editor might return false if it's in read-only mode.
  36. */
  37. virtual bool isTextInputActive() const = 0;
  38. /** Returns the extents of the selected text region, or an empty range if
  39. nothing is selected,
  40. */
  41. virtual Range<int> getHighlightedRegion() const = 0;
  42. /** Sets the currently-selected text region. */
  43. virtual void setHighlightedRegion (const Range<int>& newRange) = 0;
  44. /** Sets a number of temporarily underlined sections.
  45. This is needed by MS Windows input method UI.
  46. */
  47. virtual void setTemporaryUnderlining (const Array <Range<int> >& underlinedRegions) = 0;
  48. /** Returns a specified sub-section of the text. */
  49. virtual String getTextInRange (const Range<int>& range) const = 0;
  50. /** Inserts some text, overwriting the selected text region, if there is one. */
  51. virtual void insertTextAtCaret (const String& textToInsert) = 0;
  52. /** Returns the position of the caret, relative to the component's origin. */
  53. virtual Rectangle<int> getCaretRectangle() = 0;
  54. /** A set of possible on-screen keyboard types, for use in the
  55. getKeyboardType() method.
  56. */
  57. enum VirtualKeyboardType
  58. {
  59. textKeyboard = 0,
  60. numericKeyboard,
  61. decimalKeyboard,
  62. urlKeyboard,
  63. emailAddressKeyboard,
  64. phoneNumberKeyboard
  65. };
  66. /** Returns the target's preference for the type of keyboard that would be most appropriate.
  67. This may be ignored, depending on the capabilities of the OS.
  68. */
  69. virtual VirtualKeyboardType getKeyboardType() { return textKeyboard; }
  70. };