Tizen 2.1 base
[platform/upstream/hplip.git] / prnt / hpijs / dj3600.cpp
1 /*****************************************************************************\
2   dj3600.cpp : Implimentation for the DJ3600 class
3
4   Copyright (c) 2003-2003, 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 #if defined(APDK_DJ3600) && defined (APDK_DJ3320)
33
34 #include "header.h"
35 #include "dj3320.h"
36 #include "dj3600.h"
37 #include "printerproxy.h"
38
39 APDK_BEGIN_NAMESPACE
40
41 DJ3600::DJ3600 (SystemServices* pSS, BOOL proto)
42     : DJ3320 (pSS, proto)
43 {
44 }
45
46 /*
47 * byte 13 - indicates full bleed (to every edge of paper) is supported if 
48 * the modifier bit in the lowest position is "set".  
49 *
50
51 * 0000b or 0h = Unimplemented, or not specified.
52 * 0001b or 1h = Full bleed (4 edge) printing supported on photo quality papers; this field is a modifier upon the bits in byte 12. That is, if this bit is set, it implies that the "max print width supported" values and smaller widths, ALL support full bleed, 4 edge, printing on photo quality paper.
53 * 0010b or 2h = Full bleed (4 edge) printing supported on non-photo papers (e.g. plain, bond, etc.); this field is a modifier upon the bits in byte 12. If this bit is set, it implies that the "max print width supported" values and smaller widths, all support full bleed, 4 edge, printing on non-photo paper.
54 * nn00b  = The "nn" bits are reserved for future definitions
55 */
56
57 BOOL DJ3600::FullBleedCapable (PAPER_SIZE ps, FullbleedType  *fbType, float *xOverSpray, float *yOverSpray,
58                                      float *fLeftOverSpray, float *fTopOverSpray)
59 {
60     BYTE    sDevIdStr[DevIDBuffSize];
61     char    *pStr;
62     if (pSS->IOMode.bDevID && (pSS->GetDeviceID (sDevIdStr, DevIDBuffSize, FALSE)) == NO_ERROR)
63     {
64         if ((pStr = strstr ((char *) sDevIdStr, ";S:")))
65         {
66                         char  byte13 = pStr[18];
67                         short value = (byte13 >= '0' && byte13 <= '9') ? byte13 - '0' : 
68                                           ((byte13 >= 'A' && byte13 <= 'F') ? byte13 - 'A' + 10 :
69                                           ((byte13 >= 'a' && byte13 <= 'f') ? byte13 - 'a' + 10 : -1));
70                         switch (ps)
71                         {
72                                 case PHOTO_SIZE:
73                                 case A6:
74                                 case CARD_4x6:
75                                 case OUFUKU:
76                                 case HAGAKI:
77                                 case A6_WITH_TEAR_OFF_TAB:
78                                 {
79                                         *xOverSpray = (float) 0.216;
80                                         *yOverSpray = (float) 0.174;
81
82                                         if (fLeftOverSpray)
83                                                 *fLeftOverSpray = (float) 0.098;
84                                         if (fTopOverSpray)
85                                                 *fTopOverSpray  = (float) 0.070;
86
87                                         if (ps == PHOTO_SIZE || ps == A6_WITH_TEAR_OFF_TAB)
88                                                 *fbType = fullbleed4EdgeAllMedia;
89                                         else if ((value != -1) && ((value & 0x03) == 0x03))
90                                                 *fbType = fullbleed4EdgeAllMedia;
91                                         else if ((value != -1) && ((value & 0x01) == 0x01))
92                                                 *fbType = fullbleed4EdgePhotoMedia;
93                                         else if ((value != -1) && ((value & 0x02) == 0x02))
94                                                 *fbType = fullbleed4EdgeNonPhotoMedia;
95                                         else
96                                                 *fbType = fullbleed3EdgeAllMedia;
97
98                                         return TRUE;
99                                 }
100                                 default:
101                                         break;
102                         }
103         }
104     }
105         else
106         {
107                 switch (ps)
108                 {
109                         case PHOTO_SIZE:
110                         case A6:
111                         case CARD_4x6:
112                         case OUFUKU:
113                         case HAGAKI:
114                         case A6_WITH_TEAR_OFF_TAB:
115                         {
116                                 *xOverSpray = (float) 0.216;
117                                 *yOverSpray = (float) 0.174;
118
119                                 if (fLeftOverSpray)
120                                         *fLeftOverSpray = (float) 0.098;
121                                 if (fTopOverSpray)
122                                         *fTopOverSpray  = (float) 0.070;
123
124                                 if (ps == PHOTO_SIZE || ps == A6_WITH_TEAR_OFF_TAB)
125                                         *fbType = fullbleed4EdgeAllMedia;
126                                 else
127                                         *fbType = fullbleed3EdgeAllMedia;
128
129                                 return TRUE;
130                         }
131                         default:
132                                 break;
133                 }
134         }
135     *xOverSpray = (float) 0;
136     *yOverSpray = (float) 0;
137     if (fLeftOverSpray)
138         *fLeftOverSpray = (float) 0;
139     if (fTopOverSpray)
140         *fTopOverSpray  = (float) 0;
141         *fbType = fullbleedNotSupported;
142     return FALSE;
143 }
144
145
146 APDK_END_NAMESPACE
147
148 #endif // defined(APDK_DJ3600) && defined (APDK_DJ3320)