adding NSImage support to wxIcon on OSX, as IconRefs are on their way out, and performance under 10.9 is suffering
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@75994 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
21aa2122f4
commit
d692ea1c0e
@ -52,7 +52,11 @@ public:
|
||||
wxSize GetSize() const { return wxSize(GetWidth(), GetHeight()); }
|
||||
|
||||
WXHICON GetHICON() const;
|
||||
|
||||
|
||||
#if wxOSX_USE_COCOA
|
||||
WX_NSImage GetNSImage() const ;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual wxGDIRefData *CreateGDIRefData() const;
|
||||
virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
|
||||
|
@ -42,11 +42,17 @@ public:
|
||||
int GetHeight() const { return m_height; }
|
||||
|
||||
WXHICON GetHICON() const { return (WXHICON) m_iconRef; }
|
||||
#if wxOSX_USE_COCOA
|
||||
WX_NSImage GetNSImage() const;
|
||||
#endif
|
||||
|
||||
private:
|
||||
void Init();
|
||||
|
||||
IconRef m_iconRef;
|
||||
#if wxOSX_USE_COCOA
|
||||
mutable NSImage* m_nsImage;
|
||||
#endif
|
||||
int m_width;
|
||||
int m_height;
|
||||
|
||||
@ -57,6 +63,7 @@ private:
|
||||
|
||||
wxIconRefData::wxIconRefData( WXHICON icon, int desiredWidth, int desiredHeight )
|
||||
{
|
||||
Init();
|
||||
m_iconRef = (IconRef)( icon ) ;
|
||||
|
||||
// Standard sizes
|
||||
@ -67,6 +74,9 @@ wxIconRefData::wxIconRefData( WXHICON icon, int desiredWidth, int desiredHeight
|
||||
void wxIconRefData::Init()
|
||||
{
|
||||
m_iconRef = NULL ;
|
||||
#if wxOSX_USE_COCOA
|
||||
m_nsImage = NULL;
|
||||
#endif
|
||||
m_width =
|
||||
m_height = 0;
|
||||
}
|
||||
@ -78,8 +88,30 @@ void wxIconRefData::Free()
|
||||
ReleaseIconRef( m_iconRef ) ;
|
||||
m_iconRef = NULL ;
|
||||
}
|
||||
|
||||
#if wxOSX_USE_COCOA
|
||||
if ( m_nsImage )
|
||||
{
|
||||
CFRelease(m_nsImage);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if wxOSX_USE_COCOA
|
||||
WX_NSImage wxIconRefData::GetNSImage() const
|
||||
{
|
||||
wxASSERT( IsOk() );
|
||||
|
||||
if ( m_nsImage == 0 )
|
||||
{
|
||||
m_nsImage = wxOSXGetNSImageFromIconRef(m_iconRef);
|
||||
CFRetain(m_nsImage);
|
||||
}
|
||||
|
||||
return m_nsImage;
|
||||
}
|
||||
#endif
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
@ -160,6 +192,15 @@ int wxIcon::GetDepth() const
|
||||
return 32;
|
||||
}
|
||||
|
||||
#if wxOSX_USE_COCOA
|
||||
WX_NSImage wxIcon::GetNSImage() const
|
||||
{
|
||||
wxCHECK_MSG( IsOk(), NULL, wxT("invalid icon") );
|
||||
|
||||
return M_ICONDATA->GetNSImage() ;
|
||||
}
|
||||
#endif
|
||||
|
||||
void wxIcon::SetDepth( int WXUNUSED(depth) )
|
||||
{
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user