+ OSType theId = 0 ;
+
+ if ( filename == wxT("wxICON_INFORMATION") )
+ {
+ theId = kAlertNoteIcon ;
+ }
+ else if ( filename == wxT("wxICON_QUESTION") )
+ {
+ theId = kAlertCautionIcon ;
+ }
+ else if ( filename == wxT("wxICON_WARNING") )
+ {
+ theId = kAlertCautionIcon ;
+ }
+ else if ( filename == wxT("wxICON_ERROR") )
+ {
+ theId = kAlertStopIcon ;
+ }
+ else if ( filename == wxT("wxICON_FOLDER") )
+ {
+ theId = kGenericFolderIcon ;
+ }
+ else if ( filename == wxT("wxICON_FOLDER_OPEN") )
+ {
+ theId = kOpenFolderIcon ;
+ }
+ else if ( filename == wxT("wxICON_NORMAL_FILE") )
+ {
+ theId = kGenericDocumentIcon ;
+ }
+ else
+ {
+ IconRef iconRef = NULL ;
+
+ // first look in the resource fork
+ if ( iconRef == NULL )
+ {
+ Str255 theName ;
+
+ wxMacStringToPascal( filename , theName ) ;
+ Handle resHandle = GetNamedResource( 'icns' , theName ) ;
+ if ( resHandle != 0L )
+ {
+ IconFamilyHandle iconFamily = (IconFamilyHandle) resHandle ;
+ HLock((Handle) iconFamily);
+ OSStatus err = GetIconRefFromIconFamilyPtr( *iconFamily, GetHandleSize((Handle) iconFamily), &iconRef );
+ HUnlock((Handle) iconFamily);
+ wxASSERT_MSG( err == noErr , wxT("Error when constructing icon ref") );
+ ReleaseResource( resHandle ) ;
+ }
+ }
+ if ( iconRef == NULL )
+ {
+ // TODO add other attempts to load it from files etc here
+ }
+ if ( iconRef )
+ {
+ m_refData = new wxIconRefData( (WXHICON) iconRef ) ;
+ return true ;
+ }
+ }
+
+ if ( theId != 0 )
+ {
+ IconRef iconRef = NULL ;
+ verify_noerr( GetIconRef( kOnSystemDisk, kSystemIconsCreator, theId, &iconRef ) ) ;
+ if ( iconRef )
+ {
+ m_refData = new wxIconRefData( (WXHICON) iconRef ) ;
+
+ return true ;
+ }
+ }
+
+ return false ;