1 /*
2 * PCL6Cap.cpp
3 * Copyright 1999-2000 Y.Takagi. All Rights Reserved.
4 * Copyright 2003-2007 Michael Pfeiffer.
5 */
6 #include "PCL6Cap.h"
7
8 #include "PCL6Config.h"
9 #include "PCL6Writer.h"
10 #include "PrinterData.h"
11
12 #define TO72DPI(a) (a * 72.0f / 600.0f)
13
14 // since 1.1
15 const PaperCap letter(
16 "Letter",
17 false,
18 JobData::kLetter,
19 BRect(0.0f, 0.0f, TO72DPI(5100.0f), TO72DPI(6600.0f)),
20 BRect(TO72DPI(120.0f), TO72DPI(120.0f), TO72DPI(4980.0f), TO72DPI(6480.0f)));
21
22 // since 1.1
23 const PaperCap legal(
24 "Legal",
25 false,
26 JobData::kLegal,
27 BRect(0.0f, 0.0f, TO72DPI(5100.0f), TO72DPI(8400.0f)),
28 BRect(TO72DPI(120.0f), TO72DPI(120.0f), TO72DPI(4980.0f), TO72DPI(8280.0f)));
29
30 // since 1.1
31 const PaperCap a4(
32 "A4",
33 true,
34 JobData::kA4,
35 BRect(0.0f, 0.0f, TO72DPI(4960.0f), TO72DPI(7014.0f)),
36 BRect(TO72DPI(120.0f), TO72DPI(120.0f), TO72DPI(4840.0f), TO72DPI(6894.0f)));
37
38 // TODO
39 // since 1.1
40 const PaperCap exec(
41 "Executive",
42 false,
43 JobData::kA4,
44 BRect(0.0f, 0.0f, TO72DPI(4960.0f), TO72DPI(7014.0f)),
45 BRect(TO72DPI(120.0f), TO72DPI(120.0f), TO72DPI(4840.0f), TO72DPI(6894.0f)));
46
47 // TODO
48 // since 1.1
49 const PaperCap ledger(
50 "Ledger",
51 false,
52 JobData::kLegal,
53 BRect(0.0f, 0.0f, TO72DPI(5100.0f), TO72DPI(8400.0f)),
54 BRect(TO72DPI(120.0f), TO72DPI(120.0f), TO72DPI(4980.0f), TO72DPI(8280.0f)));
55
56 // since 1.1
57 const PaperCap a3(
58 "A3",
59 false,
60 JobData::kA3,
61 BRect(0.0f, 0.0f, TO72DPI(7014.0f), TO72DPI(9920.0f)),
62 BRect(TO72DPI(120.0f), TO72DPI(120.0f), TO72DPI(6894.0f), TO72DPI(9800.0f)));
63
64 // TODO
65 // COM10Envelope
66 // since 1.1
67
68 // MonarchEnvelope
69 // since 1.1
70
71 // C5Envelope
72 // since 1.1
73
74 // DLEnvelope
75 // since 1.1
76
77 // JB4Paper
78 // since 1.1
79
80 // JB5Paper
81 // since 1.1
82
83 // since 2.1
84 const PaperCap b5(
85 "B5",
86 false,
87 JobData::kB5,
88 BRect(0.0f, 0.0f, TO72DPI(4298.0f), TO72DPI(6070.0f)),
89 BRect(TO72DPI(120.0f), TO72DPI(120.0f), TO72DPI(4178.0f), TO72DPI(5950.0f)));
90
91 // since 1.1
92 const PaperCap japanese_postcard(
93 "Japanese Postcard",
94 false,
95 JobData::kJapanesePostcard,
96 BRect(0.0f, 0.0f, TO72DPI(2362.0f), TO72DPI(3506.0f)),
97 BRect(TO72DPI(120.0f), TO72DPI(120.0f), TO72DPI(2242.0f), TO72DPI(3386.0f)));
98
99 // TODO
100 // JDoublePostcard
101 // since 1.1
102
103 // since 1.1
104 const PaperCap a5(
105 "A5",
106 false,
107 JobData::kA5,
108 BRect(0.0f, 0.0f, TO72DPI(3506.0f), TO72DPI(4960.0f)),
109 BRect(TO72DPI(120.0f), TO72DPI(120.0f), TO72DPI(3386.0f), TO72DPI(4840.0f)));
110
111 // TODO
112 // A6
113 // since 2.0
114
115 // JB6
116 // since 2.0
117 // TBD: Validate. Is this JB4?
118 const PaperCap b4(
119 "B4",
120 false,
121 JobData::kB4,
122 BRect(0.0f, 0.0f, TO72DPI(6070.0f), TO72DPI(8598.0f)),
123 BRect(TO72DPI(120.0f), TO72DPI(120.0f), TO72DPI(5950.0f), TO72DPI(8478.0f)));
124
125
126 // JIS8K
127 // since 2.1
128
129 // JIS16K
130 // since 2.1
131
132 // JISExec
133 // since 2.1
134
135 // since 1.1
136 const PaperSourceCap defaultSource("Default", false, JobData::kCassette1);
137 const PaperSourceCap autobin("Auto", true, JobData::kAuto);
138 const PaperSourceCap manualFeed("Manual Feed", false, JobData::kManual);
139 const PaperSourceCap multiPurposeTray("Multi Purpose Tray", false,
140 JobData::kCassette3);
141 const PaperSourceCap upperCassette("Upper Cassette", false, JobData::kUpper);
142 const PaperSourceCap lowerCassette("Lower Cassette", false, JobData::kLower);
143 const PaperSourceCap envelopeTray("Envelope Tray", false,
144 JobData::kCassette2);
145 // since 2.0:
146 const PaperSourceCap thridCassette("Thrid Cassette", false, JobData::kMiddle);
147
148 const ResolutionCap dpi150("150dpi", false, 0, 150, 150);
149 const ResolutionCap dpi300("300dpi", true, 1, 300, 300);
150 const ResolutionCap dpi600("600dpi", false, 2, 600, 600);
151 const ResolutionCap dpi1200("1200dpi", false, 3, 1200, 1200);
152
153 const PrintStyleCap simplex("Simplex", true, JobData::kSimplex);
154 const PrintStyleCap duplex("Duplex", false, JobData::kDuplex);
155
156 const ProtocolClassCap pc1_1("PCL 6 Protocol Class 1.1", true,
157 PCL6Writer::kProtocolClass1_1,
158 "The printer driver supports the following features of protocol class 1.1:"
159 "\n"
160 "* Monochrome and Color Printing.\n"
161 "* Paper Formats: Letter, Legal, A4, A3, A5 and Japanese Postcard.\n"
162 "* Paper Sources: Auto, Default, Manual Feed, Multi-Purpose Tray, Upper "
163 "and Lower Cassette and Envelope Tray.\n"
164 "* Resolutions: 150, 300, 600 and 1200 DPI."
165 #if ENABLE_RLE_COMPRESSION
166 "\n* Compression Method: RLE."
167 #else
168 "\n* Compression Method: None."
169 #endif
170 );
171
172 const ProtocolClassCap pc2_0("PCL 6 Protocol Class 2.0", false,
173 PCL6Writer::kProtocolClass2_0,
174 "In addition to features of protocol class 1.1, the printer driver "
175 "supports the following features of protocol class 2.0:\n"
176 "* Additonal Paper Source: Third Cassette."
177 // "\n* JPEG compression (not implemented yet)"
178 );
179
180 const ProtocolClassCap pc2_1("PCL 6 Protocol Class 2.1", false,
181 PCL6Writer::kProtocolClass2_1,
182 "In addition to features of previous protocol classes, the printer driver "
183 "supports the following features of protocol class 2.1:\n"
184 "* Additional Paper Format: B5."
185 #if ENABLE_DELTA_ROW_COMPRESSION
186 "\n* Additional Compression Method: Delta Row Compression."
187 #endif
188 );
189
190 // Disable until driver supports new features of protocol class 3.0
191 // const ProtocolClassCap pc3_0("PCL 6 Protocol Class 3.0", false,
192 // PCL6Writer::kProtocolClass3_0, "Protocol Class 3.0");
193
194 const PaperCap* papers1_1[] = {
195 &letter,
196 &legal,
197 &a4,
198 &a3,
199 &a5,
200 &b4,
201 &japanese_postcard
202 };
203
204 const PaperCap* papers2_1[] = {
205 &letter,
206 &legal,
207 &a4,
208 &a3,
209 &a5,
210 &b4,
211 &b5,
212 &japanese_postcard
213 };
214
215 const PaperSourceCap* paperSources1_1[] = {
216 &autobin,
217 &defaultSource,
218 &envelopeTray,
219 &lowerCassette,
220 &upperCassette,
221 &manualFeed,
222 &multiPurposeTray
223 };
224
225 const PaperSourceCap* paperSources2_0[] = {
226 &autobin,
227 &defaultSource,
228 &envelopeTray,
229 &lowerCassette,
230 &upperCassette,
231 &thridCassette,
232 &manualFeed,
233 &multiPurposeTray
234 };
235
236 const ResolutionCap* resolutions[] = {
237 &dpi150,
238 &dpi300,
239 &dpi600,
240 &dpi1200,
241 };
242
243 const PrintStyleCap* printStyles[] = {
244 &simplex,
245 &duplex
246 };
247
248 const ProtocolClassCap* protocolClasses[] = {
249 &pc1_1,
250 &pc2_0,
251 &pc2_1
252 // Disabled until driver supports features of protocol class 3.0
253 // &pc3_0
254 };
255
256 const ColorCap color("Color", false, JobData::kColor);
257 const ColorCap colorCompressionDisabled("Color (No Compression)", false,
258 JobData::kColorCompressionDisabled);
259 const ColorCap monochrome("Shades of Gray", true, JobData::kMonochrome);
260
261 const ColorCap* colors[] = {
262 &color,
263 &colorCompressionDisabled,
264 &monochrome
265 };
266
267
PCL6Cap(const PrinterData * printer_data)268 PCL6Cap::PCL6Cap(const PrinterData* printer_data)
269 :
270 PrinterCap(printer_data)
271 {
272 }
273
274
275 int
CountCap(CapID capid) const276 PCL6Cap::CountCap(CapID capid) const
277 {
278 switch (capid) {
279 case kPaper:
280 if (GetProtocolClass() >= PCL6Writer::kProtocolClass2_1)
281 return sizeof(papers2_1) / sizeof(papers2_1[0]);
282 return sizeof(papers1_1) / sizeof(papers1_1[0]);
283 case kPaperSource:
284 if (GetProtocolClass() >= PCL6Writer::kProtocolClass2_0)
285 return sizeof(paperSources2_0) / sizeof(paperSources2_0[0]);
286 return sizeof(paperSources1_1) / sizeof(paperSources1_1[0]);
287 case kResolution:
288 return sizeof(resolutions) / sizeof(resolutions[0]);
289 case kColor:
290 return sizeof(colors) / sizeof(colors[0]);
291 case kPrintStyle:
292 return sizeof(printStyles) / sizeof(printStyles[0]);
293 case kProtocolClass:
294 return sizeof(protocolClasses) / sizeof(protocolClasses[0]);
295 default:
296 return 0;
297 }
298 }
299
300
301 const BaseCap**
GetCaps(CapID capid) const302 PCL6Cap::GetCaps(CapID capid) const
303 {
304 switch (capid) {
305 case kPaper:
306 if (GetProtocolClass() >= PCL6Writer::kProtocolClass2_1)
307 return (const BaseCap **)papers2_1;
308 return (const BaseCap**)papers1_1;
309 case kPaperSource:
310 if (GetProtocolClass() >= PCL6Writer::kProtocolClass2_0)
311 return (const BaseCap **)paperSources2_0;
312 return (const BaseCap**)paperSources1_1;
313 case kResolution:
314 return (const BaseCap**)resolutions;
315 case kColor:
316 return (const BaseCap**)colors;
317 case kPrintStyle:
318 return (const BaseCap**)printStyles;
319 case kProtocolClass:
320 return (const BaseCap**)protocolClasses;
321 default:
322 return NULL;
323 }
324 }
325
326
327 bool
Supports(CapID capid) const328 PCL6Cap::Supports(CapID capid) const
329 {
330 switch (capid) {
331 case kPaper:
332 case kPaperSource:
333 case kResolution:
334 case kColor:
335 case kCopyCommand:
336 case kPrintStyle:
337 case kProtocolClass:
338 case kHalftone:
339 return true;
340 default:
341 return false;
342 }
343 }
344