Example #1
0
FILE *choose_mac_file(char *file_name,char action)
{
        StandardFileReply reply;
        SFTypeList                type_list;
        short num_types;
        FILE *the_file;

        /* start out by using StandardGetFile to get the file name and stuff */
        num_types = -1;
        type_list[0] = 'YhMp';
        StandardGetFile(nil, num_types, type_list, &reply);
        if (!reply.sfGood)
        {
                strcpy(file_name,"User Cancelled");
                return 0;
        }


        /* now open the file */
        strcpy(file_name,(char *)reply.sfFile.name);
        PtoCstr((unsigned char *)file_name);
        the_file = fopen_mac(reply.sfFile.vRefNum,reply.sfFile.parID,
                                                                                         file_name,(char *)"r",action);

        return the_file;
}
Example #2
0
void doOpenCommand(FILE **f)
{
StandardFileReply fileReply;

	*f = NULL;

	StandardGetFile(NULL,-1,NULL,&fileReply);
	
	if(fileReply.sfGood)
	{
		
		*f = FSp_fopen(&fileReply.sfFile, "rb");
	};
}		
Example #3
0
void mac_opensession(void)
{

    if (mac_gestalts.navsvers > 0) {
	NavReplyRecord navr;
	NavDialogOptions navopts;
	NavTypeListHandle navtypes;
	AEDesc defaultloc = { 'null', NULL };
	AEDesc *navdefault = NULL;
	short vol;
	long dirid;
	FSSpec fss;

	if (NavGetDefaultDialogOptions(&navopts) != noErr) return;
	/* XXX should we create sessions dir? */
	if (get_session_dir(FALSE, &vol, &dirid) == noErr &&
	    FSMakeFSSpec(vol, dirid, NULL, &fss) == noErr &&
	    AECreateDesc(typeFSS, &fss, sizeof(fss), &defaultloc) == noErr)
	    navdefault = &defaultloc;
	/* Can't meaningfully preview a saved session yet */
	navopts.dialogOptionFlags &= ~kNavAllowPreviews;
	navtypes = (NavTypeListHandle)GetResource('open', open_pTTY);
	if (NavGetFile(navdefault, &navr, &navopts, NULL, NULL, NULL, navtypes,
		       NULL) == noErr && navr.validRecord)
	    mac_openlist(navr.selection);
	NavDisposeReply(&navr);
	if (navtypes != NULL)
	    ReleaseResource((Handle)navtypes);
    }
#if !TARGET_API_MAC_CARBON /* XXX Navigation Services */
    else {
	StandardFileReply sfr;
	static const OSType sftypes[] = { 'Sess', 0, 0, 0 };

	StandardGetFile(NULL, 1, sftypes, &sfr);
	if (!sfr.sfGood) return;

	mac_opensessionfrom(&sfr.sfFile);
	/* XXX handle error */
    }
#endif
}
Example #4
0
// The event handler for the main menu
McoStatus	ToneTab::DoEvents(short item, Point clickPoint, WindowCode *wc, int32 *numwc, void **data,Boolean &changed)
{
int					didit = 0;
int		i,j;
McoStatus 			status = MCO_SUCCESS;	
short 				item2 = item - startNum;
Str255				prompt;
StandardFileReply 	soutReply,sinReply;
Str255				outname = "\p";
SFTypeList			filelist;
Str255				inname;
Rect r1;
short	iType;
Handle	iHandle;
WindowPtr	oldP;

GetPort(&oldP);
SetPort( dp ) ;

	// no codes passed back
	*numwc = 0;
	
	for (i=0; i<numControls; i++) 
		{
		status = controls[i]->DoEvents(item,clickPoint,wc,numwc,data,changed,&didit);
		if (status) return status;
		if (changed) 
			{
			doc->changedLinearTone = 1;
			last_changed = 1;
			CopyOutofControl(i);
			CopyIntoControl(i);
			}
		else last_changed = 0;		
		if (didit) return status;
		}

	if (item2 == EXPORT)
		{
		if (doc->calCurves)
			{
			GetIndString(prompt,PROMPT_STRINGS,STANDARD_PROMPT);
			StandardPutFile(prompt, outname, &soutReply);
			if(soutReply.sfGood)
				{
				memcpy(outname, soutReply.sfFile.name, *(soutReply.sfFile.name)+1);	
				PathNameFromDirID(soutReply.sfFile.parID, soutReply.sfFile.vRefNum, outname);
				ptocstr(outname);
				status = doc->calCurves->exportTone((char*)outname);
				if (status) McoErrorAlert(status);
				else 
					{
					FileFormat ff;
	
					ff.setInfo(&soutReply.sfFile,MONACO_SIG,'TEXT');
					}
				}
			}
		}
	else if (item2 == IMPORT)
		{
		if (doc->calCurves)
			{	
			filelist[0] = 'TEXT';
			StandardGetFile(0L, 1, filelist, &sinReply);
			if(sinReply.sfGood)	
				{
				memcpy(inname, sinReply.sfFile.name, *(sinReply.sfFile.name)+1);
				PathNameFromDirID(sinReply.sfFile.parID, sinReply.sfFile.vRefNum, inname);
				ptocstr(inname);	
				status = doc->calCurves->importTone((char*)inname);
				if (status) McoErrorAlert(status);
				else 
					{
					CopyIntoControl(-1);
					doc->changedLinearTone = 1;
					}
				status = MCO_SUCCESS;
				}
			}
		}
	else
		{
		GetDItem (dp, DESCRIPTION+startNum, &iType, (Handle*)&iHandle, &r1);
		GetIText(iHandle,inname);
		if (inname[0] > 100) inname[0] = 100;
		ptocstr(inname);
		strcpy(doc->printData->setting.toneDesc,(char*)inname);
		}
	SetPort(oldP);		
	return status;
}
Example #5
0
// Open a gammut surface dialog, use info passed in data if data is valid
McoStatus AllWins::openGammutSurface1(void)
{
	GamutSurfaceWin 	*gamutsurf;
	int32		maxwinnum  = 0;
	McoStatus	state = MCO_SUCCESS;
	int i;
	Str255		patchFName;
	RawData		*raw;
	

	StandardFileReply 	sinReply;
	SFTypeList			filelist;
	Str255				inname;
	FILE 				*fs;
	if (!QD3D_Present) return MCO_NO_QD3D;
	if (xyztorgb == NULL) return MCO_FAILURE;

	
	// raw is deleted by the window
	raw = new RawData();	
	
	filelist[0] = 'TEXT';
	StandardGetFile(nil, 1, filelist, &sinReply);
	if(sinReply.sfGood == 0)
		return MCO_CANCEL;
		
	copy_str(patchFName,sinReply.sfFile.name);

	memcpy(inname, sinReply.sfFile.name, *(sinReply.sfFile.name)+1);
	PathNameFromDirID(sinReply.sfFile.parID, sinReply.sfFile.vRefNum, inname);
	ptocstr(inname);	
	
	fs = fopen( (char*)inname, "r" );
	if(!fs)
		return MCO_FILE_OPEN_ERROR;
		
	raw->loadData(fs);
	
	fclose(fs);
	
	//for (i=0; i<tempdoc->_condata.smooth; i++) raw->smooth_patch();
	
	maxwinnum = 0;
	for (i=0; i<numWins; i++) if (wins[i]->isMyWindowType(GammutSurfaceTherm1))
		{
		if (wins[i]->WinNum >= maxwinnum) maxwinnum = wins[i]->WinNum+1;
		}
		
	memcpy(inname, sinReply.sfFile.name, *(sinReply.sfFile.name)+1);	

	// the flag after raw indicates that the window should delete raw
	gamutsurf = new GamutSurfaceWin(0L,raw,1,GammutSurfaceTherm1,maxwinnum,inname);
	if (gamutsurf == 0L) return MCO_MEM_ALLOC_ERROR;
	if (gamutsurf->error == MCO_MEM_ALLOC_ERROR)
		{
		McoErrorAlert(gamutsurf->error);
		delete gamutsurf;
		return MCO_SUCCESS;
		}
	if (gamutsurf->error != MCO_SUCCESS) 
		{
		state = gamutsurf->error;
		delete gamutsurf;
		return state;
		}
	

	return AddWin(gamutsurf,0L);
}