Fixing IconRef Build re adding support for reading icns files
This commit is contained in:
@@ -39,6 +39,7 @@ void WXDLLIMPEXP_CORE wxOSXDrawNSImage(
|
||||
WX_NSImage WXDLLIMPEXP_CORE wxOSXGetSystemImage(const wxString& name);
|
||||
WX_NSImage WXDLLIMPEXP_CORE wxOSXGetNSImageFromCGImage( CGImageRef image, double scale = 1.0, bool isTemplate = false);
|
||||
WX_NSImage WXDLLIMPEXP_CORE wxOSXGetNSImageFromIconRef( WXHICON iconref );
|
||||
WX_NSImage WXDLLIMPEXP_CORE wxOSXGetNSImageFromCFURL( CFURLRef urlref );
|
||||
WX_NSImage WXDLLIMPEXP_CORE wxOSXGetIconForType(OSType type );
|
||||
void WXDLLIMPEXP_CORE wxOSXSetImageSize(WX_NSImage image, CGFloat width, CGFloat height);
|
||||
wxBitmap WXDLLIMPEXP_CORE wxOSXCreateSystemBitmap(const wxString& id, const wxString &client, const wxSize& size);
|
||||
|
@@ -226,6 +226,13 @@ WXImage WXDLLIMPEXP_CORE wxOSXGetNSImageFromIconRef( WXHICON iconref )
|
||||
[newImage autorelease];
|
||||
return( newImage );
|
||||
}
|
||||
|
||||
WX_NSImage WXDLLIMPEXP_CORE wxOSXGetNSImageFromCFURL( CFURLRef urlref )
|
||||
{
|
||||
NSImage *newImage = [[NSImage alloc] initWithContentsOfURL:(NSURL*)urlref];
|
||||
[newImage autorelease];
|
||||
return( newImage );
|
||||
}
|
||||
#endif
|
||||
|
||||
CGImageRef WXDLLIMPEXP_CORE wxOSXGetCGImageFromImage( WXImage nsimage, CGRect* r, CGContextRef cg)
|
||||
|
@@ -100,7 +100,7 @@ public:
|
||||
#if wxOSX_USE_ICONREF
|
||||
// caller should increase ref count if needed longer
|
||||
// than the bitmap exists
|
||||
IconRef GetIconRef();
|
||||
IconRef GetIconRef() const;
|
||||
#endif
|
||||
|
||||
CGContextRef GetBitmapContext() const;
|
||||
@@ -125,7 +125,7 @@ private :
|
||||
bool m_isTemplate;
|
||||
|
||||
#if wxOSX_USE_ICONREF
|
||||
IconRef m_iconRef;
|
||||
mutable IconRef m_iconRef;
|
||||
#endif
|
||||
|
||||
wxCFRef<CGContextRef> m_hBitmap;
|
||||
@@ -431,7 +431,7 @@ bool wxBitmapRefData::HasNativeSize()
|
||||
}
|
||||
|
||||
#if wxOSX_USE_ICONREF
|
||||
IconRef wxBitmapRefData::GetIconRef()
|
||||
IconRef wxBitmapRefData::GetIconRef() const
|
||||
{
|
||||
if ( m_iconRef == NULL )
|
||||
{
|
||||
@@ -1811,16 +1811,30 @@ bool wxICNSResourceHandler::LoadFile(wxBitmap *bitmap,
|
||||
theId = kHelpFolderIcon;
|
||||
}
|
||||
|
||||
WXImage img = NULL;
|
||||
|
||||
if ( theId != 0 )
|
||||
{
|
||||
IconRef iconRef = NULL ;
|
||||
|
||||
__Verify_noErr(GetIconRef( kOnSystemDisk, kSystemIconsCreator, theId, &iconRef )) ;
|
||||
if ( iconRef )
|
||||
{
|
||||
WXImage img = wxOSXGetNSImageFromIconRef(iconRef);
|
||||
bitmap->Create(img);
|
||||
return true;
|
||||
}
|
||||
img = wxOSXGetNSImageFromIconRef(iconRef);
|
||||
}
|
||||
else
|
||||
{
|
||||
wxCFRef<CFURLRef> iconURL;
|
||||
wxCFStringRef resname(resourceName);
|
||||
wxCFStringRef restype(GetExtension().Lower());
|
||||
|
||||
iconURL.reset(CFBundleCopyResourceURL(CFBundleGetMainBundle(), resname, restype, NULL));
|
||||
|
||||
img = wxOSXGetNSImageFromCFURL(iconURL);
|
||||
}
|
||||
|
||||
if ( img )
|
||||
{
|
||||
bitmap->Create(img);
|
||||
return true;
|
||||
}
|
||||
|
||||
return wxBundleResourceHandler::LoadFile( bitmap, resourceName, type, desiredWidth, desiredHeight);
|
||||
|
Reference in New Issue
Block a user