How to create cursur rsrc files on Mac?

Discussion in 'Mac Programming' started by jbsp72, Aug 20, 2008.

  1. jbsp72 macrumors newbie

    Joined:
    Jul 21, 2008
    #1
    Hi,

    I want to create custom cursors on Mac and use them in an application I am porting to Mac. The problem is that the application expects the cursors to be in a rsrc file on Mac. I am new to programming on Mac. Could you please help me and explain how I can create the rsrc files. I have the corresponding png images for the cursors which I have to use to create the rsrc files.

    I tried using the mighty mouse software to create the custom cursors ut it only allows me to save the cursors as gif images or .mightymouse files both of which are not of any use to me. So any clues would be very helpful.

    Thanks
    Shivaprasad
     
  2. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #2
    Buy an old Mac and download ResEdit ;)

    You could check out ResKnife.

    But if you're new to Mac programming why are you learning Carbon? I'd suggest dropping it and learn Cocoa. Then you can use NSCursor with a png, tiff, etc.

    Edit: check out this sample project from Apple. It provides wrappers for Cocoa's NSCursor class so you can use it in Carbon without having to use Objective-C: http://developer.apple.com/samplecode/CarbonCocoa_PictureCursor/
     
  3. jbsp72 thread starter macrumors newbie

    Joined:
    Jul 21, 2008
    #3
    May be I wasnt clear before. The application I am porting to Mac already has Custom cursors which changes on appropriate actions and everything, I have to replace these cursors with the new cursors I have in png images. Can I create the rsrc files using NSCursor. I tried using ResKnife but I cant seem to figure out how to get the image in the png to the cursor.

    I also tried using resorcerer to create the cursor resource but it is not free and the trial version doesnot let me save the resource file.

    Any suggestions??

    Thanks
    Shivaprasad
     
  4. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #4
    Did you see the project above?

    .rsrc files are old. Very few apps use them anymore, and the apps that do were written before OS X. Since you are starting out new, there's no point in using this old format which is used in the now deprecated functions. See the project above for the modern way of doing cursors. You need to load your png image into a CGImageRef. Plenty of examples on how to do that.

    Edit: to be clearer, there are two ways of setting the cursor in the Mac OS X APIs. One is the SetCursor() and related functions. These are marked as deprecated in Mac OS X v10.4 which means you shouldn't use them anymore. These functions use .rsrc files (specifically GetCursor). The other method is NSCursor, which isn't a part of Carbon. You DO want to use this, and the project above provides example code on how to use this inside a Carbon application. If none of this makes sense then you need to explain your situation clearer.
     

Share This Page