Example #1
0
static PyObject *Icn_GetCIcon(PyObject *_self, PyObject *_args)
{
	PyObject *_res = NULL;
	CIconHandle _rv;
	SInt16 iconID;
#ifndef GetCIcon
	PyMac_PRECHECK(GetCIcon);
#endif
	if (!PyArg_ParseTuple(_args, "h",
	                      &iconID))
		return NULL;
	_rv = GetCIcon(iconID);
	_res = Py_BuildValue("O&",
	                     ResObj_New, _rv);
	return _res;
}
Example #2
0
boolean ploticon (const Rect *r, short id) {
	
	/*
	plot the icon with the given id in rect r.  if a color icon is available, 
	and the machine supports color, use the color version
	*/
	
#ifdef MACVERSION
	Handle hicon;
	CIconHandle hcicn;
	
	if (systemhascolor ()) {
		
		hcicn = GetCIcon (id);
		
		if (hcicn != nil) {
			
			PlotCIcon (r, hcicn);
			
			DisposeCIcon (hcicn);
			
			return (true);
			}
		}
	
	hicon = GetResource ('ICON', id);
	
	if (hicon != nil) {
		
		PlotIcon (r, hicon);
		
		return (true);
		}
	
	return (false);
#endif

#ifdef WIN95VERSION
	return (ploticonresource (r, 0, 0, id));
#endif
	} /*ploticon*/
Example #3
0
static int open_PlayerWin()
		/*success-> return 0;*/
{
	int	i;
	OSErr	err;
	RGBColor	back={0,0,0},
				fore={65535,65535,65535};
	
	open_window( &win, kPlayerWinID);
	position_window(&win);
	
	SetPortWindowPort(win.ref);
	RGBForeColor(&fore);
	RGBBackColor(&back);
	logo= GetPicture(128);
	logoDown= GetPicture(132);
	
	for(i=0; i<6; i++)
		button[i]= GetCIcon(i+200);
	iconPlay=GetCIcon(210);
	iconPause=GetCIcon(211);
	iconVol=GetCIcon(206);
	iconTab=GetCIcon(207);
	iconNotLoop=GetCIcon(208);
	iconLoop=GetCIcon(209);
	
	if(gHasDragMgr)
	{
		receiveRgn=NewRgn();
		if( receiveRgn )
		{
			GetWindowContentRgn(win.ref, receiveRgn);
			err=InstallTrackingHandler(NewDragTrackingHandlerProc(DragTrackingProc),
								(WindowPtr)win.ref, 0);
			if(err) ExitToShell();
			
			err=InstallReceiveHandler(NewDragReceiveHandlerProc(DragReceiveFunc),
							(WindowPtr)win.ref, 0);
			if(err) ExitToShell();
		}
	}
	return 0;
}
Example #4
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*/
Example #5
0
pascal CIconHandle SafeGetCIcon(short iconID)
{
	StAcroResourceContext resContext;

	return GetCIcon(iconID);
}
Example #6
0
Pixmap
TkpGetNativeAppBitmap(
    Display *display,		/* The display. */
    CONST char *name,		/* The name of the bitmap. */
    int *width,			/* The width & height of the bitmap. */
    int *height)
{
    Pixmap pix;
    CGrafPtr savePort;
    Boolean portChanged;
    Rect destRect;
    Handle resource;
    int type = -1, destWrote;
    Str255 nativeName;
    Tcl_Encoding encoding;

    /*
     * macRoman is the encoding that the resource fork uses.
     */

    encoding = Tcl_GetEncoding(NULL, "macRoman");
    Tcl_UtfToExternal(NULL, encoding, name, strlen(name), 0, NULL,
	    (char *) &nativeName[1], 255, NULL, &destWrote, NULL);
    nativeName[0] = destWrote;
    Tcl_FreeEncoding(encoding);

    resource = GetNamedResource('cicn', nativeName);
    if (resource != NULL) {
	type = TYPE3;
    } else {
	resource = GetNamedResource('ICON', nativeName);
	if (resource != NULL) {
	    type = TYPE2;
	}
    }

    if (resource == NULL) {
	return (Pixmap) NULL;
    }

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

    SetRect(&destRect, 0, 0, 32, 32);
    if (type == TYPE2) {
	RGBColor black = {0, 0, 0};

	RGBForeColor(&black);
	PlotIcon(&destRect, resource);
	ReleaseResource(resource);
    } else if (type == TYPE3) {
	RGBColor white = {0xFFFF, 0xFFFF, 0xFFFF};
	short id;
	ResType theType;
	Str255 dummy;

	/*
	 * We need to first paint the background white. Also, for some reason
	 * we *must* use GetCIcon instead of GetNamedResource for PlotCIcon to
	 * work - so we use GetResInfo to get the id.
	 */

	RGBForeColor(&white);
	PaintRect(&destRect);
	GetResInfo(resource, &id, &theType, dummy);
	ReleaseResource(resource);
	resource = (Handle) GetCIcon(id);
	PlotCIcon(&destRect, (CIconHandle) resource);
	DisposeCIcon((CIconHandle) resource);
    }

    *width = 32;
    *height = 32;
    if (portChanged) {
	QDSwapPort(savePort, NULL);
    }
    return pix;
}
Example #7
0
int GetStartLevel(void)
{
	static char    *Ltext1 = 
			"Enter the level to start from (1-40).  This";
	static char    *Ltext2 = 
			"disqualifies you from a high score...";
	static char    *Ltext3 = "Level:";
	static char    *Ltext4 = "Lives:";
	MFont *chicago;
	Maclike_Dialog *dialog;
	SDL_Surface *splash;
	SDL_Surface *text1, *text2, *text3, *text4;
	static char *turbotext = "Turbofunk On";
	int x, y, X, Y;
	Mac_Button *doit;
	Mac_Button *cancel;
	Mac_NumericEntry *numeric_entry;
	Mac_CheckBox *checkbox;
	int startlevel=10, startlives=5, turbofunk=0;

	/* Set up all the components of the dialog box */
	if ( (chicago = fontserv->NewFont("Chicago", 12)) == NULL ) {
		error("Can't use Chicago font!\n");
		return(0);
	}
	if ( (splash = GetCIcon(screen, 103)) == NULL ) {
		error("Can't load alien level splash!\n");
		delete chicago;
		return(0);
	}
	X=(SCREEN_WIDTH-LVL_DIALOG_WIDTH)/2;
	Y=(SCREEN_HEIGHT-LVL_DIALOG_HEIGHT)/2;
	dialog = new Maclike_Dialog(X, Y, LVL_DIALOG_WIDTH, LVL_DIALOG_HEIGHT,
								screen);
	x = y = 14;
	dialog->Add_Image(splash, x, y);
	x += (splash->w+14);
	text1 = fontserv->TextImage(Ltext1,chicago,STYLE_NORM,0x00,0x00,0x00);
	dialog->Add_Image(text1, x, y);
	y += (text1->h+2);
	text2 = fontserv->TextImage(Ltext2, chicago, STYLE_NORM,
							0x00, 0x00, 0x00);
	dialog->Add_Image(text2, x, y);
	do_level = 0;
	cancel = new Mac_Button(166, 96, 73, BUTTON_HEIGHT,
				"Cancel", chicago, fontserv, Cancel2_callback);
	dialog->Add_Dialog(cancel);
	doit = new Mac_DefaultButton(166+73+14, 96, BUTTON_WIDTH, BUTTON_HEIGHT,
				"Do it!", chicago, fontserv, Level_callback);
	dialog->Add_Dialog(doit);
	numeric_entry = new Mac_NumericEntry(X, Y, chicago, fontserv);
	numeric_entry->Add_Entry(78, 60, 3, 1, &startlevel);
	text3 = fontserv->TextImage(Ltext3,chicago,STYLE_NORM,0x00,0x00,0x00);
	dialog->Add_Image(text3, 78-text3->w-2, 60+3);
	numeric_entry->Add_Entry(78, 86, 3, 0, &startlives);
	text4 = fontserv->TextImage(Ltext4,chicago,STYLE_NORM,0x00,0x00,0x00);
	dialog->Add_Image(text4, 78-text3->w-2, 86+3);
	dialog->Add_Dialog(numeric_entry);
	checkbox = new Mac_CheckBox(&turbofunk, 136, 64, turbotext,
						chicago, fontserv);
	dialog->Add_Dialog(checkbox);

	/* Run the dialog box */
	dialog->Run(EXPAND_STEPS);

	/* Clean up and return */
	screen->FreeImage(splash);
	fontserv->FreeText(text1);
	fontserv->FreeText(text2);
	fontserv->FreeText(text3);
	fontserv->FreeText(text4);
	delete chicago;
	delete dialog;
	if ( do_level ) {
		if ( ! startlives || (startlives > 40) )
			startlives = 3;
		gStartLives = startlives;
		if ( startlevel > 40 )
			startlevel = 0;
		gStartLevel = startlevel;
		gNoDelay = turbofunk;
		return(gStartLevel);
	}
	return(0);
}