示例#1
0
McoStatus PrinterType::Save(void)
{
	int i;
	StandardFileReply 	soutReply;
	Str255				prompt;
	Str255				outname = "\p";
	McoStatus status = MCO_SUCCESS;
	FileFormat *filef;
	int   magic_num = PRINTERTYPE_MAGICNUM;
	int   version = PRINTERTYPE_VERSION;
	
	GetIndString(prompt,PROMPT_STRINGS,SETTINGS_PROMPT);
	
	StandardPutFile(prompt, outname, &soutReply);
	if(!soutReply.sfGood) return MCO_CANCEL;



	filef = new FileFormat;

	status = filef->createFilewithtype(&soutReply.sfFile,soutReply.sfScript,MONACO_SIG,'MCO6');
	if (status != MCO_SUCCESS) goto bail;

	status = filef->relWrite(sizeof(int),(char*)&magic_num);
	if (status != MCO_SUCCESS) goto bailclose;

	status = filef->relWrite(sizeof(int),(char*)&version);
	if (status != MCO_SUCCESS) goto bailclose;

	status = filef->relWrite(sizeof(ConData),(char*)&data);
	if (status != MCO_SUCCESS) goto bailclose;

	status = filef->relWrite(sizeof(int),(char*)&num_hands);
	if (status != MCO_SUCCESS) goto bailclose;

	status = filef->relWrite(sizeof(double)*31,(char*)x_hands);
	if (status != MCO_SUCCESS) goto bailclose;

	status = filef->relWrite(sizeof(double)*31,(char*)y_hands);
	if (status != MCO_SUCCESS) goto bailclose;
	
	status = filef->relWrite(sizeof(int),(char*)&sim_num);
	if (status != MCO_SUCCESS) goto bailclose;

	status = filef->relWrite(sizeof(int),(char*)&num_tweaks);
	if (status != MCO_SUCCESS) goto bailclose;

	for (i=0; i<num_tweaks; i++)
		{
		status = filef->relWrite(sizeof(Tweak_Element),(char*)tweaks[i]);
		if (status != MCO_SUCCESS) goto bailclose;
		}

	bailclose:
	filef->closeFile();
	bail:
	delete filef;
	return status;
}
示例#2
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;
}
示例#3
0
OSErr PutFile (ConstStr255Param thePrompt, ConstStr255Param theFileName, FSSpecPtr theFSSpecPtr, Boolean *theIsSelected, Boolean *theIsReplacing)
{
#if TARGET_OS_WIN32
	StandardFileReply	myReply;
#endif
#if TARGET_OS_MAC
	NavReplyRecord		myReply;
	NavDialogOptions		myDialogOptions;
	NavEventUPP		myEventUPP = NewNavEventUPP(HandleNavEvent);
#endif
	OSErr				myErr = noErr;

	if ((theFSSpecPtr == NULL) || (theIsSelected == NULL) || (theIsReplacing == NULL))
		return(paramErr);
	
	// assume we are not replacing an existing file
	*theIsReplacing = false;
	
        *theIsSelected = false;
        
#if TARGET_OS_WIN32
	StandardPutFile(thePrompt, theFileName, &myReply);
	*theFSSpecPtr = myReply.sfFile;
	*theIsSelected = myReply.sfGood;
	if (myReply.sfGood)
		*theIsReplacing = myReply.sfReplacing;
#endif

#if TARGET_OS_MAC
	// specify the options for the dialog box
	NavGetDefaultDialogOptions(&myDialogOptions);
	myDialogOptions.dialogOptionFlags += kNavNoTypePopup;
	myDialogOptions.dialogOptionFlags += kNavDontAutoTranslate;
	BlockMoveData(theFileName, myDialogOptions.savedFileName, theFileName[0] + 1);
	BlockMoveData(thePrompt, myDialogOptions.message, thePrompt[0] + 1);
	
	// prompt the user for a file
	myErr = NavPutFile(NULL, &myReply, &myDialogOptions, myEventUPP, MovieFileType, sigMoviePlayer, NULL);
	if ((myErr == noErr) && myReply.validRecord) {
		AEKeyword		myKeyword;
		DescType		myActualType;
		Size			myActualSize = 0;
		
		// get the FSSpec for the selected file
		if (theFSSpecPtr != NULL)
			myErr = AEGetNthPtr(&(myReply.selection), 1, typeFSS, &myKeyword, &myActualType, theFSSpecPtr, sizeof(FSSpec), &myActualSize);

                *theIsSelected = myReply.validRecord;
                if (myReply.validRecord)
                {
                    *theIsReplacing = myReply.replacing;
                }

		NavDisposeReply(&myReply);
	}
		

	DisposeNavEventUPP(myEventUPP);
#endif

	return(myErr);
}