+ int w = icon.GetWidth() ;
+ int h = icon.GetHeight() ;
+
+
+ Create( icon.GetWidth() , icon.GetHeight() ) ;
+
+ bool created = false ;
+
+ if ( w == h && ( w == 16 || w == 32 || w == 48 || w == 128 ) )
+ {
+ IconFamilyHandle iconFamily = NULL ;
+ Handle imagehandle = NewHandle(0) ;
+ Handle maskhandle = NewHandle(0) ;
+
+ OSType maskType = 0;
+ OSType dataType = 0;
+ IconSelectorValue selector = 0 ;
+ if ( w == 128 )
+ {
+ dataType = kThumbnail32BitData ;
+ maskType = kThumbnail8BitMask ;
+ selector = kSelectorAllAvailableData ;
+ }
+ else if ( w == 48 )
+ {
+ dataType = kHuge32BitData ;
+ maskType = kHuge8BitMask ;
+ selector = kSelectorHuge32Bit | kSelectorHuge8BitMask ;
+ }
+ else if ( w == 32 )
+ {
+ dataType = kLarge32BitData ;
+ maskType = kLarge8BitMask ;
+ selector = kSelectorLarge32Bit | kSelectorLarge8BitMask ;
+ }
+ else if ( w == 16 )
+ {
+ dataType = kSmall32BitData ;
+ maskType = kSmall8BitMask ;
+ selector = kSelectorSmall32Bit | kSelectorSmall8BitMask ;
+ }
+
+
+ OSStatus err = ( IconRefToIconFamily( MAC_WXHICON(icon.GetHICON()) , selector , &iconFamily ) ) ;
+
+ err =( GetIconFamilyData( iconFamily , dataType , imagehandle ) ) ;
+ err =( GetIconFamilyData( iconFamily , maskType , maskhandle ) ) ;
+ size_t imagehandlesize = GetHandleSize( imagehandle ) ;
+ size_t maskhandlesize = GetHandleSize( maskhandle ) ;
+
+ if ( imagehandlesize != 0 && maskhandlesize != 0 )
+ {
+ wxASSERT( GetHandleSize( imagehandle ) == w * 4 * h ) ;
+ wxASSERT( GetHandleSize( maskhandle ) == w * h ) ;
+ UseAlpha() ;
+ unsigned char *source = (unsigned char *) *imagehandle ;
+ unsigned char *sourcemask = (unsigned char *) *maskhandle ;
+
+ unsigned char* destination = (unsigned char*) BeginRawAccess() ;
+ for ( int y = 0 ; y < h ; ++y )
+ {
+ for ( int x = 0 ; x < w ; ++x )
+ {
+ *destination++ = *sourcemask++ ;
+ source++ ;
+ *destination++ = *source++ ;
+ *destination++ = *source++ ;
+ *destination++ = *source++ ;
+ }
+ }
+ EndRawAccess() ;
+ DisposeHandle( imagehandle ) ;
+ DisposeHandle( maskhandle ) ;
+ }
+ DisposeHandle( (Handle) iconFamily ) ;
+
+ }
+
+ if ( !created )
+ {
+ wxMemoryDC dc ;
+ dc.SelectObject( *this ) ;
+ dc.DrawIcon( icon , 0 , 0 ) ;
+ dc.SelectObject( wxNullBitmap ) ;
+ }