2004-04-29 07:14:21 +04:00
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-12-02 01:27:03 +03:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is nsCursors.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Andrew Thompson.
|
|
|
|
* Portions created by the Andrew Thompson are Copyright (C) 2004
|
|
|
|
* Andrew Thompson. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
2006-12-15 20:32:16 +03:00
|
|
|
* Josh Aas <josh@mozilla.com>
|
2004-12-02 01:27:03 +03:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2004-04-29 07:14:21 +04:00
|
|
|
|
2010-03-11 19:44:31 +03:00
|
|
|
#include "imgIContainer.h"
|
|
|
|
#include "nsCocoaUtils.h"
|
2007-01-18 09:34:07 +03:00
|
|
|
#include "nsCursorManager.h"
|
2008-02-19 23:58:01 +03:00
|
|
|
#include "nsObjCExceptions.h"
|
2007-01-18 09:34:07 +03:00
|
|
|
#include <math.h>
|
2004-04-29 07:14:21 +04:00
|
|
|
|
|
|
|
static nsCursorManager *gInstance;
|
2010-03-11 19:44:31 +03:00
|
|
|
static imgIContainer *sCursorImgContainer = nsnull;
|
|
|
|
static const nsCursor sCustomCursor = eCursorCount;
|
2004-04-29 07:14:21 +04:00
|
|
|
|
|
|
|
/*! @category nsCursorManager(PrivateMethods)
|
|
|
|
Private methods for the cursor manager class.
|
|
|
|
*/
|
|
|
|
@interface nsCursorManager(PrivateMethods)
|
|
|
|
/*! @method getCursor:
|
|
|
|
@abstract Get a reference to the native Mac representation of a cursor.
|
|
|
|
@discussion Gets a reference to the Mac native implementation of a cursor.
|
2006-12-15 20:32:16 +03:00
|
|
|
If the cursor has been requested before, it is retreived from the cursor cache,
|
|
|
|
otherwise it is created and cached.
|
2004-04-29 07:14:21 +04:00
|
|
|
@param aCursor the cursor to get
|
|
|
|
@result the Mac native implementation of the cursor
|
|
|
|
*/
|
|
|
|
- (nsMacCursor *) getCursor: (nsCursor) aCursor;
|
|
|
|
|
2010-03-11 19:44:31 +03:00
|
|
|
/*! @method setMacCursor:
|
|
|
|
@abstract Set the current Mac native cursor
|
|
|
|
@discussion Sets the current cursor - this routine is what actually causes the cursor to change.
|
|
|
|
The argument is retained and the old cursor is released.
|
|
|
|
@param aMacCursor the cursor to set
|
|
|
|
@result NS_OK
|
|
|
|
*/
|
|
|
|
- (nsresult) setMacCursor: (nsMacCursor*) aMacCursor;
|
|
|
|
|
2004-04-29 07:14:21 +04:00
|
|
|
/*! @method createCursor:
|
|
|
|
@abstract Create a Mac native representation of a cursor.
|
2006-12-15 20:32:16 +03:00
|
|
|
@discussion Creates a version of the Mac native representation of this cursor
|
2004-04-29 07:14:21 +04:00
|
|
|
@param aCursor the cursor to create
|
|
|
|
@result the Mac native implementation of the cursor
|
|
|
|
*/
|
|
|
|
+ (nsMacCursor *) createCursor: (enum nsCursor) aCursor;
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation nsCursorManager
|
|
|
|
|
|
|
|
+ (nsCursorManager *) sharedInstance
|
|
|
|
{
|
2008-02-19 23:58:01 +03:00
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
|
|
|
|
|
2006-12-15 20:32:16 +03:00
|
|
|
if (!gInstance) {
|
2004-04-29 07:14:21 +04:00
|
|
|
gInstance = [[nsCursorManager alloc] init];
|
|
|
|
}
|
|
|
|
return gInstance;
|
2008-02-19 23:58:01 +03:00
|
|
|
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
|
2004-04-29 07:14:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
+ (void) dispose
|
|
|
|
{
|
2008-02-19 23:58:01 +03:00
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
|
|
|
|
2004-04-29 07:14:21 +04:00
|
|
|
[gInstance release];
|
|
|
|
gInstance = nil;
|
2008-02-19 23:58:01 +03:00
|
|
|
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK;
|
2004-04-29 07:14:21 +04:00
|
|
|
}
|
|
|
|
|
2010-03-11 19:44:31 +03:00
|
|
|
+ (nsMacCursor *) createCursor: (enum nsCursor) aCursor
|
2004-04-29 07:14:21 +04:00
|
|
|
{
|
2008-02-19 23:58:01 +03:00
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
|
|
|
|
|
2004-04-29 07:14:21 +04:00
|
|
|
switch(aCursor)
|
|
|
|
{
|
2009-12-12 01:17:27 +03:00
|
|
|
SEL cursorSelector;
|
2004-04-29 07:14:21 +04:00
|
|
|
case eCursor_standard:
|
2010-03-11 19:44:31 +03:00
|
|
|
return [nsMacCursor cursorWithCursor:[NSCursor arrowCursor] type:aCursor];
|
2004-04-29 07:14:21 +04:00
|
|
|
case eCursor_wait:
|
2009-01-17 22:23:43 +03:00
|
|
|
case eCursor_spinning:
|
2010-07-28 17:12:12 +04:00
|
|
|
{
|
|
|
|
NSCursor* cursor1 = [nsMacCursor cocoaCursorWithImageNamed:@"spin1" hotSpot:NSMakePoint(1.0, 1.0)];
|
|
|
|
NSCursor* cursor2 = [nsMacCursor cocoaCursorWithImageNamed:@"spin2" hotSpot:NSMakePoint(1.0, 1.0)];
|
|
|
|
NSCursor* cursor3 = [nsMacCursor cocoaCursorWithImageNamed:@"spin3" hotSpot:NSMakePoint(1.0, 1.0)];
|
|
|
|
NSCursor* cursor4 = [nsMacCursor cocoaCursorWithImageNamed:@"spin4" hotSpot:NSMakePoint(1.0, 1.0)];
|
|
|
|
NSArray* spinCursorFrames = [[[NSArray alloc] initWithObjects:cursor1, cursor2, cursor3, cursor4, nil] autorelease];
|
|
|
|
return [nsMacCursor cursorWithFrames:spinCursorFrames type:aCursor];
|
|
|
|
}
|
2008-11-29 01:43:29 +03:00
|
|
|
case eCursor_select:
|
2010-03-11 19:44:31 +03:00
|
|
|
return [nsMacCursor cursorWithCursor:[NSCursor IBeamCursor] type:aCursor];
|
2004-04-29 07:14:21 +04:00
|
|
|
case eCursor_hyperlink:
|
2010-03-11 19:44:31 +03:00
|
|
|
return [nsMacCursor cursorWithCursor:[NSCursor pointingHandCursor] type:aCursor];
|
2004-04-29 07:14:21 +04:00
|
|
|
case eCursor_crosshair:
|
2010-03-11 19:44:31 +03:00
|
|
|
return [nsMacCursor cursorWithCursor:[NSCursor crosshairCursor] type:aCursor];
|
2004-04-29 07:14:21 +04:00
|
|
|
case eCursor_move:
|
2010-03-11 19:44:31 +03:00
|
|
|
return [nsMacCursor cursorWithCursor:[NSCursor openHandCursor] type:aCursor];
|
2004-04-29 07:14:21 +04:00
|
|
|
case eCursor_help:
|
2010-03-11 19:44:31 +03:00
|
|
|
return [nsMacCursor cursorWithImageNamed:@"help" hotSpot:NSMakePoint(1,1) type:aCursor];
|
2004-04-29 07:14:21 +04:00
|
|
|
case eCursor_copy:
|
2009-12-12 01:17:27 +03:00
|
|
|
cursorSelector = @selector(dragCopyCursor);
|
2010-03-11 19:44:31 +03:00
|
|
|
return [nsMacCursor cursorWithCursor:[NSCursor respondsToSelector:cursorSelector] ?
|
|
|
|
[NSCursor performSelector:cursorSelector] :
|
|
|
|
[NSCursor arrowCursor] type:aCursor];
|
2004-04-29 07:14:21 +04:00
|
|
|
case eCursor_alias:
|
2009-12-12 01:17:27 +03:00
|
|
|
cursorSelector = @selector(dragLinkCursor);
|
2010-03-11 19:44:31 +03:00
|
|
|
return [nsMacCursor cursorWithCursor:[NSCursor respondsToSelector:cursorSelector] ?
|
|
|
|
[NSCursor performSelector:cursorSelector] :
|
|
|
|
[NSCursor arrowCursor] type:aCursor];
|
2004-04-29 07:14:21 +04:00
|
|
|
case eCursor_context_menu:
|
2009-12-12 01:17:27 +03:00
|
|
|
cursorSelector = @selector(contextualMenuCursor);
|
2010-03-11 19:44:31 +03:00
|
|
|
return [nsMacCursor cursorWithCursor:[NSCursor respondsToSelector:cursorSelector] ?
|
|
|
|
[NSCursor performSelector:cursorSelector] :
|
|
|
|
[NSCursor arrowCursor] type:aCursor];
|
2004-04-29 07:14:21 +04:00
|
|
|
case eCursor_cell:
|
2010-03-11 19:44:31 +03:00
|
|
|
return [nsMacCursor cursorWithCursor:[NSCursor crosshairCursor] type:aCursor];
|
2004-04-29 07:14:21 +04:00
|
|
|
case eCursor_grab:
|
2010-03-11 19:44:31 +03:00
|
|
|
return [nsMacCursor cursorWithCursor:[NSCursor openHandCursor] type:aCursor];
|
2004-04-29 07:14:21 +04:00
|
|
|
case eCursor_grabbing:
|
2010-03-11 19:44:31 +03:00
|
|
|
return [nsMacCursor cursorWithCursor:[NSCursor closedHandCursor] type:aCursor];
|
2004-04-29 07:14:21 +04:00
|
|
|
case eCursor_zoom_in:
|
2010-03-11 19:44:31 +03:00
|
|
|
return [nsMacCursor cursorWithImageNamed:@"zoomIn" hotSpot:NSMakePoint(6,6) type:aCursor];
|
2004-04-29 07:14:21 +04:00
|
|
|
case eCursor_zoom_out:
|
2010-03-11 19:44:31 +03:00
|
|
|
return [nsMacCursor cursorWithImageNamed:@"zoomOut" hotSpot:NSMakePoint(6,6) type:aCursor];
|
2004-09-12 03:24:30 +04:00
|
|
|
case eCursor_vertical_text:
|
2010-03-11 19:44:31 +03:00
|
|
|
return [nsMacCursor cursorWithImageNamed:@"vtIBeam" hotSpot:NSMakePoint(7,8) type:aCursor];
|
2004-09-12 03:24:30 +04:00
|
|
|
case eCursor_all_scroll:
|
2010-03-11 19:44:31 +03:00
|
|
|
return [nsMacCursor cursorWithCursor:[NSCursor openHandCursor] type:aCursor];
|
2004-09-12 03:24:30 +04:00
|
|
|
case eCursor_not_allowed:
|
|
|
|
case eCursor_no_drop:
|
2009-12-12 01:17:27 +03:00
|
|
|
cursorSelector = @selector(operationNotAllowedCursor);
|
2010-03-11 19:44:31 +03:00
|
|
|
return [nsMacCursor cursorWithCursor:[NSCursor respondsToSelector:cursorSelector] ?
|
|
|
|
[NSCursor performSelector:cursorSelector] :
|
|
|
|
[NSCursor arrowCursor] type:aCursor];
|
2004-09-19 23:49:29 +04:00
|
|
|
// Resize Cursors:
|
2010-03-11 19:44:31 +03:00
|
|
|
// North
|
2004-09-12 03:24:30 +04:00
|
|
|
case eCursor_n_resize:
|
2010-03-11 19:44:31 +03:00
|
|
|
return [nsMacCursor cursorWithCursor:[NSCursor resizeUpCursor] type:aCursor];
|
|
|
|
// North East
|
2004-09-12 03:24:30 +04:00
|
|
|
case eCursor_ne_resize:
|
2010-03-11 19:44:31 +03:00
|
|
|
return [nsMacCursor cursorWithImageNamed:@"sizeNE" hotSpot:NSMakePoint(8,7) type:aCursor];
|
|
|
|
// East
|
|
|
|
case eCursor_e_resize:
|
|
|
|
return [nsMacCursor cursorWithCursor:[NSCursor resizeRightCursor] type:aCursor];
|
|
|
|
// South East
|
2004-09-12 03:24:30 +04:00
|
|
|
case eCursor_se_resize:
|
2010-03-11 19:44:31 +03:00
|
|
|
return [nsMacCursor cursorWithImageNamed:@"sizeSE" hotSpot:NSMakePoint(8,8) type:aCursor];
|
|
|
|
// South
|
2004-09-12 03:24:30 +04:00
|
|
|
case eCursor_s_resize:
|
2010-03-11 19:44:31 +03:00
|
|
|
return [nsMacCursor cursorWithCursor:[NSCursor resizeDownCursor] type:aCursor];
|
|
|
|
// South West
|
2004-09-12 03:24:30 +04:00
|
|
|
case eCursor_sw_resize:
|
2010-03-11 19:44:31 +03:00
|
|
|
return [nsMacCursor cursorWithImageNamed:@"sizeSW" hotSpot:NSMakePoint(6,8) type:aCursor];
|
|
|
|
// West
|
2004-09-12 03:24:30 +04:00
|
|
|
case eCursor_w_resize:
|
2010-03-11 19:44:31 +03:00
|
|
|
return [nsMacCursor cursorWithCursor:[NSCursor resizeLeftCursor] type:aCursor];
|
|
|
|
// North West
|
2004-09-12 03:24:30 +04:00
|
|
|
case eCursor_nw_resize:
|
2010-03-11 19:44:31 +03:00
|
|
|
return [nsMacCursor cursorWithImageNamed:@"sizeNW" hotSpot:NSMakePoint(7,7) type:aCursor];
|
|
|
|
// North & South
|
2004-09-12 03:24:30 +04:00
|
|
|
case eCursor_ns_resize:
|
2010-03-11 19:44:31 +03:00
|
|
|
return [nsMacCursor cursorWithCursor:[NSCursor resizeUpDownCursor] type:aCursor];
|
|
|
|
// East & West
|
2004-09-12 03:24:30 +04:00
|
|
|
case eCursor_ew_resize:
|
2010-03-11 19:44:31 +03:00
|
|
|
return [nsMacCursor cursorWithCursor:[NSCursor resizeLeftRightCursor] type:aCursor];
|
|
|
|
// North East & South West
|
2004-09-12 03:24:30 +04:00
|
|
|
case eCursor_nesw_resize:
|
2010-03-11 19:44:31 +03:00
|
|
|
return [nsMacCursor cursorWithImageNamed:@"sizeNESW" hotSpot:NSMakePoint(8,8) type:aCursor];
|
|
|
|
// North West & South East
|
2004-09-12 03:24:30 +04:00
|
|
|
case eCursor_nwse_resize:
|
2010-03-11 19:44:31 +03:00
|
|
|
return [nsMacCursor cursorWithImageNamed:@"sizeNWSE" hotSpot:NSMakePoint(8,8) type:aCursor];
|
|
|
|
// Column Resize
|
2004-09-12 03:24:30 +04:00
|
|
|
case eCursor_col_resize:
|
2010-03-11 19:44:31 +03:00
|
|
|
return [nsMacCursor cursorWithImageNamed:@"colResize" hotSpot:NSMakePoint(8,8) type:aCursor];
|
|
|
|
// Row Resize
|
2004-09-12 03:24:30 +04:00
|
|
|
case eCursor_row_resize:
|
2010-03-11 19:44:31 +03:00
|
|
|
return [nsMacCursor cursorWithImageNamed:@"rowResize" hotSpot:NSMakePoint(8,8) type:aCursor];
|
2004-04-29 07:14:21 +04:00
|
|
|
default:
|
2010-03-11 19:44:31 +03:00
|
|
|
return [nsMacCursor cursorWithCursor:[NSCursor arrowCursor] type:aCursor];
|
2004-04-29 07:14:21 +04:00
|
|
|
}
|
2008-02-19 23:58:01 +03:00
|
|
|
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
|
2004-04-29 07:14:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
- (id) init
|
|
|
|
{
|
2008-02-19 23:58:01 +03:00
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
|
|
|
|
|
2006-12-15 20:32:16 +03:00
|
|
|
if ((self = [super init])) {
|
2008-02-19 23:58:01 +03:00
|
|
|
mCursors = [[NSMutableDictionary alloc] initWithCapacity:25];
|
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
|
|
|
}
|
|
|
|
|
2010-03-11 19:44:31 +03:00
|
|
|
- (nsresult) setCursor: (enum nsCursor) aCursor
|
2004-04-29 07:14:21 +04:00
|
|
|
{
|
2010-03-11 19:44:31 +03:00
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
2008-02-19 23:58:01 +03:00
|
|
|
|
2009-09-08 01:40:10 +04:00
|
|
|
// Some plugins mess with our cursors and set a cursor that even
|
|
|
|
// [NSCursor currentCursor] doesn't know about. In case that happens, just
|
|
|
|
// reset the state.
|
|
|
|
[[NSCursor currentCursor] set];
|
|
|
|
|
2010-03-11 19:44:31 +03:00
|
|
|
nsCursor oldType = [mCurrentMacCursor type];
|
|
|
|
if (oldType != aCursor) {
|
2009-12-12 01:05:21 +03:00
|
|
|
if (aCursor == eCursor_none) {
|
|
|
|
[NSCursor hide];
|
2010-03-11 19:44:31 +03:00
|
|
|
} else if (oldType == eCursor_none) {
|
2009-12-12 01:05:21 +03:00
|
|
|
[NSCursor unhide];
|
|
|
|
}
|
2009-09-08 01:40:10 +04:00
|
|
|
}
|
2010-03-11 19:44:31 +03:00
|
|
|
[self setMacCursor:[self getCursor:aCursor]];
|
2009-09-08 01:40:10 +04:00
|
|
|
|
2010-03-11 19:44:31 +03:00
|
|
|
// if a custom cursor was previously set, release sCursorImgContainer
|
|
|
|
if (oldType == sCustomCursor) {
|
|
|
|
NS_IF_RELEASE(sCursorImgContainer);
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
|
|
|
|
}
|
2009-12-12 01:05:21 +03:00
|
|
|
|
2010-03-11 19:44:31 +03:00
|
|
|
- (nsresult) setMacCursor: (nsMacCursor*) aMacCursor
|
|
|
|
{
|
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
|
|
|
|
|
|
|
if (mCurrentMacCursor != aMacCursor || ![mCurrentMacCursor isSet]) {
|
|
|
|
[aMacCursor retain];
|
|
|
|
[mCurrentMacCursor unset];
|
|
|
|
[aMacCursor set];
|
|
|
|
[mCurrentMacCursor release];
|
|
|
|
mCurrentMacCursor = aMacCursor;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (nsresult) setCursorWithImage: (imgIContainer*) aCursorImage hotSpotX: (PRUint32) aHotspotX hotSpotY: (PRUint32) aHotspotY
|
|
|
|
{
|
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
|
|
|
// As the user moves the mouse, this gets called repeatedly with the same aCursorImage
|
|
|
|
if (sCursorImgContainer == aCursorImage && mCurrentMacCursor) {
|
|
|
|
[self setMacCursor:mCurrentMacCursor];
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
[[NSCursor currentCursor] set];
|
|
|
|
PRInt32 width = 0, height = 0;
|
|
|
|
aCursorImage->GetWidth(&width);
|
|
|
|
aCursorImage->GetHeight(&height);
|
|
|
|
// prevent DoS attacks
|
|
|
|
if (width > 128 || height > 128) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NSImage *cursorImage;
|
|
|
|
nsresult rv = nsCocoaUtils::CreateNSImageFromImageContainer(aCursorImage, imgIContainer::FRAME_FIRST, &cursorImage);
|
|
|
|
if (NS_FAILED(rv) || !cursorImage) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// if the hotspot is nonsensical, make it 0,0
|
2012-02-22 05:44:40 +04:00
|
|
|
aHotspotX = (aHotspotX > (PRUint32)width - 1) ? 0 : aHotspotX;
|
|
|
|
aHotspotY = (aHotspotY > (PRUint32)height - 1) ? 0 : aHotspotY;
|
2010-03-11 19:44:31 +03:00
|
|
|
|
|
|
|
NSPoint hotSpot = ::NSMakePoint(aHotspotX, aHotspotY);
|
|
|
|
[self setMacCursor:[nsMacCursor cursorWithCursor:[[NSCursor alloc] initWithImage:cursorImage hotSpot:hotSpot] type:sCustomCursor]];
|
|
|
|
[cursorImage release];
|
|
|
|
|
|
|
|
NS_IF_RELEASE(sCursorImgContainer);
|
|
|
|
sCursorImgContainer = aCursorImage;
|
|
|
|
NS_ADDREF(sCursorImgContainer);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
|
2004-04-29 07:14:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
- (nsMacCursor *) getCursor: (enum nsCursor) aCursor
|
|
|
|
{
|
2008-02-19 23:58:01 +03:00
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
|
|
|
|
|
2010-03-11 19:44:31 +03:00
|
|
|
nsMacCursor * result = [mCursors objectForKey:[NSNumber numberWithInt:aCursor]];
|
2006-12-15 20:32:16 +03:00
|
|
|
if (!result) {
|
2010-03-11 19:44:31 +03:00
|
|
|
result = [nsCursorManager createCursor:aCursor];
|
|
|
|
[mCursors setObject:result forKey:[NSNumber numberWithInt:aCursor]];
|
2004-04-29 07:14:21 +04:00
|
|
|
}
|
|
|
|
return result;
|
2008-02-19 23:58:01 +03:00
|
|
|
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
|
2004-04-29 07:14:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) dealloc
|
|
|
|
{
|
2008-02-19 23:58:01 +03:00
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
|
|
|
|
2010-03-11 19:44:31 +03:00
|
|
|
[mCurrentMacCursor unset];
|
|
|
|
[mCurrentMacCursor release];
|
|
|
|
[mCursors release];
|
|
|
|
NS_IF_RELEASE(sCursorImgContainer);
|
2008-02-19 23:58:01 +03:00
|
|
|
[super dealloc];
|
|
|
|
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK;
|
2004-04-29 07:14:21 +04:00
|
|
|
}
|
2006-12-15 20:32:16 +03:00
|
|
|
|
2004-04-29 07:14:21 +04:00
|
|
|
@end
|