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