|
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
4 |
|
5 #ifndef nsCursorManager_h_ |
|
6 #define nsCursorManager_h_ |
|
7 |
|
8 #import <Foundation/Foundation.h> |
|
9 #include "nsIWidget.h" |
|
10 #include "nsMacCursor.h" |
|
11 |
|
12 /*! @class nsCursorManager |
|
13 @abstract Singleton service provides access to all cursors available in the application. |
|
14 @discussion Use <code>nsCusorManager</code> to set the current cursor using an XP <code>nsCusor</code> enum value. |
|
15 <code>nsCursorManager</code> encapsulates the details of setting different types of cursors, animating |
|
16 cursors and cleaning up cursors when they are no longer in use. |
|
17 */ |
|
18 @interface nsCursorManager : NSObject |
|
19 { |
|
20 @private |
|
21 NSMutableDictionary *mCursors; |
|
22 nsMacCursor *mCurrentMacCursor; |
|
23 } |
|
24 |
|
25 /*! @method setCursor: |
|
26 @abstract Sets the current cursor. |
|
27 @discussion Sets the current cursor to the cursor indicated by the XP cursor constant given as an argument. |
|
28 Resources associated with the previous cursor are cleaned up. |
|
29 @param aCursor the cursor to use |
|
30 */ |
|
31 - (nsresult) setCursor: (nsCursor) aCursor; |
|
32 |
|
33 /*! @method setCursorWithImage:hotSpotX:hotSpotY: |
|
34 @abstract Sets the current cursor to a custom image |
|
35 @discussion Sets the current cursor to the cursor given by the aCursorImage argument. |
|
36 Resources associated with the previous cursor are cleaned up. |
|
37 @param aCursorImage the cursor image to use |
|
38 @param aHotSpotX the x coordinate of the cursor's hotspot |
|
39 @param aHotSpotY the y coordinate of the cursor's hotspot |
|
40 @param scaleFactor the scale factor of the target display (2 for a retina display) |
|
41 */ |
|
42 - (nsresult) setCursorWithImage: (imgIContainer*) aCursorImage hotSpotX: (uint32_t) aHotspotX hotSpotY: (uint32_t) aHotspotY scaleFactor: (CGFloat) scaleFactor; |
|
43 |
|
44 |
|
45 /*! @method sharedInstance |
|
46 @abstract Get the Singleton instance of the cursor manager. |
|
47 @discussion Use this method to obtain a reference to the cursor manager. |
|
48 @result a reference to the cursor manager |
|
49 */ |
|
50 + (nsCursorManager *) sharedInstance; |
|
51 |
|
52 /*! @method dispose |
|
53 @abstract Releases the shared instance of the cursor manager. |
|
54 @discussion Use dispose to clean up the cursor manager and associated cursors. |
|
55 */ |
|
56 + (void) dispose; |
|
57 @end |
|
58 |
|
59 @interface NSCursor (Undocumented) |
|
60 // busyButClickableCursor is an undocumented NSCursor API, but has been in use since |
|
61 // at least OS X 10.4 and through 10.9. |
|
62 + (NSCursor*)busyButClickableCursor; |
|
63 @end |
|
64 |
|
65 #endif // nsCursorManager_h_ |