xref: /haiku/src/add-ons/print/drivers/pcl5/PCL5Cap.cpp (revision 1e60bdeab63fa7a57bc9a55b032052e95a18bd2c)
1 /*
2  * PCL5Cap.cpp
3  * Copyright 1999-2000 Y.Takagi. All Rights Reserved.
4  */
5 
6 
7 #include "PCL5Cap.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("Shades of Gray", true, JobData::kMonochrome);
97 
98 const ColorCap* colors[] = {
99 	&color,
100 	&monochrome
101 };
102 
103 
104 PCL5Cap::PCL5Cap(const PrinterData* printer_data)
105 	:
106 	PrinterCap(printer_data)
107 {
108 }
109 
110 
111 int
112 PCL5Cap::CountCap(CapID capid) const
113 {
114 	switch (capid) {
115 		case kPaper:
116 			return sizeof(papers) / sizeof(papers[0]);
117 		case kPaperSource:
118 			return sizeof(papersources) / sizeof(papersources[0]);
119 		case kResolution:
120 			return sizeof(resolutions) / sizeof(resolutions[0]);
121 		case kColor:
122 			return sizeof(colors) / sizeof(colors[0]);
123 		default:
124 			return 0;
125 	}
126 }
127 
128 
129 const BaseCap**
130 PCL5Cap::GetCaps(CapID capid) const
131 {
132 	switch (capid) {
133 		case kPaper:
134 			return (const BaseCap **)papers;
135 		case kPaperSource:
136 			return (const BaseCap **)papersources;
137 		case kResolution:
138 			return (const BaseCap **)resolutions;
139 		case kColor:
140 			return (const BaseCap **)colors;
141 		default:
142 			return NULL;
143 	}
144 }
145 
146 
147 bool
148 PCL5Cap::Supports(CapID capid) const
149 {
150 	switch (capid) {
151 		case kPaper:
152 		case kPaperSource:
153 		case kResolution:
154 		case kColor:
155 		case kHalftone:
156 			return true;
157 		default:
158 			return false;
159 	}
160 }
161