1 /*****************************************************************************\ 2 printer.h : Interface for the Printer class 3 4 Copyright (c) 1996 - 2008, HP Co. 5 All rights reserved. 6 7 Redistribution and use in source and binary forms, with or without 8 modification, are permitted provided that the following conditions 9 are met: 10 1. Redistributions of source code must retain the above copyright 11 notice, this list of conditions and the following disclaimer. 12 2. Redistributions in binary form must reproduce the above copyright 13 notice, this list of conditions and the following disclaimer in the 14 documentation and/or other materials provided with the distribution. 15 3. Neither the name of HP nor the names of its 16 contributors may be used to endorse or promote products derived 17 from this software without specific prior written permission. 18 19 THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED 20 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 21 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN 22 NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 TO, PATENT INFRINGEMENT; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 25 OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 26 ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 \*****************************************************************************/ 30 31 32 #ifndef APDK_PRINTER_H 33 #define APDK_PRINTER_H 34 35 #include "modes.h" 36 37 APDK_BEGIN_NAMESPACE 38 39 //////////////////////////////////////////////////////////////////////////// 40 // PRINTER classes 41 42 #define MAX_PRINTER_FONTS 4 43 #define NUM_DJ400_FONTS 3 // ultimately obsolete these values since 44 #define NUM_DJ6XX_FONTS 4 // number of fonts is flexible 45 46 #define MAX_COMPATIBLE_PENS MAX_PEN_TYPE + 1 47 48 #define CANCEL_BUTTON_CHECK_THRESHOLD 150000 // will poll printer's cancel button state every 49 // time this quantity of bytes is written out 50 51 class Compressor; 52 53 //ClassName 54 //! 55 /*! 56 \internal 57 ******************************************************************************/ 58 class PrintMode 59 { 60 friend class Job; 61 friend class Header; 62 friend class PrintContext; 63 friend class Translator; 64 friend class GraphicsTranslator; 65 friend class Halftoner; 66 friend class Printer; 67 friend class Tester; 68 #ifdef APDK_DJ9xxVIP 69 friend class DJGenericVIP; 70 #endif 71 #ifdef APDK_DJ3320 72 friend class DJ4100; 73 #endif 74 public: 75 PrintMode (uint32_t *map1,uint32_t *map2=(uint32_t*)NULL); ~PrintMode()76 virtual ~PrintMode () 77 { 78 } 79 80 BOOL Compatible(PEN_TYPE pens); ColorCompatible(COLORMODE color)81 inline BOOL ColorCompatible(COLORMODE color) { return (color == pmColor); } QualityCompatible(QUALITY_MODE eQuality)82 inline BOOL QualityCompatible(QUALITY_MODE eQuality) { return (eQuality == pmQuality); } MediaCompatible(MEDIATYPE eMedia)83 virtual inline BOOL MediaCompatible(MEDIATYPE eMedia) { return (eMedia == pmMediaType); } GetQualityMode()84 inline QUALITY_MODE GetQualityMode() { return pmQuality;} GetMediaType()85 inline MEDIATYPE GetMediaType() { return pmMediaType; } 86 void GetValues (QUALITY_MODE& eQuality, MEDIATYPE& eMedia, COLORMODE& eColor, BOOL& bDeviceText); 87 88 // The resolutions can be different for different planes 89 unsigned int ResolutionX[MAXCOLORPLANES]; 90 unsigned int ResolutionY[MAXCOLORPLANES]; 91 92 unsigned int ColorDepth[MAXCOLORPLANES]; 93 94 MediaType medium; 95 96 BOOL bFontCapable; 97 98 // char ModeName[12]; 99 100 PipeConfigTable Config; 101 unsigned int dyeCount; // number of inks in the pen(s) 102 #ifdef APDK_AUTODUPLEX 103 BOOL bDuplexCapable; SetDuplexMode(DUPLEXMODE duplexmode)104 void SetDuplexMode (DUPLEXMODE duplexmode) 105 { 106 DuplexMode = duplexmode; 107 if (DuplexMode != DUPLEXMODE_NONE) 108 bFontCapable = FALSE; 109 }; 110 QueryDuplexMode()111 DUPLEXMODE QueryDuplexMode () 112 { 113 return DuplexMode; 114 }; 115 #endif // APDK_AUTODUPLEX 116 SetMediaType(MEDIATYPE eMediaType)117 DRIVER_ERROR SetMediaType (MEDIATYPE eMediaType) 118 { 119 if (MediaCompatible (eMediaType)) 120 { 121 pmMediaType = eMediaType; 122 return NO_ERROR; 123 } 124 return WARN_MODE_MISMATCH; 125 } 126 127 protected: 128 Quality theQuality; 129 #ifdef APDK_AUTODUPLEX 130 DUPLEXMODE DuplexMode; 131 #endif 132 133 ColorMap cmap; 134 135 unsigned int BaseResX,BaseResY, TextRes; 136 BOOL MixedRes; 137 138 unsigned char* BlackFEDTable; 139 unsigned char* ColorFEDTable; 140 141 142 PEN_TYPE CompatiblePens[MAX_COMPATIBLE_PENS]; 143 QUALITY_MODE pmQuality; 144 MEDIATYPE pmMediaType; 145 COLORMODE pmColor; 146 147 unsigned int myIndex; // record what index this mode has within the Printer 148 149 }; //PrintMode 150 151 152 //ClassName 153 //! 154 /*! 155 ******************************************************************************/ 156 class GrayMode : public PrintMode 157 { 158 public: 159 GrayMode(uint32_t *map); 160 }; //GrayMode 161 162 163 //ClassName 164 //! 165 /*! 166 ******************************************************************************/ 167 class CMYGrayMode : public GrayMode 168 { 169 public: 170 CMYGrayMode(uint32_t *map); 171 }; //CMYGrayMode 172 173 //ClassName 174 //! 175 /*! 176 ******************************************************************************/ 177 class KCMYGrayMode : public GrayMode 178 { 179 public: 180 KCMYGrayMode(uint32_t *map); 181 }; //KCMYGrayMode 182 183 //Printer 184 //! Encapulate printer functionality 185 /*! 186 \internal 187 ******************************************************************************/ 188 class Printer 189 { 190 friend class Job; 191 friend class Tester; 192 public: 193 194 Printer(SystemServices* pSys, int numfonts, 195 BOOL proto = FALSE); 196 197 virtual ~Printer(); 198 199 DRIVER_ERROR constructor_error; 200 GetModeCount(void)201 virtual unsigned int GetModeCount(void) { return ModeCount; } 202 virtual PrintMode* GetMode(unsigned int index); 203 204 205 #if defined(APDK_FONTS_NEEDED) 206 ReferenceFont* EnumFont(int& iCurrIdx); 207 208 virtual Font* RealizeFont(const int index, const BYTE bSize, 209 const TEXTCOLOR eColor = BLACK_TEXT, 210 const BOOL bBold = FALSE, 211 const BOOL bItalic = FALSE, 212 const BOOL bUnderline = FALSE); 213 #endif 214 215 virtual DRIVER_ERROR Send(const BYTE* pWriteBuff); 216 virtual DRIVER_ERROR Send(const BYTE* pWriteBuff, DWORD dwWriteLen); 217 218 virtual DRIVER_ERROR Flush(int FlushSize = MAX_RASTERSIZE); // flush printer input buffer 219 220 // select Header component of Translator 221 virtual Header* SelectHeader(PrintContext* pc) = 0; 222 223 224 virtual Compressor* CreateCompressor(unsigned int RasterSize); 225 226 virtual Compressor* CreateBlackPlaneCompressor (unsigned int RasterSize, BOOL bVIPPrinter = FALSE); 227 228 virtual DISPLAY_STATUS ParseError(BYTE status_reg); 229 230 virtual DRIVER_ERROR CleanPen(); 231 PagesPrinted(unsigned int & count)232 virtual DRIVER_ERROR PagesPrinted(unsigned int& count) // read pagecount from printer memory 233 { return UNSUPPORTED_FUNCTION; } // default behavior for printers without the ability 234 235 236 // DEVID stuff 237 IO_MODE IOMode; 238 239 int iNumFonts; // size of fontarray 240 BOOL bCheckForCancelButton; 241 unsigned long ulBytesSentSinceCancelCheck; /* XXX unused? */ 242 UseGUIMode(PrintMode * pPrintMode)243 virtual BOOL UseGUIMode(PrintMode* pPrintMode) { return FALSE; } UseCMYK(unsigned int iPrintMode)244 virtual BOOL UseCMYK(unsigned int iPrintMode) { return TRUE;} 245 PhotoTrayPresent(BOOL bQueryPrinter)246 virtual BOOL PhotoTrayPresent(BOOL bQueryPrinter) 247 { return FALSE; } 248 PhotoTrayEngaged(BOOL bQueryPrinter)249 virtual PHOTOTRAY_STATE PhotoTrayEngaged (BOOL bQueryPrinter) 250 { return DISENGAGED; } 251 252 //! Returns TRUE if a hagaki feed is present in printer. HagakiFeedPresent(BOOL bQueryPrinter)253 virtual BOOL HagakiFeedPresent(BOOL bQueryPrinter) 254 { return FALSE; } 255 256 #ifdef APDK_AUTODUPLEX 257 //!Returns TRUE if duplexer and hagaki feed (combined) unit is present in printer. HagakiFeedDuplexerPresent(BOOL bQueryPrinter)258 virtual BOOL HagakiFeedDuplexerPresent(BOOL bQueryPrinter) 259 { return FALSE; } 260 #endif 261 MandatoryPaperSize()262 virtual PAPER_SIZE MandatoryPaperSize() 263 { return UNSUPPORTED_SIZE; } //code for "nothing mandatory" 264 265 // tells currently installed pen type 266 inline virtual DRIVER_ERROR ParsePenInfo(PEN_TYPE& ePen, BOOL QueryPrinter = TRUE) 267 { 268 ePen = NO_PEN; 269 return NO_ERROR; 270 } 271 VIPPrinter()272 inline BOOL VIPPrinter() {return m_bVIPPrinter;} 273 SupportSeparateBlack(PrintMode * pCurrentMode)274 inline virtual BOOL SupportSeparateBlack (PrintMode *pCurrentMode) {return TRUE;} 275 276 PEN_TYPE ePen; 277 uint32_t *CMYMap; 278 CheckInkLevel()279 virtual DRIVER_ERROR CheckInkLevel() { return NO_ERROR; } 280 DefaultPenSet()281 virtual PEN_TYPE DefaultPenSet() { return BOTH_PENS; } 282 // need ParsePenInfo to remember this ActualPens()283 PEN_TYPE ActualPens() { return ePen; } 284 virtual DRIVER_ERROR SetPens(PEN_TYPE eNewPen); 285 286 // function to set PrintMode indices, which can't be done in base constructor 287 // so is called from PrintContext::SelectDevice 288 void SetPMIndices(); 289 SkipRasters(int nBlankRasters)290 virtual DRIVER_ERROR SkipRasters (int nBlankRasters) // needed for crossbow 291 { 292 return NO_ERROR; 293 } 294 295 virtual DRIVER_ERROR Encapsulate (const RASTERDATA* InputRaster, BOOL bLastPlane); 296 297 virtual BOOL FullBleedCapable (PAPER_SIZE ps, FullbleedType *fbType, float *xOverSpray, float *yOverSpray, 298 float *fLeftOverSpray = NULL, float *fTopOverSpray = NULL) 299 { 300 *fbType = fullbleedNotSupported; 301 return FALSE; 302 } 303 304 /* 305 * Some printers may require different margins than the default initialized in 306 * page size metrics table. If so, Getmargins should return TRUE and return the 307 * margin values in Left, Right, Top and Bottom in that order in the array fMargins. 308 * If default values are acceptable, return FALSE. 309 * At present, all 6xx family have larger bottom margin than the default 0.5 inch. 310 */ 311 GetMargins(PAPER_SIZE ps,float * fMargins)312 virtual BOOL GetMargins (PAPER_SIZE ps, float *fMargins) 313 { 314 return FALSE; 315 } 316 317 /* 318 * Malibu based printers do not handle media sense and full bleed simultaneously. 319 * For those printers, media type and quality have to be set explicitly. 320 */ 321 AdjustModeSettings(BOOL bDoFullBleed,MEDIATYPE ReqMedia,MediaType * medium,Quality * quality)322 virtual void AdjustModeSettings (BOOL bDoFullBleed, MEDIATYPE ReqMedia, 323 MediaType *medium, Quality *quality) 324 { 325 return; 326 } 327 PrinterLanguage()328 virtual int PrinterLanguage () 329 { 330 return 0; // 0 - PCL, 10 - PostScript 331 } 332 SaveText(const char * psStr,int iPointSize,int iX,int iY,const char * pTextString,int iTextStringLen,BOOL bUnderline)333 virtual DRIVER_ERROR SaveText (const char *psStr, int iPointSize, int iX, int iY, 334 const char *pTextString, int iTextStringLen, 335 BOOL bUnderline) 336 { 337 return NO_ERROR; 338 } 339 340 341 #ifdef APDK_AUTODUPLEX 342 BOOL bDuplexCapable; RotateImageForBackPage()343 BOOL RotateImageForBackPage () 344 { 345 return m_bRotateBackPage; 346 }; 347 348 #endif 349 SendPerPageHeader(BOOL bLastPage)350 virtual DRIVER_ERROR SendPerPageHeader (BOOL bLastPage) 351 { 352 return NO_ERROR; 353 } SetHint(PRINTER_HINT eHint,int iValue)354 virtual DRIVER_ERROR SetHint (PRINTER_HINT eHint, int iValue) 355 { 356 return NO_ERROR; 357 } GetHint(PRINTER_HINT eHint)358 virtual int GetHint (PRINTER_HINT eHint) 359 { 360 return 0; 361 } 362 AddPJLHeader()363 virtual DRIVER_ERROR AddPJLHeader () 364 { 365 return NO_ERROR; 366 } 367 368 protected: 369 SystemServices* pSS; 370 #if defined(APDK_FONTS_NEEDED) 371 ReferenceFont* fontarray[MAX_PRINTER_FONTS+1]; 372 #endif 373 374 int InSlowPollMode; 375 int iTotal_SLOW_POLL_Count; // total SLOW_POLLs (multiple of iMax_SLOW_POLL_Count) 376 int iMax_SLOW_POLL_Count; // time-out value at which point we do error check 377 BOOL ErrorTerminationState; 378 379 // buffering stuff 380 const unsigned int iBuffSize; 381 BYTE* pSendBuffer; 382 unsigned int iCurrBuffSize; 383 BOOL EndJob; 384 385 virtual DRIVER_ERROR VerifyPenInfo() = 0; 386 virtual BOOL TopCoverOpen(BYTE status_reg); GetDataFormat()387 virtual DATA_FORMAT GetDataFormat() { return RASTER_LINE; } 388 DRIVER_ERROR SetPenInfo(char*& pStr, BOOL QueryPrinter); 389 390 PrintMode* pMode[MAX_PRINTMODES]; 391 unsigned int ModeCount; 392 BOOL m_bVIPPrinter; 393 BOOL m_bStatusByPJL; 394 #ifdef APDK_AUTODUPLEX 395 BOOL m_bRotateBackPage; 396 #endif 397 398 int m_iNumPages; 399 400 virtual Printer& operator=(const Printer& rhs) {return *this;} // don't allow assignment 401 402 }; //Printer 403 404 APDK_END_NAMESPACE 405 406 #endif //APDK_PRINTER_H 407