Exemple #1
0
bool MacPrinterCanvas::setup(bool s){
#if carbon
	return false;
#else
	GetPort(&oldPort);
	PrOpen();
  if (!prRecHdl) {
	prRecHdl = THPrint(NewHandleClear(sizeof(TPrint)));
	if (PrError()  != noErr) {
		return false;
	}
	PrintDefault(prRecHdl);
	if (PrError()  != noErr) {
		return false;
	}
  }else{
	PrValidate(prRecHdl);
  }
    if (s) {
		PrStlDialog(prRecHdl);
	}
	PrClose();
	if (PrError()  != noErr) {
		return false;
	}
	//debugfile("MacPrinterCanvas::setup  width=%d height=%d\n", pwidth(), pheight());
	SetPort(oldPort);
	return true;
#endif
}
Exemple #2
0
bool MacPrinterCanvas::start() {
#if carbon
	return false;
#else
//debugfile("MacPrinter::init\n");
	GetPort(&oldPort);
	PrOpen();
  if (!prRecHdl) {
	prRecHdl = THPrint(NewHandleClear(sizeof(TPrint)));
	if (PrError()  != noErr) {
		return false;
	}
	PrintDefault(prRecHdl);
	if (PrError()  != noErr) {
		return false;
	}
	PrStlDialog(prRecHdl);
  }else{
	PrValidate(prRecHdl);
  }
	gPrinterPort = PrOpenDoc(prRecHdl, nil, nil);
	if (PrError()  != noErr) {
		return false;
	}
	PrOpenPage(gPrinterPort, nil);
	if (PrError()  != noErr) {
		return false;
	}
	damage_all();
	beginPaint();
	return true;
#endif
}
OSStatus  OpenPrinterAndValidate(void)
{
	OSStatus			err = noErr;

	#if TARGET_API_MAC_CARBON
	/////////////////////////////////////////////////
		err =  PMCreateSession(&gPrintSession);
		if(err) return err;

		// get and validate the page formatting
		if (gPageFormat == kPMNoPageFormat) {   // Set up a valid PageFormat object
			err = PMCreatePageFormat(&gPageFormat);
			//  Note that PMPageFormat is not session-specific, but calling
			//  PMSessionDefaultPageFormat assigns values specific to the printer
			//  associated with the current printing session.
			if ((err == noErr) && (gPageFormat != kPMNoPageFormat))
				err = PMSessionDefaultPageFormat(gPrintSession, gPageFormat);
		}
		else{
			err = PMSessionValidatePageFormat(gPrintSession, gPageFormat, kPMDontWantBoolean);
		}
		if(err) return err;
		/////////////////////////////////////////////////
		// let's also get and validate the print settings
		if (gPrintSettings == kPMNoPrintSettings)
		{
			err = PMCreatePrintSettings(&gPrintSettings);	
			// Note that PMPrintSettings is not session-specific, but calling
			// PMSessionDefaultPrintSettings assigns values specific to the printer
			// associated with the current printing session.
			if ((err == noErr) && (gPrintSettings != kPMNoPrintSettings))
				err = PMSessionDefaultPrintSettings(gPrintSession, gPrintSettings);
		}
		else {
			err = PMSessionValidatePrintSettings(gPrintSession, gPrintSettings, kPMDontWantBoolean);
		}

		return err;
	
	#else //// MACB4CARBON ////////////////////////////////////////
	/////////////////////////////////////////////////
		PrOpen();
		err = PrError();
		if(err) return err;		
	   
		// always use the global
		if(gPrRecHdl == nil){
			gPrRecHdl  = (THPrint)_NewHandleClear(sizeof(TPrint));
			if(!gPrRecHdl)return memFullErr; 
			PrintDefault(gPrRecHdl);
		}
	
		PrValidate(gPrRecHdl); 	
		// We ignore the returned value  
		
		return(noErr);
	#endif
} 
Exemple #4
0
int ioPrintSetup(PrintingLogicPtr *token)
{
    OSStatus		status = noErr;
    PrintingLogicPtr printJob;
   
    printJob = *token = (PrintingLogicPtr) NewPtrClear(sizeof(PrintingLogic));
    printJob->thePrRecHdl = (THPrint)  NewHandle (sizeof (TPrint));
	status = MemError();
    if (status != noErr) 
        return -1;	// pointless to continue if memory allocation fails
    
    //	Initialize the printing manager and create a printing session.
 	PrOpen(); //The PrOpen procedure prepares the current printer driver for use. 
 	status = PrError();
    if (status != noErr) 
    	return status;	
 	
 	PrintDefault(printJob->thePrRecHdl);
	status = PrError();
    if (status != noErr) 
    	return status;	

	PrValidate(printJob->thePrRecHdl);
	status = PrError();
    if (status != noErr) 
    	return status;	

    //	Display the Page Setup dialog.
	if (! PrStlDialog(printJob->thePrRecHdl)) 
  	    goto cleanup; // user cancelled

    
    return status;
    cleanup: 
    	DisposeHandle ((Handle) printJob->thePrRecHdl);
    	printJob->thePrRecHdl = NULL;
    	return -4;
}
Exemple #5
0
boolean shellprint (WindowPtr w, boolean fldialog) {

	/*
	9/5/90 dmb:  open and close print resources each time we're called.  also, 
	make sure we close each page opened, even when errors occur
	
	9/28/91 dmb: for exit of edit mode before printing
	
	4/24/92 dmb: make sure bJDocLoop is bSpoolLoop before calling PrPicFile, as 
	per IM II-155.  otherwise, we can get bogus PrErrors
	*/

	// classic mac
	TPPrPort printport;
	TPrStatus printstatus;
	THPrint hp = shellprintinfo.printhandle;

	SInt32	firstPage = 1;
	SInt32	lastPage = 9999;

	short i;
	boolean fl = false;
	
	if (w == nil) /*defensive driving*/
		return (false);

	PrOpen ();
	if (!shellcheckprinterror (true))
		return (false);

	fl = false; /*until sucessfull print, this is return value*/

	if (fldialog) {
		if (!PrJobDialog (hp))
			goto exit;
	}
	else
		PrValidate (hp);

	setcursortype (cursoriswatch);

	shellupdateallnow (); /*update all windows that were dirtied by the print dialog*/

	shellpushglobals (w);

	(*shellglobals.settextmoderoutine) (false); /*make sure editing changes are accepted*/

	pushport (nil); /*save current port on stack*/

	shellprintinfo.printport = printport = PrOpenDoc (hp, nil, nil);
	currentprintport = w;

	/*prepares for printing*/
	(*shellglobals.beginprintroutine) ();

	/*fills in fields of printinfo record*/
	(*shellglobals.setprintinfoproutine) ();
	//this only counts the number of pages.

	// wird in classic lastPage gesetzt?
	if(lastPage > shellprintinfo.ctpages)
		lastPage = shellprintinfo.ctpages;

	for (i = 1; i <= lastPage; i++) { /*print one page*/

		if (PrError () != noErr)
			break;

		PrOpenPage (printport, nil);

		if (PrError () == noErr) {

			SetFractEnable (true);

			fl = (*shellglobals.printroutine) (i);

			SetFractEnable (false);
		}

		PrClosePage (printport);

		if (!fl)
			break;

		if (keyboardescape ()) {

			PrSetError (iPrAbort);

		}
	} /*for*/

	PrCloseDoc (printport);

	if (fl) {

		if (	(PrError () == noErr)
			&& ((**hp).prJob.bJDocLoop == bSpoolLoop))
		{
			PrPicFile (hp, nil, nil, nil, &printstatus);
		}

		fl = shellcheckprinterror (false);
	}

	popport ();
	
	(*shellglobals.endprintroutine) ();

	shellpopglobals ();

exit:

	PrClose ();

	currentprintport = NULL;

	return (fl);

	} /*shellprint*/
Exemple #6
0
boolean shellpagesetup (void) {
	
	/*
	 9/5/90 dmb:  open and close print resources each time we're called
	 
	 9/27/91 dmb: don't do anything when the user cancels the dialog
	 */
	
	boolean fl;
	
#ifdef MACVERSION
	
	//Code change by Timothy Paustian Friday, June 16, 2000 10:08:37 PM
	//new code for the new print manager.
	
#	if TARGET_API_MAC_CARBON == 1
	
	if (!carbonValidSession())
	{
		carbonStdSetup();
	}
	
	{
		OSStatus status;
		
		status = PMSessionPageSetupDialog(
										  shellprintinfo.printhandle, 
										  shellprintinfo.pageformat,
										  &fl);
		
		if (!fl)
			status = kPMCancel; // user clicked Cancel button
		
		if(status != noErr)
			return false;
		
	}
	
#	else
	
	PrOpen ();
	
	if (!shellcheckprinterror (true)) 
		return (false);
	
	PrValidate (shellprintinfo.printhandle);
	
	fl = PrStlDialog (shellprintinfo.printhandle);
	
	PrClose ();
	
	if (!shellcheckprinterror (false))
		return (false);
	
#	endif
	
#endif
	
#ifdef WIN95VERSION
	
	shellprintinfo.pagesetupinfo.Flags = PSD_MARGINS | PSD_INTHOUSANDTHSOFINCHES;
	
	shellprintinfo.pagesetupinfo.hwndOwner = hwndMDIClient;
	
	fl = PageSetupDlg (&shellprintinfo.pagesetupinfo);
	
#endif
	
	if (!fl)
		return (false);
	
	shellcopyprintinfo (); /*copies fields from handle into record*/
	
	shellvisittypedwindows (-1, &shellpagesetupvisit, nil); /*visit all windows*/
	
	return (true);
} /*shellpagesetup*/