xref: /haiku/headers/libs/print/libprint/JobData.h (revision dfc8a217db488098641462dfc334dcc0f7d62456)
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 
26 class JobData {
27 public:
28 	enum Orientation {
29 		kPortrait,
30 		kLandscape
31 	};
32 
33 	enum Paper {
34 		kLetter = 1,            //   1  Letter 8 1/2 x 11 in
35 		kLetterSmall,           //   2  Letter Small 8 1/2 x 11 in
36 		kTabloid,               //   3  Tabloid 11 x 17 in
37 		kLedger,                //   4  Ledger 17 x 11 in
38 		kLegal,                 //   5  Legal 8 1/2 x 14 in
39 		kStatement,             //   6  Statement 5 1/2 x 8 1/2 in
40 		kExecutive,             //   7  Executive 7 1/4 x 10 1/2 in
41 		kA3,                    //   8  A3 297 x 420 mm
42 		kA4,                    //   9  A4 210 x 297 mm
43 		kA4Small,               //  10  A4 Small 210 x 297 mm
44 		kA5,                    //  11  A5 148 x 210 mm
45 		kB4,                    //  12  B4 (JIS) 250 x 354
46 		kB5,                    //  13  B5 (JIS) 182 x 257 mm
47 		kFolio,                 //  14  Folio 8 1/2 x 13 in
48 		kQuarto,                //  15  Quarto 215 x 275 mm
49 		k10X14,                 //  16  10x14 in
50 		k11X17,                 //  17  11x17 in
51 		kNote,                  //  18  Note 8 1/2 x 11 in
52 		kEnv9,                  //  19  Envelope #9 3 7/8 x 8 7/8
53 		kEnv10,                 //  20  Envelope #10 4 1/8 x 9 1/2
54 		kEnv11,                 //  21  Envelope #11 4 1/2 x 10 3/8
55 		kEnv12,                 //  22  Envelope #12 4 \276 x 11
56 		kEnv14,                 //  23  Envelope #14 5 x 11 1/2
57 		kCSheet,                //  24  C size sheet
58 		kDSheet,                //  25  D size sheet
59 		kESheet,                //  26  E size sheet
60 		kEnvDL,                 //  27  Envelope DL 110 x 220mm
61 		kEnvC5,                 //  28  Envelope C5 162 x 229 mm
62 		kEnvC3,                 //  29  Envelope C3  324 x 458 mm
63 		kEnvC4,                 //  30  Envelope C4  229 x 324 mm
64 		kEnvC6,                 //  31  Envelope C6  114 x 162 mm
65 		kEnvC65,                //  32  Envelope C65 114 x 229 mm
66 		kEnvB4,                 //  33  Envelope B4  250 x 353 mm
67 		kEnvB5,                 //  34  Envelope B5  176 x 250 mm
68 		kEnvB6,                 //  35  Envelope B6  176 x 125 mm
69 		kEnvItaly,              //  36  Envelope 110 x 230 mm
70 		kEnvMonarch,            //  37  Envelope Monarch 3.875 x 7.5 in
71 		kEnvPersonal,           //  38  6 3/4 Envelope 3 5/8 x 6 1/2 in
72 		kFanFoldUS,             //  39  US Std Fanfold 14 7/8 x 11 in
73 		kFanFoldStdGerman,      //  40  German Std Fanfold 8 1/2 x 12 in
74 		kFanFoldLglGerman,      //  41  German Legal Fanfold 8 1/2 x 13 in
75 		kIsoB4,                 //  42  B4 (ISO) 250 x 353 mm
76 		kJapanesePostcard,      //  43  Japanese Postcard 100 x 148 mm
77 		k9X11,                  //  44  9 x 11 in
78 		k10X11,                 //  45  10 x 11 in
79 		k15X11,                 //  46  15 x 11 in
80 		kEnvInvite,             //  47  Envelope Invite 220 x 220 mm
81 		kReserved48,            //  48  RESERVED--DO NOT USE
82 		kReserved49,            //  49  RESERVED--DO NOT USE
83 		kLetterExtra,	        //  50  Letter Extra 9 \275 x 12 in
84 		kLegalExtra, 	        //  51  Legal Extra 9 \275 x 15 in
85 		kTabloidExtra,	        //  52  Tabloid Extra 11.69 x 18 in
86 		kA4Extra,     	        //  53  A4 Extra 9.27 x 12.69 in
87 		kLetterTransverse,      //  54  Letter Transverse 8 \275 x 11 in
88 		kA4Transverse,          //  55  A4 Transverse 210 x 297 mm
89 		kLetterExtraTransverse, //  56  Letter Extra Transverse 9\275 x 12 in
90 		kAPlus,                 //  57  SuperA/SuperA/A4 227 x 356 mm
91 		kBPlus,                 //  58  SuperB/SuperB/A3 305 x 487 mm
92 		kLetterPlus,            //  59  Letter Plus 8.5 x 12.69 in
93 		kA4Plus,                //  60  A4 Plus 210 x 330 mm
94 		kA5Transverse,          //  61  A5 Transverse 148 x 210 mm
95 		kB5Transverse,          //  62  B5 (JIS) Transverse 182 x 257 mm
96 		kA3Extra,               //  63  A3 Extra 322 x 445 mm
97 		kA5Extra,               //  64  A5 Extra 174 x 235 mm
98 		kB5Extra,               //  65  B5 (ISO) Extra 201 x 276 mm
99 		kA2,                    //  66  A2 420 x 594 mm
100 		kA3Transverse,          //  67  A3 Transverse 297 x 420 mm
101 		kA3ExtraTransverse,     //  68  A3 Extra Transverse 322 x 445 mm
102 		kDBLJapanesePostcard,   //  69  Japanese Double Postcard 200 x 148 mm
103 		kA6,                    //  70  A6 105 x 148 mm
104 		kJEnvKaku2,             //  71  Japanese Envelope Kaku #2
105 		kJEnvKaku3,             //  72  Japanese Envelope Kaku #3
106 		kJEnvChou3,             //  73  Japanese Envelope Chou #3
107 		kJEnvChou4,             //  74  Japanese Envelope Chou #4
108 		kLetterRotated,         //  75  Letter Rotated 11 x 8 1/2 11 in
109 		kA3Rotated,             //  76  A3 Rotated 420 x 297 mm
110 		kA4Rotated,             //  77  A4 Rotated 297 x 210 mm
111 		kA5Rotated,             //  78  A5 Rotated 210 x 148 mm
112 		kB4JISRotated,          //  79  B4 (JIS) Rotated 364 x 257 mm
113 		kB5JISRotated,          //  80  B5 (JIS) Rotated 257 x 182 mm
114 		kJapanesePostcardRotated, //  81 Japanese Postcard Rotated 148 x 100 mm
115 		kDBLJapanesePostcardRotated, // 82 Double Japanese Postcard Rotated 148 x 200 mm
116 		kA6Rotated,             //  83  A6 Rotated 148 x 105 mm
117 		kJEnvKaku2Rotated,      //  84  Japanese Envelope Kaku #2 Rotated
118 		kJEnvKaku3Rotated,      //  85  Japanese Envelope Kaku #3 Rotated
119 		kJEnvChou3Rotated,      //  86  Japanese Envelope Chou #3 Rotated
120 		kJEnvChou4Rotated,      //  87  Japanese Envelope Chou #4 Rotated
121 		kB6JIS,                 //  88  B6 (JIS) 128 x 182 mm
122 		kB6JISRotated,          //  89  B6 (JIS) Rotated 182 x 128 mm
123 		k12X11,                 //  90  12 x 11 in
124 		kJEnvYou4,              //  91  Japanese Envelope You #4
125 		kJEnvYou4Rotated,       //  92  Japanese Envelope You #4 Rotated
126 		kP16K,                  //  93  PRC 16K 146 x 215 mm
127 		kP32K,                  //  94  PRC 32K 97 x 151 mm
128 		kP32KBig,               //  95  PRC 32K(Big) 97 x 151 mm
129 		kPEnv1,                 //  96  PRC Envelope #1 102 x 165 mm
130 		kPEnv2,                 //  97  PRC Envelope #2 102 x 176 mm
131 		kPEnv3,                 //  98  PRC Envelope #3 125 x 176 mm
132 		kPEnv4,                 //  99  PRC Envelope #4 110 x 208 mm
133 		kPEnv5,                 // 100  PRC Envelope #5 110 x 220 mm
134 		kPEnv6,                 // 101  PRC Envelope #6 120 x 230 mm
135 		kPEnv7,                 // 102  PRC Envelope #7 160 x 230 mm
136 		kPEnv8,                 // 103  PRC Envelope #8 120 x 309 mm
137 		kPEnv9,                 // 104  PRC Envelope #9 229 x 324 mm
138 		kPEnv10,                // 105  PRC Envelope #10 324 x 458 mm
139 		kP16KRotated,           // 106  PRC 16K Rotated
140 		kP32KRotated,           // 107  PRC 32K Rotated
141 		kP32KBIGRotated,        // 108  PRC 32K(Big) Rotated
142 		kPEnv1Rotated,          // 109  PRC Envelope #1 Rotated 165 x 102 mm
143 		kPEnv2Rotated,          // 110  PRC Envelope #2 Rotated 176 x 102 mm
144 		kPEnv3Rotated,          // 111  PRC Envelope #3 Rotated 176 x 125 mm
145 		kPEnv4Rotated,          // 112  PRC Envelope #4 Rotated 208 x 110 mm
146 		kPEnv5Rotated,          // 113  PRC Envelope #5 Rotated 220 x 110 mm
147 		kPEnv6Rotated,          // 114  PRC Envelope #6 Rotated 230 x 120 mm
148 		kPEnv7Rotated,          // 115  PRC Envelope #7 Rotated 230 x 160 mm
149 		kPEnv8Rotated,          // 116  PRC Envelope #8 Rotated 309 x 120 mm
150 		kPEnv9Rotated,          // 117  PRC Envelope #9 Rotated 324 x 229 mm
151 		kPEnv10Rotated,         // 118  PRC Envelope #10 Rotated 458 x 324 mm
152 		kUserDefined = 256
153 	};
154 
155 	enum PaperSource {
156 		kAuto,          // 7	o
157 		kManual,        // 4	o
158 		kUpper,         // 1	o
159 		kMiddle,        // 3	o
160 		kLower,         // 2	o
161 //		kOnlyOne,       // 1	x
162 //		kEnvelope,      // 5	o
163 //		kEnvManual,     // 6	x
164 //		kTractor,       // 8	x
165 //		kSmallFmt,      // 9	x
166 //		kLargeFmt,      // 10	x
167 //		kLargeCapacity, // 11	x
168 //		kCassette,      // 14	x
169 //		kFormSource,    // 15	x
170 		kCassette1 = 21,
171 		kCassette2,
172 		kCassette3,
173 		kCassette4,
174 		kCassette5,
175 		kCassette6,
176 		kCassette7,
177 		kCassette8,
178 		kCassette9,
179 		kUser = 256     // device specific bins start here
180 	};
181 
182 	enum PrintStyle {
183 		kSimplex,
184 		kDuplex,
185 		kBooklet
186 	};
187 
188 	enum BindingLocation {
189 		kLongEdgeLeft,
190 		kLongEdgeRight,
191 		kShortEdgeTop,
192 		kShortEdgeBottom,
193 		kLongEdge  = kLongEdgeLeft,
194 		kShortEdge = kShortEdgeTop
195 	};
196 
197 	enum PageOrder {
198 		kAcrossFromLeft,
199 		kDownFromLeft,
200 		kAcrossFromRight,
201 		kDownFromRight,
202 		kLeftToRight = kAcrossFromLeft,
203 		kRightToLeft = kAcrossFromRight
204 	};
205 
206 /*
207 	enum Quality {
208 		kDraft  = -1,
209 		kLow    = -2,
210 		kMedium = -3,
211 		kHigh   = -4
212 	};
213 */
214 	enum Color {
215 		kMonochrome = 1,
216 		kColor,
217 		// Some PCL6 printers do not support compressed data
218 		// in color mode.
219 		kColorCompressionDisabled
220 	};
221 
222 	enum Settings {
223 		kPageSettings,
224 		kJobSettings
225 	};
226 
227 	enum PageSelection {
228 		kAllPages,
229 		kOddNumberedPages,
230 		kEvenNumberedPages
231 	};
232 
233 private:
234 	bool        fShowPreview;
235 	Paper       fPaper;
236 	int32       fResolutionID;
237 	int32       fXRes;
238 	int32       fYRes;
239 	Orientation fOrientation;
240 	float       fScaling;
241 	BRect       fPaperRect;
242 	BRect       fScaledPaperRect;
243 	BRect       fPrintableRect;
244 	BRect       fScaledPrintableRect;
245 	BRect       fPhysicalRect;
246 	BRect       fScaledPhysicalRect;
247 	int32       fNup;
248 	int32       fFirstPage;
249 	int32       fLastPage;
250 	float       fGamma;      // 1 identiy, < 1 brigther, > 1 darker
251 	float       fInkDensity; // [0, 255] lower means higher density
252 	PaperSource fPaperSource;
253 	int32       fCopies;
254 	bool        fCollate;
255 	bool        fReverse;
256 	PrintStyle  fPrintStyle;
257 	BindingLocation fBindingLocation;
258 	PageOrder   fPageOrder;
259 	Settings    fSettings;
260 	BMessage    *fMsg;
261 	Color       fColor;
262 	Halftone::DitherType fDitherType;
263 	PageSelection        fPageSelection;
264 	MarginUnit  fMarginUnit;
265 	map<string, string>	fDriverSpecificSettings;
266 
267 public:
268 	JobData(BMessage *msg, const PrinterCap *cap, Settings settings);
269 	~JobData();
270 
271 	JobData(const JobData &job_data);
272 	JobData &operator = (const JobData &job_data);
273 
274 	void load(BMessage *msg, const PrinterCap *cap, Settings settings);
275 	void save(BMessage *msg = NULL);
276 
277 	bool getShowPreview() const { return fShowPreview; }
278 	void setShowPreview(bool showPreview) { fShowPreview = showPreview; }
279 
280 	Paper getPaper() const { return fPaper; }
281 	void  setPaper(Paper paper) { fPaper = paper; }
282 
283 	int32 getResolutionID() const { return fResolutionID; }
284 	void setResolutionID(int32 resolution) { fResolutionID = resolution; }
285 
286 	int32 getXres() const { return fXRes; }
287 	void  setXres(int32 xres) { fXRes = xres; }
288 
289 	int32 getYres() const { return fYRes; }
290 	void  setYres(int32 yres) { fYRes = yres; };
291 
292 	Orientation getOrientation() const { return fOrientation; }
293 	void  setOrientation(Orientation orientation) { fOrientation = orientation; }
294 
295 	float getScaling() const { return fScaling; }
296 	void  setScaling(float scaling) { fScaling = scaling; }
297 
298 	const BRect &getPaperRect() const { return fPaperRect; }
299 	void  setPaperRect(const BRect &paper_rect) { fPaperRect = paper_rect; }
300 
301 	const BRect &getScaledPaperRect() const { return fScaledPaperRect; }
302 	void  setScaledPaperRect(const BRect &paper_rect) { fScaledPaperRect = paper_rect; }
303 
304 	const BRect &getPrintableRect() const { return fPrintableRect; }
305 	void  setPrintableRect(const BRect &printable_rect) { fPrintableRect = printable_rect; }
306 
307 	const BRect &getScaledPrintableRect() const { return fScaledPrintableRect; }
308 	void  setScaledPrintableRect(const BRect &printable_rect) { fScaledPrintableRect = printable_rect; }
309 
310 	const BRect &getPhysicalRect() const { return fPhysicalRect; }
311 	void  setPhysicalRect(const BRect &Physical_rect) { fPhysicalRect = Physical_rect; }
312 
313 	const BRect &getScaledPhysicalRect() const { return fScaledPhysicalRect; }
314 	void  setScaledPhysicalRect(const BRect &Physical_rect) { fScaledPhysicalRect = Physical_rect; }
315 
316 	int32 getNup() const { return fNup; }
317 	void  setNup(int32 nup) { fNup = nup; }
318 
319 	bool getReverse() const { return fReverse; }
320 	void  setReverse(bool reverse) { fReverse = reverse; }
321 
322 	int32 getFirstPage() const { return fFirstPage; }
323 	void  setFirstPage(int32 first_page) { fFirstPage = first_page; }
324 
325 	int32 getLastPage() const { return fLastPage; }
326 	void  setLastPage(int32 last_page) { fLastPage = last_page; }
327 
328 	// libprint supports only B_RGB32
329 	color_space getSurfaceType() const { return B_RGB32; }
330 
331 	float getGamma() const { return fGamma; }
332 	void setGamma(float gamma) { fGamma = gamma; }
333 
334 	float getInkDensity() const { return fInkDensity; }
335 	void setInkDensity(float inkDensity) { fInkDensity = inkDensity; }
336 
337 	PaperSource getPaperSource() const { return fPaperSource; }
338 	void setPaperSource(PaperSource paper_source) { fPaperSource = paper_source; };
339 
340 	int32 getCopies() const { return fCopies; }
341 	void  setCopies(int32 copies) { fCopies = copies; }
342 
343 	bool getCollate() const { return fCollate; }
344 	void setCollate(bool collate) { fCollate = collate; }
345 
346 	PrintStyle getPrintStyle() const { return fPrintStyle; }
347 	void setPrintStyle(PrintStyle print_style) { fPrintStyle = print_style; }
348 
349 	BindingLocation getBindingLocation() const { return fBindingLocation; }
350 	void setBindingLocation(BindingLocation binding_location) { fBindingLocation = binding_location; }
351 
352 	PageOrder getPageOrder() const { return fPageOrder; }
353 	void setPageOrder(PageOrder page_order) { fPageOrder = page_order; }
354 
355 	Color getColor() const { return fColor; }
356 	void setColor(Color color) { fColor = color; }
357 
358 	Halftone::DitherType getDitherType() const { return fDitherType; }
359 	void setDitherType(Halftone::DitherType dither_type) { fDitherType = dither_type; }
360 
361 	PageSelection getPageSelection() const { return fPageSelection; }
362 	void setPageSelection(PageSelection pageSelection) { fPageSelection = pageSelection; }
363 
364 	MarginUnit getMarginUnit() const { return fMarginUnit; }
365 	void setMarginUnit(MarginUnit marginUnit) { fMarginUnit = marginUnit; }
366 
367 	bool	HasDriverSpecificSetting(const string& category) const;
368 	const string&	DriverSpecificSetting(const string& category) const;
369 	void	SetDriverSpecificSetting(const string& category, const string& value);
370 
371 private:
372 	void	SerializePrinterSpecificSettings(BString& serializedSettings);
373 	void	DeserializePrinterSpecificSettings(BString& serializedSettings);
374 };
375 
376 #endif	/* __JOBDATA_H */
377