[2.9.1, Mac OS X 10.6, gcc(xcode)] How create cursor from a resource on cocoa?

36 views
Skip to first unread message

Tank2005

unread,
Jan 22, 2011, 11:41:06 AM1/22/11
to wx-users
I want to embed and use a original cursor from a resource data. I
would like to use not cocoa API but wxWidgets API as much as possible.
Are there any good way?

M Gagnon

unread,
Jan 22, 2011, 2:51:40 PM1/22/11
to wx-u...@googlegroups.com
Hi,

resource forks have been deprecated for a long time on OSX in favor of
simply placing
files inside the Resources directory of the application bundle. So why
do you want to use
them for?

-- Auria

Tank2005

unread,
Jan 23, 2011, 2:19:13 AM1/23/11
to wx-users
I developing a graphic software. But the suitable image was not on the
standard cursor in OS.
Is such this image that packing into a resource directory?

http://wxforum.shadonet.com/attachments/cursor_139.png
(*バンドルリソースをコピー=Copy bundle resource)

Stefan Csomor

unread,
Jan 23, 2011, 3:32:52 AM1/23/11
to wx-u...@googlegroups.com

I have added the code for loading icns from the Bundle, I'll do the same
for PNGs, deprecating the former default, the PICT Resource

Best,

Stefan

Stefan Csomor

unread,
Jan 23, 2011, 5:12:59 AM1/23/11
to wx-u...@googlegroups.com
>>
>>I developing a graphic software. But the suitable image was not on the
>>standard cursor in OS.
>>Is such this image that packing into a resource directory?
>>
>>http://wxforum.shadonet.com/attachments/cursor_139.png
>>(*バンドルリソースをコピー=Copy bundle resource)
>
>I have added the code for loading icns from the Bundle, I'll do the same
>for PNGs, deprecating the former default, the PICT Resource

I've added support for wxBITMAP_TYPE_PNG_RESOURCE and
wxBITMAP_TYPE_JPEG_RESOURCE which are loaded, so you can construct a
wxImage from such a bitmap and a wxCursor from the wxImage

Best,

Stefan

Stefan Csomor

unread,
Jan 23, 2011, 6:28:02 AM1/23/11
to wx-u...@googlegroups.com
>
>I've added support for wxBITMAP_TYPE_PNG_RESOURCE and
>wxBITMAP_TYPE_JPEG_RESOURCE which are loaded
... from the Resources folder in the App Bundle ...

Best,

Stefan

Tank2005

unread,
Jan 23, 2011, 9:53:33 PM1/23/11
to wx-users
I converted from png to icns like this.
http://www.flickr.com/photos/58698053@N02/5383266584/

But a loading goes wrong by any following way.
wxCursor cursor = wxCursor(wxT("cur_del.icns"));
wxCursor cursor = wxCursor(wxT("Resouces/cur_del.icns"));
wxCursor cursor = wxCursor(wxT("../Resouces/cur_del.icns"));

Stefan Csomor

unread,
Jan 24, 2011, 1:00:24 AM1/24/11
to wx-u...@googlegroups.com
Hi

no, icns are for wxIcons only, pngs are the way to go, and you must
convert the bitmap to an image:
wxCursor(wxBitmap("pngnamewithoutextension",wxBITMAP_TYPE_PNG_RESOURCE).Con
vertToImage
()) should work

Best,

Stefan

Tank2005

unread,
Jan 24, 2011, 3:53:42 AM1/24/11
to wx-users
I restored the format of the resource(http://wxforum.shadonet.com/
attachments/cursor_139.png) and inputted the following code. But,
bmp.IsOK() returns false.
wxBitmap bmp = wxBitmap("cur_del", wxBITMAP_TYPE_PNG_RESOURCE);

I think that a handler is insufficient and inputted this:
wxBitmap::AddHandler(new wxPNGFileHandler());

However, building is impossible.
"vtable for wxPNGFileHandler", referenced from: ... Symbol(s) not
found

What is insufficient?

Tank2005

unread,
Jan 24, 2011, 6:42:08 AM1/24/11
to wx-users
My application is not a application project and is a bundle project.
Is this one of the causes?
Reply all
Reply to author
Forward
0 new messages