]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/carbon/icon.cpp
Clean up indentation / tabs from previous patch
[wxWidgets.git] / src / mac / carbon / icon.cpp
index bd1937bc2a45dba54274849335887c399a7832f3..25543c1e9575bfbb6436302838d895d9fe0dfd66 100644 (file)
@@ -9,16 +9,19 @@
 // Licence:       wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
-#ifdef __GNUG__
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
 #pragma implementation "icon.h"
 #endif
 
+#include "wx/wxprec.h"
+
 #include "wx/icon.h"
 
 #if !USE_SHARED_LIBRARIES
 IMPLEMENT_DYNAMIC_CLASS(wxIcon, wxBitmap)
 #endif
 
+#include "wx/image.h"
 #include "wx/mac/private.h"
 
 
@@ -61,14 +64,31 @@ bool wxIcon::LoadFile(const wxString& filename, wxBitmapType type,
 {
     UnRef();
     
-    m_refData = new wxBitmapRefData;
-    
-    wxBitmapHandler *handler = FindHandler((wxBitmapType)type);
-    
+    wxBitmapHandler *handler = FindHandler(type);
+
     if ( handler )
-        return handler->LoadFile(this, filename, type, desiredWidth, desiredHeight);
+    {
+        m_refData = new wxBitmapRefData;
+        return handler->LoadFile(this, filename, type, desiredWidth, desiredHeight );
+    }
     else
-        return FALSE;
+    {
+        wxImage loadimage(filename, type);
+        if (loadimage.Ok()) 
+        {
+            if ( desiredWidth == -1 )
+                desiredWidth = loadimage.GetWidth() ;
+            if ( desiredHeight == -1 )
+                desiredHeight = loadimage.GetHeight() ;
+            if ( desiredWidth != loadimage.GetWidth() || desiredHeight != loadimage.GetHeight() )
+                loadimage.Rescale( desiredWidth , desiredHeight ) ;
+            wxBitmap bmp( loadimage );
+            wxIcon *icon = (wxIcon*)(&bmp);
+            *this = *icon;
+            return true;
+        }
+    }
+    return false ;
 }
 
 void wxIcon::CopyFromBitmap(const wxBitmap& bmp)