Tizen 2.1 base
[platform/upstream/hplip.git] / prnt / hpijs / dj600.cpp
1 /*****************************************************************************\
2   dj600.cpp : Implimentation for the DJ600 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_DJ600
33
34 #include "header.h"
35 #include "dj6xx.h"
36 #include "dj600.h"
37 #include "printerproxy.h"
38
39 APDK_BEGIN_NAMESPACE
40
41 extern uint32_t ulMapDJ600_CCM_K[ 9 * 9 * 9 ];
42 extern uint32_t ulMapDJ600_CCM_CMY[ 9 * 9 * 9 ];
43 //
44 // ** DJ600:Printer CLASS **
45 //
46
47 Mode600::Mode600()
48 : PrintMode( ulMapDJ600_CCM_CMY )
49 {
50    dyeCount=3;
51    CompatiblePens[0] = COLOR_PEN;   // only color pen allowed
52 }
53
54 #ifdef APDK_EXTENDED_MEDIASIZE
55 Mode600DraftColor::Mode600DraftColor()
56 : PrintMode( ulMapDJ600_CCM_CMY )
57 {
58     dyeCount=3;
59     CompatiblePens[0] = COLOR_PEN;   // only color pen allowed
60     theQuality = qualityDraft;
61     pmQuality = QUALITY_DRAFT;
62 }
63
64 Mode600DraftGrayK::Mode600DraftGrayK()
65 : GrayMode(ulMapDJ600_CCM_K)
66 {
67    theQuality = qualityDraft;
68    pmQuality = QUALITY_DRAFT;
69 }
70
71 Mode600BestGrayK::Mode600BestGrayK()
72 : GrayMode(ulMapDJ600_CCM_K)
73 {
74    theQuality = qualityPresentation;
75    pmQuality = QUALITY_BEST;
76    BaseResX = 600;
77    ResolutionX[0] = 600;
78 #ifdef APDK_HIGH_RES_MODES
79    BaseResY = 600;
80    ResolutionY[0] = 600;
81 #else
82    BaseResY = 300;
83    ResolutionY[0] = 300;
84 #endif
85 }
86 #endif // APDK_EXTENDED_MEDIASIZE
87
88 DJ600::DJ600(SystemServices* pSS, BOOL proto)
89     : DJ6XX(pSS, NUM_DJ6XX_FONTS,proto)
90 {
91     if ((!proto) && (IOMode.bDevID))
92     {
93         constructor_error = VerifyPenInfo();
94         CERRCHECK;
95     }
96     else
97     {
98         ePen=COLOR_PEN;    // matches default mode
99     }
100
101     CMYMap = ulMapDJ600_CCM_CMY;
102
103     pMode[DEFAULTMODE_INDEX] = new Mode600();
104     pMode[GRAYMODE_INDEX] = new GrayMode(ulMapDJ600_CCM_K);
105 #ifdef APDK_EXTENDED_MEDIASIZE
106     pMode[SPECIALMODE_INDEX] = new Mode600DraftGrayK();
107     pMode[SPECIALMODE_INDEX+1] = new Mode600DraftColor();
108     pMode[SPECIALMODE_INDEX+2] = new Mode600BestGrayK();
109 #endif
110
111 DBG1("DeskJet 600 created\n");
112 }
113
114 PEN_TYPE DJ600::DefaultPenSet()
115 {
116     return COLOR_PEN;
117 }
118
119 Header600::Header600(Printer* p,PrintContext* pc)
120     : Header6XX(p,pc)
121 { }
122
123 DRIVER_ERROR Header600::Send()
124 // Sends 600-style header to printer.
125 {   DRIVER_ERROR err;
126
127     StartSend();
128
129     if (dyeCount==3)    // color pen
130       {
131         err = ConfigureRasterData();
132         ERRCHECK;
133       }
134     else                // black pen
135       {
136         err=Simple();           // set color mode and resolution
137         ERRCHECK;
138       }
139
140     err=Graphics();     // start raster graphics and set compression mode
141
142 return err;
143 }
144
145 Header* DJ600::SelectHeader(PrintContext* pc)
146 {
147     return new Header600(this,pc);
148 }
149
150 DRIVER_ERROR DJ600::VerifyPenInfo()
151 {
152     DRIVER_ERROR err=NO_ERROR;
153
154     if(IOMode.bDevID == FALSE)
155         return err;
156
157     err = ParsePenInfo(ePen);
158     ERRCHECK;
159
160     if (ePen == BLACK_PEN || ePen == COLOR_PEN)
161     // pen was recognized
162     {
163         return NO_ERROR;
164     }
165
166     // BLACK_PEN and COLOR_PEN are the only valid pens, so loop and
167     // display error message until user cancels or a valid pen installed
168     while(ePen != BLACK_PEN && ePen != COLOR_PEN)
169     {
170         pSS->DisplayPrinterStatus(DISPLAY_NO_PEN_DJ600);
171
172         if(pSS->BusyWait(500) == JOB_CANCELED)
173         {
174             return JOB_CANCELED;
175         }
176
177         err = ParsePenInfo(ePen);
178         ERRCHECK;
179     }
180
181     pSS->DisplayPrinterStatus(DISPLAY_PRINTING);
182
183     // The 600 will report OFFLINE for a while after the
184     // pen has been installed.  Let's wait for it to
185     // come online and not confuse the user with a potentially
186     // bogus OFFLINE message
187
188     if (pSS->BusyWait((DWORD)1000) == JOB_CANCELED)
189         return JOB_CANCELED;
190
191     return NO_ERROR;
192
193 }
194
195 DRIVER_ERROR DJ600::ParsePenInfo(PEN_TYPE& ePen, BOOL QueryPrinter)
196 {
197     char* c;
198     DRIVER_ERROR err = SetPenInfo(c, QueryPrinter);
199     ERRCHECK;
200
201     if (*c != '$')
202     {
203         return BAD_DEVICE_ID;
204     }
205
206     c++;    // skip $
207     // parse penID
208
209     if(c[0] == 'R')         // (R)obinhood color
210         ePen = COLOR_PEN;
211     else if(c[0] == 'C')    // (C)andide black
212             ePen = BLACK_PEN;
213          else ePen = NO_PEN;
214
215     return NO_ERROR;
216 }
217
218 APDK_END_NAMESPACE
219
220 #endif  //APDK_DJ600