CPCursor refactor according to discussion in http://groups.google.com/group/objectivej-dev/browse_thread/thread/eabe59dc7d71122b/ddc6f1b61e5f3c2a?lnk=gst&q=cpcursor#ddc6f1b61e5f3c2a and new test for CPCursor that is easier to go through.
@@ -1,36 +1,41 @@
|
||||
/*
|
||||
Testing browsers:
|
||||
WebKit r50235 (Safari 4.0.3+)
|
||||
FireFox 3.5
|
||||
Opera 10.0.0
|
||||
|
||||
Implemented class methods:
|
||||
Webkit : All
|
||||
IE : All
|
||||
FireFox Win : All
|
||||
FireFox Mac : All except closedHandCursor disappearingItemCursor // Firefox mac does not support url cursors
|
||||
Opera : All except resizeLeftRightCursor resizeUpDownCursor operationNotAllowedCursor dragCopyCursor dragLinkCursor contextualMenuCursor openHandCursor closedHandCursor disappearingItemCursor // Opera does not support url cursors so these won't work with images
|
||||
Cursor support by browser:
|
||||
OS X 10.6/Chrome 8 : All
|
||||
OS X 10.6/Safari 5 : All
|
||||
OS X 10.6/Firefox 3 : All except disappearingItemCursor (no url() support)
|
||||
OS X 10.6/Firefox 3.5 : All except disappearingItemCursor (no url() support)
|
||||
OS X 10.6/Firefox 3.6 : All except disappearingItemCursor, contextualMenuCursor, dragLinkCursor, dragCopyCursor, operationNotAllowedCursor (no url() support)
|
||||
OS X 10.6/Firefox 4.0b10 : All
|
||||
OS X/Opera 9 : All except disappearingItemCursor, closedHandCursor, openHandCursor, contextualMenuCursor, dragLinkCursor, dragCopyCursor, operationNotAllowedCursor, resizeUpDownCursor, resizeLeftRightCursor (no url() support)
|
||||
OS X/Opera 10 : All except disappearingItemCursor, closedHandCursor, contextualMenuCursor, dragLinkCursor, dragCopyCursor, operationNotAllowedCursor (no url() support)
|
||||
OS X/Opera 11 : All except disappearingItemCursor, closedHandCursor, contextualMenuCursor, dragLinkCursor, dragCopyCursor, operationNotAllowedCursor (no url() support)
|
||||
Win XP/Chrome 8 : All
|
||||
Win XP/Safari 5 : All
|
||||
Win XP/Firefox 3 : All
|
||||
Win XP/Firefox 3.5 : All
|
||||
Win XP/Firefox 3.6 : All
|
||||
Win XP/Firefox 4.0b10 : All
|
||||
Win XP/Opera 10 : All except disappearingItemCursor, closedHandCursor, openHandCursor, contextualMenuCursor, dragLinkCursor, dragCopyCursor, operationNotAllowedCursor, resizeUpDownCursor, resizeLeftRightCursor (no url() support)
|
||||
Win XP/Opera 11 : All except disappearingItemCursor, closedHandCursor, openHandCursor, contextualMenuCursor, dragLinkCursor, dragCopyCursor, operationNotAllowedCursor, resizeUpDownCursor, resizeLeftRightCursor (no url() support)
|
||||
Win XP/IE 7 : All
|
||||
Win XP/IE 8 : All
|
||||
*/
|
||||
|
||||
@import <Foundation/CPObject.j>
|
||||
|
||||
var currentCursor = nil,
|
||||
cursorStack = [],
|
||||
cursors = {},
|
||||
cursorURLFormat = nil;
|
||||
cursors = {};
|
||||
|
||||
@implementation CPCursor : CPObject
|
||||
{
|
||||
CPString _cssString;
|
||||
CPString _cssString @accessors(readonly);
|
||||
CPString _hotSpot @accessors(readonly, getter=hotSpot);
|
||||
CPImage _image @accessors(readonly, getter=image);
|
||||
BOOL _isSetOnMouseEntered @accessors(readwrite, getter=isSetOnMouseEntered, setter=setOnMouseEntered:);
|
||||
BOOL _isSetOnMouseExited @accessors(readwrite, getter=isSetOnMouseExited, setter=setOnMouseExited:);
|
||||
}
|
||||
|
||||
+ (CPCursor)currentCursor
|
||||
{
|
||||
return currentCursor;
|
||||
}
|
||||
|
||||
- (id)initWithCSSString:(CPString)aString
|
||||
{
|
||||
if (self = [super init])
|
||||
@@ -39,155 +44,18 @@ var currentCursor = nil,
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (CPCursor)cursorWithCSSString:(CPString)cssString
|
||||
// hotspot is supported in CSS3 (but not IE).
|
||||
- (id)initWithImage:(CPImage)image hotSpot:(CPPoint)hotSpot
|
||||
{
|
||||
var cursor = cursors[cssString];
|
||||
|
||||
if (typeof cursor == 'undefined')
|
||||
{
|
||||
cursor = [[CPCursor alloc] initWithCSSString:cssString];
|
||||
cursors[cssString] = cursor;
|
||||
}
|
||||
|
||||
return cursor;
|
||||
_hotSpot = hotSpot;
|
||||
_image = image;
|
||||
return [self initWithCSSString:"url(" + [_image filename] + ")" + hotSpot.x + " " + hotSpot.y + ", auto"];
|
||||
}
|
||||
|
||||
+ (CPCursor)cursorWithImageNamed:(CPString)imageName
|
||||
// foregroundColor and backgroundColor are ignored in Cocoa as well. See http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSCursor_Class/Reference/Reference.html
|
||||
– (id)initWithImage:(CPImage)image foregroundColorHint:(CPColor)foregroundColor backgroundColorHint:(CPColor)backgroundColor hotSpot:(CPPoint)aHotSpot
|
||||
{
|
||||
if (!cursorURLFormat)
|
||||
{
|
||||
cursorURLFormat = @"url(" + [[CPBundle bundleForClass:self] resourcePath] + @"/CPCursor/%@.cur)";
|
||||
|
||||
if (CPBrowserIsEngine(CPGeckoBrowserEngine))
|
||||
cursorURLFormat += ", default";
|
||||
}
|
||||
|
||||
var url = [CPString stringWithFormat:cursorURLFormat, imageName];
|
||||
|
||||
return [[CPCursor alloc] initWithCSSString:url];
|
||||
}
|
||||
|
||||
- (CPString)_cssString
|
||||
{
|
||||
return _cssString;
|
||||
}
|
||||
|
||||
+ (CPCursor)arrowCursor
|
||||
{
|
||||
return [CPCursor cursorWithCSSString:@"default"]; // WebKit | FF | opera | IE
|
||||
}
|
||||
|
||||
+ (CPCursor)crosshairCursor
|
||||
{
|
||||
return [CPCursor cursorWithCSSString:@"crosshair"]; // WebKit | FF | opera | IE
|
||||
}
|
||||
|
||||
+ (CPCursor)IBeamCursor
|
||||
{
|
||||
return [CPCursor cursorWithCSSString:@"text"]; // WebKit | FF | opera | IE
|
||||
}
|
||||
|
||||
+ (CPCursor)pointingHandCursor
|
||||
{
|
||||
return [CPCursor cursorWithCSSString:@"pointer"]; // WebKit | FF | opera | IE
|
||||
}
|
||||
|
||||
+ (CPCursor)resizeDownCursor
|
||||
{
|
||||
if (CPBrowserIsEngine(CPInternetExplorerBrowserEngine))
|
||||
return [CPCursor cursorWithImageNamed:CPStringFromSelector(_cmd)];
|
||||
|
||||
return [CPCursor cursorWithCSSString:"s-resize"]; // WebKit | FF | opera
|
||||
}
|
||||
|
||||
+ (CPCursor)resizeUpCursor
|
||||
{
|
||||
if (CPBrowserIsEngine(CPInternetExplorerBrowserEngine))
|
||||
return [CPCursor cursorWithImageNamed:CPStringFromSelector(_cmd)];
|
||||
|
||||
return [CPCursor cursorWithCSSString:@"n-resize"]; // WebKit | FF | opera
|
||||
}
|
||||
|
||||
+ (CPCursor)resizeLeftCursor
|
||||
{
|
||||
if (CPBrowserIsEngine(CPInternetExplorerBrowserEngine))
|
||||
return [CPCursor cursorWithImageNamed:CPStringFromSelector(_cmd)];
|
||||
|
||||
return [CPCursor cursorWithCSSString:@"w-resize"]; // WebKit | FF | opera
|
||||
}
|
||||
|
||||
+ (CPCursor)resizeRightCursor
|
||||
{
|
||||
if (CPBrowserIsEngine(CPInternetExplorerBrowserEngine))
|
||||
return [CPCursor cursorWithImageNamed:CPStringFromSelector(_cmd)];
|
||||
|
||||
return [CPCursor cursorWithCSSString:@"e-resize"]; // WebKit | FF | opera
|
||||
}
|
||||
|
||||
+ (CPCursor)resizeLeftRightCursor
|
||||
{
|
||||
return [CPCursor cursorWithCSSString:@"col-resize"]; // WebKit | FF | IE
|
||||
}
|
||||
|
||||
+ (CPCursor)resizeUpDownCursor
|
||||
{
|
||||
return [CPCursor cursorWithCSSString:@"row-resize"]; // WebKit | FF | IE
|
||||
}
|
||||
|
||||
+ (CPCursor)operationNotAllowedCursor
|
||||
{
|
||||
return [CPCursor cursorWithCSSString:@"not-allowed"]; // WebKit | FF | IE
|
||||
}
|
||||
|
||||
+ (CPCursor)dragCopyCursor
|
||||
{
|
||||
if (CPBrowserIsEngine(CPInternetExplorerBrowserEngine))
|
||||
return [CPCursor cursorWithImageNamed:CPStringFromSelector(_cmd)];
|
||||
|
||||
return [CPCursor cursorWithCSSString:@"copy"]; // WebKit | FF
|
||||
}
|
||||
|
||||
+ (CPCursor)dragLinkCursor
|
||||
{
|
||||
if (CPBrowserIsEngine(CPInternetExplorerBrowserEngine))
|
||||
return [CPCursor cursorWithImageNamed:CPStringFromSelector(_cmd)];
|
||||
|
||||
return [CPCursor cursorWithCSSString:@"alias"]; // WebKit | FF
|
||||
}
|
||||
|
||||
+ (CPCursor)contextualMenuCursor
|
||||
{
|
||||
if (CPBrowserIsEngine(CPInternetExplorerBrowserEngine))
|
||||
return [CPCursor cursorWithImageNamed:CPStringFromSelector(_cmd)];
|
||||
|
||||
return [CPCursor cursorWithCSSString:@"context-menu"]; // WebKit | FF Mac . Not impl FF Win.
|
||||
}
|
||||
|
||||
+ (CPCursor)openHandCursor
|
||||
{
|
||||
if (CPBrowserIsEngine(CPWebKitBrowserEngine))
|
||||
return [CPCursor cursorWithCSSString:@"-webkit-grab"];
|
||||
else if (CPBrowserIsEngine(CPGeckoBrowserEngine))
|
||||
return [CPCursor cursorWithCSSString:@"-moz-grab"];
|
||||
else if (CPBrowserIsEngine(CPOperaBrowserEngine))
|
||||
return [CPCursor cursorWithCSSString:@"move"];
|
||||
|
||||
return [CPCursor cursorWithImageNamed:CPStringFromSelector(_cmd)]; // WebKit only. move in FFMac|Opera
|
||||
}
|
||||
|
||||
+ (CPCursor)closedHandCursor
|
||||
{
|
||||
if (CPBrowserIsEngine(CPWebKitBrowserEngine))
|
||||
return [CPCursor cursorWithCSSString:@"-webkit-grabbing"];
|
||||
else if (CPBrowserIsEngine(CPGeckoBrowserEngine))
|
||||
return [CPCursor cursorWithCSSString:@"-moz-grabbing"];
|
||||
|
||||
return [CPCursor cursorWithImageNamed:CPStringFromSelector(_cmd)]; // WebKit || FF
|
||||
}
|
||||
|
||||
+ (CPCursor)disappearingItemCursor
|
||||
{
|
||||
return [CPCursor cursorWithImageNamed:CPStringFromSelector(_cmd)]; // None
|
||||
return [self initWithImage:image hotSpot:hotSpot];
|
||||
}
|
||||
|
||||
+ (void)hide
|
||||
@@ -208,44 +76,6 @@ var currentCursor = nil,
|
||||
[CPCursor unhide];
|
||||
}
|
||||
|
||||
- (id)initWithImage:(CPImage)image hotSpot:(CPPoint)hotSpot
|
||||
{
|
||||
return [self initWithCSSString:"url(" + [image filename] + "), auto"];
|
||||
}
|
||||
|
||||
|
||||
- (void)mouseEntered:(CPEvent)event
|
||||
{
|
||||
}
|
||||
|
||||
- (void)mouseExited:(CPEvent)event
|
||||
{
|
||||
}
|
||||
|
||||
- (void)set
|
||||
{
|
||||
currentCursor = self;
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
[[self class] _setCursorCSS:_cssString];
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
+ (void)_setCursorCSS:(CPString)aString
|
||||
{
|
||||
#if PLATFORM(DOM)
|
||||
var platformWindows = [[CPPlatformWindow visiblePlatformWindows] allObjects];
|
||||
for (var i = 0, count = [platformWindows count]; i < count; i++)
|
||||
platformWindows[i]._DOMBodyElement.style.cursor = aString;
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)push
|
||||
{
|
||||
currentCursor = cursorStack.push(self);
|
||||
}
|
||||
|
||||
- (void)pop
|
||||
{
|
||||
[CPCursor pop];
|
||||
@@ -260,6 +90,148 @@ var currentCursor = nil,
|
||||
}
|
||||
}
|
||||
|
||||
- (void)push
|
||||
{
|
||||
currentCursor = cursorStack.push(self);
|
||||
}
|
||||
|
||||
- (void)set
|
||||
{
|
||||
currentCursor = self;
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
[[self class] _setCursorCSS:_cssString];
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)mouseEntered:(CPEvent)event
|
||||
{
|
||||
}
|
||||
|
||||
- (void)mouseExited:(CPEvent)event
|
||||
{
|
||||
}
|
||||
|
||||
+ (CPCursor)currentCursor
|
||||
{
|
||||
return currentCursor;
|
||||
}
|
||||
|
||||
+ (void)_setCursorCSS:(CPString)aString
|
||||
{
|
||||
#if PLATFORM(DOM)
|
||||
var platformWindows = [[CPPlatformWindow visiblePlatformWindows] allObjects];
|
||||
for (var i = 0, count = [platformWindows count]; i < count; i++)
|
||||
platformWindows[i]._DOMBodyElement.style.cursor = aString;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Internal method that is used to return the system cursors. Caches the system cursors for performance.
|
||||
+ (CPCursor)_systemCursorWithName:(CPString)cursorName cssString:(CPString)aString hasImage:(BOOL)doesHaveImage
|
||||
{
|
||||
var cursor = cursors[cursorName];
|
||||
if (typeof cursor === 'undefined')
|
||||
{
|
||||
var cssString;
|
||||
if (doesHaveImage)
|
||||
cssString = @"url(" + [[CPBundle bundleForClass:self] resourcePath] + @"/CPCursor/" + cursorName + ".cur), " + aString;
|
||||
else
|
||||
cssString = aString
|
||||
cursor = [[CPCursor alloc] initWithCSSString:cssString];
|
||||
cursors[cursorName] = cursor;
|
||||
}
|
||||
return cursor;
|
||||
}
|
||||
|
||||
+ (CPCursor)arrowCursor
|
||||
{
|
||||
return [CPCursor _systemCursorWithName:CPStringFromSelector(_cmd) cssString:"default" hasImage:NO];
|
||||
}
|
||||
|
||||
+ (CPCursor)crosshairCursor
|
||||
{
|
||||
return [CPCursor _systemCursorWithName:CPStringFromSelector(_cmd) cssString:@"crosshair" hasImage:NO];
|
||||
}
|
||||
|
||||
+ (CPCursor)IBeamCursor
|
||||
{
|
||||
return [CPCursor _systemCursorWithName:CPStringFromSelector(_cmd) cssString:@"text" hasImage:NO];
|
||||
}
|
||||
|
||||
+ (CPCursor)pointingHandCursor
|
||||
{
|
||||
return [CPCursor _systemCursorWithName:CPStringFromSelector(_cmd) cssString:@"pointer" hasImage:NO];
|
||||
}
|
||||
|
||||
+ (CPCursor)resizeDownCursor
|
||||
{
|
||||
return [CPCursor _systemCursorWithName:CPStringFromSelector(_cmd) cssString:@"s-resize" hasImage:NO];
|
||||
}
|
||||
|
||||
+ (CPCursor)resizeUpCursor
|
||||
{
|
||||
return [CPCursor _systemCursorWithName:CPStringFromSelector(_cmd) cssString:@"n-resize" hasImage:NO];
|
||||
}
|
||||
|
||||
+ (CPCursor)resizeLeftCursor
|
||||
{
|
||||
return [CPCursor _systemCursorWithName:CPStringFromSelector(_cmd) cssString:@"w-resize" hasImage:NO];
|
||||
}
|
||||
|
||||
+ (CPCursor)resizeRightCursor
|
||||
{
|
||||
return [CPCursor _systemCursorWithName:CPStringFromSelector(_cmd) cssString:@"e-resize" hasImage:NO];
|
||||
}
|
||||
|
||||
+ (CPCursor)resizeLeftRightCursor
|
||||
{
|
||||
return [CPCursor _systemCursorWithName:CPStringFromSelector(_cmd) cssString:@"col-resize" hasImage:NO];
|
||||
}
|
||||
|
||||
+ (CPCursor)resizeUpDownCursor
|
||||
{
|
||||
return [CPCursor _systemCursorWithName:CPStringFromSelector(_cmd) cssString:@"row-resize" hasImage:NO];
|
||||
}
|
||||
|
||||
+ (CPCursor)operationNotAllowedCursor
|
||||
{
|
||||
return [CPCursor _systemCursorWithName:CPStringFromSelector(_cmd) cssString:@"not-allowed" hasImage:NO];
|
||||
}
|
||||
|
||||
+ (CPCursor)dragCopyCursor
|
||||
{
|
||||
return [CPCursor _systemCursorWithName:CPStringFromSelector(_cmd) cssString:@"copy" hasImage:YES];
|
||||
}
|
||||
|
||||
+ (CPCursor)dragLinkCursor
|
||||
{
|
||||
return [CPCursor _systemCursorWithName:CPStringFromSelector(_cmd) cssString:@"alias" hasImage:YES];
|
||||
}
|
||||
|
||||
+ (CPCursor)contextualMenuCursor
|
||||
{
|
||||
return [CPCursor _systemCursorWithName:CPStringFromSelector(_cmd) cssString:@"context-menu" hasImage:YES];
|
||||
}
|
||||
|
||||
+ (CPCursor)openHandCursor
|
||||
{
|
||||
return [CPCursor _systemCursorWithName:CPStringFromSelector(_cmd) cssString:@"move" hasImage:YES];
|
||||
}
|
||||
|
||||
+ (CPCursor)closedHandCursor
|
||||
{
|
||||
return [CPCursor _systemCursorWithName:CPStringFromSelector(_cmd) cssString:@"-moz-grabbing" hasImage:YES];
|
||||
}
|
||||
|
||||
+ (CPCursor)disappearingItemCursor
|
||||
{
|
||||
return [CPCursor _systemCursorWithName:CPStringFromSelector(_cmd) cssString:@"auto" hasImage:YES];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation CPCursor(CPCoding)
|
||||
|
||||
- (id)initWithCoder:(CPCoder)coder
|
||||
{
|
||||
if (self = [super init])
|
||||
@@ -274,4 +246,3 @@ var currentCursor = nil,
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 326 B |
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 326 B |
|
Before Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 4.2 KiB |
@@ -1,65 +1,127 @@
|
||||
/*
|
||||
* AppController.j
|
||||
* CursorTest
|
||||
*
|
||||
* Created by You on November 6, 2009.
|
||||
* Copyright 2009, Your Company All rights reserved.
|
||||
*/
|
||||
|
||||
@import <Foundation/CPObject.j>
|
||||
|
||||
var selectors = ["pointingHandCursor", "resizeDownCursor", "resizeLeftCursor", "resizeRightCursor", "resizeUpCursor", "resizeLeftRightCursor", "resizeUpDownCursor", "operationNotAllowedCursor", "dragCopyCursor", "dragLinkCursor", "contextualMenuCursor", "openHandCursor", "closedHandCursor", "disappearingItemCursor"];
|
||||
@implementation CursorTester : CPView
|
||||
{
|
||||
CPCursor testCursor;
|
||||
CPTextField label;
|
||||
}
|
||||
|
||||
- (id)initWithText:(CPString)aLabel
|
||||
origin:(CGPoint)anOrigin
|
||||
cursor:(CPCursor)aCursor
|
||||
{
|
||||
self = [super init];
|
||||
if (self)
|
||||
{
|
||||
testCursor = aCursor;
|
||||
label = [CPTextField labelWithTitle:aLabel];
|
||||
[label setBackgroundColor:[CPColor redColor]];
|
||||
[label setTextColor:[CPColor whiteColor]];
|
||||
[self addSubview:label];
|
||||
[self setFrame:CGRectMake(anOrigin.x,
|
||||
anOrigin.y,
|
||||
[label frame].size.width,
|
||||
[label frame].size.height)];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)mouseEntered:(CPEvent)anEvent
|
||||
{
|
||||
[testCursor set];
|
||||
}
|
||||
|
||||
- (void)mouseExited:(CPEvent)anEvent
|
||||
{
|
||||
[[CPCursor arrowCursor] set];
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation AppController : CPObject
|
||||
{
|
||||
CPPopUpButton popup;
|
||||
}
|
||||
|
||||
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
|
||||
{
|
||||
var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask],
|
||||
contentView = [theWindow contentView];
|
||||
|
||||
popup = [[CPPopUpButton alloc] initWithFrame:CGRectMake(100,100,150,24)];
|
||||
var menu = [popup menu];
|
||||
for (var i = 0 , count = [selectors count];i < count;i++)
|
||||
{
|
||||
var selector = selectors[i];
|
||||
var item = [[CPMenuItem alloc] initWithTitle:selector action:nil keyEquivalent:@""];
|
||||
[item setTarget:self];
|
||||
[menu addItem:item];
|
||||
}
|
||||
[contentView addSubview:popup];
|
||||
|
||||
var button = [[CPButton alloc] initWithFrame:CGRectMake(270,100,100,24)];
|
||||
[button setAction:@selector(setCursor:)];
|
||||
[button setTarget:self];
|
||||
[button setTitle:@"set Cursor"];
|
||||
[contentView addSubview:button];
|
||||
|
||||
var button = [[CPButton alloc] initWithFrame:CGRectMake(270,150,150,24)];
|
||||
[button setAction:@selector(setUrlCursor:)];
|
||||
[button setTarget:self];
|
||||
[button setTitle:@"set Cursor from url"];
|
||||
[contentView addSubview:button];
|
||||
var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask];
|
||||
[theWindow setAcceptsMouseMovedEvents:YES];
|
||||
var contentView = [theWindow contentView],
|
||||
imageCursorTester = [[CursorTester alloc] initWithText:@"Image cursor"
|
||||
origin:CGPointMake(0, 0)
|
||||
cursor:[[CPCursor alloc] initWithImage:[[CPImage alloc] initWithContentsOfFile:[[CPBundle bundleForClass:[CPCursor class]] resourcePath] + @"/CPCursor/openHandCursor.cur"]
|
||||
hotSpot:CGPointMakeZero()]],
|
||||
arrowCursorTester = [[CursorTester alloc] initWithText:@"Arrow cursor"
|
||||
origin:CGPointMake(0, 20)
|
||||
cursor:[CPCursor arrowCursor]],
|
||||
crosshairCursorTester = [[CursorTester alloc] initWithText:@"Crosshair cursor"
|
||||
origin:CGPointMake(0, 40)
|
||||
cursor:[CPCursor crosshairCursor]]
|
||||
IBeamCursorTester = [[CursorTester alloc] initWithText:@"IBeam cursor"
|
||||
origin:CGPointMake(0, 60)
|
||||
cursor:[CPCursor IBeamCursor]],
|
||||
pointingHandCursorTester = [[CursorTester alloc] initWithText:@"Pointing hand cursor"
|
||||
origin:CGPointMake(0, 80)
|
||||
cursor:[CPCursor pointingHandCursor]],
|
||||
resizeDownCursorTester = [[CursorTester alloc] initWithText:@"Resize down cursor"
|
||||
origin:CGPointMake(0, 100)
|
||||
cursor:[CPCursor resizeDownCursor]],
|
||||
resizeUpCursorTester = [[CursorTester alloc] initWithText:@"Resize up cursor"
|
||||
origin:CGPointMake(0, 120)
|
||||
cursor:[CPCursor resizeUpCursor]],
|
||||
resizeLeftCursorTester = [[CursorTester alloc] initWithText:@"Resize left cursor"
|
||||
origin:CGPointMake(0, 140)
|
||||
cursor:[CPCursor resizeLeftCursor]],
|
||||
resizeRightCursorTester = [[CursorTester alloc] initWithText:@"Resize right cursor"
|
||||
origin:CGPointMake(0, 160)
|
||||
cursor:[CPCursor resizeRightCursor]],
|
||||
resizeLeftRightCursorTester = [[CursorTester alloc] initWithText:@"Resize left-right cursor"
|
||||
origin:CGPointMake(0, 180)
|
||||
cursor:[CPCursor resizeLeftRightCursor]],
|
||||
resizeUpDownCursorTester = [[CursorTester alloc] initWithText:@"Resize up-down cursor"
|
||||
origin:CGPointMake(0, 200)
|
||||
cursor:[CPCursor resizeUpDownCursor]],
|
||||
operationNotAllowedCursorTester = [[CursorTester alloc] initWithText:@"Operation not allowed cursor"
|
||||
origin:CGPointMake(0, 220)
|
||||
cursor:[CPCursor operationNotAllowedCursor]],
|
||||
dragCopyCursorTester = [[CursorTester alloc] initWithText:@"Drag copy cursor"
|
||||
origin:CGPointMake(0, 240)
|
||||
cursor:[CPCursor dragCopyCursor]],
|
||||
dragLinkCursorTester = [[CursorTester alloc] initWithText:@"Drag link cursor"
|
||||
origin:CGPointMake(0, 260)
|
||||
cursor:[CPCursor dragLinkCursor]],
|
||||
contextualMenuCursorTester = [[CursorTester alloc] initWithText:@"Contextual menu cursor"
|
||||
origin:CGPointMake(0, 280)
|
||||
cursor:[CPCursor contextualMenuCursor]],
|
||||
openHandCursorTester = [[CursorTester alloc] initWithText:@"Open hand cursor"
|
||||
origin:CGPointMake(0, 300)
|
||||
cursor:[CPCursor openHandCursor]],
|
||||
closedHandCursorTester = [[CursorTester alloc] initWithText:@"Closed hand cursor"
|
||||
origin:CGPointMake(0, 320)
|
||||
cursor:[CPCursor closedHandCursor]],
|
||||
disappearingItemCursorTester = [[CursorTester alloc] initWithText:@"Disappearing item cursor"
|
||||
origin:CGPointMake(0, 340)
|
||||
cursor:[CPCursor disappearingItemCursor]];
|
||||
|
||||
[contentView addSubview:imageCursorTester];
|
||||
[contentView addSubview:arrowCursorTester];
|
||||
[contentView addSubview:crosshairCursorTester];
|
||||
[contentView addSubview:IBeamCursorTester];
|
||||
[contentView addSubview:pointingHandCursorTester];
|
||||
[contentView addSubview:resizeDownCursorTester];
|
||||
[contentView addSubview:resizeUpCursorTester];
|
||||
[contentView addSubview:resizeLeftCursorTester];
|
||||
[contentView addSubview:resizeRightCursorTester];
|
||||
[contentView addSubview:resizeLeftRightCursorTester];
|
||||
[contentView addSubview:resizeUpDownCursorTester];
|
||||
[contentView addSubview:operationNotAllowedCursorTester];
|
||||
[contentView addSubview:dragCopyCursorTester];
|
||||
[contentView addSubview:dragLinkCursorTester];
|
||||
[contentView addSubview:contextualMenuCursorTester];
|
||||
[contentView addSubview:openHandCursorTester];
|
||||
[contentView addSubview:closedHandCursorTester];
|
||||
[contentView addSubview:disappearingItemCursorTester];
|
||||
|
||||
[theWindow orderFront:self];
|
||||
// Uncomment the following line to turn on the standard menu bar.
|
||||
//[CPMenu setMenuBarVisible:YES];
|
||||
}
|
||||
|
||||
- (void)setCursor:(id)sender
|
||||
{
|
||||
var selector = CPSelectorFromString([popup titleOfSelectedItem]);
|
||||
var cursor = [CPCursor performSelector:selector];
|
||||
[cursor set];
|
||||
}
|
||||
|
||||
- (void)setUrlCursor:(id)sender
|
||||
{ // note gifs don't animate when they are used as a cursor.
|
||||
var aImage = [[CPImage alloc] initWithContentsOfFile:[[CPBundle mainBundle] pathForResource:@"spinner.gif"]];
|
||||
var cursor = [[CPCursor alloc] initWithImage:aImage hotSpot:CGPointMakeZero()];
|
||||
[cursor set];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<div>Test custom cursors with .cur images.</div>
|
||||
<div style="width: 20px; height: 20px; margin: 10px; background: #ddd; cursor: url(../../../AppKit/Resources/CPCursor/disappearingItemCursor.cur), default">disappearingItemCursor</div>
|
||||
<div style="width: 20px; height: 20px; margin: 10px; background: #ddd; cursor: url(../../../AppKit/Resources/CPCursor/closedHandCursor.cur), default">closedHandCursor</div>
|
||||
<div style="width: 20px; height: 20px; margin: 10px; background: #ddd; cursor: url(../../../AppKit/Resources/CPCursor/contextMenuCursor.cur), default">contextMenuCursor</div>
|
||||
<div style="width: 20px; height: 20px; margin: 10px; background: #ddd; cursor: url(../../../AppKit/Resources/CPCursor/dragCopyCursor.cur), default">dragCopyCursor</div>
|
||||
<div style="width: 20px; height: 20px; margin: 10px; background: #ddd; cursor: url(../../../AppKit/Resources/CPCursor/dragLinkCursor.cur), default">dragLinkCursor</div>
|
||||
<div style="width: 20px; height: 20px; margin: 10px; background: #ddd; cursor: url(../../../AppKit/Resources/CPCursor/openHandCursor.cur), default">openHandCursor</div>
|
||||
<div style="width: 20px; height: 20px; margin: 10px; background: #ddd; cursor: url(../../../AppKit/Resources/CPCursor/resizeDownCursor.cur), default">resizeDownCursor</div>
|
||||
<div style="width: 20px; height: 20px; margin: 10px; background: #ddd; cursor: url(../../../AppKit/Resources/CPCursor/resizeLeftCursor.cur), default">resizeLeftCursor</div>
|
||||
<div style="width: 20px; height: 20px; margin: 10px; background: #ddd; cursor: url(../../../AppKit/Resources/CPCursor/resizeRightCursor.cur), default">resizeRightCursor</div>
|
||||
<div style="width: 20px; height: 20px; margin: 10px; background: #ddd; cursor: url(../../../AppKit/Resources/CPCursor/resizeUpCursor.cur), default">resizeUpCursor</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||