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

📄 djgenericvip.cpp

📁 HP喷墨打印机驱动代码 HP内部资料! 珍贵 珍贵 珍贵
💻 CPP
字号:
/*****************************************************************************\  djgenericvip.cpp : Implimentation for the generic VIP class  Copyright (c) 2001-2002, Hewlett-Packard Co.  All rights reserved.  Redistribution and use in source and binary forms, with or without  modification, are permitted provided that the following conditions  are met:  1. Redistributions of source code must retain the above copyright     notice, this list of conditions and the following disclaimer.  2. Redistributions in binary form must reproduce the above copyright     notice, this list of conditions and the following disclaimer in the     documentation and/or other materials provided with the distribution.  3. Neither the name of Hewlett-Packard nor the names of its     contributors may be used to endorse or promote products derived     from this software without specific prior written permission.  THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN  NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED  TO, PATENT INFRINGEMENT; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS  OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\*****************************************************************************/#if defined(APDK_DJGENERICVIP) && defined (APDK_DJ9xxVIP)#include "header.h"#include "dj9xxvip.h"#include "djgenericvip.h"#include "printerproxy.h"APDK_BEGIN_NAMESPACE/* *  All VIP printers that are released after the APDK release. *  This subclass is mainly there to allow any combination of *  installed pens. */DJGenericVIP::DJGenericVIP (SystemServices* pSS, BOOL proto)    : DJ9xxVIP (pSS, proto){    if (!proto && IOMode.bDevID)    {        bCheckForCancelButton = TRUE;        constructor_error = VerifyPenInfo ();        CERRCHECK;    }    else        ePen = BOTH_PENS;/* *  For this printer class, allow any print mode to be compatible with *  any installed pen set. Printer is expected to do the right thing. *  Also, language has to be PCL3GUI because some printers may not work *  properly in plain PCL3 mode. ex. PhotoSmart 1xx family. This means *  no device text support. */    for (int i = 0; i < (int) ModeCount; i++)    {        pMode[i]->bFontCapable = FALSE;        for (int j = BLACK_PEN; j < MAX_COMPATIBLE_PENS; j++)        {            pMode[i]->CompatiblePens[j] = (PEN_TYPE) j;        }    }}BOOL DJGenericVIP::UseGUIMode (PrintMode* pPrintMode){    return TRUE;}/* *  We don't really know beforehand the largest papersize the attached printer *  can support. The first reserved nibble after the VIP flag nibble contains *  this information. Only firmware version 4 or greater support this feature. */PAPER_SIZE DJGenericVIP::MandatoryPaperSize (){    BYTE    sDevIdStr[DevIDBuffSize];    char    *pStr;/* *  Try to get the DevID. Advance the pointer to the beginning of the status field. *  Currently, only 3 lower bits are used for reporting paper size. Meaning of these *  bit-values is as follows: *      000 - Allow any size *      001 - A6 *      010 - Letter *      011 - B4 *      100 - 13 X 19 size */    if (IOMode.bDevID && ((pSS->GetDeviceID (sDevIdStr, DevIDBuffSize, TRUE)) == NO_ERROR))    {        if ((pStr = strstr ((char *) sDevIdStr, ";S:")) && (pSS->GetVIPVersion ()) >= 3)        {#ifdef APDK_EXTENDED_MEDIASIZE			PAPER_SIZE  PaperSizes[8] = {UNSUPPORTED_SIZE, A6, LETTER, B4, SUPERB_SIZE, UNSUPPORTED_SIZE, UNSUPPORTED_SIZE, UNSUPPORTED_SIZE};#else            PAPER_SIZE  PaperSizes[8] = {UNSUPPORTED_SIZE, A6, LETTER, B4, UNSUPPORTED_SIZE, UNSUPPORTED_SIZE, UNSUPPORTED_SIZE, UNSUPPORTED_SIZE};#endif			char  byte12 = pStr[17];			short value = (byte12 >= '0' && byte12 <= '9') ? byte12 - '0' : 					  ((byte12 >= 'A' && byte12 <= 'F') ? byte12 - 'A' + 10 :					  ((byte12 >= 'a' && byte12 <= 'f') ? byte12 - 'a' + 10 : -1));			return (value == -1) ? UNSUPPORTED_SIZE : PaperSizes[(value & 0x07)];		}    }    return UNSUPPORTED_SIZE;} //MandantoryPaperSize/** byte 13 - indicates full bleed (to every edge of paper) is supported if * the modifier bit in the lowest position is "set".  ** 0000b or 0h = Unimplemented, or not specified.* 0001b or 1h = Full bleed (4 edge) printing supported on photo quality papers; this field is a modifier upon the bits in byte 12. That is, if this bit is set, it implies that the "max print width supported" values and smaller widths, ALL support full bleed, 4 edge, printing on photo quality paper.* 0010b or 2h = Full bleed (4 edge) printing supported on non-photo papers (e.g. plain, bond, etc.); this field is a modifier upon the bits in byte 12. If this bit is set, it implies that the "max print width supported" values and smaller widths, all support full bleed, 4 edge, printing on non-photo paper.* nn00b  = The "nn" bits are reserved for future definitions*/BOOL DJGenericVIP::FullBleedCapable (PAPER_SIZE ps, FullbleedType  *fbType, float *xOverSpray, float *yOverSpray,                                     float *fLeftOverSpray, float *fTopOverSpray){    BYTE    sDevIdStr[DevIDBuffSize];    char    *pStr;    if (IOMode.bDevID && ((pSS->GetDeviceID (sDevIdStr, DevIDBuffSize, TRUE)) == NO_ERROR))    {        if ((pStr = strstr ((char *) sDevIdStr, ";S:")) && (pSS->GetVIPVersion ()) >= 3)        {			char  byte13 = pStr[18];			short value = (byte13 >= '0' && byte13 <= '9') ? byte13 - '0' : 					  ((byte13 >= 'A' && byte13 <= 'F') ? byte13 - 'A' + 10 :					  ((byte13 >= 'a' && byte13 <= 'f') ? byte13 - 'a' + 10 : -1));			switch (ps)			{				case PHOTO_SIZE:				case A6:				case CARD_4x6:				case OUFUKU:				case HAGAKI:				case A6_WITH_TEAR_OFF_TAB:				{					*xOverSpray = (float) 0.12;					*yOverSpray = (float) 0.06;					if (fLeftOverSpray)						*fLeftOverSpray = (float) 0.05;					if (fTopOverSpray)						*fTopOverSpray  = (float) 0.03;					if (ps == PHOTO_SIZE || ps == A6_WITH_TEAR_OFF_TAB)						*fbType = fullbleed4EdgeAllMedia;					else if ((value != -1) && ((value & 0x03) == 0x03))						*fbType = fullbleed4EdgeAllMedia;					else if ((value != -1) && ((value & 0x01) == 0x01))						*fbType = fullbleed4EdgePhotoMedia;					else if ((value != -1) && ((value & 0x02) == 0x02))						*fbType = fullbleed4EdgeNonPhotoMedia;					else						*fbType = fullbleed3EdgeAllMedia;					return TRUE;				}				default:					break;			}			if ((value != -1) && (value & 0x03))			{				*xOverSpray = (float) 0.216;				*yOverSpray = (float) 0.149;				if (fLeftOverSpray)					*fLeftOverSpray = (float) 0.098;				if (fTopOverSpray)					*fTopOverSpray  = (float) 0.051;				if ((value & 0x03) == 0x03)					*fbType = fullbleed4EdgeAllMedia;				else if ((value & 0x01) == 0x01)					*fbType = fullbleed4EdgePhotoMedia;				else if ((value & 0x02) == 0x02)					*fbType = fullbleed4EdgeNonPhotoMedia;				return TRUE; 			}			else			{				*xOverSpray = (float) 0;				*yOverSpray = (float) 0;				if (fLeftOverSpray)					*fLeftOverSpray = (float) 0;				if (fTopOverSpray)					*fTopOverSpray  = (float) 0;				*fbType = fullbleedNotSupported;				return FALSE;			}        }    }	switch (ps)	{		case PHOTO_SIZE:		case A6:		case CARD_4x6:		case OUFUKU:		case HAGAKI:		case A6_WITH_TEAR_OFF_TAB:		{			*xOverSpray = (float) 0.12;			*yOverSpray = (float) 0.06;			if (fLeftOverSpray)				*fLeftOverSpray = (float) 0.05;			if (fTopOverSpray)				*fTopOverSpray  = (float) 0.03;			if (ps == PHOTO_SIZE || ps == A6_WITH_TEAR_OFF_TAB)				*fbType = fullbleed4EdgeAllMedia;			else				*fbType = fullbleed3EdgeAllMedia;			return TRUE;		}		default:			break;	}    *xOverSpray = (float) 0;    *yOverSpray = (float) 0;    if (fLeftOverSpray)        *fLeftOverSpray = (float) 0;    if (fTopOverSpray)        *fTopOverSpray  = (float) 0;	*fbType = fullbleedNotSupported;    return FALSE;}PHOTOTRAY_STATE DJGenericVIP::PhotoTrayEngaged (BOOL bQueryPrinter){    return UNKNOWN;}//! Returns TRUE if a hagaki feed is present in printer.BOOL DJGenericVIP::HagakiFeedPresent(BOOL bQueryPrinter) {    DRIVER_ERROR err;    char* pStr;    BYTE bDevIDBuff[DevIDBuffSize];    if (!IOMode.bDevID)    {        bQueryPrinter = FALSE;    }    err = pSS->GetDeviceID(bDevIDBuff, DevIDBuffSize, bQueryPrinter);    if (err!=NO_ERROR)    {        return 0;    }    if ( (pStr=(char *)strstr((const char*)bDevIDBuff+2,";S:")) == NULL )    {        return 0;    }    // skip over ";S:<version=2bytes><topcover><inklid><duplexer>"    pStr += 8;    BYTE b = *pStr;    return (b & 4 == 4);}#ifdef APDK_AUTODUPLEX//!Returns TRUE if duplexer and hagaki feed (combined) unit is present in printer.BOOL DJGenericVIP::HagakiFeedDuplexerPresent(BOOL bQueryPrinter){    DRIVER_ERROR err;    char* pStr;    BYTE bDevIDBuff[DevIDBuffSize];    if (!IOMode.bDevID)    {        bQueryPrinter = FALSE;    }    err = pSS->GetDeviceID(bDevIDBuff, DevIDBuffSize, bQueryPrinter);    if (err!=NO_ERROR)    {        return 0;    }    if ( (pStr=(char *)strstr((const char*)bDevIDBuff+2,";S:")) == NULL )    {        return 0;    }    // skip over ";S:<version=2bytes><topcover><inklid>"    pStr += 6;    BYTE b = *pStr;    return (b & 4 == 4);}#endifDRIVER_ERROR DJGenericVIP::VerifyPenInfo (){    DRIVER_ERROR err = NO_ERROR;    if (IOMode.bDevID == FALSE)        return err;    ePen = NO_PEN;    err = ParsePenInfo (ePen);    if(err == UNSUPPORTED_PEN) // probably Power Off - pens couldn't be read    {        // have to delay for Broadway or the POWER ON will be ignored        if (pSS->BusyWait ((DWORD) 2000) == JOB_CANCELED)        {            return JOB_CANCELED;        }        DWORD length = sizeof (Venice_Power_On);        err = pSS->ToDevice (Venice_Power_On, &length);        ERRCHECK;        err = pSS->FlushIO ();        ERRCHECK;        // give the printer some time to power up        if (pSS->BusyWait ((DWORD) 2500) == JOB_CANCELED)        {            return JOB_CANCELED;        }        err = ParsePenInfo (ePen);    }    ERRCHECK;/* *  If one or more pens are not installed, check the device id for ReserveMode *  capability for this printer. This info in in the flags nibble *  ;S:<XX><toplid><supplylic><duplexer><phototray><in-1><in-2><banner><flags> *  flags : x1xx - reserve mode supported, x0xx - not supported */    BYTE    sDevIdStr[DevIDBuffSize];    char    *pStr;    BOOL    bNeedAllPens = FALSE;    if (iNumMissingPens > 0 && ((pSS->GetDeviceID (sDevIdStr, DevIDBuffSize, FALSE)) == NO_ERROR))    {        if ((pStr = strstr ((char *) sDevIdStr, ";S:")))        {			char  byte7 = pStr[12];			short value = (byte7 >= '0' && byte7 <= '9') ? byte7 - '0' :                       ((byte7 >= 'A' && byte7 <= 'F') ? byte7 - 'A' + 10 :                      ((byte7 >= 'a' && byte7 <= 'f') ? byte7 - 'a' + 10 : 0));			bNeedAllPens = !(value & 0x04);        }    }    while (ePen == NO_PEN || (bNeedAllPens && iNumMissingPens > 0))    {        if (ePen == NO_PEN || iNumMissingPens > 0)        {            pSS->DisplayPrinterStatus (DISPLAY_NO_PENS);            if (pSS->BusyWait (500) == JOB_CANCELED)            {                return JOB_CANCELED;            }        }        err =  ParsePenInfo (ePen);        ERRCHECK;    }    pSS->DisplayPrinterStatus(DISPLAY_PRINTING);    return NO_ERROR;} //ParasePenInfovoid DJGenericVIP::AdjustModeSettings (BOOL bDoFullBleed, MEDIATYPE ReqMedia,                                       MediaType *medium, Quality *quality){/* *  Malibu platform printers have a defect that prevents these printers from *  performing full-bleed and media detect functions correctly. Check for this *  case, i.e., full-bleed and media detect flags and explicitly set the *  media type and quality as requested by the application. */    if (bDoFullBleed && *medium == mediaAuto)    {        if (ReqMedia == MEDIA_PHOTO)        {            *medium  = mediaGlossy;            *quality = qualityPresentation;        }        else        {            *medium  = mediaPlain;            *quality = qualityNormal;        }    }} // AdjustModeSettingsAPDK_END_NAMESPACE#endif // defined(APDK_DJGENERICVIP) && defined (APDK_DJ9xxVIP)

⌨️ 快捷键说明

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