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:
@@ -52,7 +52,11 @@ public:
|
|||||||
wxSize GetSize() const { return wxSize(GetWidth(), GetHeight()); }
|
wxSize GetSize() const { return wxSize(GetWidth(), GetHeight()); }
|
||||||
|
|
||||||
WXHICON GetHICON() const;
|
WXHICON GetHICON() const;
|
||||||
|
|
||||||
|
#if wxOSX_USE_COCOA
|
||||||
|
WX_NSImage GetNSImage() const ;
|
||||||
|
#endif
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual wxGDIRefData *CreateGDIRefData() const;
|
virtual wxGDIRefData *CreateGDIRefData() const;
|
||||||
virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
|
virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
|
||||||
|
@@ -42,11 +42,17 @@ public:
|
|||||||
int GetHeight() const { return m_height; }
|
int GetHeight() const { return m_height; }
|
||||||
|
|
||||||
WXHICON GetHICON() const { return (WXHICON) m_iconRef; }
|
WXHICON GetHICON() const { return (WXHICON) m_iconRef; }
|
||||||
|
#if wxOSX_USE_COCOA
|
||||||
|
WX_NSImage GetNSImage() const;
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Init();
|
void Init();
|
||||||
|
|
||||||
IconRef m_iconRef;
|
IconRef m_iconRef;
|
||||||
|
#if wxOSX_USE_COCOA
|
||||||
|
mutable NSImage* m_nsImage;
|
||||||
|
#endif
|
||||||
int m_width;
|
int m_width;
|
||||||
int m_height;
|
int m_height;
|
||||||
|
|
||||||
@@ -57,6 +63,7 @@ private:
|
|||||||
|
|
||||||
wxIconRefData::wxIconRefData( WXHICON icon, int desiredWidth, int desiredHeight )
|
wxIconRefData::wxIconRefData( WXHICON icon, int desiredWidth, int desiredHeight )
|
||||||
{
|
{
|
||||||
|
Init();
|
||||||
m_iconRef = (IconRef)( icon ) ;
|
m_iconRef = (IconRef)( icon ) ;
|
||||||
|
|
||||||
// Standard sizes
|
// Standard sizes
|
||||||
@@ -67,6 +74,9 @@ wxIconRefData::wxIconRefData( WXHICON icon, int desiredWidth, int desiredHeight
|
|||||||
void wxIconRefData::Init()
|
void wxIconRefData::Init()
|
||||||
{
|
{
|
||||||
m_iconRef = NULL ;
|
m_iconRef = NULL ;
|
||||||
|
#if wxOSX_USE_COCOA
|
||||||
|
m_nsImage = NULL;
|
||||||
|
#endif
|
||||||
m_width =
|
m_width =
|
||||||
m_height = 0;
|
m_height = 0;
|
||||||
}
|
}
|
||||||
@@ -78,8 +88,30 @@ void wxIconRefData::Free()
|
|||||||
ReleaseIconRef( m_iconRef ) ;
|
ReleaseIconRef( m_iconRef ) ;
|
||||||
m_iconRef = NULL ;
|
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;
|
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) )
|
void wxIcon::SetDepth( int WXUNUSED(depth) )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user