xref: /haiku/src/add-ons/print/drivers/postscript/PSCap.cpp (revision 7749d0bb0c358a3279b1b9cc76d8376e900130a5)
1 /*
2  * PSCap.cpp
3  * Copyright 1999-2000 Y.Takagi. All Rights Reserved.
4  */
5 
6 
7 #include "PSCap.h"
8 
9 #include "PrinterData.h"
10 
11 #define TO72DPI(a)	(a * 72.0f / 600.0f)
12 
13 const PaperCap a3(
14 	"A3",
15 	false,
16 	JobData::kA3,
17 	BRect(0.0f,            0.0f,            TO72DPI(7014.0f), TO72DPI(9920.0f)),
18 	BRect(TO72DPI(120.0f), TO72DPI(120.0f), TO72DPI(6894.0f), TO72DPI(9800.0f)));
19 
20 const PaperCap a4(
21 	"A4",
22 	true,
23 	JobData::kA4,
24 	BRect(0.0f,            0.0f,            TO72DPI(4960.0f), TO72DPI(7014.0f)),
25 	BRect(TO72DPI(120.0f), TO72DPI(120.0f), TO72DPI(4840.0f), TO72DPI(6894.0f)));
26 
27 const PaperCap a5(
28 	"A5",
29 	false,
30 	JobData::kA5,
31 	BRect(0.0f,            0.0f,            TO72DPI(3506.0f), TO72DPI(4960.0f)),
32 	BRect(TO72DPI(120.0f), TO72DPI(120.0f), TO72DPI(3386.0f), TO72DPI(4840.0f)));
33 
34 const PaperCap japanese_postcard(
35 	"Japanese Postcard",
36 	false,
37 	JobData::kJapanesePostcard,
38 	BRect(0.0f,           0.0f,             TO72DPI(2362.0f), TO72DPI(3506.0f)),
39 	BRect(TO72DPI(120.0f), TO72DPI(120.0f), TO72DPI(2242.0f), TO72DPI(3386.0f)));
40 
41 const PaperCap b4(
42 	"B4",
43 	false,
44 	JobData::kB4,
45 	BRect(0.0f,            0.0f,            TO72DPI(6070.0f), TO72DPI(8598.0f)),
46 	BRect(TO72DPI(120.0f), TO72DPI(120.0f), TO72DPI(5950.0f), TO72DPI(8478.0f)));
47 
48 const PaperCap b5(
49 	"B5",
50 	false,
51 	JobData::kB5,
52 	BRect(0.0f,            0.0f,            TO72DPI(4298.0f), TO72DPI(6070.0f)),
53 	BRect(TO72DPI(120.0f), TO72DPI(120.0f), TO72DPI(4178.0f), TO72DPI(5950.0f)));
54 
55 const PaperCap letter(
56 	"Letter",
57 	false,
58 	JobData::kLetter,
59 	BRect(0.0f,            0.0f,            TO72DPI(5100.0f), TO72DPI(6600.0f)),
60 	BRect(TO72DPI(120.0f), TO72DPI(120.0f), TO72DPI(4980.0f), TO72DPI(6480.0f)));
61 
62 const PaperCap legal(
63 	"Legal",
64 	false,
65 	JobData::kLegal,
66 	BRect(0.0f,            0.0f,            TO72DPI(5100.0f), TO72DPI(8400.0f)),
67 	BRect(TO72DPI(120.0f), TO72DPI(120.0f), TO72DPI(4980.0f), TO72DPI(8280.0f)));
68 
69 const PaperSourceCap autobin("Auto",  true,  JobData::kAuto);
70 
71 const ResolutionCap dpi300("300dpi", true, 0, 300,  300);
72 const ResolutionCap dpi600("600dpi", false, 1, 600,  600);
73 const ResolutionCap dpi1200("1200dpi", false, 2, 1200, 1200);
74 
75 const PaperCap* papers[] = {
76 	&a4,
77 	&a3,
78 	&a5,
79 	&b4,
80 	&b5,
81 	&letter,
82 	&legal
83 };
84 
85 const PaperSourceCap* papersources[] = {
86 	&autobin,
87 };
88 
89 const ResolutionCap* resolutions[] = {
90 	&dpi300,
91 	&dpi600,
92 	&dpi1200,
93 };
94 
95 const ColorCap color("Color", false, JobData::kColor);
96 const ColorCap monochrome("Monochrome", true, JobData::kMonochrome);
97 
98 const ColorCap* colors[] = {
99 	&color,
100 	&monochrome
101 };
102 
103 PSCap::PSCap(const PrinterData* printer_data)
104 	:
105 	PrinterCap(printer_data)
106 {
107 }
108 
109 
110 int
111 PSCap::CountCap(CapID capid) const
112 {
113 	switch (capid) {
114 		case kPaper:
115 			return sizeof(papers) / sizeof(papers[0]);
116 		case kPaperSource:
117 			return sizeof(papersources) / sizeof(papersources[0]);
118 		case kResolution:
119 			return sizeof(resolutions) / sizeof(resolutions[0]);
120 		case kColor:
121 			return sizeof(colors) / sizeof(colors[0]);
122 		default:
123 			return 0;
124 	}
125 }
126 
127 
128 const BaseCap**
129 PSCap::GetCaps(CapID capid) const
130 {
131 	switch (capid) {
132 		case kPaper:
133 			return (const BaseCap **)papers;
134 		case kPaperSource:
135 			return (const BaseCap **)papersources;
136 		case kResolution:
137 			return (const BaseCap **)resolutions;
138 		case kColor:
139 			return (const BaseCap **)colors;
140 		default:
141 			return NULL;
142 		}
143 }
144 
145 
146 bool
147 PSCap::Supports(CapID capid) const
148 {
149 	switch (capid) {
150 		case kPaper:
151 		case kPaperSource:
152 		case kResolution:
153 		case kColor:
154 		case kHalftone:
155 			return true;
156 		default:
157 			return false;
158 	}
159 }
160