1 /*****************************************************************************\
2 printer.h : Interface for the Printer class
4 Copyright (c) 1996 - 2008, Hewlett-Packard Co.
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions
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 Hewlett-Packard 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.
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 \*****************************************************************************/
32 #ifndef APDK_PRINTER_H
33 #define APDK_PRINTER_H
39 ////////////////////////////////////////////////////////////////////////////
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
46 #define MAX_COMPATIBLE_PENS MAX_PEN_TYPE + 1
48 #define CANCEL_BUTTON_CHECK_THRESHOLD 150000 // will poll printer's cancel button state every
49 // time this quantity of bytes is written out
57 ******************************************************************************/
62 friend class PrintContext;
63 friend class Translator;
64 friend class GraphicsTranslator;
65 friend class Halftoner;
69 friend class DJGenericVIP;
75 PrintMode (uint32_t *map1,uint32_t *map2=(uint32_t*)NULL);
\r
76 virtual ~PrintMode ()
\r
80 BOOL Compatible(PEN_TYPE pens);
81 inline BOOL ColorCompatible(COLORMODE color) { return (color == pmColor); }
82 inline BOOL QualityCompatible(QUALITY_MODE eQuality) { return (eQuality == pmQuality); }
83 virtual inline BOOL MediaCompatible(MEDIATYPE eMedia) { return (eMedia == pmMediaType); }
84 inline QUALITY_MODE GetQualityMode() { return pmQuality;}
85 inline MEDIATYPE GetMediaType() { return pmMediaType; }
86 void GetValues (QUALITY_MODE& eQuality, MEDIATYPE& eMedia, COLORMODE& eColor, BOOL& bDeviceText);
88 // The resolutions can be different for different planes
89 unsigned int ResolutionX[MAXCOLORPLANES];
90 unsigned int ResolutionY[MAXCOLORPLANES];
92 unsigned int ColorDepth[MAXCOLORPLANES];
100 PipeConfigTable Config;
101 unsigned int dyeCount; // number of inks in the pen(s)
102 #ifdef APDK_AUTODUPLEX
104 void SetDuplexMode (DUPLEXMODE duplexmode)
106 DuplexMode = duplexmode;
107 if (DuplexMode != DUPLEXMODE_NONE)
108 bFontCapable = FALSE;
111 DUPLEXMODE QueryDuplexMode ()
115 #endif // APDK_AUTODUPLEX
\r
117 DRIVER_ERROR SetMediaType (MEDIATYPE eMediaType)
\r
119 if (MediaCompatible (eMediaType))
\r
121 pmMediaType = eMediaType;
\r
124 return WARN_MODE_MISMATCH;
\r
129 #ifdef APDK_AUTODUPLEX
130 DUPLEXMODE DuplexMode;
135 unsigned int BaseResX,BaseResY, TextRes;
138 unsigned char* BlackFEDTable;
139 unsigned char* ColorFEDTable;
142 PEN_TYPE CompatiblePens[MAX_COMPATIBLE_PENS];
143 QUALITY_MODE pmQuality;
144 MEDIATYPE pmMediaType;
147 unsigned int myIndex; // record what index this mode has within the Printer
155 ******************************************************************************/
156 class GrayMode : public PrintMode
159 GrayMode(uint32_t *map);
166 ******************************************************************************/
167 class CMYGrayMode : public GrayMode
170 CMYGrayMode(uint32_t *map);
176 ******************************************************************************/
177 class KCMYGrayMode : public GrayMode
180 KCMYGrayMode(uint32_t *map);
184 //! Encapulate printer functionality
187 ******************************************************************************/
194 Printer(SystemServices* pSys, int numfonts,
199 DRIVER_ERROR constructor_error;
201 virtual unsigned int GetModeCount(void) { return ModeCount; }
202 virtual PrintMode* GetMode(unsigned int index);
205 #if defined(APDK_FONTS_NEEDED)
206 ReferenceFont* EnumFont(int& iCurrIdx);
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);
215 virtual DRIVER_ERROR Send(const BYTE* pWriteBuff);
216 virtual DRIVER_ERROR Send(const BYTE* pWriteBuff, DWORD dwWriteLen);
218 virtual DRIVER_ERROR Flush(int FlushSize = MAX_RASTERSIZE); // flush printer input buffer
220 // select Header component of Translator
221 virtual Header* SelectHeader(PrintContext* pc) = 0;
224 virtual Compressor* CreateCompressor(unsigned int RasterSize);
226 virtual Compressor* CreateBlackPlaneCompressor (unsigned int RasterSize, BOOL bVIPPrinter = FALSE);
228 virtual DISPLAY_STATUS ParseError(BYTE status_reg);
230 virtual DRIVER_ERROR CleanPen();
232 virtual DRIVER_ERROR PagesPrinted(unsigned int& count) // read pagecount from printer memory
233 { return UNSUPPORTED_FUNCTION; } // default behavior for printers without the ability
239 int iNumFonts; // size of fontarray
240 BOOL bCheckForCancelButton;
241 unsigned long ulBytesSentSinceCancelCheck; /* XXX unused? */
243 virtual BOOL UseGUIMode(PrintMode* pPrintMode) { return FALSE; }
244 virtual BOOL UseCMYK(unsigned int iPrintMode) { return TRUE;}
246 virtual BOOL PhotoTrayPresent(BOOL bQueryPrinter)
249 virtual PHOTOTRAY_STATE PhotoTrayEngaged (BOOL bQueryPrinter)
250 { return DISENGAGED; }
252 //! Returns TRUE if a hagaki feed is present in printer.
253 virtual BOOL HagakiFeedPresent(BOOL bQueryPrinter)
256 #ifdef APDK_AUTODUPLEX
257 //!Returns TRUE if duplexer and hagaki feed (combined) unit is present in printer.
258 virtual BOOL HagakiFeedDuplexerPresent(BOOL bQueryPrinter)
262 virtual PAPER_SIZE MandatoryPaperSize()
263 { return UNSUPPORTED_SIZE; } //code for "nothing mandatory"
265 // tells currently installed pen type
266 inline virtual DRIVER_ERROR ParsePenInfo(PEN_TYPE& ePen, BOOL QueryPrinter = TRUE)
272 inline BOOL VIPPrinter() {return m_bVIPPrinter;}
274 inline virtual BOOL SupportSeparateBlack (PrintMode *pCurrentMode) {return TRUE;}
279 virtual DRIVER_ERROR CheckInkLevel() { return NO_ERROR; }
281 virtual PEN_TYPE DefaultPenSet() { return BOTH_PENS; }
282 // need ParsePenInfo to remember this
283 PEN_TYPE ActualPens() { return ePen; }
284 virtual DRIVER_ERROR SetPens(PEN_TYPE eNewPen);
286 // function to set PrintMode indices, which can't be done in base constructor
287 // so is called from PrintContext::SelectDevice
290 virtual DRIVER_ERROR SkipRasters (int nBlankRasters) // needed for crossbow
295 virtual DRIVER_ERROR Encapsulate (const RASTERDATA* InputRaster, BOOL bLastPlane);
297 virtual BOOL FullBleedCapable (PAPER_SIZE ps, FullbleedType *fbType, float *xOverSpray, float *yOverSpray,
298 float *fLeftOverSpray = NULL, float *fTopOverSpray = NULL)
300 *fbType = fullbleedNotSupported;
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.
312 virtual BOOL GetMargins (PAPER_SIZE ps, float *fMargins)
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.
322 virtual void AdjustModeSettings (BOOL bDoFullBleed, MEDIATYPE ReqMedia,
323 MediaType *medium, Quality *quality)
328 virtual int PrinterLanguage ()
330 return 0; // 0 - PCL, 10 - PostScript
333 virtual DRIVER_ERROR SaveText (const char *psStr, int iPointSize, int iX, int iY,
334 const char *pTextString, int iTextStringLen,
341 #ifdef APDK_AUTODUPLEX
343 BOOL RotateImageForBackPage ()
345 return m_bRotateBackPage;
350 virtual DRIVER_ERROR SendPerPageHeader (BOOL bLastPage)
354 virtual DRIVER_ERROR SetHint (PRINTER_HINT eHint, int iValue)
358 virtual int GetHint (PRINTER_HINT eHint)
\r
363 virtual DRIVER_ERROR AddPJLHeader ()
\r
370 #if defined(APDK_FONTS_NEEDED)
371 ReferenceFont* fontarray[MAX_PRINTER_FONTS+1];
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;
380 const unsigned int iBuffSize;
382 unsigned int iCurrBuffSize;
385 virtual DRIVER_ERROR VerifyPenInfo() = 0;
386 virtual BOOL TopCoverOpen(BYTE status_reg);
387 virtual DATA_FORMAT GetDataFormat() { return RASTER_LINE; }
388 DRIVER_ERROR SetPenInfo(char*& pStr, BOOL QueryPrinter);
390 PrintMode* pMode[MAX_PRINTMODES];
391 unsigned int ModeCount;
394 #ifdef APDK_AUTODUPLEX
395 BOOL m_bRotateBackPage;
400 virtual Printer& operator=(const Printer& rhs) {return *this;} // don't allow assignment
406 #endif //APDK_PRINTER_H