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.

166 lines
7.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_MOUSECURSOR_JUCEHEADER__
  19. #define __JUCE_MOUSECURSOR_JUCEHEADER__
  20. class Image;
  21. class ComponentPeer;
  22. class Component;
  23. //==============================================================================
  24. /**
  25. Represents a mouse cursor image.
  26. This object can either be used to represent one of the standard mouse
  27. cursor shapes, or a custom one generated from an image.
  28. */
  29. class JUCE_API MouseCursor
  30. {
  31. public:
  32. //==============================================================================
  33. /** The set of available standard mouse cursors. */
  34. enum StandardCursorType
  35. {
  36. NoCursor = 0, /**< An invisible cursor. */
  37. NormalCursor, /**< The stardard arrow cursor. */
  38. WaitCursor, /**< The normal hourglass or spinning-beachball 'busy' cursor. */
  39. IBeamCursor, /**< A vertical I-beam for positioning within text. */
  40. CrosshairCursor, /**< A pair of crosshairs. */
  41. CopyingCursor, /**< The normal arrow cursor, but with a "+" on it to indicate
  42. that you're dragging a copy of something. */
  43. PointingHandCursor, /**< A hand with a pointing finger, for clicking on web-links. */
  44. DraggingHandCursor, /**< An open flat hand for dragging heavy objects around. */
  45. LeftRightResizeCursor, /**< An arrow pointing left and right. */
  46. UpDownResizeCursor, /**< an arrow pointing up and down. */
  47. UpDownLeftRightResizeCursor, /**< An arrow pointing up, down, left and right. */
  48. TopEdgeResizeCursor, /**< A platform-specific cursor for resizing the top-edge of a window. */
  49. BottomEdgeResizeCursor, /**< A platform-specific cursor for resizing the bottom-edge of a window. */
  50. LeftEdgeResizeCursor, /**< A platform-specific cursor for resizing the left-edge of a window. */
  51. RightEdgeResizeCursor, /**< A platform-specific cursor for resizing the right-edge of a window. */
  52. TopLeftCornerResizeCursor, /**< A platform-specific cursor for resizing the top-left-corner of a window. */
  53. TopRightCornerResizeCursor, /**< A platform-specific cursor for resizing the top-right-corner of a window. */
  54. BottomLeftCornerResizeCursor, /**< A platform-specific cursor for resizing the bottom-left-corner of a window. */
  55. BottomRightCornerResizeCursor /**< A platform-specific cursor for resizing the bottom-right-corner of a window. */
  56. };
  57. //==============================================================================
  58. /** Creates the standard arrow cursor. */
  59. MouseCursor();
  60. /** Creates one of the standard mouse cursor */
  61. MouseCursor (StandardCursorType type);
  62. /** Creates a custom cursor from an image.
  63. @param image the image to use for the cursor - if this is bigger than the
  64. system can manage, it might get scaled down first, and might
  65. also have to be turned to black-and-white if it can't do colour
  66. cursors.
  67. @param hotSpotX the x position of the cursor's hotspot within the image
  68. @param hotSpotY the y position of the cursor's hotspot within the image
  69. */
  70. MouseCursor (const Image& image, int hotSpotX, int hotSpotY);
  71. //==============================================================================
  72. /** Creates a copy of another cursor object. */
  73. MouseCursor (const MouseCursor& other);
  74. /** Copies this cursor from another object. */
  75. MouseCursor& operator= (const MouseCursor& other);
  76. /** Destructor. */
  77. ~MouseCursor();
  78. #if JUCE_COMPILER_SUPPORTS_MOVE_SEMANTICS
  79. MouseCursor (MouseCursor&& other) noexcept;
  80. MouseCursor& operator= (MouseCursor&& other) noexcept;
  81. #endif
  82. /** Checks whether two mouse cursors are the same.
  83. For custom cursors, two cursors created from the same image won't be
  84. recognised as the same, only MouseCursor objects that have been
  85. copied from the same object.
  86. */
  87. bool operator== (const MouseCursor& other) const noexcept;
  88. /** Checks whether two mouse cursors are the same.
  89. For custom cursors, two cursors created from the same image won't be
  90. recognised as the same, only MouseCursor objects that have been
  91. copied from the same object.
  92. */
  93. bool operator!= (const MouseCursor& other) const noexcept;
  94. //==============================================================================
  95. /** Makes the system show its default 'busy' cursor.
  96. This will turn the system cursor to an hourglass or spinning beachball
  97. until the next time the mouse is moved, or hideWaitCursor() is called.
  98. This is handy if the message loop is about to block for a couple of
  99. seconds while busy and you want to give the user feedback about this.
  100. @see MessageManager::setTimeBeforeShowingWaitCursor
  101. */
  102. static void showWaitCursor();
  103. /** If showWaitCursor has been called, this will return the mouse to its
  104. normal state.
  105. This will look at what component is under the mouse, and update the
  106. cursor to be the correct one for that component.
  107. @see showWaitCursor
  108. */
  109. static void hideWaitCursor();
  110. private:
  111. //==============================================================================
  112. class SharedCursorHandle;
  113. friend class SharedCursorHandle;
  114. SharedCursorHandle* cursorHandle;
  115. friend class MouseInputSourceInternal;
  116. void showInWindow (ComponentPeer* window) const;
  117. void showInAllWindows() const;
  118. void* getHandle() const noexcept;
  119. static void* createMouseCursorFromImage (const Image& image, int hotspotX, int hotspotY);
  120. static void* createStandardMouseCursor (MouseCursor::StandardCursorType type);
  121. static void deleteMouseCursor (void* cursorHandle, bool isStandard);
  122. JUCE_LEAK_DETECTOR (MouseCursor);
  123. };
  124. #endif // __JUCE_MOUSECURSOR_JUCEHEADER__