Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | #ifndef nsMacCursor_h_ |
michael@0 | 6 | #define nsMacCursor_h_ |
michael@0 | 7 | |
michael@0 | 8 | #import <Cocoa/Cocoa.h> |
michael@0 | 9 | #import "nsIWidget.h" |
michael@0 | 10 | |
michael@0 | 11 | /*! @class nsMacCursor |
michael@0 | 12 | @abstract Represents a native Mac cursor. |
michael@0 | 13 | @discussion <code>nsMacCursor</code> provides a simple API for creating and working with native Macintosh cursors. |
michael@0 | 14 | Cursors can be created used without needing to be aware of the way different cursors are implemented, |
michael@0 | 15 | in particular the details of managing an animated cursor are hidden. |
michael@0 | 16 | */ |
michael@0 | 17 | @interface nsMacCursor : NSObject |
michael@0 | 18 | { |
michael@0 | 19 | @private |
michael@0 | 20 | NSTimer *mTimer; |
michael@0 | 21 | @protected |
michael@0 | 22 | nsCursor mType; |
michael@0 | 23 | int mFrameCounter; |
michael@0 | 24 | } |
michael@0 | 25 | |
michael@0 | 26 | /*! @method cursorWithCursor: |
michael@0 | 27 | @abstract Create a cursor by specifying a Cocoa <code>NSCursor</code>. |
michael@0 | 28 | @discussion Creates a cursor representing the given Cocoa built-in cursor. |
michael@0 | 29 | @param aCursor the <code>NSCursor</code> to use |
michael@0 | 30 | @param aType the corresponding <code>nsCursor</code> constant |
michael@0 | 31 | @result an autoreleased instance of <code>nsMacCursor</code> representing the given <code>NSCursor</code> |
michael@0 | 32 | */ |
michael@0 | 33 | + (nsMacCursor *) cursorWithCursor: (NSCursor *) aCursor type: (nsCursor) aType; |
michael@0 | 34 | |
michael@0 | 35 | /*! @method cursorWithImageNamed:hotSpot:type: |
michael@0 | 36 | @abstract Create a cursor by specifying the name of an image resource to use for the cursor and a hotspot. |
michael@0 | 37 | @discussion Creates a cursor by loading the named image using the <code>+[NSImage imageNamed:]</code> method. |
michael@0 | 38 | <p>The image must be compatible with any restrictions laid down by <code>NSCursor</code>. These vary |
michael@0 | 39 | by operating system version.</p> |
michael@0 | 40 | <p>The hotspot precisely determines the point where the user clicks when using the cursor.</p> |
michael@0 | 41 | @param aCursor the name of the image to use for the cursor |
michael@0 | 42 | @param aPoint the point within the cursor to use as the hotspot |
michael@0 | 43 | @param aType the corresponding <code>nsCursor</code> constant |
michael@0 | 44 | @result an autoreleased instance of <code>nsMacCursor</code> that uses the given image and hotspot |
michael@0 | 45 | */ |
michael@0 | 46 | + (nsMacCursor *) cursorWithImageNamed: (NSString *) aCursorImage hotSpot: (NSPoint) aPoint type: (nsCursor) aType; |
michael@0 | 47 | |
michael@0 | 48 | /*! @method cursorWithFrames:type: |
michael@0 | 49 | @abstract Create an animated cursor by specifying the frames to use for the animation. |
michael@0 | 50 | @discussion Creates a cursor that will animate by cycling through the given frames. Each element of the array |
michael@0 | 51 | must be an instance of <code>NSCursor</code> |
michael@0 | 52 | @param aCursorFrames an array of <code>NSCursor</code>, representing the frames of an animated cursor, in the |
michael@0 | 53 | order they should be played. |
michael@0 | 54 | @param aType the corresponding <code>nsCursor</code> constant |
michael@0 | 55 | @result an autoreleased instance of <code>nsMacCursor</code> that will animate the given cursor frames |
michael@0 | 56 | */ |
michael@0 | 57 | + (nsMacCursor *) cursorWithFrames: (NSArray *) aCursorFrames type: (nsCursor) aType; |
michael@0 | 58 | |
michael@0 | 59 | /*! @method cocoaCursorWithImageNamed:hotSpot: |
michael@0 | 60 | @abstract Create a Cocoa NSCursor object with a Gecko image resource name and a hotspot point. |
michael@0 | 61 | @discussion Create a Cocoa NSCursor object with a Gecko image resource name and a hotspot point. |
michael@0 | 62 | @param imageName the name of the gecko image resource, "tiff" extension is assumed, do not append. |
michael@0 | 63 | @param aPoint the point within the cursor to use as the hotspot |
michael@0 | 64 | @result an autoreleased instance of <code>nsMacCursor</code> that will animate the given cursor frames |
michael@0 | 65 | */ |
michael@0 | 66 | + (NSCursor *) cocoaCursorWithImageNamed: (NSString *) imageName hotSpot: (NSPoint) aPoint; |
michael@0 | 67 | |
michael@0 | 68 | /*! @method isSet |
michael@0 | 69 | @abstract Determines whether this cursor is currently active. |
michael@0 | 70 | @discussion This can be helpful when the Cocoa NSCursor state can be influenced without going |
michael@0 | 71 | through nsCursorManager. |
michael@0 | 72 | @result whether the cursor is currently set |
michael@0 | 73 | */ |
michael@0 | 74 | - (BOOL) isSet; |
michael@0 | 75 | |
michael@0 | 76 | /*! @method set |
michael@0 | 77 | @abstract Set the cursor. |
michael@0 | 78 | @discussion Makes this cursor the current cursor. If the cursor is animated, the animation is started. |
michael@0 | 79 | */ |
michael@0 | 80 | - (void) set; |
michael@0 | 81 | |
michael@0 | 82 | /*! @method unset |
michael@0 | 83 | @abstract Unset the cursor. The cursor will return to the default (usually the arrow cursor). |
michael@0 | 84 | @discussion Unsets the cursor. If the cursor is animated, the animation is stopped. |
michael@0 | 85 | */ |
michael@0 | 86 | - (void) unset; |
michael@0 | 87 | |
michael@0 | 88 | /*! @method isAnimated |
michael@0 | 89 | @abstract Tests whether this cursor is animated. |
michael@0 | 90 | @discussion Use this method to determine whether a cursor is animated |
michael@0 | 91 | @result YES if the cursor is animated (has more than one frame), NO if it is a simple static cursor. |
michael@0 | 92 | */ |
michael@0 | 93 | - (BOOL) isAnimated; |
michael@0 | 94 | |
michael@0 | 95 | /** @method cursorType |
michael@0 | 96 | @abstract Get the cursor type for this cursor |
michael@0 | 97 | @discussion This method returns the <code>nsCursor</code> constant that corresponds to this cursor, which is |
michael@0 | 98 | equivalent to the CSS name for the cursor. |
michael@0 | 99 | @result The nsCursor constant corresponding to this cursor, or nsCursor's 'eCursorCount' if the cursor |
michael@0 | 100 | is a custom cursor loaded from a URI |
michael@0 | 101 | */ |
michael@0 | 102 | - (nsCursor) type; |
michael@0 | 103 | @end |
michael@0 | 104 | |
michael@0 | 105 | #endif // nsMacCursor_h_ |