示例#1
0
文件: mprinter.cpp 项目: PNCG/neuron
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
}
示例#2
0
int ioPrintPreProcessing(PrintingLogicPtr printJob,int numberOfPages) {
    OSStatus		status = noErr;
    UInt32	realNumberOfPagesinDoc;
        
    if (printJob->thePrRecHdl == NULL) 
        return -1;
        
    printJob->numberOfPages = numberOfPages;
    printJob->allowPostscript = false;
    
    if (!PrJobDialog(printJob->thePrRecHdl))
    	return -2;
    
    if (status == noErr) {
        //	Get the user's Print dialog selection for first and last pages to print.
        if (status == noErr)
            { 
            TPPrint foo = *printJob->thePrRecHdl;
            printJob->firstPage = foo->prJob.iFstPage;
            printJob->lastPage =  foo->prJob.iLstPage;
            }
    
        //	Check that the selected page range does not exceed the actual number of
        //	pages in the document.
        if (status == noErr)
            {
            realNumberOfPagesinDoc = printJob->numberOfPages;
            if (realNumberOfPagesinDoc < printJob->lastPage)
                printJob->lastPage = realNumberOfPagesinDoc;
            }
        
        //	Begin a new print job.
		printJob->thePrPort = PrOpenDoc(printJob->thePrRecHdl, nil, nil);
		status = PrError();
        }

    return status;
}
示例#3
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*/