xref: /haiku/src/add-ons/print/drivers/gutenprint/GPCapabilityExtractor.h (revision 331c922016dbd43c36016819fdff52db2a0e4e6d)
1 /*
2 * Copyright 2010, Haiku. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 *
5 * Authors:
6 *		Michael Pfeiffer
7 */
8 #ifndef GP_CAPABILITY_EXTRACTOR_H
9 #define GP_CAPABILITY_EXTRACTOR_H
10 
11 #include "GPParameterVisitor.h"
12 
13 #include <list>
14 
15 #include "GPCapabilities.h"
16 
17 enum GPCapabilityExtractorState {
18 	kIgnoreParameter,
19 	kExtractPageSizeParameter,
20 	kExtractResolutionParameter,
21 	kExtractInputSlotParameter,
22 	kExtractPrintingModeParameter,
23 	kExtractParameter,
24 	kExtractListParameter,
25 
26 };
27 
28 class GPCapabilityExtractor : public GPParameterVisitor
29 {
30 public:
31 			GPCapabilityExtractor(GPCapabilities* cap);
32 
33 	bool	BeginParameter(const char* name, const char* displayName,
34 				stp_parameter_class_t parameterClass);
35 	void	DefaultStringParameter(const char* name,
36 		const char* key);
37 	void	StringParameterSize(const char* name, int size);
38 	void	StringParameter(const char* name, const char* key,
39 		const char* displayName);
40 	void	ResolutionParameter(const char* name, const char* key,
41 		const char* displayName, int x, int y);
42 	void	PageSizeParameter(const char* name, const char* key,
43 		const char* displayName, BSize pageSize, BRect imageableArea);
44 	void	EndParameter(const char* name);
45 	void	BooleanParameter(const char* name, const char* displayName,
46 						bool defaultValue,
47 						stp_parameter_class_t parameterClass);
48 	void	DoubleParameter(const char* name, const char* displayName,
49 						double lower, double upper, double defaultValue,
50 						stp_parameter_class_t parameterClass);
51 	void	IntParameter(const char* name, const char* displayName, int lower,
52 						int upper, int defaultValue,
53 						stp_parameter_class_t parameterClass);
54 	void	DimensionParameter(const char* name, const char* displayName,
55 						int lower, int upper, int defaultValue,
56 						stp_parameter_class_t parameterClass);
57 	void	EndVisit();
58 
59 protected:
60 	bool	Supportsed(stp_parameter_class_t parameterClass);
61 	void	AddDefaultInputSlot();
62 	void	SetDriverSpecificCategories();
63 	void	AddCapability(GPArray<struct BaseCap>& array, EnumCap* capability,
64 		const char* key);
65 	void	AddDriverSpecificCapability(const char* name, const char*
66 				displayName, DriverSpecificCap::Type type, BaseCap* capability);
67 
68 private:
69 	GPCapabilityExtractorState	fState;
70 	GPCapabilities*				fCapabilities;
71 	int							fIndex;
72 	BString						fDefaultKey;
73 
74 	list<DriverSpecificCap*>	fDriverSpecificCategories;
75 	int32						fNextDriverSpecificCategoryID;
76 };
77 
78 #endif
79