xref: /haiku/headers/libs/print/libprint/PrinterCap.h (revision 746cac055adc6ac3308c7bc2d29040fb95689cc9)
1 /*
2  * PrinterCap.h
3  * Copyright 1999-2000 Y.Takagi. All Rights Reserved.
4  */
5 
6 #ifndef __PRINTERCAP_H
7 #define __PRINTERCAP_H
8 
9 #include <string>
10 #include <Rect.h>
11 #include "JobData.h"
12 
13 #if (!__MWERKS__ || defined(MSIPL_USING_NAMESPACE))
14 using namespace std;
15 #else
16 #define std
17 #endif
18 
19 enum {
20 	kUnknownPrinter = 0
21 };
22 
23 struct BaseCap {
24 	string label;
25 	bool is_default;
26 	BaseCap(const string &n, bool d) : label(n), is_default(d) {}
27 };
28 
29 struct PaperCap : public BaseCap {
30 	JobData::Paper paper;
31 	BRect paper_rect;
32 	BRect physical_rect;
33 	PaperCap(const string &n, bool d, JobData::Paper p, const BRect &r1, const BRect &r2)
34 		: BaseCap(n, d), paper(p), paper_rect(r1), physical_rect(r2) {}
35 };
36 
37 struct PaperSourceCap : public BaseCap {
38 	JobData::PaperSource paper_source;
39 	PaperSourceCap(const string &n, bool d, JobData::PaperSource f)
40 		: BaseCap(n, d), paper_source(f) {}
41 };
42 
43 struct ResolutionCap : public BaseCap {
44 	int xres;
45 	int yres;
46 	ResolutionCap(const string &n, bool d, int x, int y)
47 		: BaseCap(n, d), xres(x), yres(y) {}
48 };
49 
50 struct OrientationCap : public BaseCap {
51 	JobData::Orientation orientation;
52 	OrientationCap(const string &n, bool d, JobData::Orientation o)
53 		: BaseCap(n, d), orientation(o) {}
54 };
55 
56 struct PrintStyleCap : public BaseCap {
57 	JobData::PrintStyle print_style;
58 	PrintStyleCap(const string &n, bool d, JobData::PrintStyle x)
59 		: BaseCap(n, d), print_style(x) {}
60 };
61 
62 struct BindingLocationCap : public BaseCap {
63 	JobData::BindingLocation binding_location;
64 	BindingLocationCap(const string &n, bool d, JobData::BindingLocation b)
65 		: BaseCap(n, d), binding_location(b) {}
66 };
67 
68 struct ColorCap : public BaseCap {
69 	JobData::Color color;
70 	ColorCap(const string &n, bool d, JobData::Color c)
71 		: BaseCap(n, d), color(c) {}
72 };
73 
74 struct ProtocolClassCap : public BaseCap {
75 	int protocolClass;
76 	string description;
77 	ProtocolClassCap(const string &n, bool d, int p, const string &desc)
78 		: BaseCap(n, d)
79 		, protocolClass(p)
80 		, description(desc) {}
81 };
82 
83 
84 class PrinterData;
85 
86 class PrinterCap {
87 public:
88 	PrinterCap(const PrinterData *printer_data);
89 	virtual ~PrinterCap();
90 
91 	enum CapID {
92 		kPaper,
93 		kPaperSource,
94 		kResolution,
95 		kOrientation,
96 		kPrintStyle,
97 		kBindingLocation,
98 		kColor,
99 		kProtocolClass,
100 		// Static boolean settings follow.
101 		// For them isSupport() has to be implemented only.
102 		kCopyCommand,       // supports printer page copy command?
103 	};
104 
105 	virtual int countCap(CapID) const = 0;
106 	virtual bool isSupport(CapID) const = 0;
107 	virtual const BaseCap **enumCap(CapID) const = 0;
108 	const BaseCap *getDefaultCap(CapID) const;
109 	int getPrinterId() const;
110 	int getProtocolClass() const;
111 
112 protected:
113 	PrinterCap(const PrinterCap &);
114 	PrinterCap &operator = (const PrinterCap &);
115 	const PrinterData *getPrinterData() const;
116 	void setPrinterId(int id);
117 
118 private:
119 	const PrinterData *fPrinterData;
120 	int fPrinterID;
121 };
122 
123 inline const PrinterData *PrinterCap::getPrinterData() const
124 {
125 	return fPrinterData;
126 }
127 
128 inline int PrinterCap::getPrinterId() const
129 {
130 	return fPrinterID;
131 }
132 
133 inline void PrinterCap::setPrinterId(int id)
134 {
135 	fPrinterID = id;
136 }
137 
138 #endif	/* __PRINTERCAP_H */
139