Make UEFI boot-platform build again
[haiku.git] / headers / libs / print / libprint / PrinterCap.h
bloba2d8d84caa931804ad32614dfd73bef051423ccf
1 /*
2 * PrinterCap.h
3 * Copyright 1999-2000 Y.Takagi. All Rights Reserved.
4 */
6 #ifndef __PRINTERCAP_H
7 #define __PRINTERCAP_H
9 #include <string>
10 #include <Rect.h>
11 #include "JobData.h"
13 using namespace std;
15 enum {
16 kUnknownPrinter = 0
19 struct BaseCap {
20 BaseCap(const string &label);
21 virtual ~BaseCap();
23 const char* Label() const;
25 string fLabel;
28 struct EnumCap : public BaseCap {
29 EnumCap(const string& label, bool isDefault);
31 virtual int32 ID() const = 0;
32 const char* Key() const;
34 bool fIsDefault;
35 string fKey;
39 struct PaperCap : public EnumCap {
40 PaperCap(const string &label, bool isDefault,
41 JobData::Paper paper, const BRect &paperRect,
42 const BRect &physicalRect);
44 int32 ID() const;
46 JobData::Paper fPaper;
47 BRect fPaperRect;
48 BRect fPhysicalRect;
51 struct PaperSourceCap : public EnumCap {
52 PaperSourceCap(const string &label, bool isDefault,
53 JobData::PaperSource paperSource);
55 int32 ID() const;
57 JobData::PaperSource fPaperSource;
60 struct ResolutionCap : public EnumCap {
61 ResolutionCap(const string &label, bool isDefault,
62 int32 id, int xResolution, int yResolution);
64 int32 ID() const;
66 int32 fID;
67 int fXResolution;
68 int fYResolution;
71 struct OrientationCap : public EnumCap {
72 OrientationCap(const string &label, bool isDefault,
73 JobData::Orientation orientation);
75 int32 ID() const;
77 JobData::Orientation fOrientation;
80 struct PrintStyleCap : public EnumCap {
81 PrintStyleCap(const string &label, bool isDefault,
82 JobData::PrintStyle printStyle);
84 int32 ID() const;
86 JobData::PrintStyle fPrintStyle;
89 struct BindingLocationCap : public EnumCap {
90 BindingLocationCap(const string &label,
91 bool isDefault,
92 JobData::BindingLocation bindingLocation);
94 int32 ID() const;
96 JobData::BindingLocation fBindingLocation;
99 struct ColorCap : public EnumCap {
100 ColorCap(const string &label, bool isDefault,
101 JobData::Color color);
103 int32 ID() const;
105 JobData::Color fColor;
108 struct ProtocolClassCap : public EnumCap {
109 ProtocolClassCap(const string &label,
110 bool isDefault, int32 protocolClass,
111 const string &description);
113 int32 ID() const;
115 int32 fProtocolClass;
116 string fDescription;
120 struct DriverSpecificCap : public EnumCap {
121 enum Type {
122 kList,
123 kBoolean,
124 kIntRange,
125 kIntDimension,
126 kDoubleRange
129 DriverSpecificCap(const string& label,
130 int32 category, Type type);
132 int32 ID() const;
134 int32 fCategory;
135 Type fType;
138 struct ListItemCap : public EnumCap {
139 ListItemCap(const string& label,
140 bool isDefault, int32 id);
142 int32 ID() const;
144 private:
145 int32 fID;
148 struct BooleanCap : public BaseCap {
149 BooleanCap(const string& label, bool defaultValue);
151 bool DefaultValue() const;
153 private:
154 bool fDefaultValue;
157 struct IntRangeCap : public BaseCap {
158 IntRangeCap(const string& label, int lower,
159 int upper, int defaultValue);
161 int32 Lower() const;
162 int32 Upper() const;
163 int32 DefaultValue() const;
165 private:
166 int32 fLower;
167 int32 fUpper;
168 int32 fDefaultValue;
171 struct DoubleRangeCap : public BaseCap {
172 DoubleRangeCap(const string& label, double lower,
173 double upper, double defaultValue);
175 double Lower() const;
176 double Upper() const;
177 double DefaultValue() const;
179 double fLower;
180 double fUpper;
181 double fDefaultValue;
184 class PrinterData;
186 class PrinterCap {
187 public:
188 PrinterCap(const PrinterData *printer_data);
189 virtual ~PrinterCap();
191 enum CapID {
192 kPaper,
193 kPaperSource,
194 kResolution,
195 kOrientation,
196 kPrintStyle,
197 kBindingLocation,
198 kColor,
199 kProtocolClass,
200 kDriverSpecificCapabilities,
202 // Static boolean settings follow.
203 // For them Supports() has to be implemented only.
204 kCopyCommand, // supports printer page copy command?
205 kHalftone, // needs the printer driver the configuration
206 // for class Halftone?
207 kCanRotatePageInLandscape,
208 // can the printer driver rotate the page
209 // printing in landscape
211 // The driver specific generic capabilities start here
212 kDriverSpecificCapabilitiesBegin = 100
215 struct IDPredicate
217 IDPredicate(int id)
218 : fID(id)
223 bool operator()(const BaseCap* baseCap) {
224 const EnumCap* enumCap = dynamic_cast<const EnumCap*>(baseCap);
225 if (enumCap == NULL)
226 return false;
227 return enumCap->ID() == fID;
230 int fID;
233 struct LabelPredicate
235 LabelPredicate(const char* label)
236 : fLabel(label)
241 bool operator()(const BaseCap* baseCap) {
242 return baseCap->fLabel == fLabel;
245 const char* fLabel;
249 struct KeyPredicate
251 KeyPredicate(const char* key)
252 : fKey(key)
257 bool operator()(const BaseCap* baseCap) {
258 const EnumCap* enumCap = dynamic_cast<const EnumCap*>(baseCap);
259 if (enumCap == NULL)
260 return false;
261 return enumCap->fKey == fKey;
264 const char* fKey;
268 virtual int CountCap(CapID category) const = 0;
269 virtual bool Supports(CapID category) const = 0;
270 virtual const BaseCap** GetCaps(CapID category) const = 0;
272 const EnumCap* GetDefaultCap(CapID category) const;
273 const EnumCap* FindCap(CapID category, int id) const;
274 const BaseCap* FindCap(CapID category, const char* label) const;
275 const EnumCap* FindCapWithKey(CapID category, const char* key)
276 const;
278 const BooleanCap* FindBooleanCap(CapID category) const;
279 const IntRangeCap* FindIntRangeCap(CapID category) const;
280 const DoubleRangeCap* FindDoubleRangeCap(CapID category) const;
282 int GetProtocolClass() const;
284 protected:
285 PrinterCap(const PrinterCap& printerCap);
286 PrinterCap& operator=(const PrinterCap& printerCap);
287 template<typename Predicate>
288 const BaseCap* FindCap(CapID category, Predicate& predicate) const;
290 const PrinterData* GetPrinterData() const;
292 private:
293 const PrinterData* fPrinterData;
299 #endif /* __PRINTERCAP_H */