]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/carbon/icon.cpp
Add RunScript and implement on all backends. Document and add a very simple unit...
[wxWidgets.git] / src / osx / carbon / icon.cpp
index f391772e7574a505bec129d9dec02cb17c4fc4a1..d99c5a1e64a1a06817d131219e851eb015ce8f1e 100644 (file)
@@ -321,6 +321,26 @@ bool wxIcon::LoadIconFromBundleResource(const wxString& resourceName, int desire
             ReleaseResource( resHandle ) ;
         }
     }
+    if ( iconRef == NULL )
+    {
+        wxCFStringRef name(resourceName);
+        FSRef iconFSRef;
+        
+        wxCFRef<CFURLRef> iconURL(CFBundleCopyResourceURL(CFBundleGetMainBundle(), name, CFSTR("icns"), NULL));
+
+        if (CFURLGetFSRef(iconURL, &iconFSRef))
+        {
+            // Get a handle on the icon family
+            IconFamilyHandle iconFamily;
+            OSStatus err = ReadIconFromFSRef( &iconFSRef, &iconFamily );
+            
+            if ( err == noErr )
+            {
+                err = GetIconRefFromIconFamilyPtr( *iconFamily, GetHandleSize((Handle) iconFamily), &iconRef );
+            }
+            ReleaseResource( (Handle) iconFamily );
+        }
+    }
 
     if ( iconRef )
     {
@@ -420,8 +440,21 @@ void wxIcon::CopyFromBitmap( const wxBitmap& bmp )
     UnRef() ;
 
     // as the bitmap owns that ref, we have to acquire it as well
-    IconRef iconRef = bmp.CreateIconRef() ;
-    m_refData = new wxIconRefData( (WXHICON) iconRef, bmp.GetWidth(), bmp.GetHeight()  ) ;
+    
+    int w = bmp.GetWidth() ;
+    int h = bmp.GetHeight() ;
+    int sz = wxMax( w , h ) ;
+
+    if ( sz == 24 || sz == 64 )
+    {
+        wxBitmap scaleBmp( bmp.ConvertToImage().Scale( w * 2 , h * 2 ) ) ;
+        m_refData = new wxIconRefData( (WXHICON) scaleBmp.CreateIconRef(), bmp.GetWidth(), bmp.GetHeight()  ) ;
+    }
+    else 
+    {
+        m_refData = new wxIconRefData( (WXHICON) bmp.CreateIconRef() , bmp.GetWidth(), bmp.GetHeight()  ) ;
+    }
+
 }
 
 IMPLEMENT_DYNAMIC_CLASS(wxICONResourceHandler, wxBitmapHandler)