📄 context.cpp
字号:
*/ ps = psMandatoryPS; psError = WARN_ILLEGAL_PAPERSIZE; } } // in all other cases allow the change - even if it is the same thePaperSize = ps; bDoFullBleed = bFullBleed; unsigned int iRasterWidth = InputIsPageWidth ? 0 : InputWidth; err = setpixelsperrow (iRasterWidth, OutputWidth);/* * If we forced the requested papersize to the mandatory papersize, return a warning */ if (err == NO_ERROR && psError != NO_ERROR) { return WARN_ILLEGAL_PAPERSIZE; }/* * App is requesting full-bleed printing */ if (err == NO_ERROR && bFullBleed) { float x; FullbleedType fbType;// Does this printer support full-bleed printing if (!(thePrinter->FullBleedCapable (ps, &fbType, &x, &x))) return WARN_FULL_BLEED_UNSUPPORTED;// Media with tear-off tab can do full-bleed on all 4 sides if (fbType == fullbleedNotSupported) { return WARN_FULL_BLEED_UNSUPPORTED; } else if (fbType == fullbleed3EdgeAllMedia) { return WARN_FULL_BLEED_3SIDES; } else if (fbType == fullbleed3EdgeNonPhotoMedia) // Treat non photo case as all media { return WARN_FULL_BLEED_3SIDES; } else if (fbType == fullbleed3EdgePhotoMedia) { return WARN_FULL_BLEED_3SIDES_PHOTOPAPER_ONLY; } else if (fbType == fullbleed4EdgePhotoMedia) { return WARN_FULL_BLEED_PHOTOPAPER_ONLY; } else if (fbType == fullbleed4EdgeAllMedia) { return NO_ERROR; } else if (fbType == fullbleed4EdgeNonPhotoMedia) // Treat non photo case as all media { return NO_ERROR; } } return err;} //SetPaperSizePAPER_SIZE PrintContext::GetPaperSize(){ return thePaperSize;} //GetPaperSize/*!This method returns the currently selected device. A device is selectedimplicitly in the constructor if bi-directional communication is working.SelectDevice() is used with unidirectional communication, or to override theimplicit selection.\return PRINTER_TYPE Returns UNSUPPORTED if no Printer has been selected,either implicitly or explicitly.*/PRINTER_TYPE PrintContext::SelectedDevice(){ if (thePrinter == NULL) { return UNSUPPORTED; } return (PRINTER_TYPE)DR->device;} //SelectedDevice/*!Returns the model portion of the firmware ID string from the printer.*/const char* PrintContext::PrinterModel(){ if ((pSS == NULL) || (thePrinter == NULL)) { return (const char*)NULL; } return pSS->strModel;} //PrinterModel/*!Returns a string representing the printer model family signified by the parameter.*/const char* PrintContext::PrintertypeToString( PRINTER_TYPE pt){ return ModelName[pt];} //PrintertypeToString/*!Used outside the context of a job.For use when pre-formatted data is available from an external source.*/DRIVER_ERROR PrintContext::SendPrinterReadyData( BYTE* stream, unsigned int size){ if (stream == NULL) { return NULL_POINTER; } if (thePrinter == NULL) { return NO_PRINTER_SELECTED; } return thePrinter->Send(stream, size);} //SendPrinterReadyData/*!Used outside the context of a job.Flushes data in the printer's input buffer to prepare for new data stream.*/void PrintContext::Flush( int FlushSize){ if(thePrinter != NULL) { thePrinter->Flush(FlushSize); }} //Flush/*!\internalReturns number of pages the device has printed. Not for this job, but fromfirmware counts in the printer. Only supported on printers that keep track ofpages printed. Default is to return UNSUPPORTED_FUNCTION.*/DRIVER_ERROR PrintContext::PagesPrinted( unsigned int& count){ if (thePrinter == NULL) { return NO_PRINTER_SELECTED; // matches result when printer doesn't keep counter } return thePrinter->PagesPrinted(count);} //PagesPrinted/*!This is the method for use to check if the printer support a separate 1 bit black channel*/BOOL PrintContext::SupportSeparateBlack(){ if (thePrinter == NULL || CurrentMode == NULL) { return FALSE; } else { if (CurrentMode->dyeCount == 3 || CurrentMode->dyeCount == 6) { return FALSE; } else { return thePrinter->SupportSeparateBlack(); } }}#ifdef APDK_AUTODUPLEX/*!Request a duplexing mode if supported in current printer in current mode.*/BOOL PrintContext::SelectDuplexPrinting( DUPLEXMODE duplexmode){ if (thePrinter == NULL || CurrentMode == NULL) { return FALSE; } if (!CurrentMode->bDuplexCapable) { return FALSE; } CurrentMode->SetDuplexMode (duplexmode); return TRUE;} //SelectDuplexPrinting/*!Determine what duplexing mode is currently selected.*/DUPLEXMODE PrintContext::QueryDuplexMode (){ if (thePrinter == NULL || CurrentMode == NULL) { return DUPLEXMODE_NONE; } return CurrentMode->QueryDuplexMode ();} //QueryDuplexMode/*!Determine if the selected printer requires rasters to be rotated by 180 degreesfor printing on the back side in a duplex job.*/BOOL PrintContext::RotateImageForBackPage (){ if (thePrinter == NULL) return TRUE; return thePrinter->RotateImageForBackPage ();}#endif#ifdef APDK_EXTENDED_MEDIASIZE/*!Set custom paper size physical width and height in inches. Used with custom paper size only.*/BOOL PrintContext::SetCustomSize (float width, float height){ CustomWidth=width; CustomHeight=height; return NO_ERROR;}#endif //APDK_EXTENDED_MEDIASIZEunsigned int PrintContext::GUITopMargin(){ // we take the hard unprintable top to be .04 (see define in Header.cpp) // so here start out at 1/3"-.04" = 88 if dpi=300 // // Changed 1/3" top margin to 1/8", 1/8"-.04" = 25.5 if dpi=300. des // symmetrical top and bottom margin of 0.5 inch in duplex mode#ifdef APDK_AUTODUPLEX if (CurrentMode->QueryDuplexMode () != DUPLEXMODE_NONE) { return 138 * (EffectiveResolutionY() / 300); /* .5" */ }#endif return 26 * (EffectiveResolutionY() / 300);} //GUITopMargin/*PEN_TYPE PrintContext::GetCompatiblePen( unsigned int num){ if ((thePrinter == NULL) || (num >= MAX_COMPATIBLE_PENS)) { return DUMMY_PEN; } return thePrinter->CompatiblePens[num];} //GetCompatiblePen*/DRIVER_ERROR PrintContext::QualitySieve( ModeSet*& Modes, QUALITY_MODE& eQuality){ ModeSet* tempModeSet = Modes->QualitySubset(eQuality); if (tempModeSet == NULL) { return ALLOCMEM_ERROR; } if (tempModeSet->IsEmpty()) // failed #1 { delete tempModeSet; eQuality = QUALITY_NORMAL; // change requested quality tempModeSet = Modes->QualitySubset(eQuality); if (tempModeSet == NULL) { return ALLOCMEM_ERROR; } if (tempModeSet->IsEmpty()) // failed #2 -- just get something { delete tempModeSet; tempModeSet = Modes->Head(); if (tempModeSet == NULL) { return ALLOCMEM_ERROR; } if (tempModeSet->IsEmpty()) { delete tempModeSet; return SYSTEM_ERROR; } eQuality = tempModeSet->HeadPrintMode()->GetQualityMode(); } } delete Modes; Modes=tempModeSet; return NO_ERROR;} //QualitySieveDRIVER_ERROR PrintContext::SetCompGrayMode( PrintMode*& resPM){ DRIVER_ERROR err; ColorMatcher* pColorMatcher; uint32_t* graymap = (uint32_t*)pSS->AllocMem(sizeof(uint32_t)*9*9*9); if (graymap==NULL) { return ALLOCMEM_ERROR; } ColorMap cm; cm.ulMap1 = thePrinter->CMYMap; if (cm.ulMap1==NULL) { return SYSTEM_ERROR; } cm.ulMap2 = NULL; PEN_TYPE pen = thePrinter->ActualPens(); unsigned int numinks; if (pen == COLOR_PEN) { numinks = 3; } else { numinks = 4; // even for MDL_BOTH, 4 is still enough } pColorMatcher = Create_ColorMatcher(pSS, cm,numinks, OutputWidth); err = pColorMatcher->MakeGrayMap(thePrinter->CMYMap, graymap); delete pColorMatcher; pColorMatcher = NULL; ERRCHECK; // possible return here if (pen == COLOR_PEN) { resPM = new CMYGrayMode(graymap); } else { resPM = new KCMYGrayMode(graymap); } if (resPM == NULL) { return ALLOCMEM_ERROR; }// resPM->myIndex = MAX_PRINTMODES; if (pen == COLOR_PEN) { resPM->bFontCapable = FALSE; } // make myIndex the last one in the list resPM->myIndex = thePrinter->GetModeCount();/* * [K]CMYGrayMode sets all resolution to 300 and quality to normal. * Some printers, eg., Broadway, is 600 dpi in black and has bitdepth of 2. * So, we cannot use normal mode for these printers and must set quality to * draft. * This is also true for 8x5 in one pen mode. * Anyway, here, pen is both_pens or color_pen only. */ PrintMode *pPM = thePrinter->GetMode (DEFAULTMODE_INDEX);// if (pen != COLOR_PEN && pPM->ResolutionX[K] != 300) if (pPM->ResolutionX[K] != 300) { resPM->theQuality = qualityDraft; resPM->pmQuality = QUALITY_DRAFT; }/* * Some printers do not use any data compression. Ex. Crossbow * So, turn off the bCompress flag in such cases. */ resPM->Config.bCompress = pPM->Config.bCompress;#ifdef APDK_AUTODUPLEX resPM->bDuplexCapable = thePrinter->bDuplexCapable;#endif return NO_ERROR;} //SetCompGrayMode// SetMediaSource//! Select input media source bin/*!Used to set the bin number from which media will be loaded by the printer. Thisis relevant for those printers that have multiple input bins. All other printerswill ignore the bin number. The typical bin numbers are 1 - Upper Tray 4 - Lower Tray 5 - Duplexer Hagaki Feed 7 - Auto SelectAny value between 1 and 50 is valid where there are more than 2 trays.******************************************************************************/DRIVER_ERROR PrintContext::SetMediaSource( MediaSource num //!< Bin Number){ if ((num > sourceTrayMax) || (num < sourceTrayMin)) return WARN_INVALID_MEDIA_SOURCE; m_MediaSource = num; if (thePrinter != NULL) { BOOL bQueryHagakiTray = TRUE; if (num == sourceDuplexerNHagakiFeed && !thePrinter->HagakiFeedPresent(bQueryHagakiTray)) { m_MediaSource = sourceTrayAuto; } } return NO_ERROR;}unsigned int PrintContext::GetCurrentDyeCount(){ return CurrentMode->dyeCount; }PEN_TYPE PrintContext::GetDefaultPenSet(){ if (thePrinter==NULL) return NO_PEN; return thePrinter->DefaultPenSet();}PEN_TYPE PrintContext::GetInstalledPens(){ if(!thePrinter) return NO_PEN; return thePrinter->ePen;}APDK_END_NAMESPACE
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -