How do I get the hot spot from a .cur file in objective c on MAC Cocoa?

6 views
Skip to first unread message

Oshrat Fahima

unread,
Mar 25, 2012, 5:25:00 AM3/25/12
to coco...@lists.apple.com
Hi
In our plug-ins we are using cursors kept in a *.CUR file.
In windows there's no problem to identify the hot spot from the *.CUR file (because it's a WIN file, LoadCursor already knows where is the hot spot automatically).
But in MAC Cocoa, we've encountered a problem when we create a new NSCursor object in which we must transfer the hot spot to it by calculating it and maintaining it hard coded
(we prefer not to do that).
Are you familiar with a method that can help retrieve the hot spot from a given *.CUR file?
That way we can create the NSCursor directly using this point rather than calculating it ourselves.

Here's a sample of our code.
Thanks a lot for your time and knowledge
Oshrat


NewCursor(const resContainerRef, const short cursorID, const WTPoint2s hotSpotPoint)
{
WTCursorHandle retVal = 0;

NSCursor* crsr = 0;
wvFM::WCStPath imgPath;
WTResType resType = "Crsr";
wvRM::GetPathToActualFile (resContainerRef, resType, cursorID, imgPath);

NSString* imgPathAsNSString = 0;
imgPathAsNSString = [NSString stringWithFormat:@"%s", imgPath.GetNativePathString().c_str()];

NSImage * img = [[NSImage alloc] :imgPathAsNSString];
crsr = [[NSCursor alloc]initWithImage:img hotSpot:NSMakePoint(hotSpotPoint.m_x,hotSpotPoint.m_y)];

_______________________________________________

Cocoa-dev mailing list (Coco...@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/cocoa-dev-garchive-98506%40googlegroups.com

This email sent to cocoa-dev-ga...@googlegroups.com

Stephen J. Butler

unread,
Apr 1, 2012, 1:34:48 AM4/1/12
to Oshrat Fahima, coco...@lists.apple.com
Wikipedia says that cur/ico files have a very simple format:

http://en.wikipedia.org/wiki/ICO_(file_format)

Part of the ICONDIRENTRY structure is the hotspot information. Should
be pretty easy to write a basic parser.

> https://lists.apple.com/mailman/options/cocoa-dev/stephen.butler%40gmail.com
>
> This email sent to stephen...@gmail.com

Reply all
Reply to author
Forward
0 new messages