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 }
P1(PUBLIC pascal trap, BOOLEAN, PrValidate, THPrint, hPrint) /* IMII-158 */ { /* TODO: figure out what are problem areas for us and adjust accordingly */ set_wDev (hPrint); if (!HxX (hPrint, prInfo.iVRes) || !HxX (hPrint, prInfo.iHRes)) PrintDefault (hPrint); { int first, last; first = Hx (hPrint, prJob.iFstPage); last = Hx (hPrint, prJob.iLstPage); if (first < 1 || first > last) { HxX(hPrint, prJob.iFstPage) = CWC(1); HxX(hPrint, prJob.iLstPage) = CWC(9999); } } { int copies; copies = Hx (hPrint, prJob.iCopies); if (copies < 1 || copies > 99) HxX(hPrint, prJob.iCopies) = CWC(1); } HxX(hPrint, prJob.bJDocLoop) = 2; return FALSE; }
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 }
string Node::PrintEverything() { string output; output += "\t<NODE>\n"; output += PrintName(); output += PrintDefault(); output += PrintNodeNum(); output += PrintIPAddress(); output += PrintLocation(); output += PrintType(); output += PrintZone(); output += PrintParentNodeNum(); output += PrintParentDistance(); output += PrintStateChangeTime(); output += PrintChildren(); output += "\t</NODE>\n"; return output; }
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; }
boolean shellinitprint (void) { /* 9/5/90 dmb: close print resources after initializing stuff 10/21/91 dmb: added margins field to print info; structure is now here to have user-settable margins. 12/31/91 dmb: initialize shellprintinfo.paperrect to standard 72dpi values in case no printer is chosen and shellcopyprintinfo never gets called 1/18/93 dmb: don't call shellcheckprinterror the first time; if PrOpen fails here, we don't want to raise an alert. */ #if MACVERSION && !TARGET_API_MAC_CARBON Handle h; #endif currentprintport = NULL; clearbytes (&shellprintinfo, longsizeof (shellprintinfo)); setrect (&shellprintinfo.margins, 36, 36, 36, 36); setrect (&shellprintinfo.paperrect, 5, 6, 725, 546); /*defaults in case PrOpen fails*/ shellprintinfo.scaleMult = 1; shellprintinfo.scaleDiv = 1; #ifdef MACVERSION # if TARGET_API_MAC_CARBON == 1 //I realized this is only called once during the startup of the app. //Carbon printing really doesn't need any global structures. Better to //allocate them as we use them. // Nope. // We need a global var for calling page setup shellprintinfo.printport = nil; shellprintinfo.printhandle = nil; shellprintinfo.pageformat = nil; shellprintinfo.printsettings = nil; // shellprintinfo.pagerect = {0,0,0,0}; # else if (!newclearhandle (longsizeof (TPrint), &h)) return (false); shellprintinfo.printhandle = (THPrint) h; /*copy into print record*/ PrOpen (); /*initialize the Mac print manager*/ if (PrError () != noErr) goto error; PrintDefault (shellprintinfo.printhandle); /*set default print record*/ PrClose (); /*shouldn't leave print resources open all the time*/ if (!shellcheckprinterror (false)) goto error; # endif #endif #ifdef WIN95VERSION ZeroMemory (&shellprintinfo.pagesetupinfo, sizeof (PAGESETUPDLG)); shellprintinfo.pagesetupinfo.lStructSize = sizeof (PAGESETUPDLG); shellprintinfo.pagesetupinfo.hwndOwner = NULL; shellprintinfo.pagesetupinfo.Flags = PSD_RETURNDEFAULT | PSD_NOWARNING; if (! PageSetupDlg (&shellprintinfo.pagesetupinfo)) { if (CommDlgExtendedError() != 0) goto error; } #endif //#if !TARGET_API_MAC_CARBON shellcopyprintinfo (); /*copies fields from handle into record*/ //#endif return (true); #if !defined(MACVERSION) || !TARGET_API_MAC_CARBON error: #endif /* shelldisposeprintinfo (); */ return (false); } /*shellinitprint*/