1 /* 2 * PCL6Cap.cpp 3 * Copyright 1999-2000 Y.Takagi. All Rights Reserved. 4 * Copyright 2003-2007 Michael Pfeiffer. 5 */ 6 7 #include "PCL6Cap.h" 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, JobData::kCassette3); 140 const PaperSourceCap upperCassette("Upper Cassette", false, JobData::kUpper); 141 const PaperSourceCap lowerCassette("Lower Cassette", false, JobData::kLower); 142 const PaperSourceCap envelopeTray("Envelope Tray", false, JobData::kCassette2); 143 // since 2.0: 144 const PaperSourceCap thridCassette("Thrid Cassette", false, JobData::kMiddle); 145 146 const ResolutionCap dpi150("150dpi", false, 150, 150); 147 const ResolutionCap dpi300("300dpi", true, 300, 300); 148 const ResolutionCap dpi600("600dpi", false, 600, 600); 149 const ResolutionCap dpi1200("1200dpi", false, 1200, 1200); 150 151 const PrintStyleCap simplex("Simplex", true, JobData::kSimplex); 152 const PrintStyleCap duplex("Duplex", false, JobData::kDuplex); 153 154 const ProtocolClassCap pc1_1("PCL 6 Protocol Class 1.1", true, PCL6Writer::kProtocolClass1_1, 155 "The printer driver supports the following features of protocol class 1.1:\n" 156 "* Monochrome and Color Printing.\n" 157 "* Paper Formats: Letter, Legal, A4, A3, A5 and Japanese Postcard.\n" 158 "* Paper Sources: Auto, Default, Manual Feed, Multi-Purpose Tray, Upper and Lower Cassette and Envelope Tray.\n" 159 "* Resolutions: 150, 300, 600 and 1200 DPI." 160 #if ENABLE_RLE_COMPRESSION 161 "\n* Compression Method: RLE." 162 #else 163 "\n* Compression Method: None." 164 #endif 165 ); 166 167 const ProtocolClassCap pc2_0("PCL 6 Protocol Class 2.0", false, PCL6Writer::kProtocolClass2_0, 168 "In addition to features of protocol class 1.1, the printer driver supports the " 169 "following features of protocol class 2.0:\n" 170 "* Additonal Paper Source: Third Cassette." 171 // "\n* JPEG compression (not implemented yet)" 172 ); 173 174 const ProtocolClassCap pc2_1("PCL 6 Protocol Class 2.1", false, PCL6Writer::kProtocolClass2_1, 175 "In addition to features of previous protocol classes, the printer driver supports the " 176 "following features of protocol class 2.1:\n" 177 "* Additional Paper Format: B5." 178 #if ENABLE_DELTA_ROW_COMPRESSION 179 "\n* Additional Compression Method: Delta Row Compression." 180 #endif 181 ); 182 183 // Disable until driver supports new features of protocol class 3.0 184 //const ProtocolClassCap pc3_0("PCL 6 Protocol Class 3.0", false, PCL6Writer::kProtocolClass3_0, 185 //"Protocol Class 3.0"); 186 187 const PaperCap *papers1_1[] = { 188 &letter, 189 &legal, 190 &a4, 191 &a3, 192 &a5, 193 &b4, 194 &japanese_postcard 195 }; 196 197 const PaperCap *papers2_1[] = { 198 &letter, 199 &legal, 200 &a4, 201 &a3, 202 &a5, 203 &b4, 204 &b5, 205 &japanese_postcard 206 }; 207 208 const PaperSourceCap *paperSources1_1[] = { 209 &autobin, 210 &defaultSource, 211 &envelopeTray, 212 &lowerCassette, 213 &upperCassette, 214 &manualFeed, 215 &multiPurposeTray 216 }; 217 218 const PaperSourceCap *paperSources2_0[] = { 219 &autobin, 220 &defaultSource, 221 &envelopeTray, 222 &lowerCassette, 223 &upperCassette, 224 &thridCassette, 225 &manualFeed, 226 &multiPurposeTray 227 }; 228 229 const ResolutionCap *resolutions[] = { 230 &dpi150, 231 &dpi300, 232 &dpi600, 233 &dpi1200, 234 }; 235 236 const PrintStyleCap *printStyles[] = { 237 &simplex, 238 &duplex 239 }; 240 241 const ProtocolClassCap *protocolClasses[] = { 242 &pc1_1, 243 &pc2_0, 244 &pc2_1 245 // Disabled until driver supports features of protocol class 3.0 246 // &pc3_0 247 }; 248 249 const ColorCap color("Color", false, JobData::kColor); 250 const ColorCap colorCompressionDisabled("Color (No Compression)", false, JobData::kColorCompressionDisabled); 251 const ColorCap monochrome("Shades of Gray", true, JobData::kMonochrome); 252 253 const ColorCap *colors[] = { 254 &color, 255 &colorCompressionDisabled, 256 &monochrome 257 }; 258 259 PCL6Cap::PCL6Cap(const PrinterData *printer_data) 260 : PrinterCap(printer_data) 261 { 262 } 263 264 int PCL6Cap::countCap(CapID capid) const 265 { 266 switch (capid) { 267 case kPaper: 268 if (getProtocolClass() >= PCL6Writer::kProtocolClass2_1) { 269 return sizeof(papers2_1) / sizeof(papers2_1[0]); 270 } 271 return sizeof(papers1_1) / sizeof(papers1_1[0]); 272 case kPaperSource: 273 if (getProtocolClass() >= PCL6Writer::kProtocolClass2_0) { 274 return sizeof(paperSources2_0) / sizeof(paperSources2_0[0]); 275 } 276 return sizeof(paperSources1_1) / sizeof(paperSources1_1[0]); 277 case kResolution: 278 return sizeof(resolutions) / sizeof(resolutions[0]); 279 case kColor: 280 return sizeof(colors) / sizeof(colors[0]); 281 case kPrintStyle: 282 return sizeof(printStyles) / sizeof(printStyles[0]); 283 case kProtocolClass: 284 return sizeof(protocolClasses) / sizeof(protocolClasses[0]); 285 default: 286 return 0; 287 } 288 } 289 290 const BaseCap **PCL6Cap::enumCap(CapID capid) const 291 { 292 switch (capid) { 293 case kPaper: 294 if (getProtocolClass() >= PCL6Writer::kProtocolClass2_1) { 295 return (const BaseCap **)papers2_1; 296 } 297 return (const BaseCap **)papers1_1; 298 case kPaperSource: 299 if (getProtocolClass() >= PCL6Writer::kProtocolClass2_0) { 300 return (const BaseCap **)paperSources2_0; 301 } 302 return (const BaseCap **)paperSources1_1; 303 case kResolution: 304 return (const BaseCap **)resolutions; 305 case kColor: 306 return (const BaseCap **)colors; 307 case kPrintStyle: 308 return (const BaseCap **)printStyles; 309 case kProtocolClass: 310 return (const BaseCap **)protocolClasses; 311 default: 312 return NULL; 313 } 314 } 315 316 bool PCL6Cap::isSupport(CapID capid) const 317 { 318 switch (capid) { 319 case kPaper: 320 case kPaperSource: 321 case kResolution: 322 case kColor: 323 case kCopyCommand: 324 case kPrintStyle: 325 case kProtocolClass: 326 return true; 327 default: 328 return false; 329 } 330 } 331