Exemple #1
0
static PyObject *Icn_NewIconSuite(PyObject *_self, PyObject *_args)
{
	PyObject *_res = NULL;
	OSErr _err;
	IconSuiteRef theIconSuite;
#ifndef NewIconSuite
	PyMac_PRECHECK(NewIconSuite);
#endif
	if (!PyArg_ParseTuple(_args, ""))
		return NULL;
	_err = NewIconSuite(&theIconSuite);
	if (_err != noErr) return PyMac_Error(_err);
	_res = Py_BuildValue("O&",
	                     ResObj_New, theIconSuite);
	return _res;
}
Exemple #2
0
/* 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;
}
pascal OSErr SafeGetIconSuite(IconSuiteRef *theIconSuite, short theResID, IconSelectorValue selector)
{
	ASBool foundAnIcon = false;
	
	*theIconSuite = NULL;
	OSErr err = noErr;
	
	err = NewIconSuite(theIconSuite);
	if (err == noErr)
	{
		if (selector & kSelectorLarge1Bit)
			if (SafeGetIconSuitePart(*theIconSuite, theResID, 'ICN#'))
				foundAnIcon = true;
		
		if (selector & kSelectorLarge4Bit)
			if (SafeGetIconSuitePart(*theIconSuite, theResID, 'icl4'))
				foundAnIcon = true;
		
		if (selector & kSelectorLarge8Bit)
			if (SafeGetIconSuitePart(*theIconSuite, theResID, 'icl8'))
				foundAnIcon = true;
		
		if (selector & kSelectorSmall1Bit)
			if (SafeGetIconSuitePart(*theIconSuite, theResID, 'ics#'))
				foundAnIcon = true;
		
		if (selector & kSelectorSmall4Bit)
			if (SafeGetIconSuitePart(*theIconSuite, theResID, 'ics4'))
				foundAnIcon = true;
		
		if (selector & kSelectorSmall8Bit)
			if (SafeGetIconSuitePart(*theIconSuite, theResID, 'ics8'))
				foundAnIcon = true;
		
		if (IconFamilyToIconSuite != NULL)
		{
			Handle iconFamily = SafeGet1Resource('icns', theResID);
			if (iconFamily)
			{
				IconSuiteRef icnsIconSuite = NULL;
				IconFamilyToIconSuite((IconFamilyHandle)iconFamily, selector, &icnsIconSuite);
				if (icnsIconSuite)
				{
					IconActionUPP AddIconsToSuiteUPP = NewIconActionUPP(AddIconsToSuite);
					ForEachIconDo(icnsIconSuite, selector, AddIconsToSuiteUPP, *theIconSuite);
					DisposeIconActionUPP(AddIconsToSuiteUPP);
					foundAnIcon = true;
				}
				
				ReleaseResource(iconFamily);
			}
		}
		
		if (!foundAnIcon)
		{
			DisposeIconSuite(*theIconSuite, true);
			*theIconSuite = NULL;
			err = noSuchIconErr;
		}
	}
	
	return err;
}