Tizen 2.1 base
[platform/upstream/hplip.git] / prnt / hpijs / dj540.cpp
1 /*****************************************************************************\
2   dj540.cpp : Implimentation for the DJ540 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_DJ540
33
34 #include "header.h"
35 #include "dj6xx.h"
36 #include "dj600.h"
37 #include "dj540.h"
38 #include "printerproxy.h"
39
40 APDK_BEGIN_NAMESPACE
41
42 extern uint32_t ulMapDJ600_CCM_K[ 9 * 9 * 9 ];
43 extern uint32_t ulMapDJ600_CCM_CMY[ 9 * 9 * 9 ];
44 //
45 // ** DJ540:Printer CLASS **
46 //
47 DJ540::DJ540(SystemServices* pSS, BOOL proto)
48     : DJ6XX(pSS,NUM_DJ6XX_FONTS,proto)
49 {
50
51     if ((!proto) && (IOMode.bDevID))
52     {
53         constructor_error = VerifyPenInfo();
54         CERRCHECK;
55     }
56     else
57     {
58         ePen = COLOR_PEN;    // matches default mode
59     }
60
61     CMYMap = ulMapDJ600_CCM_CMY;
62     pMode[DEFAULTMODE_INDEX] = new Mode600();
63     pMode[GRAYMODE_INDEX] = new GrayMode(ulMapDJ600_CCM_K);
64 #ifdef APDK_EXTENDED_MEDIASIZE
65     pMode[SPECIALMODE_INDEX] = new Mode600DraftGrayK();
66     pMode[SPECIALMODE_INDEX+1] = new Mode600DraftColor();
67     ModeCount = 4;
68 #else
69     ModeCount = 2;
70 #endif
71
72 DBG1("DeskJet 540 created\n");
73 }
74
75 PEN_TYPE DJ540::DefaultPenSet()
76 {
77     return COLOR_PEN;
78 }
79
80 Header540::Header540(Printer* p,PrintContext* pc)
81     : Header(p,pc)
82 { }
83
84 DRIVER_ERROR Header540::Send()
85 // Sends 540-style header to printer.
86 // Identical to 600 Send except StartSend() has been removed.
87 // Removed ConfigureRasterData() to be downword compatable with 400 (uni-di only). des
88 {   DRIVER_ERROR err;
89
90     // modes & margins are specified in StartSend - which the 540 doesn't call
91     err=Modes();            // Set media source, type, size and quality modes.
92     ERRCHECK;
93
94     err=Margins();          // set margins
95     ERRCHECK;
96
97     err=Simple();           // set color mode and resolution
98     ERRCHECK;
99
100     err=Graphics();     // start raster graphics and set compression mode
101
102 return err;
103 }
104
105 Header* DJ540::SelectHeader(PrintContext* pc)
106 {
107     return new Header540(this,pc);
108 }
109
110 DRIVER_ERROR DJ540::VerifyPenInfo()
111 // note: this function is identical to 600::VerifyPenInfo
112 {
113     DRIVER_ERROR err = NO_ERROR;
114
115     if(IOMode.bDevID == FALSE)
116         return err;
117
118     err = ParsePenInfo(ePen);
119     ERRCHECK;
120
121     if(ePen == BLACK_PEN || ePen == COLOR_PEN)
122     // pen was recognized
123     {
124         return NO_ERROR;
125     }
126
127     // BLACK_PEN and COLOR_PEN are the only valid pens, so loop and
128     // display error message until user cancels or a valid pen installed
129     while(ePen != BLACK_PEN && ePen != COLOR_PEN)
130     {
131         pSS->DisplayPrinterStatus(DISPLAY_NO_PEN_DJ600);
132
133         if(pSS->BusyWait(500) == JOB_CANCELED)
134         {
135             return JOB_CANCELED;
136         }
137
138         err =  ParsePenInfo(ePen);
139         ERRCHECK;
140     }
141
142     pSS->DisplayPrinterStatus(DISPLAY_PRINTING);
143
144     // The 600/?540? will report OFFLINE for a while after the
145     // pen has been installed.  Let's wait for it to
146     // come online and not confuse the user with a potentially
147     // bogus OFFLINE message
148
149     if (pSS->BusyWait((DWORD)1000) == JOB_CANCELED)
150         return JOB_CANCELED;
151
152     return NO_ERROR;
153
154 }
155
156
157 DRIVER_ERROR DJ540::ParsePenInfo(PEN_TYPE& ePen, BOOL QueryPrinter)
158 {
159      char* c;
160      DRIVER_ERROR err = SetPenInfo(c, QueryPrinter);
161      ERRCHECK;
162
163     if (*c != '$')
164     {
165         return BAD_DEVICE_ID;
166     }
167
168      c++;   // skip $
169
170     // parse penID
171
172     if(c[0] == 'D')         // D = kukla color pen
173     {
174         ePen = COLOR_PEN;
175     }
176     else if(c[0] == 'E')    // E = triad black pen
177     {
178             ePen = BLACK_PEN;
179     }
180     else
181     {
182         ePen = NO_PEN;
183     }
184
185     return NO_ERROR;
186 }
187
188 APDK_END_NAMESPACE
189
190 #endif  //APDK_DJ540