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.

104 lines
4.2KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2017 - ROLI Ltd.
  5. JUCE is an open source library subject to commercial or open-source
  6. licensing.
  7. By using JUCE, you agree to the terms of both the JUCE 5 End-User License
  8. Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
  9. 27th April 2017).
  10. End User License Agreement: www.juce.com/juce-5-licence
  11. Privacy Policy: www.juce.com/juce-5-privacy-policy
  12. Or: You may also use this code under the terms of the GPL v3 (see
  13. www.gnu.org/licenses).
  14. JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
  15. EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
  16. DISCLAIMED.
  17. ==============================================================================
  18. */
  19. #pragma once
  20. //==============================================================================
  21. /**
  22. Components derived from this class can have text dropped onto them by an external application.
  23. @see DragAndDropContainer
  24. */
  25. class JUCE_API TextDragAndDropTarget
  26. {
  27. public:
  28. /** Destructor. */
  29. virtual ~TextDragAndDropTarget() {}
  30. /** Callback to check whether this target is interested in the set of text being offered.
  31. Note that this will be called repeatedly when the user is dragging the mouse around over your
  32. component, so don't do anything time-consuming in here!
  33. @param text the text that the user is dragging
  34. @returns true if this component wants to receive the other callbacks regarging this
  35. type of object; if it returns false, no other callbacks will be made.
  36. */
  37. virtual bool isInterestedInTextDrag (const String& text) = 0;
  38. /** Callback to indicate that some text is being dragged over this component.
  39. This gets called when the user moves the mouse into this component while dragging.
  40. Use this callback as a trigger to make your component repaint itself to give the
  41. user feedback about whether the text can be dropped here or not.
  42. @param text the text that the user is dragging
  43. @param x the mouse x position, relative to this component
  44. @param y the mouse y position, relative to this component
  45. */
  46. virtual void textDragEnter (const String& text, int x, int y);
  47. /** Callback to indicate that the user is dragging some text over this component.
  48. This gets called when the user moves the mouse over this component while dragging.
  49. Normally overriding itemDragEnter() and itemDragExit() are enough, but
  50. this lets you know what happens in-between.
  51. @param text the text that the user is dragging
  52. @param x the mouse x position, relative to this component
  53. @param y the mouse y position, relative to this component
  54. */
  55. virtual void textDragMove (const String& text, int x, int y);
  56. /** Callback to indicate that the mouse has moved away from this component.
  57. This gets called when the user moves the mouse out of this component while dragging
  58. the text.
  59. If you've used textDragEnter() to repaint your component and give feedback, use this
  60. as a signal to repaint it in its normal state.
  61. @param text the text that the user is dragging
  62. */
  63. virtual void textDragExit (const String& text);
  64. /** Callback to indicate that the user has dropped the text onto this component.
  65. When the user drops the text, this get called, and you can use the text in whatever
  66. way is appropriate.
  67. Note that after this is called, the textDragExit method may not be called, so you should
  68. clean up in here if there's anything you need to do when the drag finishes.
  69. @param text the text that the user is dragging
  70. @param x the mouse x position, relative to this component
  71. @param y the mouse y position, relative to this component
  72. */
  73. virtual void textDropped (const String& text, int x, int y) = 0;
  74. };