Tizen 2.1 base
[platform/upstream/hplip.git] / prnt / hpijs / dj660.cpp
1 /*****************************************************************************\
2   dj660.cpp : Implimentation for the DJ660 class
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 #ifdef APDK_DJ6xx
33
34 #include "header.h"
35 #include "dj6xx.h"
36 #include "dj660.h"
37 #include "printerproxy.h"
38
39 APDK_BEGIN_NAMESPACE
40
41 extern uint32_t ulMapDJ660_CCM_KCMY[ 9 * 9 * 9 ];
42 extern uint32_t ulMapDJ600_CCM_K[ 9 * 9 * 9 ];
43 extern uint32_t ulMapDJ600_CCM_CMY[ 9 * 9 * 9 ];
44 //
45 // ** DJ660:Printer CLASS **
46 //
47
48 DJ660::DJ660(SystemServices* pSS,BOOL proto)
49     : DJ6XX(pSS,NUM_DJ6XX_FONTS,proto)
50 // create two dummy font objects to be queried via EnumFont
51 {
52 DBG1("DJ660::VerifyPenInfo(): called\n");
53
54     if ((!proto) && (IOMode.bDevID))
55       {
56         constructor_error = VerifyPenInfo();
57         CERRCHECK;
58       }
59     else ePen=BOTH_PENS;    // matches default mode
60
61     pMode[DEFAULTMODE_INDEX] = new PrintMode( ulMapDJ660_CCM_KCMY );
62     pMode[GRAYMODE_INDEX] = new GrayMode(ulMapDJ600_CCM_K);
63     pMode[SPECIALMODE_INDEX] = new Mode660Draft();
64 #ifdef APDK_EXTENDED_MEDIASIZE
65     pMode[SPECIALMODE_INDEX+1] = new Mode660DraftGrayK();
66     pMode[SPECIALMODE_INDEX+2] = new Mode660BestGrayK();
67     ModeCount=5;
68 #else
69     ModeCount=3;
70 #endif
71     CMYMap = ulMapDJ660_CCM_KCMY;
72
73
74 DBG1("DJ 660 created\n");
75 }
76
77 Mode660Draft::Mode660Draft()
78 : PrintMode( ulMapDJ660_CCM_KCMY )
79 {
80   theQuality = qualityDraft;
81
82     Config.eHT = MATRIX;
83
84     pmQuality = QUALITY_DRAFT;
85
86 //   strcpy(ModeName, "Draft");
87
88 }
89
90 #ifdef APDK_EXTENDED_MEDIASIZE
91 Mode660DraftGrayK::Mode660DraftGrayK()
92 : GrayMode(ulMapDJ600_CCM_K)
93 {
94    theQuality = qualityDraft;
95    pmQuality = QUALITY_DRAFT;
96 }
97
98 Mode660BestGrayK::Mode660BestGrayK()
99 : GrayMode(ulMapDJ600_CCM_K)
100 {
101    theQuality = qualityPresentation;
102    pmQuality = QUALITY_BEST;
103    BaseResX = 600;
104    ResolutionX[0] = 600;
105 #ifdef APDK_HIGH_RES_MODES
106    BaseResY = 600;
107    ResolutionY[0] = 600;
108 #else
109    BaseResY = 300;
110    ResolutionY[0] = 300;
111 #endif
112 }
113 #endif // APDK_EXTENDED_MEDIASIZE
114
115 Header* DJ660::SelectHeader(PrintContext* pc)
116 {
117     return new Header6XX(this,pc);
118 }
119
120 DRIVER_ERROR DJ660::VerifyPenInfo()
121 {
122
123     DRIVER_ERROR err=NO_ERROR;
124
125     if(IOMode.bDevID == FALSE)
126         return err;
127
128     err = ParsePenInfo(ePen);
129     ERRCHECK;
130
131
132     // check for the normal case
133     if (ePen == BOTH_PENS)
134         return NO_ERROR;
135
136
137     // the 6XX printers are all two-pen, so trap
138     // on any pen type that is not BOTH_PENS
139     while ( ePen != BOTH_PENS )
140     {
141
142         switch (ePen)
143         {
144             case MDL_BOTH:
145             case MDL_PEN:
146                 // user shouldn't be able to get photopen in a non-690...
147                 pSS->DisplayPrinterStatus(DISPLAY_PHOTO_PEN_WARN);
148                 break;
149             case BLACK_PEN:
150                 // black pen installed, need to install color pen
151                 pSS->DisplayPrinterStatus(DISPLAY_NO_COLOR_PEN);
152                 break;
153             case COLOR_PEN:
154                 // color pen installed, need to install black pen
155                 pSS->DisplayPrinterStatus(DISPLAY_NO_BLACK_PEN);
156                 break;
157             case NO_PEN:
158                 // neither pen installed
159             default:
160                 pSS->DisplayPrinterStatus(DISPLAY_NO_PENS);
161                 break;
162         }
163
164         if (pSS->BusyWait(500) == JOB_CANCELED)
165             return JOB_CANCELED;
166
167         err =  ParsePenInfo(ePen);
168         ERRCHECK;
169     }
170
171     pSS->DisplayPrinterStatus(DISPLAY_PRINTING);
172
173     return NO_ERROR;
174
175 }
176
177 DRIVER_ERROR DJ660::ParsePenInfo(PEN_TYPE& ePen, BOOL QueryPrinter)
178 {
179     char* str;
180     DRIVER_ERROR err = SetPenInfo(str, QueryPrinter);
181     ERRCHECK;
182
183     if (*str != '$')
184     {
185         return BAD_DEVICE_ID;
186     }
187
188     str++;  // skip $
189     // parse penID
190     PEN_TYPE temp_pen1;
191     // check pen1, assume it is black or MDL, pen2 is color
192     switch (str[0])
193     {
194         // check for MDL in case someone wedged one in there
195         case 'M': temp_pen1 = MDL_PEN; break; // (M)ulti-Dye load pen
196         case 'C': temp_pen1 = BLACK_PEN; break; // (C)andide black
197         default:  temp_pen1 = NO_PEN; break;
198     }
199
200     // now check pen2
201
202     int i=2;
203     while((i < DevIDBuffSize) && str[i]!='$') i++; // handles variable length penIDs
204     if (i == DevIDBuffSize)
205     {
206         return BAD_DEVICE_ID;
207     }
208
209     i++;
210
211     if(str[i]=='R') // we have the (R)obinhood color pen,
212                     // check what pen1 was
213     {
214         if (temp_pen1 == BLACK_PEN)
215                 ePen = BOTH_PENS;
216         else
217         {
218             if (temp_pen1 == MDL_PEN)
219                 ePen = MDL_BOTH;
220             else
221                 ePen = COLOR_PEN;
222         }
223     }
224     else // no color pen, just set what pen1 was
225         ePen = temp_pen1;
226
227     return NO_ERROR;
228 }
229
230 APDK_END_NAMESPACE
231
232 #endif  //APDK_DJ660