1 /* 2 * JobData.h 3 * Copyright 1999-2000 Y.Takagi. All Rights Reserved. 4 */ 5 6 #ifndef __JOBDATA_H 7 #define __JOBDATA_H 8 9 #include <SupportDefs.h> 10 #include <GraphicsDefs.h> 11 #include <Rect.h> 12 13 #include <map> 14 #include <string> 15 16 #include "Halftone.h" 17 #include "MarginView.h" // for MarginUnit 18 19 class BMessage; 20 class PrinterCap; 21 22 23 using namespace std; 24 25 class DriverSpecificSettings 26 { 27 public: 28 DriverSpecificSettings(); 29 DriverSpecificSettings(const DriverSpecificSettings& Settings); 30 31 DriverSpecificSettings &operator=(const DriverSpecificSettings &Settings); 32 33 void MakeEmpty(); 34 35 bool HasString(const char* key) const; 36 const char* GetString(const char* key) const; 37 void SetString(const char* key, const char* value); 38 39 bool HasBoolean(const char* ekey) const; 40 bool GetBoolean(const char* key) const; 41 void SetBoolean(const char* key, bool value); 42 43 bool HasInt(const char* ekey) const; 44 int32 GetInt(const char* key) const; 45 void SetInt(const char* key, int32 value); 46 47 bool HasDouble(const char* ekey) const; 48 double GetDouble(const char* key) const; 49 void SetDouble(const char* key, double value); 50 51 BMessage& Message(); 52 53 private: 54 BMessage fSettings; 55 }; 56 57 58 class JobData { 59 public: 60 enum Orientation { 61 kPortrait, 62 kLandscape 63 }; 64 65 enum Paper { 66 kLetter = 1, // 1 Letter 8 1/2 x 11 in 67 kLetterSmall, // 2 Letter Small 8 1/2 x 11 in 68 kTabloid, // 3 Tabloid 11 x 17 in 69 kLedger, // 4 Ledger 17 x 11 in 70 kLegal, // 5 Legal 8 1/2 x 14 in 71 kStatement, // 6 Statement 5 1/2 x 8 1/2 in 72 kExecutive, // 7 Executive 7 1/4 x 10 1/2 in 73 kA3, // 8 A3 297 x 420 mm 74 kA4, // 9 A4 210 x 297 mm 75 kA4Small, // 10 A4 Small 210 x 297 mm 76 kA5, // 11 A5 148 x 210 mm 77 kB4, // 12 B4 (JIS) 250 x 354 78 kB5, // 13 B5 (JIS) 182 x 257 mm 79 kFolio, // 14 Folio 8 1/2 x 13 in 80 kQuarto, // 15 Quarto 215 x 275 mm 81 k10X14, // 16 10x14 in 82 k11X17, // 17 11x17 in 83 kNote, // 18 Note 8 1/2 x 11 in 84 kEnv9, // 19 Envelope #9 3 7/8 x 8 7/8 85 kEnv10, // 20 Envelope #10 4 1/8 x 9 1/2 86 kEnv11, // 21 Envelope #11 4 1/2 x 10 3/8 87 kEnv12, // 22 Envelope #12 4 \276 x 11 88 kEnv14, // 23 Envelope #14 5 x 11 1/2 89 kCSheet, // 24 C size sheet 90 kDSheet, // 25 D size sheet 91 kESheet, // 26 E size sheet 92 kEnvDL, // 27 Envelope DL 110 x 220mm 93 kEnvC5, // 28 Envelope C5 162 x 229 mm 94 kEnvC3, // 29 Envelope C3 324 x 458 mm 95 kEnvC4, // 30 Envelope C4 229 x 324 mm 96 kEnvC6, // 31 Envelope C6 114 x 162 mm 97 kEnvC65, // 32 Envelope C65 114 x 229 mm 98 kEnvB4, // 33 Envelope B4 250 x 353 mm 99 kEnvB5, // 34 Envelope B5 176 x 250 mm 100 kEnvB6, // 35 Envelope B6 176 x 125 mm 101 kEnvItaly, // 36 Envelope 110 x 230 mm 102 kEnvMonarch, // 37 Envelope Monarch 3.875 x 7.5 in 103 kEnvPersonal, // 38 6 3/4 Envelope 3 5/8 x 6 1/2 in 104 kFanFoldUS, // 39 US Std Fanfold 14 7/8 x 11 in 105 kFanFoldStdGerman, // 40 German Std Fanfold 8 1/2 x 12 in 106 kFanFoldLglGerman, // 41 German Legal Fanfold 8 1/2 x 13 in 107 kIsoB4, // 42 B4 (ISO) 250 x 353 mm 108 kJapanesePostcard, // 43 Japanese Postcard 100 x 148 mm 109 k9X11, // 44 9 x 11 in 110 k10X11, // 45 10 x 11 in 111 k15X11, // 46 15 x 11 in 112 kEnvInvite, // 47 Envelope Invite 220 x 220 mm 113 kReserved48, // 48 RESERVED--DO NOT USE 114 kReserved49, // 49 RESERVED--DO NOT USE 115 kLetterExtra, // 50 Letter Extra 9 \275 x 12 in 116 kLegalExtra, // 51 Legal Extra 9 \275 x 15 in 117 kTabloidExtra, // 52 Tabloid Extra 11.69 x 18 in 118 kA4Extra, // 53 A4 Extra 9.27 x 12.69 in 119 kLetterTransverse, // 54 Letter Transverse 8 \275 x 11 in 120 kA4Transverse, // 55 A4 Transverse 210 x 297 mm 121 kLetterExtraTransverse, // 56 Letter Extra Transverse 9\275 x 12 in 122 kAPlus, // 57 SuperA/SuperA/A4 227 x 356 mm 123 kBPlus, // 58 SuperB/SuperB/A3 305 x 487 mm 124 kLetterPlus, // 59 Letter Plus 8.5 x 12.69 in 125 kA4Plus, // 60 A4 Plus 210 x 330 mm 126 kA5Transverse, // 61 A5 Transverse 148 x 210 mm 127 kB5Transverse, // 62 B5 (JIS) Transverse 182 x 257 mm 128 kA3Extra, // 63 A3 Extra 322 x 445 mm 129 kA5Extra, // 64 A5 Extra 174 x 235 mm 130 kB5Extra, // 65 B5 (ISO) Extra 201 x 276 mm 131 kA2, // 66 A2 420 x 594 mm 132 kA3Transverse, // 67 A3 Transverse 297 x 420 mm 133 kA3ExtraTransverse, // 68 A3 Extra Transverse 322 x 445 mm 134 kDBLJapanesePostcard, // 69 Japanese Double Postcard 200 x 148 mm 135 kA6, // 70 A6 105 x 148 mm 136 kJEnvKaku2, // 71 Japanese Envelope Kaku #2 137 kJEnvKaku3, // 72 Japanese Envelope Kaku #3 138 kJEnvChou3, // 73 Japanese Envelope Chou #3 139 kJEnvChou4, // 74 Japanese Envelope Chou #4 140 kLetterRotated, // 75 Letter Rotated 11 x 8 1/2 11 in 141 kA3Rotated, // 76 A3 Rotated 420 x 297 mm 142 kA4Rotated, // 77 A4 Rotated 297 x 210 mm 143 kA5Rotated, // 78 A5 Rotated 210 x 148 mm 144 kB4JISRotated, // 79 B4 (JIS) Rotated 364 x 257 mm 145 kB5JISRotated, // 80 B5 (JIS) Rotated 257 x 182 mm 146 kJapanesePostcardRotated, // 81 Japanese Postcard Rotated 148 x 100 mm 147 kDBLJapanesePostcardRotated, // 82 Double Japanese Postcard Rotated 148 x 200 mm 148 kA6Rotated, // 83 A6 Rotated 148 x 105 mm 149 kJEnvKaku2Rotated, // 84 Japanese Envelope Kaku #2 Rotated 150 kJEnvKaku3Rotated, // 85 Japanese Envelope Kaku #3 Rotated 151 kJEnvChou3Rotated, // 86 Japanese Envelope Chou #3 Rotated 152 kJEnvChou4Rotated, // 87 Japanese Envelope Chou #4 Rotated 153 kB6JIS, // 88 B6 (JIS) 128 x 182 mm 154 kB6JISRotated, // 89 B6 (JIS) Rotated 182 x 128 mm 155 k12X11, // 90 12 x 11 in 156 kJEnvYou4, // 91 Japanese Envelope You #4 157 kJEnvYou4Rotated, // 92 Japanese Envelope You #4 Rotated 158 kP16K, // 93 PRC 16K 146 x 215 mm 159 kP32K, // 94 PRC 32K 97 x 151 mm 160 kP32KBig, // 95 PRC 32K(Big) 97 x 151 mm 161 kPEnv1, // 96 PRC Envelope #1 102 x 165 mm 162 kPEnv2, // 97 PRC Envelope #2 102 x 176 mm 163 kPEnv3, // 98 PRC Envelope #3 125 x 176 mm 164 kPEnv4, // 99 PRC Envelope #4 110 x 208 mm 165 kPEnv5, // 100 PRC Envelope #5 110 x 220 mm 166 kPEnv6, // 101 PRC Envelope #6 120 x 230 mm 167 kPEnv7, // 102 PRC Envelope #7 160 x 230 mm 168 kPEnv8, // 103 PRC Envelope #8 120 x 309 mm 169 kPEnv9, // 104 PRC Envelope #9 229 x 324 mm 170 kPEnv10, // 105 PRC Envelope #10 324 x 458 mm 171 kP16KRotated, // 106 PRC 16K Rotated 172 kP32KRotated, // 107 PRC 32K Rotated 173 kP32KBIGRotated, // 108 PRC 32K(Big) Rotated 174 kPEnv1Rotated, // 109 PRC Envelope #1 Rotated 165 x 102 mm 175 kPEnv2Rotated, // 110 PRC Envelope #2 Rotated 176 x 102 mm 176 kPEnv3Rotated, // 111 PRC Envelope #3 Rotated 176 x 125 mm 177 kPEnv4Rotated, // 112 PRC Envelope #4 Rotated 208 x 110 mm 178 kPEnv5Rotated, // 113 PRC Envelope #5 Rotated 220 x 110 mm 179 kPEnv6Rotated, // 114 PRC Envelope #6 Rotated 230 x 120 mm 180 kPEnv7Rotated, // 115 PRC Envelope #7 Rotated 230 x 160 mm 181 kPEnv8Rotated, // 116 PRC Envelope #8 Rotated 309 x 120 mm 182 kPEnv9Rotated, // 117 PRC Envelope #9 Rotated 324 x 229 mm 183 kPEnv10Rotated, // 118 PRC Envelope #10 Rotated 458 x 324 mm 184 kUserDefined = 256 185 }; 186 187 enum PaperSource { 188 kAuto, // 7 o 189 kManual, // 4 o 190 kUpper, // 1 o 191 kMiddle, // 3 o 192 kLower, // 2 o 193 // kOnlyOne, // 1 x 194 // kEnvelope, // 5 o 195 // kEnvManual, // 6 x 196 // kTractor, // 8 x 197 // kSmallFmt, // 9 x 198 // kLargeFmt, // 10 x 199 // kLargeCapacity, // 11 x 200 // kCassette, // 14 x 201 // kFormSource, // 15 x 202 kCassette1 = 21, 203 kCassette2, 204 kCassette3, 205 kCassette4, 206 kCassette5, 207 kCassette6, 208 kCassette7, 209 kCassette8, 210 kCassette9, 211 kUser = 256 // device specific bins start here 212 }; 213 214 enum PrintStyle { 215 kSimplex, 216 kDuplex, 217 kBooklet 218 }; 219 220 enum BindingLocation { 221 kLongEdgeLeft, 222 kLongEdgeRight, 223 kShortEdgeTop, 224 kShortEdgeBottom, 225 kLongEdge = kLongEdgeLeft, 226 kShortEdge = kShortEdgeTop 227 }; 228 229 enum PageOrder { 230 kAcrossFromLeft, 231 kDownFromLeft, 232 kAcrossFromRight, 233 kDownFromRight, 234 kLeftToRight = kAcrossFromLeft, 235 kRightToLeft = kAcrossFromRight 236 }; 237 238 /* 239 enum Quality { 240 kDraft = -1, 241 kLow = -2, 242 kMedium = -3, 243 kHigh = -4 244 }; 245 */ 246 enum Color { 247 kMonochrome = 1, 248 kColor, 249 // Some PCL6 printers do not support compressed data 250 // in color mode. 251 kColorCompressionDisabled 252 }; 253 254 enum SettingType { 255 kPageSettings, 256 kJobSettings 257 }; 258 259 enum PageSelection { 260 kAllPages, 261 kOddNumberedPages, 262 kEvenNumberedPages 263 }; 264 265 JobData(BMessage* message, const PrinterCap* printerCap, 266 SettingType type); 267 ~JobData(); 268 269 JobData(const JobData& jobData); 270 JobData& operator=(const JobData& jobData); 271 272 void Load(BMessage* message, const PrinterCap* printerCap, 273 SettingType type); 274 void Save(BMessage* message = NULL); 275 276 bool GetShowPreview() const; 277 void SetShowPreview(bool showPreview); 278 279 Paper GetPaper() const; 280 void SetPaper(Paper paper); 281 282 int32 GetResolutionID() const; 283 void SetResolutionID(int32 resolution); 284 285 int32 GetXres() const; 286 void SetXres(int32 xres); 287 288 int32 GetYres() const; 289 void SetYres(int32 yres); 290 291 Orientation GetOrientation() const; 292 void SetOrientation(Orientation orientation); 293 294 float GetScaling() const; 295 void SetScaling(float scaling); 296 297 const BRect& GetPaperRect() const; 298 void SetPaperRect(const BRect& paperRect); 299 300 const BRect& GetScaledPaperRect() const; 301 void SetScaledPaperRect(const BRect& paperRect); 302 303 const BRect& GetPrintableRect() const; 304 void SetPrintableRect(const BRect& printableRect); 305 306 const BRect& GetScaledPrintableRect() const; 307 void SetScaledPrintableRect(const BRect& printableRect); 308 309 const BRect& GetPhysicalRect() const; 310 void SetPhysicalRect(const BRect& PhysicalRect); 311 312 const BRect& GetScaledPhysicalRect() const; 313 void SetScaledPhysicalRect(const BRect& PhysicalRect); 314 315 int32 GetNup() const; 316 void SetNup(int32 nup); 317 318 bool GetReverse() const; 319 void SetReverse(bool reverse); 320 321 int32 GetFirstPage() const; 322 void SetFirstPage(int32 firstPage); 323 324 int32 GetLastPage() const; 325 void SetLastPage(int32 lastPage); 326 327 // libprint supports only B_RGB32 328 color_space GetSurfaceType() const; 329 330 float GetGamma() const; 331 void SetGamma(float gamma); 332 333 float GetInkDensity() const; 334 void SetInkDensity(float inkDensity); 335 336 PaperSource GetPaperSource() const; 337 void SetPaperSource(PaperSource paperSource); 338 339 int32 GetCopies() const; 340 void SetCopies(int32 copies); 341 342 bool GetCollate() const; 343 void SetCollate(bool collate); 344 345 PrintStyle GetPrintStyle() const; 346 void SetPrintStyle(PrintStyle printStyle); 347 348 BindingLocation GetBindingLocation() const; 349 void SetBindingLocation(BindingLocation bindingLocation); 350 351 PageOrder GetPageOrder() const; 352 void SetPageOrder(PageOrder pageOrder); 353 354 Color GetColor() const; 355 void SetColor(Color color); 356 357 Halftone::DitherType GetDitherType() const; 358 void SetDitherType(Halftone::DitherType ditherType); 359 360 PageSelection GetPageSelection() const; 361 void SetPageSelection(PageSelection pageSelection); 362 363 MarginUnit GetMarginUnit() const; 364 void SetMarginUnit(MarginUnit marginUnit); 365 366 DriverSpecificSettings& Settings(); 367 const DriverSpecificSettings& Settings() const; 368 369 private: 370 bool fShowPreview; 371 Paper fPaper; 372 int32 fResolutionID; 373 int32 fXRes; 374 int32 fYRes; 375 Orientation fOrientation; 376 float fScaling; 377 BRect fPaperRect; 378 BRect fScaledPaperRect; 379 BRect fPrintableRect; 380 BRect fScaledPrintableRect; 381 BRect fPhysicalRect; 382 BRect fScaledPhysicalRect; 383 int32 fNup; 384 int32 fFirstPage; 385 int32 fLastPage; 386 float fGamma; // 1 identiy, < 1 brigther, > 1 darker 387 float fInkDensity; // [0, 255] lower means higher density 388 PaperSource fPaperSource; 389 int32 fCopies; 390 bool fCollate; 391 bool fReverse; 392 PrintStyle fPrintStyle; 393 BindingLocation fBindingLocation; 394 PageOrder fPageOrder; 395 SettingType fSettingType; 396 BMessage *fMsg; 397 Color fColor; 398 Halftone::DitherType fDitherType; 399 PageSelection fPageSelection; 400 MarginUnit fMarginUnit; 401 DriverSpecificSettings fDriverSpecificSettings; 402 }; 403 404 405 inline bool 406 JobData::GetShowPreview() const 407 { 408 return fShowPreview; 409 } 410 411 inline void 412 JobData::SetShowPreview(bool showPreview) 413 { 414 fShowPreview = showPreview; 415 } 416 417 418 inline JobData::Paper 419 JobData::GetPaper() const 420 { 421 return fPaper; 422 } 423 424 425 inline void 426 JobData::SetPaper(Paper paper) 427 { 428 fPaper = paper; 429 } 430 431 432 inline int32 433 JobData::GetResolutionID() const 434 { 435 return fResolutionID; 436 } 437 438 439 inline void 440 JobData::SetResolutionID(int32 resolution) 441 { 442 fResolutionID = resolution; 443 } 444 445 446 inline int32 447 JobData::GetXres() const 448 { 449 return fXRes; 450 } 451 452 453 inline void 454 JobData::SetXres(int32 xres) 455 { 456 fXRes = xres; 457 } 458 459 460 inline int32 461 JobData::GetYres() const 462 { 463 return fYRes; 464 } 465 466 467 inline void 468 JobData::SetYres(int32 yres) 469 { 470 fYRes = yres; 471 }; 472 473 474 inline JobData::Orientation 475 JobData::GetOrientation() const 476 { 477 return fOrientation; 478 } 479 480 481 inline void 482 JobData::SetOrientation(Orientation orientation) 483 { 484 fOrientation = orientation; 485 } 486 487 488 inline float 489 JobData::GetScaling() const 490 { 491 return fScaling; 492 } 493 494 495 inline void 496 JobData::SetScaling(float scaling) 497 { 498 fScaling = scaling; 499 } 500 501 502 inline const BRect& 503 JobData::GetPaperRect() const 504 { 505 return fPaperRect; 506 } 507 508 509 inline void 510 JobData::SetPaperRect(const BRect &rect) 511 { 512 fPaperRect = rect; 513 } 514 515 516 inline const BRect& 517 JobData::GetScaledPaperRect() const 518 { 519 return fScaledPaperRect; 520 } 521 522 523 inline void 524 JobData::SetScaledPaperRect(const BRect &rect) 525 { 526 fScaledPaperRect = rect; 527 } 528 529 530 inline const BRect & 531 JobData::GetPrintableRect() const 532 { 533 return fPrintableRect; 534 } 535 536 537 inline void 538 JobData::SetPrintableRect(const BRect &rect) 539 { 540 fPrintableRect = rect; 541 } 542 543 544 inline const BRect& 545 JobData::GetScaledPrintableRect() const 546 { 547 return fScaledPrintableRect; 548 } 549 550 551 inline void 552 JobData::SetScaledPrintableRect(const BRect &rect) 553 { 554 fScaledPrintableRect = rect; 555 } 556 557 558 inline const BRect& 559 JobData::GetPhysicalRect() const 560 { 561 return fPhysicalRect; 562 } 563 564 565 inline void 566 JobData::SetPhysicalRect(const BRect &rect) 567 { 568 fPhysicalRect = rect; 569 } 570 571 572 inline const BRect& 573 JobData::GetScaledPhysicalRect() const 574 { 575 return fScaledPhysicalRect; 576 } 577 578 579 580 inline void 581 JobData::SetScaledPhysicalRect(const BRect &rect) 582 { 583 fScaledPhysicalRect = rect; 584 } 585 586 587 inline int32 588 JobData::GetNup() const 589 { 590 return fNup; 591 } 592 593 594 inline void 595 JobData::SetNup(int32 nup) 596 { 597 fNup = nup; 598 } 599 600 601 inline bool 602 JobData::GetReverse() const 603 { 604 return fReverse; 605 } 606 607 608 inline void 609 JobData::SetReverse(bool reverse) 610 { 611 fReverse = reverse; 612 } 613 614 615 inline int32 616 JobData::GetFirstPage() const 617 { 618 return fFirstPage; 619 } 620 621 622 inline void 623 JobData::SetFirstPage(int32 firstPage) 624 { 625 fFirstPage = firstPage; 626 } 627 628 629 inline int32 630 JobData::GetLastPage() const 631 { 632 return fLastPage; 633 } 634 635 636 inline void 637 JobData::SetLastPage(int32 lastPage) 638 { 639 fLastPage = lastPage; 640 } 641 642 643 color_space 644 inline JobData::GetSurfaceType() const 645 { 646 return B_RGB32; 647 } 648 649 650 inline float 651 JobData::GetGamma() const 652 { 653 return fGamma; 654 } 655 656 657 inline void 658 JobData::SetGamma(float gamma) 659 { 660 fGamma = gamma; 661 } 662 663 664 inline float 665 JobData::GetInkDensity() const 666 { 667 return fInkDensity; 668 } 669 670 671 inline void 672 JobData::SetInkDensity(float inkDensity) 673 { 674 fInkDensity = inkDensity; 675 } 676 677 678 inline JobData::PaperSource 679 JobData::GetPaperSource() const 680 { 681 return fPaperSource; 682 } 683 684 685 inline void 686 JobData::SetPaperSource(PaperSource paperSource) 687 { 688 fPaperSource = paperSource; 689 }; 690 691 692 inline int32 693 JobData::GetCopies() const 694 { 695 return fCopies; 696 } 697 698 699 inline void 700 JobData::SetCopies(int32 copies) 701 { 702 fCopies = copies; 703 } 704 705 706 inline bool 707 JobData::GetCollate() const 708 { 709 return fCollate; 710 } 711 712 713 inline void 714 JobData::SetCollate(bool collate) 715 { 716 fCollate = collate; 717 } 718 719 720 inline JobData::PrintStyle 721 JobData::GetPrintStyle() const 722 { 723 return fPrintStyle; 724 } 725 726 727 inline void 728 JobData::SetPrintStyle(PrintStyle print_style) 729 { 730 fPrintStyle = print_style; 731 } 732 733 734 inline JobData::BindingLocation 735 JobData::GetBindingLocation() const 736 { 737 return fBindingLocation; 738 } 739 740 741 inline void 742 JobData::SetBindingLocation(BindingLocation binding_location) 743 { 744 fBindingLocation = binding_location; 745 } 746 747 748 inline JobData::PageOrder 749 JobData::GetPageOrder() const { return fPageOrder; } 750 751 752 inline void 753 JobData::SetPageOrder(PageOrder page_order) 754 { 755 fPageOrder = page_order; 756 } 757 758 759 inline JobData::Color 760 JobData::GetColor() const 761 { 762 return fColor; 763 } 764 765 766 inline void 767 JobData::SetColor(Color color) 768 { 769 fColor = color; 770 } 771 772 773 inline Halftone::DitherType 774 JobData::GetDitherType() const 775 { 776 return fDitherType; 777 } 778 779 780 inline void 781 JobData::SetDitherType(Halftone::DitherType dither_type) 782 { 783 fDitherType = dither_type; 784 } 785 786 787 inline JobData::PageSelection 788 JobData::GetPageSelection() const 789 { 790 return fPageSelection; 791 } 792 793 794 inline void 795 JobData::SetPageSelection(PageSelection pageSelection) 796 { 797 fPageSelection = pageSelection; 798 } 799 800 801 inline MarginUnit 802 JobData::GetMarginUnit() const 803 { 804 return fMarginUnit; 805 } 806 807 808 inline void 809 JobData::SetMarginUnit(MarginUnit marginUnit) 810 { 811 fMarginUnit = marginUnit; 812 } 813 814 #endif /* __JOBDATA_H */ 815