X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e9576ca53db96b462ed4c0b4bdf47d64c40203e4..79f585d90388128f9d245f7c92d3013b98b9ed14:/src/mac/icon.cpp diff --git a/src/mac/icon.cpp b/src/mac/icon.cpp index 6deee7dbdc..2fb0616ba8 100644 --- a/src/mac/icon.cpp +++ b/src/mac/icon.cpp @@ -15,9 +15,7 @@ #include "wx/icon.h" -#if !USE_SHARED_LIBRARIES IMPLEMENT_DYNAMIC_CLASS(wxIcon, wxBitmap) -#endif /* * Icons @@ -26,12 +24,30 @@ IMPLEMENT_DYNAMIC_CLASS(wxIcon, wxBitmap) wxIconRefData::wxIconRefData() { - // TODO: init icon handle + m_ok = FALSE; + m_width = 0; + m_height = 0; + m_depth = 0; + m_quality = 0; + m_numColors = 0; + m_bitmapMask = NULL; + m_hBitmap = NULL ; + m_hIcon = NULL ; } wxIconRefData::~wxIconRefData() { - // TODO: destroy icon handle + if ( m_hIcon ) + { + DisposeCIcon( m_hIcon ) ; + m_hIcon = NULL ; + } + + if (m_bitmapMask) + { + delete m_bitmapMask; + m_bitmapMask = NULL; + } } wxIcon::wxIcon() @@ -68,3 +84,32 @@ bool wxIcon::LoadFile(const wxString& filename, long type, return FALSE; } +IMPLEMENT_DYNAMIC_CLASS(wxICONResourceHandler, wxBitmapHandler) + +bool wxICONResourceHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags, + int desiredWidth, int desiredHeight) +{ + Str255 theName ; + short theId ; + OSType theType ; + strcpy( (char*) theName , name ) ; + c2pstr( (char*) theName ) ; + + Handle resHandle = GetNamedResource( 'cicn' , theName ) ; + GetResInfo( resHandle , &theId , &theType , theName ) ; + ReleaseResource( resHandle ) ; + + CIconHandle theIcon = (CIconHandle ) GetCIcon( theId ) ; + if ( theIcon ) + { + M_ICONHANDLERDATA->m_hIcon = theIcon ; + M_ICONHANDLERDATA->m_width = 32 ; + M_ICONHANDLERDATA->m_height = 32 ; + + M_ICONHANDLERDATA->m_depth = 8 ; + M_ICONHANDLERDATA->m_ok = true ; + M_ICONHANDLERDATA->m_numColors = 256 ; + return TRUE ; + } + return FALSE ; +}