Exemplo n.º 1
0
static PyObject *Icn_PlotIconID(PyObject *_self, PyObject *_args)
{
	PyObject *_res = NULL;
	OSErr _err;
	Rect theRect;
	IconAlignmentType align;
	IconTransformType transform;
	SInt16 theResID;
#ifndef PlotIconID
	PyMac_PRECHECK(PlotIconID);
#endif
	if (!PyArg_ParseTuple(_args, "O&hhh",
	                      PyMac_GetRect, &theRect,
	                      &align,
	                      &transform,
	                      &theResID))
		return NULL;
	_err = PlotIconID(&theRect,
	                  align,
	                  transform,
	                  theResID);
	if (_err != noErr) return PyMac_Error(_err);
	Py_INCREF(Py_None);
	_res = Py_None;
	return _res;
}
Exemplo n.º 2
0
Pixmap
TkpCreateNativeBitmap(
    Display *display,
    CONST char *source)		/* Info about the icon to build. */
{
    Pixmap pix;
    Rect destRect;
    CGrafPtr savePort;
    Boolean portChanged;
    const NativeIcon *nativeIconPtr;

    pix = Tk_GetPixmap(display, None, 32, 32, 0);
    portChanged = QDSwapPort(TkMacOSXGetDrawablePort(pix), &savePort);

    nativeIconPtr = (const NativeIcon *) source;
    SetRect(&destRect, 0, 0, 32, 32);
    if (nativeIconPtr->type == TYPE1) {
	RGBColor white = {0xFFFF, 0xFFFF, 0xFFFF};

	RGBForeColor(&white);
	PaintRect(&destRect);
	PlotIconID(&destRect, atAbsoluteCenter, ttNone, nativeIconPtr->id);
    } else if (nativeIconPtr->type == TYPE2) {
	Handle icon = GetIcon(nativeIconPtr->id);

	if (icon != NULL) {
	    RGBColor black = {0, 0, 0};

	    RGBForeColor(&black);
	    PlotIcon(&destRect, icon);
	    ReleaseResource(icon);
	}
    }

    if (portChanged) {
	QDSwapPort(savePort, NULL);
    }
    return pix;
}
Exemplo n.º 3
0
boolean ploticonresource (const Rect *r, short align, short transform, short resid) {
	
	/*
	1.0b20 dmb: try plotting cicn if icon family isn't found. This 
	allows all of the stand system icons to be used.
	
	1.0b21 dmb: try geting normal b&w icon if all else fails

	5.0a8 dmb: use srccopy, not srcand for win blits
	 
	Note that the Windows version does NOT use the transform parameter
	*/
	
#ifdef MACVERSION
	OSErr ec;
	CIconHandle hcicon;
	Handle hicon;
	Rect rlocal = *r;
	
#ifdef SWAP_BYTE_ORDER
	/* For some unknown reason the Intel OS X builds shift the icon displays */
	rlocal.top		+= 3;
	rlocal.bottom	+= 3;
	rlocal.left	+= 6;
	rlocal.right += 6;
#endif
	
	ec = PlotIconID (&rlocal, align, transform, resid);
	
	if (ec == noErr)
		return (true);
	
	hcicon = GetCIcon (resid);
	
	if (hcicon != nil) {
		
		PlotCIcon (&rlocal, hcicon);
		
		DisposeCIcon (hcicon);
		
		return (true);
		}
	
	hicon = GetIcon (resid);
	
	if (hicon != nil) {
		
		PlotIcon (&rlocal, hicon);
		
		/*ReleaseResource (hicon);*/ /*dmb 1.0b21 - don't need to*/
		
		return (true);
		}
	
	return (false);
#endif

#ifdef WIN95VERSION
	HBITMAP hbm, oldbm;
	BITMAP bm;
	HDC hdcsrc, hdc;
	boolean flprinting;
	HDC hdcmask;
	HBITMAP hbmmask, oldmaskbm;
	COLORREF oldclr, oldclr2;


	hbm = LoadBitmap (shellinstance, MAKEINTRESOURCE (resid));

	if (hbm)
		{
		hdc = getcurrentDC();

		flprinting = iscurrentportprintport ();

		if (hdc)
			{
			hdcsrc = CreateCompatibleDC (hdc);

			if (hdcsrc)
				{
				GetObject (hbm, sizeof (BITMAP), &bm);

				oldbm = (HBITMAP) SelectObject (hdcsrc, hbm);
				
				if (flprinting) {
				//	StretchBlt (hdc, r->left, r->top, r->right-r->left, r->bottom - r->top, hdcsrc, 0,0, bm.bmWidth, bm.bmHeight, SRCCOPY);
					}
				else {
					hdcmask = CreateCompatibleDC (hdc);
					hbmmask = CreateBitmap (bm.bmWidth, bm.bmHeight, 1, 1, NULL);

					if (hdcmask && hbmmask) {
						oldmaskbm = (HBITMAP) SelectObject (hdcmask, hbmmask);

						oldclr = SetBkColor (hdcsrc, RGB(255,255,255));

						BitBlt (hdcmask, 0,0,bm.bmWidth, bm.bmHeight, hdcsrc, 0,0, SRCCOPY);

						SetBkColor (hdcsrc,oldclr);

						eraserect (*r);

						oldclr = SetBkColor (hdc, RGB(255,255,255));
						oldclr2 = SetTextColor (hdc, RGB(0,0,0));

						BitBlt (hdc, r->left, r->bottom - bm.bmHeight, bm.bmWidth, bm.bmHeight, hdcsrc, 0,0, SRCINVERT);
						BitBlt (hdc, r->left, r->bottom - bm.bmHeight, bm.bmWidth, bm.bmHeight, hdcmask, 0,0, SRCAND);
						BitBlt (hdc, r->left, r->bottom - bm.bmHeight, bm.bmWidth, bm.bmHeight, hdcsrc, 0,0, SRCINVERT);

						SetBkColor (hdc,oldclr);
						SetTextColor (hdc,oldclr2);

						SelectObject (hdcmask, oldmaskbm);

	//					BitBlt (hdc, r->left, r->bottom - bm.bmHeight, bm.bmWidth, bm.bmHeight, hdcsrc, 0,0, SRCAND);
						}

					DeleteObject (hbmmask);
					DeleteDC (hdcmask);
					}

				SelectObject (hdcsrc, oldbm);
				DeleteDC (hdcsrc);
				}
			}

		DeleteObject (hbm);
		}
	
	return (true);	
#endif
	} /*ploticonresource*/