]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/carbon/bitmap.cpp
must be AnyState , not NoState to get all elements (error in apple's doc, reported)
[wxWidgets.git] / src / mac / carbon / bitmap.cpp
index 89f0d0e12705f8df38b77f9e84c97e90f88ac565..d7f9c3ba838af7b508e368c5ceb894aebf822c65 100644 (file)
@@ -1,5 +1,5 @@
 /////////////////////////////////////////////////////////////////////////////
-// Name:        bitmap.cpp
+// Name:        src/mac/carbon/bitmap.cpp
 // Purpose:     wxBitmap
 // Author:      Stefan Csomor
 // Modified by:
 #include "wx/wxprec.h"
 
 #include "wx/bitmap.h"
+
+#ifndef WX_PRECOMP
+    #include "wx/log.h"
+#endif
+
 #include "wx/icon.h"
-#include "wx/log.h"
 #include "wx/image.h"
 #include "wx/metafile.h"
 #include "wx/xpmdecod.h"
@@ -392,9 +396,14 @@ IconRef wxBitmapRefData::GetIconRef()
             PicHandle pic = GetPictHandle() ;
             SetIconFamilyData( iconFamily, 'PICT' , (Handle) pic ) ;
         }
-
         // transform into IconRef
-
+#ifdef __WXMAC_OSX__
+        // cleaner version existing from 10.3 upwards
+        HLock((Handle) iconFamily);
+        OSStatus err = GetIconRefFromIconFamilyPtr( *iconFamily, GetHandleSize((Handle) iconFamily), &m_iconRef );
+        HUnlock((Handle) iconFamily);
+        wxASSERT_MSG( err == noErr , wxT("Error when constructing icon ref") );
+#else
         static int iconCounter = 2 ;
 
         OSStatus err = RegisterIconRefFromIconFamily( 'WXNG' , (OSType) iconCounter, iconFamily, &m_iconRef ) ;
@@ -403,8 +412,9 @@ IconRef wxBitmapRefData::GetIconRef()
         // we have to retain a reference, as Unregister will decrement it
         AcquireIconRef( m_iconRef ) ;
         UnregisterIconRef( 'WXNG' , (OSType) iconCounter ) ;
-        DisposeHandle( (Handle) iconFamily ) ;
         ++iconCounter ;
+#endif
+        DisposeHandle( (Handle) iconFamily ) ;
     }
 
     return m_iconRef ;