⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 context.cpp

📁 HP喷墨打印机驱动代码 HP内部资料! 珍贵 珍贵 珍贵
💻 CPP
📖 第 1 页 / 共 4 页
字号:
                eColorMode = COLOR;            }        }        else        {            return SYSTEM_ERROR;        }        tempModeSet = Modes->ColorCompatibleSubset(eColorMode);        if (tempModeSet == NULL)        {            return ALLOCMEM_ERROR;        }    }    delete Modes;    if(tempModeSet->IsEmpty())    {        delete tempModeSet;        return SYSTEM_ERROR;    }    Modes = tempModeSet;    tempModeSet = NULL;    // set is nonempty because every printer has virtual    // black and composite-black modes in addition to some kind of color    /// note: this order accords with the decision that text-support trumps quality;    ///       to make quality trump fonts, move quality-selection code here    // rule out gui-only if devicetext requested    if (bDeviceText)    {        tempModeSet = Modes->FontCapableSubset();        if (tempModeSet == NULL)        {            return ALLOCMEM_ERROR;        }        if (tempModeSet->IsEmpty())        {            delete tempModeSet;            tempModeSet = NULL;            bDeviceText = FALSE;  // change value of reference parameter        }        else    // we found font-capable modes        {            delete Modes;            Modes = tempModeSet;            tempModeSet = NULL;        }    }    // find best fit for quality setting    // 1. look for exact match    // 2. if not, look for normal    // 3. if not, use anything    oldModeSet = new ModeSet(Modes);    // remember in case of media mismatch    if (oldModeSet == NULL)    {        return ALLOCMEM_ERROR;    }    // find best fit for quality    err = QualitySieve(Modes, eQuality);    // this changes Modes list    ERRCHECK;    // check compatibility of quality and media    // note: this implementation assumes media trumps quality    //  to make quality trump media, then don't let mediatest whittle down to nothing    tempModeSet = Modes->MediaSubset(eMedia);    if (tempModeSet == NULL)    {        return ALLOCMEM_ERROR;    }    if (tempModeSet->IsEmpty())    {   // try changing quality to fit media        delete tempModeSet;        // we are retrieving oldModeSet, saved before quality sieve        tempModeSet = oldModeSet->MediaSubset(eMedia);        if (tempModeSet == NULL)        {            return ALLOCMEM_ERROR;        }        if (tempModeSet->IsEmpty())        // there was never a mode that matched media, so change media        {            delete tempModeSet;            eMedia = Modes->HeadPrintMode()->GetMediaType();        }        else    // we found modes with the specified mediatype        {            eQuality = tempModeSet->HeadPrintMode()->GetQualityMode();            delete Modes;            Modes = tempModeSet;            // but now we may have to apply quality test again            if (Modes->Size() > 1)            {                err = QualitySieve(Modes,eQuality); // changes modes                ERRCHECK;            }        }    }    else // we found modes with specified mediatype    {        delete Modes;        Modes = tempModeSet;    }    delete oldModeSet;    // because there are no printers having multiple modes with    // all 4 parameters the same, we are down to a single result    // (check this!)    if (Modes->Size() != 1)    {        ASSERT(0);                  // this is is not supposed to happen        return SYSTEM_ERROR;    }    CurrentMode = Modes->HeadPrintMode();    if (CurrentMode == tmpPM)    {        MadeCompGrayMode=TRUE;  // remember to delete it in PC destructor    }    delete Modes;    //need to make sure that print context checks to see if size of image is ok for paper we want to use DWK    unsigned int    iRasterWidth = InputIsPageWidth ? 0 : InputWidth;    err = setpixelsperrow(iRasterWidth, OutputWidth);    if(err != NO_ERROR)    {        return err;    }//end if    // return warning if any of the first 3 params changed,    // or if text was requested but not available    if ((requestedColor != eColorMode) ||        (((requestedMedia != eMedia) ||        (requestedQuality != eQuality)) && CurrentMode->medium != mediaAuto) ||        (requestedText && !bDeviceText))    {        return WARN_MODE_MISMATCH;    }	return NO_ERROR;} //SelectPrintMode//GetPrintModeSettings//! Returns pointer to print mode settings/*!Used to determine the currently selected print mode.  Print mode could bedifferent then requested values in SelectePrintMode because the printer maynot be able to support the requested combination.  In that case thePrintContext will make an intelegent choice about changing the print mode.This method can be used to determin the differences between the requested modeand the selected mode.******************************************************************************/DRIVER_ERROR PrintContext::GetPrintModeSettings(    QUALITY_MODE& eQuality,          //!< Quality of output: DRAFT, NORMAL, BEST    MEDIATYPE& eMedia,               //!< Media type: PLAIN, PREMIUM, PHOTO    COLORMODE& eColorMode,           //!< Color Mode: GREY_K, GREY_CMY, COLOR    BOOL& bDeviceText                //!< Support Device Text: TRUE, FALSE){    if (CurrentMode == NULL)    {        return SYSTEM_ERROR;    }    else    {        CurrentMode->GetValues(eQuality, eMedia, eColorMode, bDeviceText);    }    return NO_ERROR;} //GetPrintModeSettings/*!Sets the pen set to be used (much match what is actually in the printer).For use in uni-di mode.*/DRIVER_ERROR PrintContext::SetPenSet(    PEN_TYPE ePen){    if (thePrinter == NULL)    {        return NO_PRINTER_SELECTED;    }    return thePrinter->SetPens(ePen);} //SetPenSetBOOL PrintContext::ModeAgreesWithHardware(    BOOL QueryPrinter)// no check for null printer{    BOOL agree = FALSE;    PEN_TYPE ePen;/*    This should not be nessesarry any more.  Each printer class now has a    DefaultPenSet method that sets the pens to what the printer is shipped    with for the unidi case. If that method has been called (which it should    be in the unidi case then ModeAgreesWithHardware will work properly.    Dave S. discovered this does not work yet so we must leave this here until    another version and we are sure it works for unidi mode. - JLM*/    if (pSS->IOMode.bDevID == FALSE)    {        return TRUE;    }    if (thePrinter->ParsePenInfo(ePen,QueryPrinter) == NO_ERROR)    {        for (int i = 0; i < MAX_COMPATIBLE_PENS; i++)        {            if (ePen == CurrentMode->CompatiblePens[i])            {                agree = TRUE;            }        }    }    return agree;} //ModeAgreesWithHardwareBOOL PrintContext::PhotoTrayPresent(    BOOL bQueryPrinter){    if (thePrinter == NULL)    {        return FALSE;    }    else    {        return thePrinter->PhotoTrayPresent (bQueryPrinter);    }} //PhotoTrayPresent//! Return current status of PhotoTray - can be UNKNOWN, ENGAGED or DISENGAGED/*!******************************************************************************/PHOTOTRAY_STATE PrintContext::PhotoTrayEngaged(    BOOL bQueryPrinter){    if (thePrinter == NULL)    {        return DISENGAGED;    }    else    {        return thePrinter->PhotoTrayEngaged (bQueryPrinter);    }} //PhotoTrayEngaged//! Returns TRUE if a hagaki feed is present in printer.BOOL PrintContext::HagakiFeedPresent(BOOL bQueryPrinter){    if (thePrinter == NULL)    {        return FALSE;    }    else    {        return thePrinter->HagakiFeedPresent(bQueryPrinter);    }}#ifdef APDK_AUTODUPLEX//!Returns TRUE if duplexer and hagaki feed (combined) unit is present in printer.BOOL PrintContext::HagakiFeedDuplexerPresent(BOOL bQueryPrinter){    if (thePrinter == NULL)    {        return FALSE;    }    else    {        return thePrinter->HagakiFeedDuplexerPresent(bQueryPrinter);    }}#endif//~PrintContext//! Destroy the print device context/*!******************************************************************************/PrintContext::~PrintContext(){#ifdef APDK_CAPTURECapture_dPrintContext();#endifDBG1("deleting PrintContext\n");    if (thePrinter)    {        delete thePrinter;    }    if (MadeCompGrayMode)    {        pSS->FreeMem((BYTE*)CurrentMode->cmap.ulMap1);        delete CurrentMode;    }} //~PrintContext///////////////////////////////////////////////////////////////////////// Functions to report on device-dependent properties.// Note that mixed-case versions of function names are used// for the client API; lower-case versions are for calls// made by the driver itself, to avoid the APDK_CAPTURE instrumentation./////////////////////////////////////////////////////////////////////////! Retrieves information about the physical width of the currently selected paper size.float PrintContext::PhysicalPageSizeX()   // returned in inches{    if (thePrinter == NULL)    {        return 0.0;    }    float   xOverSpray, yOverSpray;	FullbleedType    fbType;#ifdef APDK_EXTENDED_MEDIASIZE    float PhysicalPageX = (thePaperSize == CUSTOM_SIZE) ? CustomWidth : PSM[thePaperSize].fPhysicalPageX;#else    float PhysicalPageX = PSM[thePaperSize].fPhysicalPageX;#endif    if (bDoFullBleed && (thePrinter->FullBleedCapable (thePaperSize, &fbType, &xOverSpray, &yOverSpray)))    {        return (PhysicalPageX + xOverSpray);    }    return PhysicalPageX;} //PhysicalPageSizeX//! Retrieves information about the physical height of the currently selected paper size.float PrintContext::PhysicalPageSizeY()   // returned in inches{    if (thePrinter == NULL)    {        return 0.0;    }    float   xOverSpray, yOverSpray;	FullbleedType   fbType;#ifdef APDK_EXTENDED_MEDIASIZE    float PhysicalPageY = (thePaperSize == CUSTOM_SIZE) ? CustomHeight : PSM[thePaperSize].fPhysicalPageY;#else    float PhysicalPageY = PSM[thePaperSize].fPhysicalPageY;#endif    if (bDoFullBleed && (thePrinter->FullBleedCapable (thePaperSize, &fbType, &xOverSpray, &yOverSpray)))    {        return (PhysicalPageY + yOverSpray);    }    return PhysicalPageY;} //PhysicalPageSizeY//! Returns width of printable region in inches.float PrintContext::PrintableWidth()    // returned in inches// for external use{    return printablewidth();} //PrintableWidth/////////////////////////////////////////////////////////////////////// NOTE ON RESOLUTIONS: These functions access ResolutionX[C],//  where C is the conventional index for Cyan. The assumption//  is that Res[C]=Res[M]=Res[Y], AND that Res[K]>=Res[C]/////////////////////////////////////////////////////////////////////float PrintContext::printablewidth()// for internal use{    if (thePrinter == NULL)    {        return 0.0;    }    float   xOverSpray, yOverSpray;	FullbleedType  fbType;#ifdef APDK_EXTENDED_MEDIASIZE    float PhysicalPageX = (thePaperSize == CUSTOM_SIZE) ? CustomWidth : PSM[thePaperSize].fPhysicalPageX;    float PrintablePageX = (thePaperSize == CUSTOM_SIZE) ? CustomWidth - (0.25+0.25) : PSM[thePaperSize].fPrintablePageX;#else    float PhysicalPageX = PSM[thePaperSize].fPhysicalPageX;    float PrintablePageX = PSM[thePaperSize].fPrintablePageX;#endif    if (bDoFullBleed && (thePrinter->FullBleedCapable (thePaperSize, &fbType, &xOverSpray, &yOverSpray)))    {        return (PhysicalPageX + xOverSpray);    }    float   fMargins[4];    // Left, Right, Top, Bottom margin values    if (!(thePrinter->GetMargins (thePaperSize, fMargins)))    {        return PrintablePageX;    }    return (PhysicalPageX - (fMargins[0] + fMargins[1]));} //printablewidth//! Returns height of printable region in inches.float PrintContext::PrintableHeight()     // returned in inches// for external use{    return printableheight();} //PrintableHeightfloat PrintContext::printableheight()// for internal use{    if (thePrinter == NULL)    {        return 0.0;    }/* *  Full bleed printing will be possible only on 3 sides for those media *  that do not have a tear-off tab. Currently, 4x6 and A6 are the only two *  media sizes that can have tear-off tab. So, for all the media that do not *  have a tear-off tab at the bottom, physical height is unaltered, but printable *  height is less by bottom margin. *  1/22/03 SY.  *  Starting from MalibuPlus, 4-edge full bleed is possible for most media.  A check *  for 4-edge full bleed capability is needed. */    float   xOverSpray, yOverSpray;	FullbleedType   fbType;#ifdef APDK_EXTENDED_MEDIASIZE    float PhysicalPageY = (thePaperSize == CUSTOM_SIZE) ? CustomHeight : PSM[thePaperSize].fPhysicalPageY;    float PrintablePageY = (thePaperSize == CUSTOM_SIZE) ? CustomHeight - (0.125+0.5) : PSM[thePaperSize].fPrintablePageY;#else    float PhysicalPageY = PSM[thePaperSize].fPhysicalPageY;    float PrintablePageY = PSM[thePaperSize].fPrintablePageY;#endif    if (bDoFullBleed  && (thePrinter->FullBleedCapable (thePaperSize, &fbType, &xOverSpray, &yOverSpray)))    {		if (fbType == fullbleed3EdgeAllMedia || 			fbType == fullbleed3EdgeNonPhotoMedia || 			fbType == fullbleed3EdgePhotoMedia)			return (PhysicalPageY - (float) 0.5);		else if (fbType == fullbleed4EdgePhotoMedia || 			     fbType == fullbleed4EdgeNonPhotoMedia || 				 fbType == fullbleed4EdgeAllMedia)			return (PhysicalPageY + yOverSpray);		else			return (PhysicalPageY - (float) 0.5);    }/* *  REVISIT: *  The paper size metrics table assumes a bottom margin of 0.5 inch. *  But bottom margin on 6xx based printers is a little larger, ~0.58 inch. *  We should do per-printer get bottom margin/left margin to adjust printable height *  and printable width. * *  (Note, a 0.67 inch bottom margin is now in GetMargins() for 6xx based printers. des) */    float   fMargins[4];    // Left, Right, Top, Bottom margin values    if (!(thePrinter->GetMargins (thePaperSize, fMargins)))    {        return PrintablePageY;    }    return (PhysicalPageY - (fMargins[2] + fMargins[3]));} //printableheight

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -