2002-11-27 02:03:14 +03:00
|
|
|
/*
|
|
|
|
* PrinterCap.h
|
|
|
|
* Copyright 1999-2000 Y.Takagi. All Rights Reserved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __PRINTERCAP_H
|
|
|
|
#define __PRINTERCAP_H
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <Rect.h>
|
|
|
|
#include "JobData.h"
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
2004-01-30 20:10:36 +03:00
|
|
|
enum {
|
|
|
|
kUnknownPrinter = 0
|
|
|
|
};
|
2002-11-27 02:03:14 +03:00
|
|
|
|
|
|
|
struct BaseCap {
|
2010-11-14 13:58:10 +03:00
|
|
|
BaseCap(const string &label);
|
2010-10-25 18:21:09 +04:00
|
|
|
virtual ~BaseCap();
|
|
|
|
|
2010-11-14 13:58:10 +03:00
|
|
|
const char* Label() const;
|
|
|
|
|
|
|
|
string fLabel;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct EnumCap : public BaseCap {
|
|
|
|
EnumCap(const string& label, bool isDefault);
|
|
|
|
|
2010-10-26 17:06:29 +04:00
|
|
|
virtual int32 ID() const = 0;
|
2010-10-26 13:48:36 +04:00
|
|
|
const char* Key() const;
|
2010-10-25 15:34:31 +04:00
|
|
|
|
|
|
|
bool fIsDefault;
|
2010-10-25 18:21:09 +04:00
|
|
|
string fKey;
|
2002-11-27 02:03:14 +03:00
|
|
|
};
|
|
|
|
|
2010-11-14 13:58:10 +03:00
|
|
|
|
|
|
|
struct PaperCap : public EnumCap {
|
2010-10-25 15:34:31 +04:00
|
|
|
PaperCap(const string &label, bool isDefault,
|
|
|
|
JobData::Paper paper, const BRect &paperRect,
|
|
|
|
const BRect &physicalRect);
|
|
|
|
|
2010-10-26 17:06:29 +04:00
|
|
|
int32 ID() const;
|
2010-10-25 18:21:09 +04:00
|
|
|
|
2010-10-25 15:34:31 +04:00
|
|
|
JobData::Paper fPaper;
|
|
|
|
BRect fPaperRect;
|
|
|
|
BRect fPhysicalRect;
|
2002-11-27 02:03:14 +03:00
|
|
|
};
|
|
|
|
|
2010-11-14 13:58:10 +03:00
|
|
|
struct PaperSourceCap : public EnumCap {
|
2010-10-25 15:34:31 +04:00
|
|
|
PaperSourceCap(const string &label, bool isDefault,
|
|
|
|
JobData::PaperSource paperSource);
|
|
|
|
|
2010-10-26 17:06:29 +04:00
|
|
|
int32 ID() const;
|
2010-10-25 18:21:09 +04:00
|
|
|
|
2010-10-25 15:34:31 +04:00
|
|
|
JobData::PaperSource fPaperSource;
|
2002-11-27 02:03:14 +03:00
|
|
|
};
|
|
|
|
|
2010-11-14 13:58:10 +03:00
|
|
|
struct ResolutionCap : public EnumCap {
|
2010-10-25 15:34:31 +04:00
|
|
|
ResolutionCap(const string &label, bool isDefault,
|
2010-10-26 17:06:29 +04:00
|
|
|
int32 id, int xResolution, int yResolution);
|
2010-10-25 15:34:31 +04:00
|
|
|
|
2010-10-26 17:06:29 +04:00
|
|
|
int32 ID() const;
|
2010-10-25 18:21:09 +04:00
|
|
|
|
2010-10-26 17:06:29 +04:00
|
|
|
int32 fID;
|
2010-10-25 15:34:31 +04:00
|
|
|
int fXResolution;
|
|
|
|
int fYResolution;
|
2002-11-27 02:03:14 +03:00
|
|
|
};
|
|
|
|
|
2010-11-14 13:58:10 +03:00
|
|
|
struct OrientationCap : public EnumCap {
|
2010-10-25 15:34:31 +04:00
|
|
|
OrientationCap(const string &label, bool isDefault,
|
|
|
|
JobData::Orientation orientation);
|
|
|
|
|
2010-10-26 17:06:29 +04:00
|
|
|
int32 ID() const;
|
2010-10-25 18:21:09 +04:00
|
|
|
|
2010-10-25 15:34:31 +04:00
|
|
|
JobData::Orientation fOrientation;
|
2002-11-27 02:03:14 +03:00
|
|
|
};
|
|
|
|
|
2010-11-14 13:58:10 +03:00
|
|
|
struct PrintStyleCap : public EnumCap {
|
2010-10-25 15:34:31 +04:00
|
|
|
PrintStyleCap(const string &label, bool isDefault,
|
|
|
|
JobData::PrintStyle printStyle);
|
|
|
|
|
2010-10-26 17:06:29 +04:00
|
|
|
int32 ID() const;
|
2010-10-25 18:21:09 +04:00
|
|
|
|
2010-10-25 15:34:31 +04:00
|
|
|
JobData::PrintStyle fPrintStyle;
|
2002-11-27 02:03:14 +03:00
|
|
|
};
|
|
|
|
|
2010-11-14 13:58:10 +03:00
|
|
|
struct BindingLocationCap : public EnumCap {
|
2010-10-25 15:34:31 +04:00
|
|
|
BindingLocationCap(const string &label,
|
|
|
|
bool isDefault,
|
|
|
|
JobData::BindingLocation bindingLocation);
|
|
|
|
|
2010-10-26 17:06:29 +04:00
|
|
|
int32 ID() const;
|
2010-10-25 18:21:09 +04:00
|
|
|
|
2010-10-25 15:34:31 +04:00
|
|
|
JobData::BindingLocation fBindingLocation;
|
2002-11-27 02:03:14 +03:00
|
|
|
};
|
|
|
|
|
2010-11-14 13:58:10 +03:00
|
|
|
struct ColorCap : public EnumCap {
|
2010-10-25 15:34:31 +04:00
|
|
|
ColorCap(const string &label, bool isDefault,
|
|
|
|
JobData::Color color);
|
|
|
|
|
2010-10-26 17:06:29 +04:00
|
|
|
int32 ID() const;
|
2010-10-25 18:21:09 +04:00
|
|
|
|
2010-10-25 15:34:31 +04:00
|
|
|
JobData::Color fColor;
|
2004-01-28 00:22:16 +03:00
|
|
|
};
|
|
|
|
|
2010-11-14 13:58:10 +03:00
|
|
|
struct ProtocolClassCap : public EnumCap {
|
2010-10-25 15:34:31 +04:00
|
|
|
ProtocolClassCap(const string &label,
|
2010-10-26 17:06:29 +04:00
|
|
|
bool isDefault, int32 protocolClass,
|
2010-10-25 15:34:31 +04:00
|
|
|
const string &description);
|
|
|
|
|
2010-10-26 17:06:29 +04:00
|
|
|
int32 ID() const;
|
2010-10-25 18:21:09 +04:00
|
|
|
|
2010-10-26 17:06:29 +04:00
|
|
|
int32 fProtocolClass;
|
2010-10-25 15:34:31 +04:00
|
|
|
string fDescription;
|
2005-02-06 21:22:40 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-11-14 13:58:10 +03:00
|
|
|
struct DriverSpecificCap : public EnumCap {
|
2010-10-26 13:48:36 +04:00
|
|
|
enum Type {
|
|
|
|
kList,
|
2010-11-14 13:58:10 +03:00
|
|
|
kBoolean,
|
|
|
|
kIntRange,
|
|
|
|
kIntDimension,
|
|
|
|
kDoubleRange
|
2010-10-26 13:48:36 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
DriverSpecificCap(const string& label,
|
2010-10-30 10:54:16 +04:00
|
|
|
int32 category, Type type);
|
2010-10-26 13:48:36 +04:00
|
|
|
|
2010-10-26 17:06:29 +04:00
|
|
|
int32 ID() const;
|
2010-10-26 13:48:36 +04:00
|
|
|
|
2010-10-26 17:06:29 +04:00
|
|
|
int32 fCategory;
|
2010-10-26 13:48:36 +04:00
|
|
|
Type fType;
|
|
|
|
};
|
|
|
|
|
2010-11-14 13:58:10 +03:00
|
|
|
struct ListItemCap : public EnumCap {
|
2010-10-30 10:54:16 +04:00
|
|
|
ListItemCap(const string& label,
|
|
|
|
bool isDefault, int32 id);
|
|
|
|
|
|
|
|
int32 ID() const;
|
2010-11-14 13:58:10 +03:00
|
|
|
|
|
|
|
private:
|
2010-10-30 10:54:16 +04:00
|
|
|
int32 fID;
|
|
|
|
};
|
2010-10-26 13:48:36 +04:00
|
|
|
|
2010-11-14 13:58:10 +03:00
|
|
|
struct BooleanCap : public BaseCap {
|
|
|
|
BooleanCap(const string& label, bool defaultValue);
|
|
|
|
|
|
|
|
bool DefaultValue() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool fDefaultValue;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct IntRangeCap : public BaseCap {
|
|
|
|
IntRangeCap(const string& label, int lower,
|
|
|
|
int upper, int defaultValue);
|
|
|
|
|
|
|
|
int32 Lower() const;
|
|
|
|
int32 Upper() const;
|
|
|
|
int32 DefaultValue() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
int32 fLower;
|
|
|
|
int32 fUpper;
|
|
|
|
int32 fDefaultValue;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct DoubleRangeCap : public BaseCap {
|
|
|
|
DoubleRangeCap(const string& label, double lower,
|
|
|
|
double upper, double defaultValue);
|
|
|
|
|
|
|
|
double Lower() const;
|
|
|
|
double Upper() const;
|
|
|
|
double DefaultValue() const;
|
|
|
|
|
|
|
|
double fLower;
|
|
|
|
double fUpper;
|
|
|
|
double fDefaultValue;
|
|
|
|
};
|
|
|
|
|
2002-11-27 02:03:14 +03:00
|
|
|
class PrinterData;
|
|
|
|
|
|
|
|
class PrinterCap {
|
|
|
|
public:
|
2010-10-25 15:34:31 +04:00
|
|
|
PrinterCap(const PrinterData *printer_data);
|
|
|
|
virtual ~PrinterCap();
|
2005-02-06 21:22:40 +03:00
|
|
|
|
2004-01-30 20:10:36 +03:00
|
|
|
enum CapID {
|
|
|
|
kPaper,
|
|
|
|
kPaperSource,
|
|
|
|
kResolution,
|
|
|
|
kOrientation,
|
|
|
|
kPrintStyle,
|
|
|
|
kBindingLocation,
|
2004-03-27 10:08:38 +03:00
|
|
|
kColor,
|
2005-02-06 21:22:40 +03:00
|
|
|
kProtocolClass,
|
2010-10-30 10:54:16 +04:00
|
|
|
kDriverSpecificCapabilities,
|
2010-10-26 13:48:36 +04:00
|
|
|
|
2004-03-27 10:08:38 +03:00
|
|
|
// Static boolean settings follow.
|
2010-12-10 13:47:19 +03:00
|
|
|
// For them Supports() has to be implemented only.
|
2010-10-26 13:48:36 +04:00
|
|
|
kCopyCommand, // supports printer page copy command?
|
|
|
|
kHalftone, // needs the printer driver the configuration
|
|
|
|
// for class Halftone?
|
2010-12-10 13:47:19 +03:00
|
|
|
kCanRotatePageInLandscape,
|
|
|
|
// can the printer driver rotate the page
|
|
|
|
// printing in landscape
|
2010-10-26 13:48:36 +04:00
|
|
|
|
|
|
|
// The driver specific generic capabilities start here
|
2010-10-30 10:54:16 +04:00
|
|
|
kDriverSpecificCapabilitiesBegin = 100
|
|
|
|
};
|
|
|
|
|
|
|
|
struct IDPredicate
|
|
|
|
{
|
|
|
|
IDPredicate(int id)
|
|
|
|
: fID(id)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool operator()(const BaseCap* baseCap) {
|
2010-11-14 13:58:10 +03:00
|
|
|
const EnumCap* enumCap = dynamic_cast<const EnumCap*>(baseCap);
|
|
|
|
if (enumCap == NULL)
|
|
|
|
return false;
|
|
|
|
return enumCap->ID() == fID;
|
2010-10-30 10:54:16 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int fID;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct LabelPredicate
|
|
|
|
{
|
|
|
|
LabelPredicate(const char* label)
|
|
|
|
: fLabel(label)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool operator()(const BaseCap* baseCap) {
|
|
|
|
return baseCap->fLabel == fLabel;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* fLabel;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
struct KeyPredicate
|
|
|
|
{
|
|
|
|
KeyPredicate(const char* key)
|
|
|
|
: fKey(key)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool operator()(const BaseCap* baseCap) {
|
2010-11-14 13:58:10 +03:00
|
|
|
const EnumCap* enumCap = dynamic_cast<const EnumCap*>(baseCap);
|
|
|
|
if (enumCap == NULL)
|
|
|
|
return false;
|
|
|
|
return enumCap->fKey == fKey;
|
2010-10-30 10:54:16 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
const char* fKey;
|
|
|
|
|
2002-11-27 02:03:14 +03:00
|
|
|
};
|
|
|
|
|
2010-12-08 23:07:22 +03:00
|
|
|
virtual int CountCap(CapID category) const = 0;
|
2010-12-10 10:26:14 +03:00
|
|
|
virtual bool Supports(CapID category) const = 0;
|
2010-12-08 23:07:22 +03:00
|
|
|
virtual const BaseCap** GetCaps(CapID category) const = 0;
|
2010-12-10 10:26:14 +03:00
|
|
|
|
2010-12-08 23:07:22 +03:00
|
|
|
const EnumCap* GetDefaultCap(CapID category) const;
|
|
|
|
const EnumCap* FindCap(CapID category, int id) const;
|
|
|
|
const BaseCap* FindCap(CapID category, const char* label) const;
|
|
|
|
const EnumCap* FindCapWithKey(CapID category, const char* key)
|
2010-10-30 10:54:16 +04:00
|
|
|
const;
|
2010-10-25 18:21:09 +04:00
|
|
|
|
2010-12-08 23:07:22 +03:00
|
|
|
const BooleanCap* FindBooleanCap(CapID category) const;
|
|
|
|
const IntRangeCap* FindIntRangeCap(CapID category) const;
|
|
|
|
const DoubleRangeCap* FindDoubleRangeCap(CapID category) const;
|
2010-11-14 13:58:10 +03:00
|
|
|
|
2010-12-08 23:07:22 +03:00
|
|
|
int GetProtocolClass() const;
|
2002-11-27 02:03:14 +03:00
|
|
|
|
|
|
|
protected:
|
2010-10-26 17:06:29 +04:00
|
|
|
PrinterCap(const PrinterCap& printerCap);
|
|
|
|
PrinterCap& operator=(const PrinterCap& printerCap);
|
2010-10-30 10:54:16 +04:00
|
|
|
template<typename Predicate>
|
2010-12-08 23:07:22 +03:00
|
|
|
const BaseCap* FindCap(CapID category, Predicate& predicate) const;
|
2010-10-25 15:34:31 +04:00
|
|
|
|
2010-12-08 23:07:22 +03:00
|
|
|
const PrinterData* GetPrinterData() const;
|
2002-11-27 02:03:14 +03:00
|
|
|
|
|
|
|
private:
|
2010-10-25 15:34:31 +04:00
|
|
|
const PrinterData* fPrinterData;
|
2002-11-27 02:03:14 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-10-30 10:54:16 +04:00
|
|
|
|
|
|
|
|
2002-11-27 02:03:14 +03:00
|
|
|
#endif /* __PRINTERCAP_H */
|