X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e9576ca53db96b462ed4c0b4bdf47d64c40203e4..947ea04d016852aa293291069d5c91ce4c6dde60:/src/mac/carbon/icon.cpp diff --git a/src/mac/carbon/icon.cpp b/src/mac/carbon/icon.cpp index 6deee7dbdc..7f666da534 100644 --- a/src/mac/carbon/icon.cpp +++ b/src/mac/carbon/icon.cpp @@ -26,12 +26,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() @@ -42,6 +60,14 @@ wxIcon::wxIcon(const char WXUNUSED(bits)[], int WXUNUSED(width), int WXUNUSED(he { } +wxIcon::wxIcon( const char **bits, int width, int height ) +{ +} + +wxIcon::wxIcon( char **bits, int width, int height ) +{ +} + wxIcon::wxIcon(const wxString& icon_file, long flags, int desiredWidth, int desiredHeight) @@ -68,3 +94,40 @@ 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 ; + +#if TARGET_CARBON + c2pstrcpy( (StringPtr) theName , name ) ; +#else + strcpy( (char *) theName , name ) ; + c2pstr( (char *) theName ) ; +#endif + + Handle resHandle = GetNamedResource( 'cicn' , theName ) ; + if ( resHandle != 0L ) + { + 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 ; +}