1 /*****************************************************************************\
2 dj690.cpp : Implimentation for the DJ6xxPhoto class
3
4 Copyright (c) 1996 - 2015, HP 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 HP 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_DJ6xxPhoto
33
34 #include "header.h"
35 #include "dj690.h"
36 #include "printerproxy.h"
37
38 APDK_BEGIN_NAMESPACE
39
40 extern uint32_t ulMapDJ690_CMYK[ 9 * 9 * 9 ];
41 extern uint32_t ulMapDJ690_ClMlxx[ 9 * 9 * 9 ];
42 extern uint32_t ulMapDJ660_CCM_KCMY[ 9 * 9 * 9 ];
43 extern uint32_t ulMapDJ600_CCM_K[ 9 * 9 * 9 ];
44
45 //
46 // ** DJ6xxPhoto:Printer CLASS **
47 //
Mode690()48 Mode690::Mode690()
49 // print mode for photo pen
50 : PrintMode( ulMapDJ690_CMYK, ulMapDJ690_ClMlxx )
51 {
52 dyeCount=6;
53 medium = mediaSpecial;
54 theQuality = qualityPresentation;
55 // theQuality = qualityNormal;
56
57 BaseResX = 600;
58 for (int i=0; i < 6; i++)
59 ResolutionX[i]=600;
60
61 CompatiblePens[0] = MDL_BOTH;
62
63 // strcpy(ModeName, "Photo");
64
65 pmQuality = QUALITY_BEST;
66 pmMediaType = MEDIA_PREMIUM;
67
68 }
69
GrayMode690()70 GrayMode690::GrayMode690()
71 // print mode for photo pen
72 : PrintMode( ulMapDJ600_CCM_K )
73 {
74 CompatiblePens[1] = MDL_BOTH;
75
76 dyeCount = 1;
77
78 pmColor=GREY_K;
79
80 }
81
82 #ifdef APDK_EXTENDED_MEDIASIZE
Mode690DraftColor()83 Mode690DraftColor::Mode690DraftColor()
84 : PrintMode( ulMapDJ660_CCM_KCMY )
85 {
86 theQuality = qualityDraft;
87 Config.eHT = MATRIX;
88 pmQuality = QUALITY_DRAFT;
89 }
90
Mode690DraftGrayK()91 Mode690DraftGrayK::Mode690DraftGrayK()
92 : GrayMode(ulMapDJ600_CCM_K)
93 {
94 theQuality = qualityDraft;
95 pmQuality = QUALITY_DRAFT;
96 }
97
Mode690BestGrayK()98 Mode690BestGrayK::Mode690BestGrayK()
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
DJ6xxPhoto(SystemServices * pSS,BOOL proto)115 DJ6xxPhoto::DJ6xxPhoto(SystemServices* pSS, BOOL proto)
116 : Printer(pSS, NUM_DJ6XX_FONTS,proto)
117 // create two dummy font objects to be queried via EnumFont
118 {
119
120 if ((!proto) && (IOMode.bDevID))
121 {
122 constructor_error = VerifyPenInfo();
123 CERRCHECK;
124 }
125 else
126 {
127 ePen=BOTH_PENS; // matches default mode
128 }
129
130 pMode[DEFAULTMODE_INDEX] = new PrintMode( ulMapDJ660_CCM_KCMY ); // normal color
131 pMode[GRAYMODE_INDEX] = new GrayMode690(); // normal gray k
132 pMode[SPECIALMODE_INDEX] = new Mode690(); // photo
133 #ifdef APDK_EXTENDED_MEDIASIZE
134 pMode[SPECIALMODE_INDEX+1] = new Mode690DraftGrayK();
135 pMode[SPECIALMODE_INDEX+2] = new Mode690DraftColor();
136 pMode[SPECIALMODE_INDEX+3] = new Mode690BestGrayK();
137 ModeCount=6;
138 #else
139 ModeCount = 3;
140 #endif
141
142 CMYMap = ulMapDJ660_CCM_KCMY;
143
144 DBG1("DJ6xxPhoto created\n");
145
146 }
147
148
Header690(Printer * p,PrintContext * pc)149 Header690::Header690(Printer* p,PrintContext* pc)
150 : Header(p,pc)
151 { }
152
SelectHeader(PrintContext * pc)153 Header* DJ6xxPhoto::SelectHeader(PrintContext* pc)
154 {
155 return new Header690(this, pc);
156 }
157
Send()158 DRIVER_ERROR Header690::Send()
159 { DRIVER_ERROR err;
160
161 StartSend();
162
163 err = thePrinter->Send((const BYTE*)BlackExtractOff,
164 sizeof(BlackExtractOff)); // just pertains to 2-pen
165 ERRCHECK;
166
167 err = ConfigureRasterData();
168 ERRCHECK;
169
170 if (ResolutionY[0] == 600)
171 {
172 char uom[10];
173 sprintf(uom,"%c%c%c%d%c",ESC,'&','u',thePrintMode->ResolutionY[K],'D');
174 err=thePrinter->Send((const BYTE*)uom, 7 );
175 ERRCHECK;
176 }
177
178 err=Graphics(); // start raster graphics and set compression mode
179
180 return err;
181 }
VerifyPenInfo()182 DRIVER_ERROR DJ6xxPhoto::VerifyPenInfo()
183 {
184
185 DRIVER_ERROR err=NO_ERROR;
186
187 if(IOMode.bDevID == FALSE)
188 return err;
189
190 err = ParsePenInfo(ePen);
191 ERRCHECK;
192
193 // check for the normal case
194 if (ePen == BOTH_PENS || ePen == MDL_BOTH)
195 return NO_ERROR;
196
197 DBG1("DJ6xxPhoto::VerifyPenInfo(): ePen is not BOTH_PENS or MDL_BOTH\n");
198
199 // the 6XX printers are all two-pen, so trap
200 // on any pen type that is not MDL_BOTH or
201 // BOTH_PENS
202 while ( (ePen != BOTH_PENS) && (ePen != MDL_BOTH) )
203 {
204 DBG1("DJ6xxPhoto::VerifyPenInfo(): in while loop\n");
205
206 switch (ePen)
207 {
208 case MDL_PEN:
209 case BLACK_PEN:
210 // black or photopen installed, need to install color pen
211 pSS->DisplayPrinterStatus(DISPLAY_NO_COLOR_PEN);
212 break;
213 case COLOR_PEN:
214 // color pen installed, need to install black pen
215 // - use ambiguous message because of black or photo pen
216 pSS->DisplayPrinterStatus(DISPLAY_NO_PEN_DJ600);
217 break;
218 case NO_PEN:
219 // neither pen installed
220 default:
221 pSS->DisplayPrinterStatus(DISPLAY_NO_PENS);
222 break;
223 }
224
225 if (pSS->BusyWait(500) == JOB_CANCELED)
226 return JOB_CANCELED;
227
228 err = ParsePenInfo(ePen);
229 ERRCHECK;
230 }
231
232 pSS->DisplayPrinterStatus(DISPLAY_PRINTING);
233
234 return NO_ERROR;
235
236 }
237
ParsePenInfo(PEN_TYPE & ePen,BOOL QueryPrinter)238 DRIVER_ERROR DJ6xxPhoto::ParsePenInfo(PEN_TYPE& ePen, BOOL QueryPrinter)
239 {
240 char* str;
241 DRIVER_ERROR err = SetPenInfo(str, QueryPrinter);
242 ERRCHECK;
243
244 if (*str != '$')
245 {
246 return BAD_DEVICE_ID;
247 }
248
249 str++; // skip $
250 // parse penID
251 PEN_TYPE temp_pen1;
252 // check pen1, assume it is black or MDL, pen2 is color
253 switch (str[0])
254 {
255 // check for MDL in case someone wedged one in there
256 case 'M': temp_pen1 = MDL_PEN; break; // (M)ulti-Dye load pen
257 case 'C': temp_pen1 = BLACK_PEN; break; // (C)andide black
258 default: temp_pen1 = NO_PEN; break;
259 }
260
261 // now check pen2
262
263 int i=2;
264 while((i < DevIDBuffSize) && str[i]!='$') i++; // handles variable length penIDs
265 if (i == DevIDBuffSize)
266 {
267 return BAD_DEVICE_ID;
268 }
269
270 i++;
271
272 if(str[i]=='R') // we have the (R)obinhood color pen,
273 // check what pen1 was
274 {
275 if (temp_pen1 == BLACK_PEN)
276 ePen = BOTH_PENS;
277 else
278 {
279 if (temp_pen1 == MDL_PEN)
280 ePen = MDL_BOTH;
281 else
282 ePen = COLOR_PEN;
283 }
284 }
285 else // no color pen, just set what pen1 was
286 ePen = temp_pen1;
287
288 return NO_ERROR;
289 }
290
291 APDK_END_NAMESPACE
292
293 #endif //APDK_DJ690
294