Example #1
0
static PyObject *Icn_PlotIconRef(PyObject *_self, PyObject *_args)
{
	PyObject *_res = NULL;
	OSErr _err;
	Rect theRect;
	IconAlignmentType align;
	IconTransformType transform;
	IconServicesUsageFlags theIconServicesUsageFlags;
	IconRef theIconRef;
#ifndef PlotIconRef
	PyMac_PRECHECK(PlotIconRef);
#endif
	if (!PyArg_ParseTuple(_args, "O&hhlO&",
	                      PyMac_GetRect, &theRect,
	                      &align,
	                      &transform,
	                      &theIconServicesUsageFlags,
	                      ResObj_Convert, &theIconRef))
		return NULL;
	_err = PlotIconRef(&theRect,
	                   align,
	                   transform,
	                   theIconServicesUsageFlags,
	                   theIconRef);
	if (_err != noErr) return PyMac_Error(_err);
	Py_INCREF(Py_None);
	_res = Py_None;
	return _res;
}
// --------------------------------------------------------------------------------------
pascal void DrawIconDataBrowserItem86CB(ControlRef browser, DataBrowserItemID item, 
										DataBrowserPropertyID property, 
										DataBrowserItemState itemState, const Rect *theRect, 
										SInt16 gdDepth, Boolean colorDevice)
{
#pragma unused (theRect)
	Rect enclosingRect, iconRect, textRect;
	Boolean active;
	IconDBItemDataRec *itemData;
	
		/* The data browser currently gives us the content part bounds in the theRect 
		   parameter but we want the enclosing part bounds to draw in so that we can 
		   draw a fill style highlight. */
	GetDataBrowserItemPartBounds(browser, item, property, kDataBrowserPropertyEnclosingPart, 
									&enclosingRect);
	
	active = IsControlActive(browser);
	
	if ((itemState & kDataBrowserItemIsSelected) != 0)
	{
		ThemeDrawingState savedState;
		
		GetThemeDrawingState(&savedState);
		
		SetThemePen(active ? kThemeBrushPrimaryHighlightColor : kThemeBrushSecondaryHighlightColor, 
					gdDepth, colorDevice);
		PaintRect(&enclosingRect);
		
		SetThemeDrawingState(savedState, true);
	}
	
	calculateDrawingBounds(&enclosingRect, &iconRect, &textRect);
	itemData = (IconDBItemDataRec *)item;
	
	PlotIconRef(&iconRect, kAlignNone, active ? kTransformNone : kTransformDisabled, 
				kIconServicesNormalUsageFlag, itemData->icon);
	DrawThemeTextBox(itemData->name, kThemeViewsFont, 
						active ? kThemeStateActive : kThemeStateInactive, true, 
						&textRect, teCenter, NULL);
}
Example #3
0
static void ccdrawfrontiericon (Rect rcicn, boolean flpressed) {

	//
	// 2006-07-12 creedon: FSRef-ized
	//
	// 7.0b53 PBS: draw an OS X style icon
	//
		
	#ifdef MACVERSION

		IconRef iconref;
		tyfilespec programfspec;
		short label;
		OSErr err;
		Rect r = rcicn;
		FSSpec fs;
		
		getapplicationfilespec (nil, &programfspec);
		
		err = macgetfsspec (&programfspec, &fs);

		if (GetIconRefFromFile (&fs, &iconref, &label) == noErr) {
			
			err = PlotIconRef (&r, kAlignAbsoluteCenter, flpressed? kTransformSelected : 0, kIconServicesNormalUsageFlag, iconref);			
			
			ReleaseIconRef (iconref);
		
			if (err == noErr)
				return;
			} // if

	#endif // MACVERSION
	
	ploticonresource ( &rcicn, kAlignAbsoluteCenter, flpressed ? kTransformSelected : 0, idfrontiericon );
	
	} // ccdrawfrontiericon
Example #4
0
boolean ploticonfromodb (const Rect *r, short align, short transform, bigstring bsadricon) {
#if defined (MACVERSION)
	//bigstring bsadricon = "\psystem.verbs.builtins.Frontier.tools.data.nodeTypes.link.icon.mac";
	

	IconRef iconRef;
	IconFamilyHandle iconHand;
	SInt32 theSize;
	OSStatus theErr;
	Handle hicon;
	bigstring bsadriconpart;
	
	theErr = noErr;
	theSize = sizeof(OSType) + sizeof(OSType);
	
	newhandle(theSize, (Handle*) &iconHand);

	//iconHand = (IconFamilyHandle) getnewhandle(theSize, false);
	
	if (iconHand == NULL) theErr = memFullErr;
	
	if (theErr == noErr) {
		(*iconHand)->resourceType = EndianU32_NtoB(kIconFamilyType);
		(*iconHand)->resourceSize = EndianU32_NtoB(theSize);
	}
	
	if (theErr == noErr) {
		setemptystring(bsadriconpart);
		copystring(bsadricon, bsadriconpart);
		pushstring(BIGSTRING("\x05" ".ics4"), bsadriconpart);
		theErr = loadicondatafromodb(bsadriconpart, BIGSTRING("\x04" "ics4"), &hicon);
		
		if (theErr == noErr) {
			theErr = SetIconFamilyData(iconHand, kSmall4BitData, hicon);
			disposehandle(hicon);
		}
	}
	
	if (theErr == noErr) {
		setemptystring(bsadriconpart);
		copystring(bsadricon, bsadriconpart);
		pushstring(BIGSTRING("\x05" ".ics8"), bsadriconpart);
		theErr = loadicondatafromodb(bsadriconpart, BIGSTRING("\x04" "ics8"), &hicon);
		
		if (theErr == noErr) {
			theErr = SetIconFamilyData(iconHand, kSmall8BitData, hicon);
			disposehandle(hicon);
		}
	}
	
	if (theErr == noErr) {
		setemptystring(bsadriconpart);
		copystring(bsadricon, bsadriconpart);
		pushstring(BIGSTRING("\x09" ".icspound"), bsadriconpart);
		theErr = loadicondatafromodb(bsadriconpart, BIGSTRING("\x08" "icspound"), &hicon);
		
		if (theErr == noErr) {
			theErr = SetIconFamilyData(iconHand, kSmall1BitMask, hicon);
			disposehandle(hicon);
		}
	}
	
	if (theErr == noErr) {
		theErr = GetIconRefFromIconFamilyPtr(*iconHand, GetHandleSize((Handle) iconHand), &iconRef);
	}
	
	if (theErr == noErr) {
		theErr = PlotIconRef(r, align, transform, kIconServicesNormalUsageFlag, iconRef);
	}
	
	setemptystring(bsadriconpart);
	ReleaseIconRef(iconRef);
	disposehandle((Handle) iconHand);
	
	return theErr == noErr;
#else if defined (WIN95VERSION)
	return FALSE;
#endif
}
Example #5
0
// --------------------------------------------------------------------------------------
static void drawIconListCell(ListHandle theList, const Rect *cellRect, 
								IconListCellDataRec *theCellData, Boolean selected)
{
	GrafPtr savedPort;
	CGrafPtr listPort;
	ThemeDrawingState savedState;
	Boolean active;
	Rect iconRect, textRect;
	short savedFont, savedSize;
	Style savedFace;
	CFStringRef cellName;
	
	GetPort(&savedPort);
	listPort = GetListPort(theList);
	SetPort((GrafPtr)listPort);
	
	GetThemeDrawingState(&savedState);
	
	if (selected)						// we don't need to change the background 
	{									// color if this Cell isn't highlighted
		Pattern whitePattern;
		RGBColor highlightColor;
		
		GetQDGlobalsWhite(&whitePattern);	// set the background pattern so that 
		BackPat(&whitePattern);				// the color is properly set as a solid color
		
		LMGetHiliteRGB(&highlightColor);
		RGBBackColor(&highlightColor);		// set the background to the highlight color
	}
	
	EraseRect(cellRect);
	
	calculateDrawingBounds(cellRect, &iconRect, &textRect);	// get the drawing Rects
	active = GetListActive(theList);
	
		// draw the IconRef using Icon Services
	PlotIconRef(&iconRect, kAlignNone, active ? kTransformNone : kTransformDisabled, 
				kIconServicesNormalUsageFlag, theCellData->icon);
	
#if TARGET_API_MAC_OS8		// draw TextEdit text in Classic
#pragma unused (cellName)
	savedFont = GetPortTextFont(listPort);	// Get/SetThemeDrawingState doesn't save or 
	savedFace = GetPortTextFace(listPort);	// restore these
	savedSize = GetPortTextSize(listPort);
	
	UseThemeFont(kThemeViewsFont, smCurrentScript);
	TETextBox(&theCellData->name[1], theCellData->name[0], &textRect, teCenter);
	
	TextFont(savedFont);
	TextFace(savedFace);
	TextSize(savedSize);
#else						// draw Appearance text in Carbon
#pragma unused (savedFont, savedSize, savedFace)
	cellName = CFStringCreateWithPascalString(kCFAllocatorDefault, theCellData->name, 
												GetApplicationTextEncoding());
	DrawThemeTextBox(cellName, kThemeViewsFont, 
						active ? kThemeStateActive : kThemeStateInactive, true, 
						&textRect, teCenter, NULL);
	CFRelease(cellName);
#endif
	
	SetThemeDrawingState(savedState, true);
	SetPort(savedPort);
} // drawIconListCell
Example #6
0
/* アイコンプレビューのアップデート */
void DrawIPIconPreview(const IPIconRec *ipIcon)
{
	PicHandle	previewPict;
	Rect		r;
	Pattern		pat;
	Boolean		drawLarge=false,drawSmall=false,drawThumbnail=false;
	Handle		h;
	OSErr		err;
	IconSuiteRef	iconSuite=NULL;
	IconRef		iconRef;
    Rect        picRect;
	
	/* プレビューの大きさ */
	GetWindowPortBounds(gPreviewWindow,&r);
	
	/* まず背景 */
	switch (gListBackground)
	{
		case iBackWhite:
			EraseRect(&r);
			break;
		
		case iBackGray:
			GetIndPattern(&pat,0,4);
			FillRect(&r,&pat);
			break;
		
		case iBackBlack:
			PaintRect(&r);
			break;

		case iBackDesktop:
			#if !TARGET_API_MAC_CARBON
			{
				PixPatHandle	ppat;
				
				UseResFile(0);
	//			ppat=GetPixPat(16);
				ppat=LMGetDeskCPat();
				if (ppat==nil)
				{
					LMGetDeskPattern(&pat);
					FillRect(&r,&pat);
				}
				else
				{
					FillCRect(&r,ppat);
			//		DisposePixPat(ppat);
				}
				UseResFile(gApplRefNum);
			}
			#else
			EraseRect(&r);
			#endif
			break;

        default:
			EraseRect(&r);
			break;
}
	
	if (ipIcon!=NULL)
	{
		err=GetDataFromIPIcon(&h,ipIcon,kL1Data);
		drawLarge=(h!=nil);
		err=GetDataFromIPIcon(&h,ipIcon,kS1Data);
		drawSmall=(h!=nil);
		err=GetDataFromIPIcon(&h,ipIcon,kT32Data);
		drawThumbnail=(h!=nil);
	}
	
	if (drawThumbnail)
		previewPict = GetPicture(142);
	else
		previewPict = GetPicture(141);
    QDGetPictureBounds(previewPict, &picRect);
	DrawPicture(previewPict,&picRect);
	
	if (ipIcon==NULL) return;
	
	if (!isThumbnailIconsAvailable || !drawThumbnail)
	{
		iconSuite = ipIcon->iconSuite;
	}
	else
	{
		IconFamilyHandle	iconFamily;
		
		err=IPIconToIconFamily(ipIcon,&iconFamily);
		err=RegisterIconRefFromIconFamily(kIconPartyCreator,'TEMP',iconFamily,&iconRef);
	//	DisposeHandle((Handle)iconFamily);
	}
	
	if (isThumbnailIconsAvailable && drawThumbnail)
	{
		err=PlotIconRef(&iconPreviewRect[12],kAlignNone,kTransformNone,kIconServicesNormalUsageFlag,
					iconRef);
		err=ReleaseIconRef(iconRef);
	}
	else
	{
		if (iconSuite != NULL)
		{
			PlotIconSuite(&iconPreviewRect[0],kAlignNone,kTransformNone,iconSuite);
			PlotIconSuite(&iconPreviewRect[1],kAlignNone,kTransformSelected,iconSuite);
			
			if (drawLarge)
			{
				PlotIconSuite(&iconPreviewRect[4],kAlignNone,kTransformOpen,iconSuite);
				PlotIconSuite(&iconPreviewRect[5],kAlignNone,kTransformSelectedOpen,iconSuite);
				
				PlotIconSuite(&iconPreviewRect[8],kAlignNone,kTransformOffline,iconSuite);
				PlotIconSuite(&iconPreviewRect[9],kAlignNone,kTransformSelectedOffline,iconSuite);
			}
			PlotIconSuite(&iconPreviewRect[2],kAlignNone,kTransformNone,iconSuite);
			PlotIconSuite(&iconPreviewRect[3],kAlignNone,kTransformSelected,iconSuite);
			
			if (drawSmall)
			{
				PlotIconSuite(&iconPreviewRect[6],kAlignNone,kTransformOpen,iconSuite);
				PlotIconSuite(&iconPreviewRect[7],kAlignNone,kTransformSelectedOpen,iconSuite);
				
				PlotIconSuite(&iconPreviewRect[10],kAlignNone,kTransformOffline,iconSuite);
				PlotIconSuite(&iconPreviewRect[11],kAlignNone,kTransformSelectedOffline,iconSuite);
			}
		}
	}
}
Example #7
0
/* convert IPIcon to Picture */
PicHandle IPIconToPicture(const IPIconRec *ipIcon,short iconKind)
{
	ResType	iconType;
	short	iconSize,iconDepth;
	long	offset=0;
	OSErr	err;
	GWorldPtr	iconGWorld;
	PixMapHandle	iconPix;
	Handle	dataHandle;
	Ptr		src,dst;
	PicHandle	picture;
	OpenCPicParams	picParam;
	Rect	iconRect;
	Rect	temp;
	long	rowBytes,iconRowBytes;
	short	i;
	CTabHandle	ctab=nil;
	GWorldPtr	cPort;
	GDHandle	cDevice;
	
	/* invalid icon kind */
	if (iconKind < 0) return nil;
	
	iconType=gIconType[iconKind];
	iconSize=gIconSize[iconKind];
	iconDepth=gIconDepth[iconKind];
	
	SetRect(&iconRect,0,0,iconSize,iconSize);
	temp=iconRect;
	temp.right++;
	
	err=GetDataFromIPIcon(&dataHandle,ipIcon,iconKind);
	
	if (err != noErr || dataHandle == nil) return nil; /* return nil when there are no icons */
	if (GetHandleSize(dataHandle) != iconSize*(long)iconSize*(iconDepth>1 ? iconDepth : 2)/8) return nil;
	
	switch (iconKind)
	{
		case kL1Mask:
			offset=32*32/8;
			break;
		
		case kS1Mask:
			offset=16*16/8;
			break;
		
		case kL8Mask:
		case kS8Mask:
		case kT8Mask:
			ctab=GetGrayscaleCTable(iconDepth,true);
			break;
	}
	
	GetGWorld(&cPort,&cDevice);
	err=NewGWorld(&iconGWorld,iconDepth,&temp,ctab,0,useTempMem);
	if (ctab != NULL) DisposeHandle((Handle)ctab);
	if (err != noErr) return nil;
	
	HLock(dataHandle);
	
	SetGWorld(iconGWorld,0);
	iconPix=GetGWorldPixMap(iconGWorld);
	LockPixels(iconPix);
	rowBytes=MyGetPixRowBytes(iconPix) & 0x3fff;
	EraseRect(&iconRect);
	
	src=*dataHandle+offset;
	dst=MyGetPixBaseAddr(iconPix);
	iconRowBytes=iconSize*iconDepth/8;
	for (i=0; i<iconSize; i++)
	{
		BlockMoveData(src,dst,iconRowBytes);
		src+=iconRowBytes;
		dst+=rowBytes;
	}
	HUnlock(dataHandle);
	UnlockPixels(iconPix);
	
	picParam.srcRect=iconRect;
	picParam.hRes=72L<<16;
	picParam.vRes=72L<<16;
	picParam.version=-2;
	picParam.reserved1=0;
	picParam.reserved2=0;
	
	picture=OpenCPicture(&picParam);
	
	ForeColor(blackColor);
	BackColor(whiteColor);
	
	ClipRect(&iconRect);
	EraseRect(&iconRect);
	#if 1
	CopyBits(GetPortBitMapForCopyBits(iconGWorld),GetPortBitMapForCopyBits(iconGWorld),
		&iconRect,&iconRect,srcCopy,nil);
	#else
	{
		IconFamilyHandle	iconFamily;
		IconRef				iconRef;
		
		err=IPIconToIconFamily(ipIcon,&iconFamily);
		err=RegisterIconRefFromIconFamily(kIconPartyCreator,'TEMP',iconFamily,&iconRef);
		DisposeHandle((Handle)iconFamily);
		
		err=PlotIconRef(&iconRect,kAlignNone,kTransformNone,kIconServicesNormalUsageFlag,
				iconRef);
		err=ReleaseIconRef(iconRef);
	}
	#endif
#if __BIG_ENDIAN__
	(**picture).picFrame=iconRect;
#endif
	ClosePicture();
	
	SetGWorld(cPort,cDevice);
	
	#if 0
	CopyBits(GetPortBitMapForCopyBits(iconGWorld),GetPortBitMapForCopyBits(GetWindowPort(MyFrontNonFloatingWindow())),
		&iconRect,&familyIconRect[iconKind],srcCopy,nil);
	
	DrawPicture(picture,&familyIconRect[iconKind]);
	#endif
	
	DisposeGWorld(iconGWorld);
	
	return picture;
}