1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/widget/cocoa/nsMacCursor.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,105 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +#ifndef nsMacCursor_h_ 1.9 +#define nsMacCursor_h_ 1.10 + 1.11 +#import <Cocoa/Cocoa.h> 1.12 +#import "nsIWidget.h" 1.13 + 1.14 +/*! @class nsMacCursor 1.15 + @abstract Represents a native Mac cursor. 1.16 + @discussion <code>nsMacCursor</code> provides a simple API for creating and working with native Macintosh cursors. 1.17 + Cursors can be created used without needing to be aware of the way different cursors are implemented, 1.18 + in particular the details of managing an animated cursor are hidden. 1.19 +*/ 1.20 +@interface nsMacCursor : NSObject 1.21 +{ 1.22 + @private 1.23 + NSTimer *mTimer; 1.24 + @protected 1.25 + nsCursor mType; 1.26 + int mFrameCounter; 1.27 +} 1.28 + 1.29 +/*! @method cursorWithCursor: 1.30 + @abstract Create a cursor by specifying a Cocoa <code>NSCursor</code>. 1.31 + @discussion Creates a cursor representing the given Cocoa built-in cursor. 1.32 + @param aCursor the <code>NSCursor</code> to use 1.33 + @param aType the corresponding <code>nsCursor</code> constant 1.34 + @result an autoreleased instance of <code>nsMacCursor</code> representing the given <code>NSCursor</code> 1.35 + */ 1.36 ++ (nsMacCursor *) cursorWithCursor: (NSCursor *) aCursor type: (nsCursor) aType; 1.37 + 1.38 +/*! @method cursorWithImageNamed:hotSpot:type: 1.39 + @abstract Create a cursor by specifying the name of an image resource to use for the cursor and a hotspot. 1.40 + @discussion Creates a cursor by loading the named image using the <code>+[NSImage imageNamed:]</code> method. 1.41 + <p>The image must be compatible with any restrictions laid down by <code>NSCursor</code>. These vary 1.42 + by operating system version.</p> 1.43 + <p>The hotspot precisely determines the point where the user clicks when using the cursor.</p> 1.44 + @param aCursor the name of the image to use for the cursor 1.45 + @param aPoint the point within the cursor to use as the hotspot 1.46 + @param aType the corresponding <code>nsCursor</code> constant 1.47 + @result an autoreleased instance of <code>nsMacCursor</code> that uses the given image and hotspot 1.48 + */ 1.49 ++ (nsMacCursor *) cursorWithImageNamed: (NSString *) aCursorImage hotSpot: (NSPoint) aPoint type: (nsCursor) aType; 1.50 + 1.51 +/*! @method cursorWithFrames:type: 1.52 + @abstract Create an animated cursor by specifying the frames to use for the animation. 1.53 + @discussion Creates a cursor that will animate by cycling through the given frames. Each element of the array 1.54 + must be an instance of <code>NSCursor</code> 1.55 + @param aCursorFrames an array of <code>NSCursor</code>, representing the frames of an animated cursor, in the 1.56 + order they should be played. 1.57 + @param aType the corresponding <code>nsCursor</code> constant 1.58 + @result an autoreleased instance of <code>nsMacCursor</code> that will animate the given cursor frames 1.59 + */ 1.60 ++ (nsMacCursor *) cursorWithFrames: (NSArray *) aCursorFrames type: (nsCursor) aType; 1.61 + 1.62 +/*! @method cocoaCursorWithImageNamed:hotSpot: 1.63 + @abstract Create a Cocoa NSCursor object with a Gecko image resource name and a hotspot point. 1.64 + @discussion Create a Cocoa NSCursor object with a Gecko image resource name and a hotspot point. 1.65 + @param imageName the name of the gecko image resource, "tiff" extension is assumed, do not append. 1.66 + @param aPoint the point within the cursor to use as the hotspot 1.67 + @result an autoreleased instance of <code>nsMacCursor</code> that will animate the given cursor frames 1.68 + */ 1.69 ++ (NSCursor *) cocoaCursorWithImageNamed: (NSString *) imageName hotSpot: (NSPoint) aPoint; 1.70 + 1.71 +/*! @method isSet 1.72 + @abstract Determines whether this cursor is currently active. 1.73 + @discussion This can be helpful when the Cocoa NSCursor state can be influenced without going 1.74 + through nsCursorManager. 1.75 + @result whether the cursor is currently set 1.76 + */ 1.77 +- (BOOL) isSet; 1.78 + 1.79 +/*! @method set 1.80 + @abstract Set the cursor. 1.81 + @discussion Makes this cursor the current cursor. If the cursor is animated, the animation is started. 1.82 + */ 1.83 +- (void) set; 1.84 + 1.85 +/*! @method unset 1.86 + @abstract Unset the cursor. The cursor will return to the default (usually the arrow cursor). 1.87 + @discussion Unsets the cursor. If the cursor is animated, the animation is stopped. 1.88 + */ 1.89 +- (void) unset; 1.90 + 1.91 +/*! @method isAnimated 1.92 + @abstract Tests whether this cursor is animated. 1.93 + @discussion Use this method to determine whether a cursor is animated 1.94 + @result YES if the cursor is animated (has more than one frame), NO if it is a simple static cursor. 1.95 + */ 1.96 +- (BOOL) isAnimated; 1.97 + 1.98 +/** @method cursorType 1.99 + @abstract Get the cursor type for this cursor 1.100 + @discussion This method returns the <code>nsCursor</code> constant that corresponds to this cursor, which is 1.101 + equivalent to the CSS name for the cursor. 1.102 + @result The nsCursor constant corresponding to this cursor, or nsCursor's 'eCursorCount' if the cursor 1.103 + is a custom cursor loaded from a URI 1.104 + */ 1.105 +- (nsCursor) type; 1.106 +@end 1.107 + 1.108 +#endif // nsMacCursor_h_