static pascal OSErr AddIconsToSuite(ResType theType, Handle *theIcon, void *yourDataPtr) { IconSuiteRef iconSuite = (IconSuiteRef)yourDataPtr; AddIconToSuite(*theIcon, iconSuite, theType); return noErr; }
static ASBool SafeGetIconSuitePart(IconSuiteRef theIconSuite, short theResID, ResType theType) { ASBool foundAnIcon = false; Handle h = SafeGet1Resource(theType, theResID); if (h) { DetachResource(h); AddIconToSuite(h, theIconSuite, theType); foundAnIcon = true; } return foundAnIcon; }
/* set icon data to IPIcon */ OSErr SetDataToIPIcon(Handle dataHandle,IPIconRec *ipIcon,short iconKind) { OSErr err=noErr; if (iconKind == kT32Data) ipIcon->it32Data = dataHandle; else if (iconKind == kT8Mask) ipIcon->t8mkData = dataHandle; else { if (ipIcon->iconSuite == NULL) err = NewIconSuite(&ipIcon->iconSuite); if (err!=noErr) return err; err=AddIconToSuite(dataHandle,ipIcon->iconSuite,gIconType[iconKind]); } return err; }
static PyObject *Icn_AddIconToSuite(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; OSErr _err; Handle theIconData; IconSuiteRef theSuite; ResType theType; #ifndef AddIconToSuite PyMac_PRECHECK(AddIconToSuite); #endif if (!PyArg_ParseTuple(_args, "O&O&O&", ResObj_Convert, &theIconData, ResObj_Convert, &theSuite, PyMac_GetOSType, &theType)) return NULL; _err = AddIconToSuite(theIconData, theSuite, theType); if (_err != noErr) return PyMac_Error(_err); Py_INCREF(Py_None); _res = Py_None; return _res; }
OSErr IconFamilyToIPIconWithSelector(IconFamilyHandle theIconFamily, const IPIconSelector *ipSelector,IPIconRec *ipIcon) { OSErr err=noErr; Handle dataHandle; long dataSize; if (ipSelector->selector != 0) { err=IconFamilyToIconSuite(theIconFamily,ipSelector->selector,&ipIcon->iconSuite); if (err==noErr) { /* Mac OS X 10.8 (Mavericks) で動作させると、32ビットデータがコピーされないので、 手作業でコピーする */ if (ipSelector->selector|kLarge32BitData) { Handle dummyHandle; dummyHandle = NewHandle(0); err=GetIconFamilyData(theIconFamily,kLarge32BitData,dummyHandle); if (err==noErr) { dataSize=GetHandleSize(dummyHandle); err=AddIconToSuite(dummyHandle,ipIcon->iconSuite,kLarge32BitData); } else { DisposeHandle(dummyHandle); err=noErr; } } if (ipSelector->selector|kSmall32BitData) { Handle dummyHandle; dummyHandle = NewHandle(0); err=GetIconFamilyData(theIconFamily,kSmall32BitData,dummyHandle); if (err==noErr) { dataSize=GetHandleSize(dummyHandle); err=AddIconToSuite(dummyHandle,ipIcon->iconSuite,kSmall32BitData); } else { DisposeHandle(dummyHandle); err=noErr; } } } } else ipIcon->iconSuite = NULL; if (err==noErr) { if (isThumbnailIconsAvailable) { /* the others */ if (ipSelector->it32) { dataHandle=NewHandle(0); err=GetIconFamilyData(theIconFamily,kThumbnail32BitData,dataHandle); if (err==noErr) { dataSize = GetHandleSize(dataHandle); if (dataSize > 0) { ipIcon->it32Data = dataHandle; HandToHand(&ipIcon->it32Data); } else ipIcon->it32Data = NULL; } else if (err == noIconDataAvailableErr || err == paramErr) // 1.20b14 { err = noErr; ipIcon->it32Data = NULL; } DisposeHandle(dataHandle); } else ipIcon->it32Data = NULL; if (ipSelector->t8mk) { dataHandle=NewHandle(0); err=GetIconFamilyData(theIconFamily,kThumbnail8BitMask,dataHandle); if (err==noErr) { dataSize = GetHandleSize(dataHandle); if (dataSize > 0) { ipIcon->t8mkData = dataHandle; HandToHand(&ipIcon->t8mkData); } else ipIcon->t8mkData = NULL; } else if (err == noIconDataAvailableErr || err == paramErr) // 1.20b14 { err = noErr; ipIcon->t8mkData = NULL; } DisposeHandle(dataHandle); } else ipIcon->t8mkData = NULL; } else { ipIcon->it32Data = NULL; ipIcon->t8mkData = NULL; } } return err; }