2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2004-04-29 07:14:21 +04:00
|
|
|
|
2007-01-18 09:34:07 +03:00
|
|
|
#include "nsMacCursor.h"
|
2008-02-19 23:58:01 +03:00
|
|
|
#include "nsObjCExceptions.h"
|
2007-01-18 09:34:07 +03:00
|
|
|
#include "nsDebug.h"
|
2007-04-04 00:19:36 +04:00
|
|
|
#include "nsDirectoryServiceDefs.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsIFile.h"
|
|
|
|
#include "nsString.h"
|
2004-04-29 07:14:21 +04:00
|
|
|
|
|
|
|
/*! @category nsMacCursor (PrivateMethods)
|
|
|
|
@abstract Private methods internal to the nsMacCursor class.
|
2019-01-21 20:18:16 +03:00
|
|
|
@discussion <code>nsMacCursor</code> is effectively an abstract class. It does not define
|
|
|
|
complete behaviour in and of itself, the subclasses defined in this file provide the useful
|
|
|
|
implementations.
|
2004-04-29 07:14:21 +04:00
|
|
|
*/
|
|
|
|
@interface nsMacCursor (PrivateMethods)
|
|
|
|
|
|
|
|
/*! @method getNextCursorFrame
|
|
|
|
@abstract get the index of the next cursor frame to display.
|
|
|
|
@discussion Increments and returns the frame counter of an animated cursor.
|
|
|
|
@result The index of the next frame to display in the cursor animation
|
|
|
|
*/
|
2019-01-21 20:18:16 +03:00
|
|
|
- (int)getNextCursorFrame;
|
2004-04-29 07:14:21 +04:00
|
|
|
|
|
|
|
/*! @method numFrames
|
|
|
|
@abstract Query the number of frames in this cursor's animation.
|
|
|
|
@discussion Returns the number of frames in this cursor's animation. Static cursors return 1.
|
|
|
|
*/
|
2019-01-21 20:18:16 +03:00
|
|
|
- (int)numFrames;
|
2004-04-29 07:14:21 +04:00
|
|
|
|
|
|
|
/*! @method createTimer
|
|
|
|
@abstract Create a Timer to use to animate the cursor.
|
2019-01-21 20:18:16 +03:00
|
|
|
@discussion Creates an instance of <code>NSTimer</code> which is used to drive the cursor
|
|
|
|
animation. This method should only be called for cursors that are animated.
|
2004-04-29 07:14:21 +04:00
|
|
|
*/
|
2019-01-21 20:18:16 +03:00
|
|
|
- (void)createTimer;
|
2004-04-29 07:14:21 +04:00
|
|
|
|
|
|
|
/*! @method destroyTimer
|
|
|
|
@abstract Destroy any timer instance associated with this cursor.
|
2019-01-21 20:18:16 +03:00
|
|
|
@discussion Invalidates and releases any <code>NSTimer</code> instance associated with this
|
|
|
|
cursor.
|
2004-04-29 07:14:21 +04:00
|
|
|
*/
|
2019-01-21 20:18:16 +03:00
|
|
|
- (void)destroyTimer;
|
2004-04-29 07:14:21 +04:00
|
|
|
/*! @method destroyTimer
|
|
|
|
@abstract Destroy any timer instance associated with this cursor.
|
2019-01-21 20:18:16 +03:00
|
|
|
@discussion Invalidates and releases any <code>NSTimer</code> instance associated with this
|
|
|
|
cursor.
|
2004-04-29 07:14:21 +04:00
|
|
|
*/
|
|
|
|
|
2009-01-17 22:23:43 +03:00
|
|
|
/*! @method advanceAnimatedCursor:
|
2004-04-29 07:14:21 +04:00
|
|
|
@abstract Method called by animation timer to perform animation.
|
2019-01-21 20:18:16 +03:00
|
|
|
@discussion Called by an animated cursor's associated timer to advance the animation to the next
|
|
|
|
frame. Determines which frame should occur next and sets the cursor to that frame.
|
2004-04-29 07:14:21 +04:00
|
|
|
@param aTimer the timer causing the animation
|
|
|
|
*/
|
2019-01-21 20:18:16 +03:00
|
|
|
- (void)advanceAnimatedCursor:(NSTimer *)aTimer;
|
2004-04-29 07:14:21 +04:00
|
|
|
|
|
|
|
/*! @method setFrame:
|
2019-01-21 20:18:16 +03:00
|
|
|
@abstract Sets the current cursor, using an index to determine which frame in the animation to
|
|
|
|
display.
|
|
|
|
@discussion Sets the current cursor. The frame index determines which frame is shown if the
|
|
|
|
cursor is animated. Frames and numbered from <code>0</code> to <code>-[nsMacCursor numFrames] -
|
|
|
|
1</code>. A static cursor has a single frame, numbered 0.
|
2004-04-29 07:14:21 +04:00
|
|
|
@param aFrameIndex the index indicating which frame from the animation to display
|
|
|
|
*/
|
2019-01-21 20:18:16 +03:00
|
|
|
- (void)setFrame:(int)aFrameIndex;
|
2007-09-03 18:43:03 +04:00
|
|
|
|
2004-04-29 07:14:21 +04:00
|
|
|
@end
|
|
|
|
|
|
|
|
/*! @class nsCocoaCursor
|
2019-01-21 20:18:16 +03:00
|
|
|
@abstract Implementation of <code>nsMacCursor</code> that uses Cocoa <code>NSCursor</code>
|
|
|
|
instances.
|
|
|
|
@discussion Displays a static or animated cursor, using Cocoa <code>NSCursor</code> instances.
|
|
|
|
These can be either built-in <code>NSCursor</code> instances, or custom <code>NSCursor</code>s
|
|
|
|
created from images. When more than one <code>NSCursor</code> is provided, the cursor will use
|
|
|
|
these as animation frames.
|
2004-04-29 07:14:21 +04:00
|
|
|
*/
|
2019-01-21 20:18:16 +03:00
|
|
|
@interface nsCocoaCursor : nsMacCursor {
|
|
|
|
@private
|
2004-04-29 07:14:21 +04:00
|
|
|
NSArray *mFrames;
|
2009-09-08 01:40:10 +04:00
|
|
|
NSCursor *mLastSetCocoaCursor;
|
2004-04-29 07:14:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*! @method initWithFrames:
|
|
|
|
@abstract Create an animated cursor by specifying the frames to use for the animation.
|
2019-01-21 20:18:16 +03:00
|
|
|
@discussion Creates a cursor that will animate by cycling through the given frames. Each element
|
|
|
|
of the array must be an instance of <code>NSCursor</code>
|
|
|
|
@param aCursorFrames an array of <code>NSCursor</code>, representing the frames of an
|
|
|
|
animated cursor, in the order they should be played.
|
2010-03-11 19:44:31 +03:00
|
|
|
@param aType the corresponding <code>nsCursor</code> constant
|
2004-04-29 07:14:21 +04:00
|
|
|
@result an instance of <code>nsCocoaCursor</code> that will animate the given cursor frames
|
|
|
|
*/
|
2019-01-21 20:18:16 +03:00
|
|
|
- (id)initWithFrames:(NSArray *)aCursorFrames type:(nsCursor)aType;
|
2004-04-29 07:14:21 +04:00
|
|
|
|
|
|
|
/*! @method initWithCursor:
|
|
|
|
@abstract Create a cursor by specifying a Cocoa <code>NSCursor</code>.
|
|
|
|
@discussion Creates a cursor representing the given Cocoa built-in cursor.
|
|
|
|
@param aCursor the <code>NSCursor</code> to use
|
2010-03-11 19:44:31 +03:00
|
|
|
@param aType the corresponding <code>nsCursor</code> constant
|
2019-01-21 20:18:16 +03:00
|
|
|
@result an instance of <code>nsCocoaCursor</code> representing the given
|
|
|
|
<code>NSCursor</code>
|
2004-04-29 07:14:21 +04:00
|
|
|
*/
|
2019-01-21 20:18:16 +03:00
|
|
|
- (id)initWithCursor:(NSCursor *)aCursor type:(nsCursor)aType;
|
2004-04-29 07:14:21 +04:00
|
|
|
|
|
|
|
/*! @method initWithImageNamed:hotSpot:
|
2019-01-21 20:18:16 +03:00
|
|
|
@abstract Create a cursor by specifying the name of an image resource to use for the cursor
|
|
|
|
and a hotspot.
|
|
|
|
@discussion Creates a cursor by loading the named image using the <code>+[NSImage
|
|
|
|
imageNamed:]</code> method. <p>The image must be compatible with any restrictions laid down by
|
|
|
|
<code>NSCursor</code>. These vary by operating system version.</p> <p>The hotspot precisely
|
|
|
|
determines the point where the user clicks when using the cursor.</p>
|
2004-04-29 07:14:21 +04:00
|
|
|
@param aCursor the name of the image to use for the cursor
|
|
|
|
@param aPoint the point within the cursor to use as the hotspot
|
2010-03-11 19:44:31 +03:00
|
|
|
@param aType the corresponding <code>nsCursor</code> constant
|
2004-04-29 07:14:21 +04:00
|
|
|
@result an instance of <code>nsCocoaCursor</code> that uses the given image and hotspot
|
|
|
|
*/
|
2019-01-21 20:18:16 +03:00
|
|
|
- (id)initWithImageNamed:(NSString *)aCursorImage hotSpot:(NSPoint)aPoint type:(nsCursor)aType;
|
2007-09-03 18:43:03 +04:00
|
|
|
|
2004-04-29 07:14:21 +04:00
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation nsMacCursor
|
|
|
|
|
2019-01-21 20:18:16 +03:00
|
|
|
+ (nsMacCursor *)cursorWithCursor:(NSCursor *)aCursor type:(nsCursor)aType {
|
2008-02-19 23:58:01 +03:00
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
|
|
|
|
|
2010-03-11 19:44:31 +03:00
|
|
|
return [[[nsCocoaCursor alloc] initWithCursor:aCursor type:aType] autorelease];
|
2008-02-19 23:58:01 +03:00
|
|
|
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
|
2004-04-29 07:14:21 +04:00
|
|
|
}
|
|
|
|
|
2019-01-21 20:18:16 +03:00
|
|
|
+ (nsMacCursor *)cursorWithImageNamed:(NSString *)aCursorImage
|
|
|
|
hotSpot:(NSPoint)aPoint
|
|
|
|
type:(nsCursor)aType {
|
2008-02-19 23:58:01 +03:00
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
|
|
|
|
|
2019-01-21 20:18:16 +03:00
|
|
|
return [[[nsCocoaCursor alloc] initWithImageNamed:aCursorImage hotSpot:aPoint
|
|
|
|
type:aType] autorelease];
|
2008-02-19 23:58:01 +03:00
|
|
|
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
|
2004-04-29 07:14:21 +04:00
|
|
|
}
|
|
|
|
|
2019-01-21 20:18:16 +03:00
|
|
|
+ (nsMacCursor *)cursorWithFrames:(NSArray *)aCursorFrames type:(nsCursor)aType {
|
2008-02-19 23:58:01 +03:00
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
|
|
|
|
|
2010-03-11 19:44:31 +03:00
|
|
|
return [[[nsCocoaCursor alloc] initWithFrames:aCursorFrames type:aType] autorelease];
|
2008-02-19 23:58:01 +03:00
|
|
|
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
|
2004-04-29 07:14:21 +04:00
|
|
|
}
|
|
|
|
|
2019-01-21 20:18:16 +03:00
|
|
|
+ (NSCursor *)cocoaCursorWithImageNamed:(NSString *)imageName hotSpot:(NSPoint)aPoint {
|
2008-02-19 23:58:01 +03:00
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
|
|
|
|
|
2009-01-17 22:23:43 +03:00
|
|
|
nsCOMPtr<nsIFile> resDir;
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString resPath;
|
2019-01-21 20:18:16 +03:00
|
|
|
NSString *pathToImage, *pathToHiDpiImage;
|
|
|
|
NSImage *cursorImage, *hiDpiCursorImage;
|
2008-02-19 23:58:01 +03:00
|
|
|
|
2009-01-17 22:23:43 +03:00
|
|
|
nsresult rv = NS_GetSpecialDirectory(NS_GRE_DIR, getter_AddRefs(resDir));
|
2019-01-21 20:18:16 +03:00
|
|
|
if (NS_FAILED(rv)) goto INIT_FAILURE;
|
2009-01-17 22:23:43 +03:00
|
|
|
resDir->AppendNative(NS_LITERAL_CSTRING("res"));
|
|
|
|
resDir->AppendNative(NS_LITERAL_CSTRING("cursors"));
|
2004-04-29 07:14:21 +04:00
|
|
|
|
2009-01-17 22:23:43 +03:00
|
|
|
rv = resDir->GetNativePath(resPath);
|
2019-01-21 20:18:16 +03:00
|
|
|
if (NS_FAILED(rv)) goto INIT_FAILURE;
|
2008-02-19 23:58:01 +03:00
|
|
|
|
2019-01-21 20:18:16 +03:00
|
|
|
pathToImage = [NSString stringWithUTF8String:(const char *)resPath.get()];
|
|
|
|
if (!pathToImage) goto INIT_FAILURE;
|
2009-01-17 22:23:43 +03:00
|
|
|
pathToImage = [pathToImage stringByAppendingPathComponent:imageName];
|
2012-09-28 12:27:11 +04:00
|
|
|
pathToHiDpiImage = [pathToImage stringByAppendingString:@"@2x"];
|
|
|
|
// Add same extension to both image paths.
|
2019-01-21 20:18:16 +03:00
|
|
|
pathToImage = [pathToImage stringByAppendingPathExtension:@"png"];
|
2012-09-28 12:27:11 +04:00
|
|
|
pathToHiDpiImage = [pathToHiDpiImage stringByAppendingPathExtension:@"png"];
|
2009-01-17 22:23:43 +03:00
|
|
|
|
|
|
|
cursorImage = [[[NSImage alloc] initWithContentsOfFile:pathToImage] autorelease];
|
2019-01-21 20:18:16 +03:00
|
|
|
if (!cursorImage) goto INIT_FAILURE;
|
2012-09-28 12:27:11 +04:00
|
|
|
|
|
|
|
// Note 1: There are a few different ways to get a hidpi image via
|
|
|
|
// initWithContentsOfFile. We let the OS handle this here: when the
|
|
|
|
// file basename ends in "@2x", it will be displayed at native resolution
|
|
|
|
// instead of being pixel-doubled. See bug 784909 comment 7 for alternates ways.
|
|
|
|
//
|
|
|
|
// Note 2: The OS is picky, and will ignore the hidpi representation
|
|
|
|
// unless it is exactly twice the size of the lowdpi image.
|
|
|
|
hiDpiCursorImage = [[[NSImage alloc] initWithContentsOfFile:pathToHiDpiImage] autorelease];
|
|
|
|
if (hiDpiCursorImage) {
|
|
|
|
NSImageRep *imageRep = [[hiDpiCursorImage representations] objectAtIndex:0];
|
2019-01-21 20:18:16 +03:00
|
|
|
[cursorImage addRepresentation:imageRep];
|
2012-09-28 12:27:11 +04:00
|
|
|
}
|
2010-03-11 19:44:31 +03:00
|
|
|
return [[[NSCursor alloc] initWithImage:cursorImage hotSpot:aPoint] autorelease];
|
2009-01-17 22:23:43 +03:00
|
|
|
|
|
|
|
INIT_FAILURE:
|
|
|
|
NS_WARNING("Problem getting path to cursor image file!");
|
|
|
|
[self release];
|
|
|
|
return nil;
|
2008-02-19 23:58:01 +03:00
|
|
|
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
|
2004-04-29 07:14:21 +04:00
|
|
|
}
|
|
|
|
|
2019-01-21 20:18:16 +03:00
|
|
|
- (BOOL)isSet {
|
2009-09-08 01:40:10 +04:00
|
|
|
// implemented by subclasses
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
2019-01-21 20:18:16 +03:00
|
|
|
- (void)set {
|
2006-12-15 20:32:16 +03:00
|
|
|
if ([self isAnimated]) {
|
2004-04-29 07:14:21 +04:00
|
|
|
[self createTimer];
|
|
|
|
}
|
2010-03-11 19:44:31 +03:00
|
|
|
// if the cursor isn't animated or the timer creation fails for any reason...
|
2006-12-15 20:32:16 +03:00
|
|
|
if (!mTimer) {
|
2010-03-11 19:44:31 +03:00
|
|
|
[self setFrame:0];
|
2004-04-29 07:14:21 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-21 20:18:16 +03:00
|
|
|
- (void)unset {
|
|
|
|
[self destroyTimer];
|
2004-04-29 07:14:21 +04:00
|
|
|
}
|
|
|
|
|
2019-01-21 20:18:16 +03:00
|
|
|
- (BOOL)isAnimated {
|
2004-04-29 07:14:21 +04:00
|
|
|
return [self numFrames] > 1;
|
|
|
|
}
|
|
|
|
|
2019-01-21 20:18:16 +03:00
|
|
|
- (int)numFrames {
|
2010-03-11 19:44:31 +03:00
|
|
|
// subclasses need to override this to support animation
|
2004-04-29 07:14:21 +04:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2019-01-21 20:18:16 +03:00
|
|
|
- (int)getNextCursorFrame {
|
2004-04-29 07:14:21 +04:00
|
|
|
mFrameCounter = (mFrameCounter + 1) % [self numFrames];
|
|
|
|
return mFrameCounter;
|
|
|
|
}
|
|
|
|
|
2019-01-21 20:18:16 +03:00
|
|
|
- (void)createTimer {
|
2008-02-19 23:58:01 +03:00
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
|
|
|
|
2009-01-17 22:23:43 +03:00
|
|
|
if (!mTimer) {
|
2010-03-11 19:44:31 +03:00
|
|
|
mTimer = [[NSTimer scheduledTimerWithTimeInterval:0.25
|
|
|
|
target:self
|
|
|
|
selector:@selector(advanceAnimatedCursor:)
|
|
|
|
userInfo:nil
|
|
|
|
repeats:YES] retain];
|
2004-04-29 07:14:21 +04:00
|
|
|
}
|
2008-02-19 23:58:01 +03:00
|
|
|
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK;
|
2004-04-29 07:14:21 +04:00
|
|
|
}
|
|
|
|
|
2019-01-21 20:18:16 +03:00
|
|
|
- (void)destroyTimer {
|
2008-02-19 23:58:01 +03:00
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
|
|
|
|
2006-12-15 20:32:16 +03:00
|
|
|
if (mTimer) {
|
2019-01-21 20:18:16 +03:00
|
|
|
[mTimer invalidate];
|
|
|
|
[mTimer release];
|
|
|
|
mTimer = nil;
|
2004-04-29 07:14:21 +04:00
|
|
|
}
|
2008-02-19 23:58:01 +03:00
|
|
|
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK;
|
2004-04-29 07:14:21 +04:00
|
|
|
}
|
|
|
|
|
2019-01-21 20:18:16 +03:00
|
|
|
- (void)advanceAnimatedCursor:(NSTimer *)aTimer {
|
2008-02-19 23:58:01 +03:00
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
|
|
|
|
2006-12-15 20:32:16 +03:00
|
|
|
if ([aTimer isValid]) {
|
2010-03-11 19:44:31 +03:00
|
|
|
[self setFrame:[self getNextCursorFrame]];
|
2004-04-29 07:14:21 +04:00
|
|
|
}
|
2008-02-19 23:58:01 +03:00
|
|
|
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK;
|
2004-04-29 07:14:21 +04:00
|
|
|
}
|
|
|
|
|
2019-01-21 20:18:16 +03:00
|
|
|
- (void)setFrame:(int)aFrameIndex {
|
2010-03-11 19:44:31 +03:00
|
|
|
// subclasses need to do something useful here
|
|
|
|
}
|
|
|
|
|
2019-01-21 20:18:16 +03:00
|
|
|
- (nsCursor)type {
|
2010-03-11 19:44:31 +03:00
|
|
|
return mType;
|
2004-04-29 07:14:21 +04:00
|
|
|
}
|
|
|
|
|
2019-01-21 20:18:16 +03:00
|
|
|
- (void)dealloc {
|
2008-02-19 23:58:01 +03:00
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
|
|
|
|
2004-04-29 07:14:21 +04:00
|
|
|
[self destroyTimer];
|
2008-02-19 23:58:01 +03:00
|
|
|
[super dealloc];
|
|
|
|
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK;
|
2004-04-29 07:14:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation nsCocoaCursor
|
2007-09-03 18:43:03 +04:00
|
|
|
|
2019-01-21 20:18:16 +03:00
|
|
|
- (id)initWithFrames:(NSArray *)aCursorFrames type:(nsCursor)aType {
|
2008-02-19 23:58:01 +03:00
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
|
|
|
|
|
2004-04-29 07:14:21 +04:00
|
|
|
self = [super init];
|
|
|
|
NSEnumerator *it = [aCursorFrames objectEnumerator];
|
|
|
|
NSObject *frame = nil;
|
2006-12-15 20:32:16 +03:00
|
|
|
while ((frame = [it nextObject])) {
|
2019-01-21 20:18:16 +03:00
|
|
|
NS_ASSERTION([frame isKindOfClass:[NSCursor class]],
|
|
|
|
"Invalid argument: All frames must be of type NSCursor");
|
2004-04-29 07:14:21 +04:00
|
|
|
}
|
|
|
|
mFrames = [aCursorFrames retain];
|
|
|
|
mFrameCounter = 0;
|
2010-03-11 19:44:31 +03:00
|
|
|
mType = aType;
|
2004-04-29 07:14:21 +04:00
|
|
|
return self;
|
2008-02-19 23:58:01 +03:00
|
|
|
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
|
2004-04-29 07:14:21 +04:00
|
|
|
}
|
|
|
|
|
2019-01-21 20:18:16 +03:00
|
|
|
- (id)initWithCursor:(NSCursor *)aCursor type:(nsCursor)aType {
|
2008-02-19 23:58:01 +03:00
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
|
|
|
|
|
2010-03-11 19:44:31 +03:00
|
|
|
NSArray *frame = [NSArray arrayWithObjects:aCursor, nil];
|
|
|
|
return [self initWithFrames:frame type:aType];
|
2008-02-19 23:58:01 +03:00
|
|
|
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
|
2004-04-29 07:14:21 +04:00
|
|
|
}
|
|
|
|
|
2019-01-21 20:18:16 +03:00
|
|
|
- (id)initWithImageNamed:(NSString *)aCursorImage hotSpot:(NSPoint)aPoint type:(nsCursor)aType {
|
2008-02-19 23:58:01 +03:00
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
|
|
|
|
|
2019-01-21 20:18:16 +03:00
|
|
|
return [self initWithCursor:[nsMacCursor cocoaCursorWithImageNamed:aCursorImage hotSpot:aPoint]
|
|
|
|
type:aType];
|
2008-02-19 23:58:01 +03:00
|
|
|
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
|
2004-04-29 07:14:21 +04:00
|
|
|
}
|
|
|
|
|
2019-01-21 20:18:16 +03:00
|
|
|
- (BOOL)isSet {
|
2009-09-08 01:40:10 +04:00
|
|
|
return [NSCursor currentCursor] == mLastSetCocoaCursor;
|
|
|
|
}
|
|
|
|
|
2019-01-21 20:18:16 +03:00
|
|
|
- (void)setFrame:(int)aFrameIndex {
|
2008-02-19 23:58:01 +03:00
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
|
|
|
|
2019-01-21 20:18:16 +03:00
|
|
|
NSCursor *newCursor = [mFrames objectAtIndex:aFrameIndex];
|
2009-09-08 01:40:10 +04:00
|
|
|
[newCursor set];
|
|
|
|
mLastSetCocoaCursor = newCursor;
|
2008-02-19 23:58:01 +03:00
|
|
|
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK;
|
2004-04-29 07:14:21 +04:00
|
|
|
}
|
|
|
|
|
2019-01-21 20:18:16 +03:00
|
|
|
- (int)numFrames {
|
2008-02-19 23:58:01 +03:00
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
|
|
|
|
|
2004-04-29 07:14:21 +04:00
|
|
|
return [mFrames count];
|
2008-02-19 23:58:01 +03:00
|
|
|
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(0);
|
2004-04-29 07:14:21 +04:00
|
|
|
}
|
|
|
|
|
2019-01-21 20:18:16 +03:00
|
|
|
- (NSString *)description {
|
2008-02-19 23:58:01 +03:00
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
|
|
|
|
|
2004-04-29 07:14:21 +04:00
|
|
|
return [mFrames description];
|
2008-02-19 23:58:01 +03:00
|
|
|
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
|
2004-04-29 07:14:21 +04:00
|
|
|
}
|
|
|
|
|
2019-01-21 20:18:16 +03:00
|
|
|
- (void)dealloc {
|
2008-02-19 23:58:01 +03:00
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
|
|
|
|
2004-04-29 07:14:21 +04:00
|
|
|
[mFrames release];
|
2007-09-03 18:43:03 +04:00
|
|
|
[super dealloc];
|
2008-02-19 23:58:01 +03:00
|
|
|
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK;
|
2004-04-29 07:14:21 +04:00
|
|
|
}
|
2007-09-03 18:43:03 +04:00
|
|
|
|
2004-04-29 07:14:21 +04:00
|
|
|
@end
|