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.

142 lines
6.8KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library - "Jules' Utility Class Extensions"
  4. Copyright 2004-9 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_DRAGANDDROPTARGET_JUCEHEADER__
  19. #define __JUCE_DRAGANDDROPTARGET_JUCEHEADER__
  20. #include "../juce_Component.h"
  21. //==============================================================================
  22. /**
  23. Components derived from this class can have things dropped onto them by a DragAndDropContainer.
  24. To create a component that can receive things drag-and-dropped by a DragAndDropContainer,
  25. derive your component from this class, and make sure that it is somewhere inside a
  26. DragAndDropContainer component.
  27. Note: If all that you need to do is to respond to files being drag-and-dropped from
  28. the operating system onto your component, you don't need any of these classes: instead
  29. see the FileDragAndDropTarget class.
  30. @see DragAndDropContainer, FileDragAndDropTarget
  31. */
  32. class JUCE_API DragAndDropTarget
  33. {
  34. public:
  35. /** Destructor. */
  36. virtual ~DragAndDropTarget() {}
  37. /** Callback to check whether this target is interested in the type of object being
  38. dragged.
  39. @param sourceDescription the description string passed into DragAndDropContainer::startDragging()
  40. @param sourceComponent the component that was passed into DragAndDropContainer::startDragging()
  41. @returns true if this component wants to receive the other callbacks regarging this
  42. type of object; if it returns false, no other callbacks will be made.
  43. */
  44. virtual bool isInterestedInDragSource (const String& sourceDescription,
  45. Component* sourceComponent) = 0;
  46. /** Callback to indicate that something is being dragged over this component.
  47. This gets called when the user moves the mouse into this component while dragging
  48. something.
  49. Use this callback as a trigger to make your component repaint itself to give the
  50. user feedback about whether the item can be dropped here or not.
  51. @param sourceDescription the description string passed into DragAndDropContainer::startDragging()
  52. @param sourceComponent the component that was passed into DragAndDropContainer::startDragging()
  53. @param x the mouse x position, relative to this component
  54. @param y the mouse y position, relative to this component
  55. @see itemDragExit
  56. */
  57. virtual void itemDragEnter (const String& sourceDescription,
  58. Component* sourceComponent,
  59. int x,
  60. int y);
  61. /** Callback to indicate that the user is dragging something over this component.
  62. This gets called when the user moves the mouse over this component while dragging
  63. something. Normally overriding itemDragEnter() and itemDragExit() are enough, but
  64. this lets you know what happens in-between.
  65. @param sourceDescription the description string passed into DragAndDropContainer::startDragging()
  66. @param sourceComponent the component that was passed into DragAndDropContainer::startDragging()
  67. @param x the mouse x position, relative to this component
  68. @param y the mouse y position, relative to this component
  69. */
  70. virtual void itemDragMove (const String& sourceDescription,
  71. Component* sourceComponent,
  72. int x,
  73. int y);
  74. /** Callback to indicate that something has been dragged off the edge of this component.
  75. This gets called when the user moves the mouse out of this component while dragging
  76. something.
  77. If you've used itemDragEnter() to repaint your component and give feedback, use this
  78. as a signal to repaint it in its normal state.
  79. @param sourceDescription the description string passed into DragAndDropContainer::startDragging()
  80. @param sourceComponent the component that was passed into DragAndDropContainer::startDragging()
  81. @see itemDragEnter
  82. */
  83. virtual void itemDragExit (const String& sourceDescription,
  84. Component* sourceComponent);
  85. /** Callback to indicate that the user has dropped something onto this component.
  86. When the user drops an item this get called, and you can use the description to
  87. work out whether your object wants to deal with it or not.
  88. Note that after this is called, the itemDragExit method may not be called, so you should
  89. clean up in here if there's anything you need to do when the drag finishes.
  90. @param sourceDescription the description string passed into DragAndDropContainer::startDragging()
  91. @param sourceComponent the component that was passed into DragAndDropContainer::startDragging()
  92. @param x the mouse x position, relative to this component
  93. @param y the mouse y position, relative to this component
  94. */
  95. virtual void itemDropped (const String& sourceDescription,
  96. Component* sourceComponent,
  97. int x,
  98. int y) = 0;
  99. /** Overriding this allows the target to tell the drag container whether to
  100. draw the drag image while the cursor is over it.
  101. By default it returns true, but if you return false, then the normal drag
  102. image will not be shown when the cursor is over this target.
  103. */
  104. virtual bool shouldDrawDragImageWhenOver();
  105. };
  106. #endif // __JUCE_DRAGANDDROPTARGET_JUCEHEADER__