michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsMacCursor_h_ michael@0: #define nsMacCursor_h_ michael@0: michael@0: #import michael@0: #import "nsIWidget.h" michael@0: michael@0: /*! @class nsMacCursor michael@0: @abstract Represents a native Mac cursor. michael@0: @discussion nsMacCursor provides a simple API for creating and working with native Macintosh cursors. michael@0: Cursors can be created used without needing to be aware of the way different cursors are implemented, michael@0: in particular the details of managing an animated cursor are hidden. michael@0: */ michael@0: @interface nsMacCursor : NSObject michael@0: { michael@0: @private michael@0: NSTimer *mTimer; michael@0: @protected michael@0: nsCursor mType; michael@0: int mFrameCounter; michael@0: } michael@0: michael@0: /*! @method cursorWithCursor: michael@0: @abstract Create a cursor by specifying a Cocoa NSCursor. michael@0: @discussion Creates a cursor representing the given Cocoa built-in cursor. michael@0: @param aCursor the NSCursor to use michael@0: @param aType the corresponding nsCursor constant michael@0: @result an autoreleased instance of nsMacCursor representing the given NSCursor michael@0: */ michael@0: + (nsMacCursor *) cursorWithCursor: (NSCursor *) aCursor type: (nsCursor) aType; michael@0: michael@0: /*! @method cursorWithImageNamed:hotSpot:type: michael@0: @abstract Create a cursor by specifying the name of an image resource to use for the cursor and a hotspot. michael@0: @discussion Creates a cursor by loading the named image using the +[NSImage imageNamed:] method. michael@0:

The image must be compatible with any restrictions laid down by NSCursor. These vary michael@0: by operating system version.

michael@0:

The hotspot precisely determines the point where the user clicks when using the cursor.

michael@0: @param aCursor the name of the image to use for the cursor michael@0: @param aPoint the point within the cursor to use as the hotspot michael@0: @param aType the corresponding nsCursor constant michael@0: @result an autoreleased instance of nsMacCursor that uses the given image and hotspot michael@0: */ michael@0: + (nsMacCursor *) cursorWithImageNamed: (NSString *) aCursorImage hotSpot: (NSPoint) aPoint type: (nsCursor) aType; michael@0: michael@0: /*! @method cursorWithFrames:type: michael@0: @abstract Create an animated cursor by specifying the frames to use for the animation. michael@0: @discussion Creates a cursor that will animate by cycling through the given frames. Each element of the array michael@0: must be an instance of NSCursor michael@0: @param aCursorFrames an array of NSCursor, representing the frames of an animated cursor, in the michael@0: order they should be played. michael@0: @param aType the corresponding nsCursor constant michael@0: @result an autoreleased instance of nsMacCursor that will animate the given cursor frames michael@0: */ michael@0: + (nsMacCursor *) cursorWithFrames: (NSArray *) aCursorFrames type: (nsCursor) aType; michael@0: michael@0: /*! @method cocoaCursorWithImageNamed:hotSpot: michael@0: @abstract Create a Cocoa NSCursor object with a Gecko image resource name and a hotspot point. michael@0: @discussion Create a Cocoa NSCursor object with a Gecko image resource name and a hotspot point. michael@0: @param imageName the name of the gecko image resource, "tiff" extension is assumed, do not append. michael@0: @param aPoint the point within the cursor to use as the hotspot michael@0: @result an autoreleased instance of nsMacCursor that will animate the given cursor frames michael@0: */ michael@0: + (NSCursor *) cocoaCursorWithImageNamed: (NSString *) imageName hotSpot: (NSPoint) aPoint; michael@0: michael@0: /*! @method isSet michael@0: @abstract Determines whether this cursor is currently active. michael@0: @discussion This can be helpful when the Cocoa NSCursor state can be influenced without going michael@0: through nsCursorManager. michael@0: @result whether the cursor is currently set michael@0: */ michael@0: - (BOOL) isSet; michael@0: michael@0: /*! @method set michael@0: @abstract Set the cursor. michael@0: @discussion Makes this cursor the current cursor. If the cursor is animated, the animation is started. michael@0: */ michael@0: - (void) set; michael@0: michael@0: /*! @method unset michael@0: @abstract Unset the cursor. The cursor will return to the default (usually the arrow cursor). michael@0: @discussion Unsets the cursor. If the cursor is animated, the animation is stopped. michael@0: */ michael@0: - (void) unset; michael@0: michael@0: /*! @method isAnimated michael@0: @abstract Tests whether this cursor is animated. michael@0: @discussion Use this method to determine whether a cursor is animated michael@0: @result YES if the cursor is animated (has more than one frame), NO if it is a simple static cursor. michael@0: */ michael@0: - (BOOL) isAnimated; michael@0: michael@0: /** @method cursorType michael@0: @abstract Get the cursor type for this cursor michael@0: @discussion This method returns the nsCursor constant that corresponds to this cursor, which is michael@0: equivalent to the CSS name for the cursor. michael@0: @result The nsCursor constant corresponding to this cursor, or nsCursor's 'eCursorCount' if the cursor michael@0: is a custom cursor loaded from a URI michael@0: */ michael@0: - (nsCursor) type; michael@0: @end michael@0: michael@0: #endif // nsMacCursor_h_