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
19class BMessage;
20class PrinterCap;
21
22
23using namespace std;
24
25class DriverSpecificSettings
26{
27public:
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
53private:
54	BMessage fSettings;
55};
56
57
58class JobData {
59public:
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
369private:
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
405inline bool
406JobData::GetShowPreview() const
407{
408	return fShowPreview;
409}
410
411inline void
412JobData::SetShowPreview(bool showPreview)
413{
414	fShowPreview = showPreview;
415}
416
417
418inline JobData::Paper
419JobData::GetPaper() const
420{
421	return fPaper;
422}
423
424
425inline void
426JobData::SetPaper(Paper paper)
427{
428	fPaper = paper;
429}
430
431
432inline int32
433JobData::GetResolutionID() const
434{
435	return fResolutionID;
436}
437
438
439inline void
440JobData::SetResolutionID(int32 resolution)
441{
442	fResolutionID = resolution;
443}
444
445
446inline int32
447JobData::GetXres() const
448{
449	return fXRes;
450}
451
452
453inline void
454JobData::SetXres(int32 xres)
455{
456	fXRes = xres;
457}
458
459
460inline int32
461JobData::GetYres() const
462{
463	return fYRes;
464}
465
466
467inline void
468JobData::SetYres(int32 yres)
469{
470	fYRes = yres;
471};
472
473
474inline JobData::Orientation
475JobData::GetOrientation() const
476{
477	return fOrientation;
478}
479
480
481inline void
482JobData::SetOrientation(Orientation orientation)
483{
484	fOrientation = orientation;
485}
486
487
488inline float
489JobData::GetScaling() const
490{
491	return fScaling;
492}
493
494
495inline void
496JobData::SetScaling(float scaling)
497{
498	fScaling = scaling;
499}
500
501
502inline const BRect&
503JobData::GetPaperRect() const
504{
505	return fPaperRect;
506}
507
508
509inline void
510JobData::SetPaperRect(const BRect &rect)
511{
512	fPaperRect = rect;
513}
514
515
516inline const BRect&
517JobData::GetScaledPaperRect() const
518{
519	return fScaledPaperRect;
520}
521
522
523inline void
524JobData::SetScaledPaperRect(const BRect &rect)
525{
526	fScaledPaperRect = rect;
527}
528
529
530inline const BRect &
531JobData::GetPrintableRect() const
532{
533	return fPrintableRect;
534}
535
536
537inline void
538JobData::SetPrintableRect(const BRect &rect)
539{
540	fPrintableRect = rect;
541}
542
543
544inline const BRect&
545JobData::GetScaledPrintableRect() const
546{
547	return fScaledPrintableRect;
548}
549
550
551inline void
552JobData::SetScaledPrintableRect(const BRect &rect)
553{
554	fScaledPrintableRect = rect;
555}
556
557
558inline const BRect&
559JobData::GetPhysicalRect() const
560{
561	return fPhysicalRect;
562}
563
564
565inline void
566JobData::SetPhysicalRect(const BRect &rect)
567{
568	fPhysicalRect = rect;
569}
570
571
572inline const BRect&
573JobData::GetScaledPhysicalRect() const
574{
575	return fScaledPhysicalRect;
576}
577
578
579
580inline void
581JobData::SetScaledPhysicalRect(const BRect &rect)
582{
583	fScaledPhysicalRect = rect;
584}
585
586
587inline int32
588JobData::GetNup() const
589{
590	return fNup;
591}
592
593
594inline void
595JobData::SetNup(int32 nup)
596{
597	fNup = nup;
598}
599
600
601inline bool
602JobData::GetReverse() const
603{
604	return fReverse;
605}
606
607
608inline void
609JobData::SetReverse(bool reverse)
610{
611	fReverse = reverse;
612}
613
614
615inline int32
616JobData::GetFirstPage() const
617{
618	return fFirstPage;
619}
620
621
622inline void
623JobData::SetFirstPage(int32 firstPage)
624{
625	fFirstPage = firstPage;
626}
627
628
629inline int32
630JobData::GetLastPage() const
631{
632	return fLastPage;
633}
634
635
636inline void
637JobData::SetLastPage(int32 lastPage)
638{
639	fLastPage = lastPage;
640}
641
642
643color_space
644inline JobData::GetSurfaceType() const
645{
646	return B_RGB32;
647}
648
649
650inline float
651JobData::GetGamma() const
652{
653	return fGamma;
654}
655
656
657inline void
658JobData::SetGamma(float gamma)
659{
660	fGamma = gamma;
661}
662
663
664inline float
665JobData::GetInkDensity() const
666{
667	return fInkDensity;
668}
669
670
671inline void
672JobData::SetInkDensity(float inkDensity)
673{
674	fInkDensity = inkDensity;
675}
676
677
678inline JobData::PaperSource
679JobData::GetPaperSource() const
680{
681	return fPaperSource;
682}
683
684
685inline void
686JobData::SetPaperSource(PaperSource paperSource)
687{
688	fPaperSource = paperSource;
689};
690
691
692inline int32
693JobData::GetCopies() const
694{
695	return fCopies;
696}
697
698
699inline void
700JobData::SetCopies(int32 copies)
701{
702	fCopies = copies;
703}
704
705
706inline bool
707JobData::GetCollate() const
708{
709	return fCollate;
710}
711
712
713inline void
714JobData::SetCollate(bool collate)
715{
716	fCollate = collate;
717}
718
719
720inline JobData::PrintStyle
721JobData::GetPrintStyle() const
722{
723	return fPrintStyle;
724}
725
726
727inline void
728JobData::SetPrintStyle(PrintStyle print_style)
729{
730	fPrintStyle = print_style;
731}
732
733
734inline JobData::BindingLocation
735JobData::GetBindingLocation() const
736{
737	return fBindingLocation;
738}
739
740
741inline void
742JobData::SetBindingLocation(BindingLocation binding_location)
743{
744	fBindingLocation = binding_location;
745}
746
747
748inline JobData::PageOrder
749JobData::GetPageOrder() const { return fPageOrder; }
750
751
752inline void
753JobData::SetPageOrder(PageOrder page_order)
754{
755	fPageOrder = page_order;
756}
757
758
759inline JobData::Color
760JobData::GetColor() const
761{
762	return fColor;
763}
764
765
766inline void
767JobData::SetColor(Color color)
768{
769	fColor = color;
770}
771
772
773inline Halftone::DitherType
774JobData::GetDitherType() const
775{
776	return fDitherType;
777}
778
779
780inline void
781JobData::SetDitherType(Halftone::DitherType dither_type)
782{
783	fDitherType = dither_type;
784}
785
786
787inline JobData::PageSelection
788JobData::GetPageSelection() const
789{
790	return fPageSelection;
791}
792
793
794inline void
795JobData::SetPageSelection(PageSelection pageSelection)
796{
797	fPageSelection = pageSelection;
798}
799
800
801inline MarginUnit
802JobData::GetMarginUnit() const
803{
804	return fMarginUnit;
805}
806
807
808inline void
809JobData::SetMarginUnit(MarginUnit marginUnit)
810{
811	fMarginUnit = marginUnit;
812}
813
814#endif	/* __JOBDATA_H */
815