Tizen 2.1 base
[platform/upstream/hplip.git] / prnt / hpijs / internal.h
1 /*****************************************************************************\
2   internal.h : Interface for internal classes
3
4   Copyright (c) 1996 - 2001, Hewlett-Packard 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 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.
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_INTERNAL_H
33 #define APDK_INTERNAL_H
34
35 APDK_BEGIN_NAMESPACE
36
37 /////////////////////////////////////////////////////////////////////////
38 // contains all class declarations
39 // for Slimhost++ driver
40 //
41 // merged in from file "Objects.h" 5/18/98
42 /////////////////////////////////////////////////////////////////////////
43 // these correspond to PCL codes
44 typedef int TYPEFACE;
45 #define COURIER 3
46 #define LETTERGOTHIC 6
47 #define CGTIMES 4101
48 #define UNIVERS 52
49
50 // character set names for PCL
51 #define LATIN1 "0N"     // aka ECMA94
52 #define PC8 "10U"
53 #define HP_LEGAL "1U"
54
55
56 // used to encourage consistent ordering of color planes
57 #define K   0
58 #define C   1
59 #define M   2
60 #define Y   3
61 #define Clight  4
62 #define Mlight  5
63
64 #define RANDSEED 77
65
66
67 #define DEFAULT_SLOW_POLL_COUNT 30
68 #define DEFAULT_SLOW_POLL_BIDI 3
69
70 //////////////////////////////////////////
71
72 enum STYLE_TYPE { UPRIGHT, ITALIC };
73
74 enum WEIGHT_TYPE { NORMAL, BOLD };
75
76 enum DATA_FORMAT { RASTER_LINE, RASTER_STRIP };
77
78
79 ///////////////////////////////////////////////////////////////////
80
81 #define MAX_ESC_SEQ 40
82 #define MAX_RASTERSIZE  10000   // REVISIT
83
84 #define MAX_Y_OFFSET    32767
85 // very frequently used fragments made into macros for readability
86 #define CERRCHECK if (constructor_error != NO_ERROR) {DBG1("CERRCHECK fired\n"); return;}
87 #define ERRCHECK if (err != NO_ERROR) {DBG1("ERRCHECK fired\n"); return err;}
88 #define NEWCHECK(x) if (x==NULL) return ALLOCMEM_ERROR;
89 #define CNEWCHECK(x) if (x==NULL) { constructor_error=ALLOCMEM_ERROR; return; }
90
91
92
93 //////// STATIC DATA ////////////////////////////////////////////////////////////////
94 // escape sequences -- see PCL Implementor's Guide or Software Developer's PCL Guides
95 // for documentation
96 #define ESC 0x1b
97
98 const char UEL[] = {ESC, '%', '-','1','2','3','4','5','X' };
99 const char EnterLanguage[] = {'@','P','J','L',' ','E','N','T','E','R',' ',
100                         'L','A','N','G','U','A','G','E','=' };
101 const char PCL3[] = {'P','C','L','3' };
102 const char PCLGUI[] = {'P','C','L','3','G','U','I' };
103 const char JobName[] = {'@','P','J','L',' ','J','O','B',' ','N','A','M','E',' ','=',' '};
104 const char Reset[] = {ESC,'E'};
105 const char crdStart[] = {ESC, '*', 'g'};            // configure raster data command
106 const char cidStart[] = {ESC, '*', 'v'};            // configure image data command
107 const char crdFormat = 2; // only format for 600
108 const char grafStart[] = {ESC, '*', 'r', '1', 'A'}; // raster graphics mode
109 const char grafMode0[] = {ESC, '*', 'b', '0', 'M'}; // compression methods
110 const char grafMode9[] =    {ESC, '*', 'b', '9', 'M'};
111 const char grafMode2[] =    {ESC, '*', 'b', '2', 'M'};
112 const char SeedSame[] = {ESC, '*', 'b', '0', 'S'};
113 //const char EjectPage[] = {ESC, '&', 'l', '0', 'H'};   // not needed by us; will pick if no page already picked
114 const char BlackExtractOff[] = {ESC, '*', 'o', '5', 'W', 0x04, 0xC, 0, 0, 0 };
115 const char LF = '\012';
116 const char Quote = '\042';
117 const BYTE DJ895_Power_On[] = {ESC, '%','P','u','i','f','p','.',
118         'p','o','w','e','r',' ','1',';',
119         'u','d','w','.','q','u','i','t',';',ESC,'%','-','1','2','3','4','5','X' };
120 /*const BYTE DJ895_Pre_Pick[] = {ESC, '&', 'l', -2, 'H'};
121 {ESC, '%','P','m','e','c','h','.',
122         'l','o','a','d','_','p','a','p','e','r',';',
123         'u','d','w','.','q','u','i','t',';' };//,ESC,'%','-','1','2','3','4','5','X' };
124 */
125 const char EnableDuplex[] = { ESC,'&','l', '2', 'S'};
126 const char NoDepletion[] = {ESC, '*', 'o', '1', 'D'};
127 const char NoGrayBalance[] = {ESC, '*', 'b', '2', 'B'};
128 const char EnableBufferFlushing[] =  { ESC,'&','b','1','5','W','P','M','L',32,4,0,5,1,2,1,1,5,4,1,1 };
129 const char DisableBufferFlushing[] = { ESC,'&','b','1','5','W','P','M','L',32,4,0,5,1,2,1,1,5,4,1,2 };
130 const char DriverwareJobName[] = { ESC,'*','o','5','W',0x0d,0x06,0x00,0x00,0x01 };
131 const BYTE PEN_CLEAN_PML[]={0x1B,0x45,0x1B,0x26,0x62,0x31,0x36,0x57,
132                 0x50,0x4D,0x4C,0x20,  // EscE Esc&b16WPML{space}
133                 0x04,0x00,0x06,0x01,0x04,0x01,0x05,0x01,
134                 0x01,0x04,0x01,0x64}; // PML Marking-Agent-Maintenance=100
135
136 //
137 // ** move these to intenal.h
138
139 struct fOptSubSig
140 {
141     float pi;
142     const float *means;
143 };
144
145
146 struct fOptClassSig
147 {
148     int nsubclasses;
149     float variance;
150     float inv_variance;
151     float cnst;
152     struct fOptSubSig *OptSubSig;
153 };
154
155
156 struct fOptSigSet
157 {
158     int nbands;
159     struct fOptClassSig *OptClassSig;
160 };
161
162
163 struct RESSYNSTRUCT
164 {
165         int             Width;
166         int             ScaleFactorMultiplier;
167         int             ScaleFactorDivisor;
168 //      int             CallerAlloc;         // Who does the memory alloc.
169         int             Remainder;           // For use in non integer scaling cases
170         int             Repeat;              // When to send an extra output raster
171         int             RastersinBuffer;     // # of currently buffered rasters
172         unsigned char*  Bufferpt[NUMBER_RASTERS];
173         int             BufferSize;
174         unsigned char*  Buffer;
175         struct fOptSigSet OS;
176         struct fOptSubSig rsOptSubSigPtr1[45];
177         struct fOptClassSig OCS;
178         float **joint_means;
179         float ***filter;
180         float filterPtr1[45];
181         float filterPtr2[45][9];
182         float joint_meansPtr1[45];
183
184 };
185
186 typedef enum
187 {
188         COLORTYPE_COLOR,       // 0
189         COLORTYPE_BLACK,       // 1
190         COLORTYPE_BOTH
191 } COLORTYPE;
192
193 #define  MAX_COLORTYPE     2
194
195 struct RASTERDATA
196 {
197     int     rastersize[MAX_COLORTYPE];
198     BYTE*       rasterdata[MAX_COLORTYPE];
199 };
200
201 // Bitmap structure definition
202 struct HPRGBQUAD {
203   BYTE    rgbBlue; 
204   BYTE    rgbGreen; 
205   BYTE    rgbRed; 
206   BYTE    rgbReserved; 
207 };
208
209 struct HPBITMAPINFOHEADER{
210   DWORD  biSize; 
211   long   biWidth; 
212   long   biHeight; 
213   WORD   biPlanes; 
214   WORD   biBitCount; 
215   DWORD  biCompression; 
216   DWORD  biSizeImage; 
217   long   biXPelsPerMeter; 
218   long   biYPelsPerMeter; 
219   DWORD  biClrUsed; 
220   DWORD  biClrImportant; 
221 }; 
222
223 struct HPBITMAPINFO { 
224   HPBITMAPINFOHEADER bmiHeader; 
225   HPRGBQUAD          bmiColors[1]; 
226 }; 
227
228
229 struct HPLJBITMAP {
230
231     HPBITMAPINFO  bitmapInfo;
232     unsigned long cjBits;
233     BYTE          *pvBits;      
234         BYTE          *pvAlignedBits;
235 };
236
237
238 //////////////////////////////////////////
239 class Pipeline;
240 //Scaler, Halftoner, ColorMatcher, ErnieFilter, PixelReplicator,
241 //(FRE object, ...) are subclasses of Processor.
242
243
244 //Processor
245 //!\internal
246 //! Executes the "Process" method in it's containee.
247 /*!
248 Enter a full description of the class here. This will be the API doc.
249
250 \sa Scaler Halftoner ColorMatcher ErnieFilter PixelReplicator
251 ******************************************************************************/
252 class Processor
253 {
254 public:
255     Processor();
256     virtual ~Processor();
257
258     //virtual BOOL Process(BYTE* InputRaster=NULL, unsigned int size=0)=0;    // returns TRUE iff output ready
259     virtual BOOL Process(RASTERDATA  *InputRaster=NULL)=0;    // returns TRUE iff output ready
260         virtual void Flush()=0;     // take any concluding actions based on internal state
261     virtual BYTE* NextOutputRaster(COLORTYPE  rastercolor)=0;
262     virtual unsigned int GetOutputWidth(COLORTYPE  rastercolor)=0;        // in bytes, not pixels
263     virtual unsigned int GetMaxOutputWidth(COLORTYPE  rastercolor) { return GetOutputWidth(rastercolor); }
264
265     unsigned int iRastersReady, iRastersDelivered;
266     Pipeline* myphase;
267         COLORTYPE myplane;
268         RASTERDATA  raster;
269 }; //Processor
270
271
272 //Pipeline
273 //! Manages the processes used in a pipeline
274 /*!
275 \internal
276 Enter a full description of the class here. This will be the API doc.
277
278 ******************************************************************************/
279 class Pipeline
280 {
281 public:
282     Pipeline(Processor* E);
283     virtual ~Pipeline();
284
285     void AddPhase(Pipeline* p);             // add p at end
286
287     //DRIVER_ERROR Execute(BYTE* InputRaster=NULL, unsigned int size=0);   // run pipeline
288         DRIVER_ERROR Execute(RASTERDATA* InputRaster=NULL);   // run pipeline
289
290     DRIVER_ERROR Flush();
291
292     //BOOL Process(BYTE* InputRaster=NULL, unsigned int size=0);   // call processor for this phase
293     BOOL Process(RASTERDATA*  InputRaster=NULL);   // call processor for this phase
294
295     BYTE* NextOutputRaster(COLORTYPE  rastercolor)      { return Exec->NextOutputRaster(rastercolor); }
296     unsigned int GetOutputWidth(COLORTYPE  rastercolor) { return Exec->GetOutputWidth(rastercolor); }
297     unsigned int GetMaxOutputWidth(COLORTYPE  rastercolor) { return Exec->GetMaxOutputWidth(rastercolor); }
298
299     Pipeline* next;
300     Pipeline* prev;
301
302     Processor* Exec;
303
304     DRIVER_ERROR err;
305
306 }; //Pipeline
307
308 struct PipeConfigTable
309 {
310     BOOL bResSynth;
311
312 #if defined(APDK_VIP_COLORFILTERING)
313     BOOL bErnie;
314 #endif
315
316     BOOL bPixelReplicate;
317     BOOL bColorImage;
318     BOOL bCompress;
319     HALFTONING_ALGORITHM eHT;
320 };
321
322
323 //Scaler
324 //! Scales input by a factor
325 /*!
326 \internal
327 Enter a full description of the class here. This will be the API doc.
328
329 ******************************************************************************/
330 class Scaler : public Processor
331 {
332 public:
333     // constructor protected -- use Create_Scaler()
334     virtual ~Scaler();
335     //virtual BOOL Process(BYTE* InputRaster=NULL, unsigned int size=0)=0;
336     BOOL Process(RASTERDATA* InputRaster=NULL)=0;
337     virtual void Flush() { Process(); }
338
339     DRIVER_ERROR constructor_error;
340
341     float ScaleFactor;
342     unsigned int remainder;
343
344     virtual unsigned int GetOutputWidth(COLORTYPE  rastercolor);
345         virtual unsigned int GetMaxOutputWidth(COLORTYPE  rastercolor);
346     virtual BYTE* NextOutputRaster(COLORTYPE  rastercolor)=0;
347
348 protected:
349     Scaler(SystemServices* pSys,unsigned int inputwidth,
350             unsigned int numerator,unsigned int denominator, BOOL vip, unsigned int BytesPerPixel);
351     SystemServices* pSS;
352
353     BOOL scaling;       // false iff ScaleFactor==1.0
354     BOOL ReplicateOnly; // true iff 1<ScaleFactor<2
355
356
357     unsigned int iOutputWidth;
358     unsigned int iInputWidth;
359     BYTE* pOutputBuffer[MAX_COLORTYPE];
360     BOOL fractional;
361 }; //Scaler
362
363 #ifdef APDK_PSCRIPT
364 class PScriptProxy;
365 #endif
366
367 #ifdef APDK_LJMONO
368 class LJMonoProxy;
369 #endif
370
371 #ifdef APDK_LJCOLOR
372 class LJColorProxy;
373 #endif
374
375 #ifdef APDK_LJJETREADY
376 class LJJetReadyProxy;
377 #endif
378
379 #ifdef APDK_LJFASTRASTER
380 class LJFastRasterProxy;
381 #endif
382
383 #ifdef APDK_LJZJS_MONO
384 class LJZjsMonoProxy;
385 #endif
386
387 #ifdef APDK_LJZJS_COLOR
388 class LJZjsColorProxy;
389 #endif
390
391 #ifdef APDK_LJM1005
392 class LJM1005Proxy;\r
393 class LJP1XXXProxy;
394 #endif
395
396 #if defined(APDK_PSP100) && defined (APDK_DJ9xxVIP)
397 class PSP100Proxy;
398 class PSP470Proxy;
399 #endif
400
401 #if defined(APDK_DJGENERICVIP) && defined (APDK_DJ9xxVIP)
402 class DJGenericVIPProxy;
403 class DJ55xxProxy;
404 #endif
405
406 #ifdef APDK_DJ9xxVIP
407 class DJ9xxVIPProxy;
408 class OJProKx50Proxy;
409 #endif
410
411 #ifdef APDK_DJ9xx
412 class DJ9xxProxy;
413 #endif
414
415 #if defined(APDK_DJ8xx)|| defined(APDK_DJ9xx)
416 class DJ8xxProxy;
417 #endif
418
419 #if defined(APDK_DJ8xx)|| defined(APDK_DJ9xx)
420 #ifdef APDK_DJ8x5
421 class DJ8x5Proxy;
422 #endif
423 #endif
424
425 #if defined(APDK_DJ890)
426 class DJ890Proxy;
427 #endif
428
429 #if defined(APDK_DJ850)
430 class DJ850Proxy;
431 #endif
432
433 #ifdef APDK_DJ6xxPhoto
434 class DJ6xxPhotoProxy;
435 #endif
436
437 #ifdef APDK_DJ6xx
438 class DJ660Proxy;
439 #endif
440
441 #ifdef APDK_DJ630
442 class DJ630Proxy;
443 #endif
444
445 #ifdef APDK_DJ600
446 class DJ600Proxy;
447 #endif
448
449 #ifdef APDK_DJ540
450 class DJ540Proxy;
451 #endif
452
453 #ifdef APDK_DJ400
454 class DJ400Proxy;
455 #endif
456
457 #ifdef APDK_DJ350
458 class DJ350Proxy;
459 #endif
460
461 #if defined(APDK_DJ3600) && defined (APDK_DJ3320)
462 class DJ3600Proxy;
463 class DJ4100Proxy;\r
464 class DJD2600Proxy;
465 #endif
466
467 #if defined (APDK_DJ3320)
468 class DJ3320Proxy;
469 #endif
470
471 #ifdef APDK_APOLLO2560
472 class Apollo2560Proxy;
473 #endif
474
475 #ifdef APDK_APOLLO21XX
476 class Apollo21xxProxy;
477 #endif
478
479 #ifdef APDK_APOLLO2XXX
480 class Apollo2xxxProxy;
481 #endif\r
482 \r
483 #ifdef APDK_QUICKCONNECT\r
484 class QuickConnectProxy;\r
485 #endif\r
486
487 //DeviceRegistry
488 //! Isolates device dependencies
489 /*!
490 \internal
491 DeviceRegistry, for isolating all device dependencies
492 The data is contained in Registry.cpp
493
494 This object encapsulates all model-specific data for a build.
495 Its features are presented to client through the PrintContext.
496
497 ******************************************************************************/
498 class DeviceRegistry
499 {
500 public:
501     DeviceRegistry();
502     virtual ~DeviceRegistry();
503
504
505     // get model string from DevID string
506     DRIVER_ERROR ParseDevIDString(const char* sDevID, char* strModel, int *pVIPVersion, char* strPens);
507     // set "device" to index of entry
508     virtual DRIVER_ERROR SelectDevice(char* model, int* pVIPVersion, char* pens, SystemServices* pSS);
509
510     virtual DRIVER_ERROR SelectDevice(const char* sDevID, SystemServices* pSS);
511
512     virtual DRIVER_ERROR SelectDevice(const PRINTER_TYPE Model);
513
514     virtual DRIVER_ERROR GetPrinterModel(char* strModel, int* pVIPVersion, char* strPens, SystemServices* pSS);
515
516
517     // create a Printer object as pointee of p, using the given SystemServices
518     // and the current value of device; still needs to be configured
519     virtual DRIVER_ERROR InstantiatePrinter(Printer*& p,SystemServices* pSS);
520
521
522     int device;                         // ordinal of device from list (or UNSUPPORTED=-1)
523
524 #ifdef APDK_PSCRIPT
525     static PScriptProxy s_PScriptProxy;
526 #endif
527
528 #ifdef APDK_LJMONO
529     static LJMonoProxy s_LJMonoProxy;
530 #endif
531
532 #ifdef APDK_LJCOLOR
533     static LJColorProxy s_LJColorProxy;
534 #endif
535
536 #ifdef APDK_LJJETREADY
537         static LJJetReadyProxy s_LJJetReadyProxy;
538 #endif
539
540 #ifdef APDK_LJFASTRASTER
541     static LJFastRasterProxy s_LJFastRasterProxy;
542 #endif
543
544 #ifdef APDK_LJZJS_MONO
545     static LJZjsMonoProxy s_LJZjsMonoProxy;
546 #endif
547
548 #ifdef APDK_LJZJS_COLOR
549     static LJZjsColorProxy s_LJZjsColorProxy;
550 #endif
551
552 #ifdef APDK_LJM1005
553     static LJM1005Proxy s_LJM1005Proxy;\r
554     static LJP1XXXProxy s_LJP1XXXProxy;
555 #endif
556
557 #if defined(APDK_PSP100) && defined (APDK_DJ9xxVIP)
558     static PSP100Proxy s_PSP100Proxy;
559     static PSP470Proxy s_PSP470Proxy;
560 #endif
561
562 #if defined(APDK_DJGENERICVIP) && defined (APDK_DJ9xxVIP)
563     static DJGenericVIPProxy s_DJGenericVIPProxy;
564     static DJ55xxProxy s_DJ55xxProxy;
565 #endif
566
567 #ifdef APDK_DJ9xxVIP
568     static DJ9xxVIPProxy s_DJ9xxVIPProxy;
569     static OJProKx50Proxy s_OJProKx50Proxy;
570 #endif
571
572 #ifdef APDK_DJ9xx
573     static DJ9xxProxy s_DJ9xxProxy;
574 #endif
575
576 #if defined(APDK_DJ8xx)|| defined(APDK_DJ9xx)
577     static DJ8xxProxy s_DJ8xxProxy;
578 #endif
579
580 #if defined(APDK_DJ8xx)|| defined(APDK_DJ9xx)
581 #ifdef APDK_DJ8x5
582     static DJ8x5Proxy s_DJ8x5Proxy;
583 #endif
584 #endif
585
586 #if defined(APDK_DJ890)
587     static DJ890Proxy s_DJ890Proxy;
588 #endif
589
590 #if defined(APDK_DJ850)
591     static DJ850Proxy s_DJ850Proxy;
592 #endif
593
594 #ifdef APDK_DJ6xxPhoto
595     static DJ6xxPhotoProxy s_DJ6xxPhotoProxy;
596 #endif
597
598 #ifdef APDK_DJ6xx
599     static DJ660Proxy s_DJ660Proxy;
600 #endif
601
602 #ifdef APDK_DJ630
603     static DJ630Proxy s_DJ630Proxy;
604 #endif
605
606 #ifdef APDK_DJ600
607     static DJ600Proxy s_DJ600Proxy;
608 #endif
609
610 #ifdef APDK_DJ540
611     static DJ540Proxy s_DJ540Proxy;
612 #endif
613
614 #ifdef APDK_DJ400
615     static DJ400Proxy s_DJ400Proxy;
616 #endif
617
618 #ifdef APDK_DJ350
619     static DJ350Proxy s_DJ350Proxy;
620 #endif
621
622 #if defined(APDK_DJ3600) && defined (APDK_DJ3320)
623     static DJ3600Proxy s_DJ3600Proxy;
624     static DJ4100Proxy s_DJ4100Proxy;\r
625     static DJD2600Proxy s_DJD2600Proxy;
626 #endif
627
628 #if defined (APDK_DJ3320)
629     static DJ3320Proxy s_DJ3320Proxy;
630 #endif
631
632 #ifdef APDK_APOLLO2560
633     static Apollo2560Proxy s_Apollo2560Proxy;
634 #endif
635
636 #ifdef APDK_APOLLO21XX
637     static Apollo21xxProxy s_Apollo21xxProxy;
638 #endif
639
640 #ifdef APDK_APOLLO2XXX
641     static Apollo2xxxProxy s_Apollo2xxxProxy;
642 #endif
643 \r
644 #ifdef APDK_QUICKCONNECT\r
645     static QuickConnectProxy s_QuickConnectProxy;\r
646 #endif\r
647
648 }; //DeviceRegistry
649
650
651 ////////////////////////////////////////////////
652 typedef struct
653 {
654     const uint32_t *ulMap1;
655     const uint32_t *ulMap2;
656     const unsigned char *ulMap3;
657 } ColorMap;
658
659
660 //Compressor
661 //!\internal
662 //! Base for data compression methods
663 /*!
664 Impliment compression
665
666 ******************************************************************************/
667 class Compressor : public Processor
668 {
669 public:
670     Compressor(SystemServices* pSys, unsigned int RasterSize, BOOL useseed);
671     virtual ~Compressor();
672
673     virtual BOOL Process(RASTERDATA* InputRaster=NULL)=0;
674
675     virtual void Flush() { }    // no pending output
676
677     unsigned int GetOutputWidth(COLORTYPE color);
678     virtual BYTE* NextOutputRaster(COLORTYPE color);
679
680     void SetSeedRow(BYTE* seed) { SeedRow=seed; }
681
682     DRIVER_ERROR constructor_error;
683
684     SystemServices* pSS;
685     // buffer is public for use by GraphicsTranslator
686     BYTE* compressBuf;      // output buffer
687     BYTE* SeedRow;
688     BOOL UseSeedRow;
689         BYTE* originalKData;
690
691     unsigned int compressedsize;
692     unsigned int inputsize;
693     BOOL seeded;
694 }; //Compressor
695
696
697 //ClassName
698 //!
699 /*
700 \internal
701 */
702 class Mode9 : public Compressor
703 {
704 public:
705     Mode9(SystemServices* pSys,unsigned int RasterSize, BOOL bVIPPrinter = FALSE);
706     virtual ~Mode9();
707     BOOL Process(RASTERDATA* input);
708     void Flush();
709         BOOL ResetSeedRow;
710     BOOL m_bVIPPrinter;
711 }; //Mode9
712
713 //ClassName
714 //!
715 /*
716 \internal
717 */
718 class Mode2 : public Compressor
719 {
720 public:
721     Mode2(SystemServices* pSys,unsigned int RasterSize);
722     virtual ~Mode2();
723     BOOL Process(RASTERDATA* input);
724 }; //Mode2
725
726 //ClassName
727 //!
728 /*
729 \internal
730 */
731 class Mode3 : public Compressor
732 {
733 public:
734     Mode3 (SystemServices* pSys, Printer *pPrinter, unsigned int RasterSize);
735     virtual ~Mode3 ();
736     BOOL Process (RASTERDATA* input);
737     void    Flush ();
738 private:
739     Printer *m_pPrinter;
740 }; //Mode3
741
742 ////////////////////////////////////////////////////////////////////////////
743 #if defined(APDK_FONTS_NEEDED)
744
745
746 //TextTranslator
747 //! ASCII data support
748 /*!
749 \internal
750 Does encapsulation work specific to ascii data, including handling of fonts
751 and treatments.
752
753 ******************************************************************************/
754 class TextTranslator
755 {
756 public:
757     TextTranslator(Printer* p,int quality,unsigned int colorplanes);
758     virtual ~TextTranslator();
759
760     DRIVER_ERROR TextOut(const char* pTextString, unsigned int LenString,
761                 const Font& font, BOOL sendfont=FALSE,
762                 int iAbsX=-1, int iAbsY=-1);
763
764     DRIVER_ERROR SendCAP(unsigned int iAbsX,unsigned int iAbsY);
765     const BYTE* ColorSequence(TEXTCOLOR eColor);
766     BYTE ColorCode(TEXTCOLOR eColor);
767     int TypefaceCode(const char* FontName);
768     const BYTE* PointsizeSequence(unsigned int iPointsize);
769     const BYTE* PitchSequence(unsigned int iPitch);
770     const BYTE* StyleSequence(BOOL bItalic);
771     const BYTE* WeightSequence(BOOL bBold);
772     const BYTE* CompleteSequence(const Font& font);
773     const BYTE* UnderlineSequence();
774     const BYTE* DisableUnderlineSequence();
775
776     // "transparent mode" escape to treat control code (BYTE b) as normal char
777     int TransparentChar(unsigned int iMaxLen, BYTE b, BYTE* outbuff);
778
779     DRIVER_ERROR constructor_error;
780
781     DRIVER_ERROR SendFont(const Font& font);
782     DRIVER_ERROR SendColorSequence(const TEXTCOLOR eColor);
783     DRIVER_ERROR SendPointsize(const unsigned int iPointsize);
784     DRIVER_ERROR SendPitch(const unsigned int iPitch);
785     DRIVER_ERROR SendStyle(const BOOL bItalic);
786     DRIVER_ERROR SendWeight(const BOOL bBold);
787     DRIVER_ERROR SendUnderline();
788     DRIVER_ERROR SendCompleteSequence(const Font& font);
789     DRIVER_ERROR DisableUnderline();
790
791
792 private:
793     Printer* thePrinter;
794     int qualcode;                       // pcl code for text quality
795     BYTE EscSeq[MAX_ESC_SEQ];           // storage for the command
796     unsigned int iNumPlanes;                        // color planes, based on pen
797     BYTE ColorCode1(TEXTCOLOR eColor);  // if iNumPlanes==1 (black)
798     BYTE ColorCode3(TEXTCOLOR eColor);  // if iNumPlanes==3 (CMY)
799     BYTE ColorCode4(TEXTCOLOR eColor);  // if iNumPlanes==4 (KCMY)
800
801     // items for avoiding redundant font resets
802     // (cheaper than copying whole font)
803     TEXTCOLOR lastcolor;
804     char lastname[20];
805     char lastcharset[MAX_CHAR_SET];
806     int lastpointsize;
807     BOOL lastitalic;
808     BOOL lastbold;
809     void SetLast(const Font& font);
810
811 }; //TextTranslator
812
813 #endif //fonts needed
814
815
816 //Header
817 //! Composes a header stream
818 /*!
819 \internal
820 Composes a header stream, embodying specific requirements of the Printer.
821
822 ******************************************************************************/
823 class Header
824 {
825 friend class Job;
826 friend class ModeJPEG;
827
828 public:
829     Header(Printer* p,PrintContext* pc);
830     virtual ~Header ();
831
832     virtual DRIVER_ERROR Send()=0;
833
834     virtual DRIVER_ERROR EndJob();
835
836     virtual DRIVER_ERROR SendCAPy(unsigned int iAbsY);  // made virtual for crossbow
837     virtual DRIVER_ERROR FormFeed();                    // made virtual for crossbow
838
839         BOOL    IsLastBand() { return bLastBand; }
840         void    SetLastBand(BOOL lastband) { bLastBand = lastband; }
841
842     unsigned int CAPy;  // may be moved during header; retrieved by Job
843
844 protected:
845     Printer* thePrinter;
846     PrintContext* thePrintContext;
847     PrintMode* thePrintMode;
848     /// routines to set values of internal variables
849     void SetMediaType(MediaType mtype);
850     void SetMediaSize(PAPER_SIZE papersize);
851     void SetMediaSource(MediaSource msource);
852     void SetQuality(Quality qual);
853     void SetSimpleColor();
854
855     // components of a header
856     DRIVER_ERROR Margins();
857     virtual DRIVER_ERROR Graphics();
858     DRIVER_ERROR Simple();
859     DRIVER_ERROR Modes();
860     DRIVER_ERROR ConfigureRasterData();
861
862     // common escapes, plus mode and margin setting
863     virtual DRIVER_ERROR StartSend();
864
865 ////// data members /////////////////////////////////
866     unsigned int ResolutionX[MAXCOLORPLANES];
867     unsigned int ResolutionY[MAXCOLORPLANES];
868     unsigned int dyeCount;
869
870     // utilities
871
872     unsigned int ColorLevels(unsigned int ColorPlane);
873
874     // escape sequence constants
875     char SimpleColor[6]; BYTE sccount;      // color command string, and its size
876     char mediatype[6]; BYTE mtcount;        // mediatype string, and its size
877     char mediasize[8]; BYTE mscount;        // mediasize string, and its size
878     char mediasource[6]; BYTE msrccount;    // mediasource string, and its size
879     char quality[6]; BYTE qualcount;        // quality string, and its size
880     BYTE QualityCode();         // returns just the variable byte of quality
881         BOOL bLastBand;
882 }; //Header
883
884
885 //ClassName
886 /*
887 ******************************************************************************/
888 class Header350 : public Header
889 {
890 public:
891     Header350(Printer* p,PrintContext* pc);
892     DRIVER_ERROR Send();
893 }; //Header350
894
895
896 //ClassName
897 /*
898 ******************************************************************************/
899 class Header400 : public Header
900 {
901 public:
902     Header400(Printer* p,PrintContext* pc);
903     DRIVER_ERROR Send();
904
905 }; //Header400
906
907
908 //ClassName
909 /*
910 ******************************************************************************/
911 class Header6XX : public Header
912 {
913 public:
914     Header6XX(Printer* p,PrintContext* pc);
915     virtual DRIVER_ERROR Send();
916 protected:
917
918 }; //Header6XX
919
920
921 //ClassName
922 /*
923 ******************************************************************************/
924 class Header600 : public Header6XX
925 {
926 public:
927     Header600(Printer* p,PrintContext* pc);
928     DRIVER_ERROR Send();
929
930 }; //Header600
931
932
933 //ClassName
934 /*
935 ******************************************************************************/
936 class Header690 : public Header
937 {
938 public:
939     Header690(Printer* p,PrintContext* pc);
940     DRIVER_ERROR Send();
941 }; //Header690
942
943
944 //ClassName
945 /*
946 ******************************************************************************/
947 class Header540 : public Header
948 {
949 public:
950     Header540(Printer* p,PrintContext* pc);
951     DRIVER_ERROR Send();
952
953 }; //Header540
954
955
956 //ClassName
957 /*
958 ******************************************************************************/
959 class Header895 : public Header
960 {
961 public:
962     Header895(Printer* p,PrintContext* pc);
963     virtual DRIVER_ERROR Send();
964
965 protected:
966     DRIVER_ERROR Graphics();
967     DRIVER_ERROR StartSend();
968 }; //Header895
969
970
971 //ClassName
972 /*
973 ******************************************************************************/
974 class Header850 : public Header895
975 {
976 public:
977     Header850(Printer* p,PrintContext* pc);
978
979 protected:
980     DRIVER_ERROR StartSend();
981
982 }; //Header850
983
984
985 //ClassName
986 /*
987 ******************************************************************************/
988 class Header900 : public Header895
989 {
990 public:
991     Header900(Printer* p,PrintContext* pc);
992     virtual DRIVER_ERROR Send();
993
994 protected:
995     BOOL DuplexEnabled(BYTE* bDevIDBuff);
996 }; //Header900
997
998
999 //ClassName
1000 /*
1001 ******************************************************************************/
1002 class HeaderDJ990 : public Header
1003 {
1004 public:
1005     HeaderDJ990(Printer* p,PrintContext* pc);
1006     DRIVER_ERROR ConfigureRasterData();
1007     DRIVER_ERROR ConfigureImageData();
1008     DRIVER_ERROR Send();
1009     DRIVER_ERROR StartSend();
1010     void SetMediaSource(MediaSource msource);
1011 }; //HeaderDJ990
1012
1013 //ClassName
1014 /*
1015 ******************************************************************************/
1016 class HeaderDJGenericVIP : public HeaderDJ990
1017 {
1018 public:
1019     HeaderDJGenericVIP (Printer *p, PrintContext *pc);
1020 protected:
1021     unsigned int m_uiCAPy;
1022     DRIVER_ERROR SendCAPy (unsigned int iAbsY);
1023     DRIVER_ERROR FormFeed ();
1024 }; // HeaderDJGenericVIP
1025
1026 //ClassName
1027 /*
1028 ******************************************************************************/
1029 class Header630 : public Header
1030 {
1031 public:
1032     Header630(Printer* p,PrintContext* pc);
1033     DRIVER_ERROR Send();
1034 }; //Header630
1035
1036
1037 //ClassName
1038 /*
1039 ******************************************************************************/
1040 class Header2xxx : public Header
1041 {
1042 public:
1043     Header2xxx(Printer* p,PrintContext* pc);
1044     DRIVER_ERROR Send();
1045 }; //Header2xxx
1046
1047
1048 //ClassName
1049 /*
1050 ******************************************************************************/
1051 class Header3320 : public Header
1052 {
1053 public:
1054     Header3320 (Printer *p, PrintContext *pc);
1055     DRIVER_ERROR Send ();
1056 protected:
1057     DRIVER_ERROR EndJob ();
1058     DRIVER_ERROR FormFeed ();
1059     DRIVER_ERROR SendCAPy (unsigned int iAbsY);
1060 };
1061 //ClassName
1062 /*
1063 ******************************************************************************/
1064 class Header21xx : public Header
1065 {
1066 public:
1067     Header21xx(Printer* p,PrintContext* pc);
1068     DRIVER_ERROR Send();
1069 };  //Header21xx
1070
1071 //ClassName
1072 /*
1073 ******************************************************************************/
1074 class HeaderLJMono : public Header
1075 {
1076 public:
1077     HeaderLJMono (Printer* p,PrintContext* pc);
1078     virtual DRIVER_ERROR Send();
1079
1080 protected:
1081     DRIVER_ERROR EndJob ();
1082     DRIVER_ERROR Graphics ();
1083     DRIVER_ERROR StartSend ();
1084 }; //HeaderLJMono
1085
1086 //ClassName
1087 /*
1088 ******************************************************************************/
1089 class HeaderLJColor : public Header
1090 {
1091 public:
1092     HeaderLJColor (Printer* p,PrintContext* pc);
1093     virtual DRIVER_ERROR Send();
1094         virtual DRIVER_ERROR FormFeed ();
1095
1096 protected:
1097     DRIVER_ERROR EndJob ();
1098     DRIVER_ERROR Graphics ();
1099     DRIVER_ERROR StartSend ();
1100     DRIVER_ERROR SendCAPy (unsigned int iAbsY);
1101 }; //HeaderLJColor
1102
1103 //ClassName
1104 /*
1105 ******************************************************************************/
1106 class HeaderPScript : public Header
1107 {
1108 public:
1109     HeaderPScript (Printer *p, PrintContext *pc);
1110     DRIVER_ERROR Send ();
1111 protected:
1112     DRIVER_ERROR EndJob ();
1113     DRIVER_ERROR FormFeed ();
1114     DRIVER_ERROR SendCAPy (unsigned int iAbsY);
1115     DRIVER_ERROR StartSend ();
1116 };
1117
1118 //ClassName
1119 /*
1120 ******************************************************************************/
1121 class HeaderLJJetReady : public Header
1122 {
1123         friend class LJJetReady;
1124 public:
1125     HeaderLJJetReady (Printer* p,PrintContext* pc);
1126     virtual DRIVER_ERROR Send();
1127         virtual DRIVER_ERROR FormFeed ();
1128         virtual DRIVER_ERROR StartPage();
1129         virtual DRIVER_ERROR EndPage();
1130 protected:
1131     DRIVER_ERROR EndJob ();
1132     DRIVER_ERROR StartSend ();
1133     DRIVER_ERROR SendCAPy (unsigned int iAbsY);
1134         DRIVER_ERROR MapPCLMediaTypeToString (MEDIATYPE eM);
1135         int                      JRPaperToMediaSize(PAPER_SIZE ps);
1136 }; //HeaderLJJetReady
1137
1138 //ClassName
1139 /*
1140 ******************************************************************************/
1141 class HeaderLJFastRaster : public Header
1142 {
1143         friend class LJFastRaster;
1144 public:
1145     HeaderLJFastRaster (Printer* p,PrintContext* pc);
1146     virtual DRIVER_ERROR Send();
1147         virtual DRIVER_ERROR FormFeed ();
1148         virtual DRIVER_ERROR StartPage();
1149         virtual DRIVER_ERROR EndPage();
1150 protected:
1151     DRIVER_ERROR EndJob ();
1152     DRIVER_ERROR StartSend ();
1153     DRIVER_ERROR SendCAPy (unsigned int iAbsY);
1154         DRIVER_ERROR MapPCLMediaTypeToString (MEDIATYPE eM);
1155         int                      FrPaperToMediaSize(PAPER_SIZE ps);
1156 }; //HeaderLJFastRaster
1157
1158 //ClassName
1159 /*
1160 ******************************************************************************/
1161 class HeaderLJZjs : public Header
1162 {
1163     friend class LJZjs;
1164 public:
1165     HeaderLJZjs (Printer *p, PrintContext *pc);
1166     virtual DRIVER_ERROR Send ();
1167     virtual DRIVER_ERROR FormFeed ();
1168 protected:
1169     DRIVER_ERROR EndJob ();
1170     DRIVER_ERROR SendCAPy (unsigned int iAbsY);
1171 }; // HeaderLJZjs
1172 \r
1173 //ClassName\r
1174 /*\r
1175 ******************************************************************************/\r
1176 class HeaderQuickConnect : public Header\r
1177 {\r
1178 public:\r
1179     HeaderQuickConnect (Printer *p, PrintContext *pc);\r
1180     virtual DRIVER_ERROR Send ();\r
1181     virtual DRIVER_ERROR FormFeed ();\r
1182 protected:\r
1183     DRIVER_ERROR EndJob ();\r
1184     DRIVER_ERROR SendCAPy (unsigned int iAbsY);\r
1185 }; // HeaderQuickConnect\r
1186 \r
1187 //ClassName\r
1188 /*\r
1189 ******************************************************************************/\r
1190
1191 class RasterSender : public Processor
1192 {
1193 friend class Header;
1194 friend class Header895;
1195 friend class Header900;
1196 public:
1197    // installs Header and Connection
1198     RasterSender(Printer* pP, PrintContext* pPC,
1199                 Job* pJob,Halftoner* pHalftoner);
1200
1201     virtual ~RasterSender();
1202
1203     // processor interface ////////////////////////////////////
1204     //BOOL Process(BYTE* InputRaster=NULL, unsigned int size=0);
1205         BOOL Process(RASTERDATA* InputRaster=NULL);
1206     void Flush() { };
1207     BYTE* NextOutputRaster(COLORTYPE  rastercolor) { return NULL; }   // end of pipeline
1208     unsigned int GetOutputWidth(COLORTYPE  rastercolor) { return 0; } // never called
1209
1210
1211     DRIVER_ERROR constructor_error;
1212
1213     DRIVER_ERROR SendRaster(RASTERDATA* InputRaster=NULL);
1214
1215 private:
1216     Printer* thePrinter;
1217
1218     PrintContext* thePrintContext;
1219     Job* theJob;
1220     Halftoner* theHalftoner;
1221     long    m_lNBlankRasters;   /* XXX unused? */
1222 }; //RasterSender
1223
1224 // end of RasterSender section ///////////////////////////////////////////////
1225 ////////////////////////////////////////////////////////////////////////////
1226
1227 #if defined(APDK_FONTS_NEEDED)
1228
1229 //TextMapper
1230 //! Encapsulate mappings
1231 /*!
1232 \internal
1233 Component of TextManager
1234 This class encapsulates mappings that may be peculiar to different partners
1235 or data sources. The use is as follows:
1236  1. invoke Map
1237  2. now access SubstLen and charset
1238
1239 Currently sets charset to LATIN1 at construction.
1240
1241 ******************************************************************************/
1242 class TextMapper
1243 {
1244 public:
1245     TextMapper(TextTranslator* t);
1246
1247     // main function -- puts alternate string in buffer
1248     virtual void Map(BYTE b,BYTE* bSubst);
1249
1250     // public members for access after call to Map()
1251     unsigned int SubstLen;
1252     char charset[MAX_CHAR_SET];
1253
1254 protected:
1255     TextTranslator* theTranslator;
1256 }; //TextMapper
1257
1258 //GenericMapper
1259 //!
1260 /*
1261 ******************************************************************************/
1262 class GenericMapper : public TextMapper
1263 {
1264 public:
1265     GenericMapper(TextTranslator* t);
1266     void Map(BYTE b,BYTE* bSubst);
1267 }; //GenericMapper
1268
1269
1270 //TextManager
1271 //!
1272 /*!
1273 \internal
1274 ******************************************************************************/
1275 class TextManager
1276 // Component of TextJob
1277 {
1278 public:
1279     TextManager(TextTranslator* t,unsigned int PrintableX, unsigned int PrintableY);
1280     virtual ~TextManager();
1281
1282     virtual DRIVER_ERROR TextOut(const char* pTextString, unsigned int iLenString,
1283                 const Font& font, int iAbsX=-1, int iAbsY=-1);
1284     TextTranslator* theTranslator;
1285
1286     DRIVER_ERROR constructor_error;
1287
1288 protected:
1289
1290     unsigned int PrintableRegionX;
1291     unsigned int PrintableRegionY;
1292
1293     DRIVER_ERROR CheckCoords(unsigned int iAbsX, unsigned int iAbsY );
1294
1295     TextMapper* theMapper;
1296
1297 }; //TextManager
1298
1299 #endif     // FONTS
1300
1301 APDK_END_NAMESPACE
1302
1303 #endif //APDK_INTERNAL_H