+/* File: EinsteinDriver.cp Contains: Newton printer driver for the Einstein emulator. This is an implementation of the TDotPrinterDriver protocol. Copyright: (c)2022, Matthias Melcher, based on the Kodak sample printer driver included in the DDK © 1992-1994 by Apple Computer, Inc., all rights reserved.*/#ifndef __EINSTEINDRIVER_H #include "EinsteinDriver.impl.h" // **Master File Name** (.impl.h)#endif#ifndef __string_h #include "string.h"#endif#ifndef __stdio_h #include "stdio.h"#endif#ifndef __COMMMANAGERINTERFACE_H #include "CommManagerInterface.h"#endif#ifndef __COMMSERVICES_H #include "CommServices.h"#endif#ifndef __ENDPOINT_H #include "Endpoint.h"#endif#ifndef __SERIALOPTIONS_H #include "SerialOptions.h"#endif/* NATIVE_PRIM 0x0C01, PDNew NATIVE_PRIM 0x0C02, PDDelete NATIVE_PRIM 0x0C03, PDOpen NATIVE_PRIM 0x0C04, PDClose NATIVE_PRIM 0x0C05, PDOpenPage NATIVE_PRIM 0x0C06, PDClosePage NATIVE_PRIM 0x0C07, PDImageBand NATIVE_PRIM 0x0C08, PDCancelJob NATIVE_PRIM 0x0C09, PDIsProblemResolved NATIVE_PRIM 0x0C0A, PDGetPageInfo NATIVE_PRIM 0x0C0B, PDGetBandPrefs NATIVE_PRIM 0x0C0C, PDFaxEndPage*/extern "C" { void PDNew(DRIVERCLASSNAME *self); void PDDelete(DRIVERCLASSNAME *self); NewtonErr PDOpen(DRIVERCLASSNAME *self); NewtonErr PDClose(DRIVERCLASSNAME *self); NewtonErr PDOpenPage(DRIVERCLASSNAME *self); NewtonErr PDClosePage(DRIVERCLASSNAME *self); NewtonErr PDImageBand(DRIVERCLASSNAME *self, PixelMap* theBand, const Rect* minRect); void PDCancelJob(DRIVERCLASSNAME *self, Boolean asyncCancel); PrProblemResolution PDIsProblemResolved(DRIVERCLASSNAME *self); void PDGetPageInfo(DRIVERCLASSNAME *self, PrPageInfo* info); void PDGetBandPrefs(DRIVERCLASSNAME *self, DotPrinterPrefs* prefs); NewtonErr PDFaxEndPage(DRIVERCLASSNAME *self, long pageCount);}PROTOCOL_IMPL_SOURCE_MACRO(DRIVERCLASSNAME)/*----- Globals -----*/// IMPORTANT: LOADED PROTOCOLS MAY NOT HAVE GLOBALS// If you have driver-global data, it belongs in your object./*----- Driver Functions -----*//*----------------------------------------------------------------------------- NewtonErr Open(void) Initialize and Open the driver. Remember, if this call fails, no other calls will follow. So you must clean up anything you do here (especially allocations). -----------------------------------------------------------------------------*/NewtonErr DRIVERCLASSNAME::Open(void){ fAsyncIntf = nil; fCurrentError = noErr; // PRINT(("DRIVERCLASSNAME::Open")); { // check user-specified psuedo-driver RefVar routingSlip = fConnect->fConnectInfo; RefVar prRef = GetFrameSlot(routingSlip, SYM(printer)); RefVar modelRef = GetFrameSlot(prRef, SYM(prmodel)); fHWType = (EinsteinVersion) RINT(modelRef); } return PDOpen(this);}/*----------------------------------------------------------------------------- void Delete(void) Historical entry point. Probably shouldn't be used. -----------------------------------------------------------------------------*/void DRIVERCLASSNAME::Delete(void){ PDDelete(this);}/*----------------------------------------------------------------------------- NewtonErr Close(void) Close the driver. This call should follow this format: send final commands close connection cleanup allocations -----------------------------------------------------------------------------*/NewtonErr DRIVERCLASSNAME::Close(){ return PDClose(this);}/*----------------------------------------------------------------------------- NewtonErr OpenPage(void) Send any commands required to begin a new page. -----------------------------------------------------------------------------*/NewtonErr DRIVERCLASSNAME::OpenPage(){ return PDOpenPage(this);}/*----------------------------------------------------------------------------- NewtonErr ClosePage(void) Send any commands required to finish a page. -----------------------------------------------------------------------------*/NewtonErr DRIVERCLASSNAME::ClosePage(){ return PDClosePage(this);}/*----------------------------------------------------------------------------- NewtonErr ImageBand(PixelMap* theBand, const Rect* minBounds) -----------------------------------------------------------------------------*/NewtonErr DRIVERCLASSNAME::ImageBand(PixelMap* theBand, const Rect* minBounds){ return PDImageBand(this, theBand, minBounds);}/*----------------------------------------------------------------------------- void CancelJob(Boolean asyncCancel) Called by the print loop if we are going to early-abort a print job. The print loop will still call the appropriate close() calls. This just warns the driver that something fishy is going on. -----------------------------------------------------------------------------*/void DRIVERCLASSNAME::CancelJob(Boolean asyncCancel){ PDCancelJob(this, asyncCancel); return; }/*----------------------------------------------------------------------------- PrProblemResolution IsProblemResolved(void); Report on the possible resolution of the current problem or error. -----------------------------------------------------------------------------*/PrProblemResolution DRIVERCLASSNAME::IsProblemResolved(void){ return PDIsProblemResolved(this);}/*----------------------------------------------------------------------------- void GetPageInfo(PrPageInfo* result) -----------------------------------------------------------------------------*/void DRIVERCLASSNAME::GetPageInfo(PrPageInfo* result){ PrPageInfo dummy; dummy.printerDPI.x = Long2Fixed(300); dummy.printerDPI.y = Long2Fixed(300); dummy.printerPageSize.v = (Short) 10.375*300; dummy.printerPageSize.h = (Short) (2400); *result = dummy; PDGetPageInfo(this, result); return;}/*----------------------------------------------------------------------------- void GetBandPrefs(DotPrinterPrefs* result) -----------------------------------------------------------------------------*/void DRIVERCLASSNAME::GetBandPrefs(DotPrinterPrefs* result){ DotPrinterPrefs dummy; dummy.minBand = 50; // 50 because of 50 pin head dummy.optimumBand = 50; dummy.asyncBanding = false; dummy.wantMinBounds = true; *result = dummy; PDGetBandPrefs(this, result); return;}/*----------------------------------------------------------------------------- NewtonErr FaxEndPage(long pageCount) This method is used only by the fax driver. For all others, leave empty. -----------------------------------------------------------------------------*/NewtonErr DRIVERCLASSNAME::FaxEndPage(long pageCount){ return PDFaxEndPage(this, pageCount);}
0 commit comments