* Added support for the remaining Gutenprint setting types:
Boolean, Int, Dimension and Double. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39423 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -22,6 +22,38 @@ class PrinterCap;
|
||||
|
||||
using namespace std;
|
||||
|
||||
class DriverSpecificSettings
|
||||
{
|
||||
public:
|
||||
DriverSpecificSettings();
|
||||
DriverSpecificSettings(const DriverSpecificSettings& settings);
|
||||
|
||||
DriverSpecificSettings &operator=(const DriverSpecificSettings &settings);
|
||||
|
||||
void MakeEmpty();
|
||||
|
||||
bool HasString(const char* key) const;
|
||||
const char* GetString(const char* key) const;
|
||||
void SetString(const char* key, const char* value);
|
||||
|
||||
bool HasBoolean(const char* ekey) const;
|
||||
bool GetBoolean(const char* key) const;
|
||||
void SetBoolean(const char* key, bool value);
|
||||
|
||||
bool HasInt(const char* ekey) const;
|
||||
int32 GetInt(const char* key) const;
|
||||
void SetInt(const char* key, int32 value);
|
||||
|
||||
bool HasDouble(const char* ekey) const;
|
||||
double GetDouble(const char* key) const;
|
||||
void SetDouble(const char* key, double value);
|
||||
|
||||
BMessage& Message();
|
||||
|
||||
private:
|
||||
BMessage fSettings;
|
||||
};
|
||||
|
||||
|
||||
class JobData {
|
||||
public:
|
||||
@@ -219,7 +251,7 @@ public:
|
||||
kColorCompressionDisabled
|
||||
};
|
||||
|
||||
enum Settings {
|
||||
enum SettingType {
|
||||
kPageSettings,
|
||||
kJobSettings
|
||||
};
|
||||
@@ -256,22 +288,22 @@ private:
|
||||
PrintStyle fPrintStyle;
|
||||
BindingLocation fBindingLocation;
|
||||
PageOrder fPageOrder;
|
||||
Settings fSettings;
|
||||
SettingType fSettingType;
|
||||
BMessage *fMsg;
|
||||
Color fColor;
|
||||
Halftone::DitherType fDitherType;
|
||||
PageSelection fPageSelection;
|
||||
MarginUnit fMarginUnit;
|
||||
map<string, string> fDriverSpecificSettings;
|
||||
DriverSpecificSettings fDriverSpecificSettings;
|
||||
|
||||
public:
|
||||
JobData(BMessage *msg, const PrinterCap *cap, Settings settings);
|
||||
JobData(BMessage *msg, const PrinterCap *cap, SettingType type);
|
||||
~JobData();
|
||||
|
||||
JobData(const JobData &job_data);
|
||||
JobData &operator = (const JobData &job_data);
|
||||
|
||||
void load(BMessage *msg, const PrinterCap *cap, Settings settings);
|
||||
void load(BMessage *msg, const PrinterCap *cap, SettingType type);
|
||||
void save(BMessage *msg = NULL);
|
||||
|
||||
bool getShowPreview() const { return fShowPreview; }
|
||||
@@ -364,13 +396,9 @@ public:
|
||||
MarginUnit getMarginUnit() const { return fMarginUnit; }
|
||||
void setMarginUnit(MarginUnit marginUnit) { fMarginUnit = marginUnit; }
|
||||
|
||||
bool HasDriverSpecificSetting(const string& category) const;
|
||||
const string& DriverSpecificSetting(const string& category) const;
|
||||
void SetDriverSpecificSetting(const string& category, const string& value);
|
||||
DriverSpecificSettings& Settings();
|
||||
const DriverSpecificSettings& Settings() const;
|
||||
|
||||
private:
|
||||
void SerializePrinterSpecificSettings(BString& serializedSettings);
|
||||
void DeserializePrinterSpecificSettings(BString& serializedSettings);
|
||||
};
|
||||
|
||||
#endif /* __JOBDATA_H */
|
||||
|
||||
@@ -20,6 +20,7 @@ class BCheckBox;
|
||||
class BGridLayout;
|
||||
class BPopUpMenu;
|
||||
class BRadioButton;
|
||||
class BSlider;
|
||||
class BTextControl;
|
||||
class BTextView;
|
||||
class HalftoneView;
|
||||
@@ -28,6 +29,79 @@ class PagesView;
|
||||
class PrinterCap;
|
||||
class PrinterData;
|
||||
|
||||
extern BString& operator<<(BString& text, double value);
|
||||
|
||||
template<typename T, typename R>
|
||||
class Range
|
||||
{
|
||||
public:
|
||||
Range();
|
||||
Range(const char* label, const char* key, const R* range, BSlider* slider);
|
||||
const char* Key() const;
|
||||
T Value();
|
||||
void UpdateLabel();
|
||||
|
||||
private:
|
||||
const char* fLabel;
|
||||
const char* fKey;
|
||||
const R* fRange;
|
||||
BSlider* fSlider;
|
||||
};
|
||||
|
||||
|
||||
template<typename T, typename R>
|
||||
Range<T, R>::Range()
|
||||
:
|
||||
fKey(NULL),
|
||||
fRange(NULL),
|
||||
fSlider(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
template<typename T, typename R>
|
||||
Range<T, R>::Range(const char* label, const char* key, const R* range,
|
||||
BSlider* slider)
|
||||
:
|
||||
fLabel(label),
|
||||
fKey(key),
|
||||
fRange(range),
|
||||
fSlider(slider)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
template<typename T, typename R>
|
||||
const char*
|
||||
Range<T, R>::Key() const
|
||||
{
|
||||
return fKey;
|
||||
}
|
||||
|
||||
|
||||
template<typename T, typename R>
|
||||
T
|
||||
Range<T, R>::Value()
|
||||
{
|
||||
return static_cast<T>(fRange->Lower() +
|
||||
(fRange->Upper() - fRange->Lower()) * fSlider->Position());
|
||||
}
|
||||
|
||||
|
||||
template<typename T, typename R>
|
||||
void
|
||||
Range<T, R>::UpdateLabel()
|
||||
{
|
||||
BString label = fLabel;
|
||||
label << " (" << Value() << ")";
|
||||
fSlider->SetLabel(label.String());
|
||||
}
|
||||
|
||||
|
||||
typedef Range<int32, IntRangeCap> IntRange;
|
||||
typedef Range<double, DoubleRangeCap> DoubleRange;
|
||||
|
||||
class JobSetupView : public BView {
|
||||
public:
|
||||
JobSetupView(JobData* jobData, PrinterData* printerData,
|
||||
@@ -41,6 +115,14 @@ private:
|
||||
bool IsHalftoneConfigurationNeeded();
|
||||
void CreateHalftoneConfigurationUI();
|
||||
void AddDriverSpecificSettings(BGridLayout* gridLayout, int row);
|
||||
void AddPopUpMenu(const DriverSpecificCap* capability,
|
||||
BGridLayout* gridLayout, int& row);
|
||||
void AddCheckBox(const DriverSpecificCap* capability,
|
||||
BGridLayout* gridLayout, int& row);
|
||||
void AddIntSlider(const DriverSpecificCap* capability,
|
||||
BGridLayout* gridLayout, int& row);
|
||||
void AddDoubleSlider(const DriverSpecificCap* capability,
|
||||
BGridLayout* gridLayout, int& row);
|
||||
string GetDriverSpecificValue(PrinterCap::CapID category,
|
||||
const char* key);
|
||||
template<typename Predicate>
|
||||
@@ -58,6 +140,8 @@ private:
|
||||
JobData::PageSelection pageSelection);
|
||||
void AllowOnlyDigits(BTextView* textView, int maxDigits);
|
||||
void UpdateHalftonePreview();
|
||||
void UpdateIntSlider(BMessage* message);
|
||||
void UpdateDoubleSlider(BMessage* message);
|
||||
|
||||
JobData::Color Color();
|
||||
Halftone::DitherType DitherType();
|
||||
@@ -65,6 +149,7 @@ private:
|
||||
float InkDensity();
|
||||
JobData::PaperSource PaperSource();
|
||||
|
||||
|
||||
BTextControl* fCopies;
|
||||
BTextControl* fFromPage;
|
||||
BTextControl* fToPage;
|
||||
@@ -88,7 +173,10 @@ private:
|
||||
BRadioButton* fAllPages;
|
||||
BRadioButton* fOddNumberedPages;
|
||||
BRadioButton* fEvenNumberedPages;
|
||||
std::map<PrinterCap::CapID, BPopUpMenu*> fDriverSpecificLists;
|
||||
std::map<PrinterCap::CapID, BPopUpMenu*> fDriverSpecificPopUpMenus;
|
||||
std::map<string, BCheckBox*> fDriverSpecificCheckBoxes;
|
||||
std::map<PrinterCap::CapID, IntRange> fDriverSpecificIntSliders;
|
||||
std::map<PrinterCap::CapID, DoubleRange> fDriverSpecificDoubleSliders;
|
||||
BCheckBox* fPreview;
|
||||
};
|
||||
|
||||
|
||||
@@ -17,18 +17,26 @@ enum {
|
||||
};
|
||||
|
||||
struct BaseCap {
|
||||
BaseCap(const string &label, bool isDefault);
|
||||
BaseCap(const string &label);
|
||||
virtual ~BaseCap();
|
||||
|
||||
const char* Label() const;
|
||||
|
||||
string fLabel;
|
||||
};
|
||||
|
||||
struct EnumCap : public BaseCap {
|
||||
EnumCap(const string& label, bool isDefault);
|
||||
|
||||
virtual int32 ID() const = 0;
|
||||
const char* Key() const;
|
||||
|
||||
string fLabel;
|
||||
bool fIsDefault;
|
||||
string fKey;
|
||||
};
|
||||
|
||||
struct PaperCap : public BaseCap {
|
||||
|
||||
struct PaperCap : public EnumCap {
|
||||
PaperCap(const string &label, bool isDefault,
|
||||
JobData::Paper paper, const BRect &paperRect,
|
||||
const BRect &physicalRect);
|
||||
@@ -40,7 +48,7 @@ struct PaperCap : public BaseCap {
|
||||
BRect fPhysicalRect;
|
||||
};
|
||||
|
||||
struct PaperSourceCap : public BaseCap {
|
||||
struct PaperSourceCap : public EnumCap {
|
||||
PaperSourceCap(const string &label, bool isDefault,
|
||||
JobData::PaperSource paperSource);
|
||||
|
||||
@@ -49,7 +57,7 @@ struct PaperSourceCap : public BaseCap {
|
||||
JobData::PaperSource fPaperSource;
|
||||
};
|
||||
|
||||
struct ResolutionCap : public BaseCap {
|
||||
struct ResolutionCap : public EnumCap {
|
||||
ResolutionCap(const string &label, bool isDefault,
|
||||
int32 id, int xResolution, int yResolution);
|
||||
|
||||
@@ -60,7 +68,7 @@ struct ResolutionCap : public BaseCap {
|
||||
int fYResolution;
|
||||
};
|
||||
|
||||
struct OrientationCap : public BaseCap {
|
||||
struct OrientationCap : public EnumCap {
|
||||
OrientationCap(const string &label, bool isDefault,
|
||||
JobData::Orientation orientation);
|
||||
|
||||
@@ -69,7 +77,7 @@ struct OrientationCap : public BaseCap {
|
||||
JobData::Orientation fOrientation;
|
||||
};
|
||||
|
||||
struct PrintStyleCap : public BaseCap {
|
||||
struct PrintStyleCap : public EnumCap {
|
||||
PrintStyleCap(const string &label, bool isDefault,
|
||||
JobData::PrintStyle printStyle);
|
||||
|
||||
@@ -78,7 +86,7 @@ struct PrintStyleCap : public BaseCap {
|
||||
JobData::PrintStyle fPrintStyle;
|
||||
};
|
||||
|
||||
struct BindingLocationCap : public BaseCap {
|
||||
struct BindingLocationCap : public EnumCap {
|
||||
BindingLocationCap(const string &label,
|
||||
bool isDefault,
|
||||
JobData::BindingLocation bindingLocation);
|
||||
@@ -88,7 +96,7 @@ struct BindingLocationCap : public BaseCap {
|
||||
JobData::BindingLocation fBindingLocation;
|
||||
};
|
||||
|
||||
struct ColorCap : public BaseCap {
|
||||
struct ColorCap : public EnumCap {
|
||||
ColorCap(const string &label, bool isDefault,
|
||||
JobData::Color color);
|
||||
|
||||
@@ -97,7 +105,7 @@ struct ColorCap : public BaseCap {
|
||||
JobData::Color fColor;
|
||||
};
|
||||
|
||||
struct ProtocolClassCap : public BaseCap {
|
||||
struct ProtocolClassCap : public EnumCap {
|
||||
ProtocolClassCap(const string &label,
|
||||
bool isDefault, int32 protocolClass,
|
||||
const string &description);
|
||||
@@ -109,11 +117,13 @@ struct ProtocolClassCap : public BaseCap {
|
||||
};
|
||||
|
||||
|
||||
struct DriverSpecificCap : public BaseCap {
|
||||
struct DriverSpecificCap : public EnumCap {
|
||||
enum Type {
|
||||
kList,
|
||||
kCheckBox,
|
||||
kRange
|
||||
kBoolean,
|
||||
kIntRange,
|
||||
kIntDimension,
|
||||
kDoubleRange
|
||||
};
|
||||
|
||||
DriverSpecificCap(const string& label,
|
||||
@@ -125,14 +135,52 @@ struct DriverSpecificCap : public BaseCap {
|
||||
Type fType;
|
||||
};
|
||||
|
||||
struct ListItemCap : public BaseCap {
|
||||
struct ListItemCap : public EnumCap {
|
||||
ListItemCap(const string& label,
|
||||
bool isDefault, int32 id);
|
||||
|
||||
int32 ID() const;
|
||||
|
||||
private:
|
||||
int32 fID;
|
||||
};
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
class PrinterData;
|
||||
|
||||
class PrinterCap {
|
||||
@@ -170,7 +218,10 @@ public:
|
||||
|
||||
|
||||
bool operator()(const BaseCap* baseCap) {
|
||||
return baseCap->ID() == fID;
|
||||
const EnumCap* enumCap = dynamic_cast<const EnumCap*>(baseCap);
|
||||
if (enumCap == NULL)
|
||||
return false;
|
||||
return enumCap->ID() == fID;
|
||||
}
|
||||
|
||||
int fID;
|
||||
@@ -201,7 +252,10 @@ public:
|
||||
|
||||
|
||||
bool operator()(const BaseCap* baseCap) {
|
||||
return baseCap->fKey == fKey;
|
||||
const EnumCap* enumCap = dynamic_cast<const EnumCap*>(baseCap);
|
||||
if (enumCap == NULL)
|
||||
return false;
|
||||
return enumCap->fKey == fKey;
|
||||
}
|
||||
|
||||
const char* fKey;
|
||||
@@ -211,12 +265,16 @@ public:
|
||||
virtual int countCap(CapID category) const = 0;
|
||||
virtual bool isSupport(CapID category) const = 0;
|
||||
virtual const BaseCap** enumCap(CapID category) const = 0;
|
||||
const BaseCap* getDefaultCap(CapID category) const;
|
||||
const BaseCap* findCap(CapID category, int id) const;
|
||||
const EnumCap* getDefaultCap(CapID category) const;
|
||||
const EnumCap* findCap(CapID category, int id) const;
|
||||
const BaseCap* findCap(CapID category, const char* label) const;
|
||||
const BaseCap* findCapWithKey(CapID category, const char* key)
|
||||
const EnumCap* findCapWithKey(CapID category, const char* key)
|
||||
const;
|
||||
|
||||
const BooleanCap* findBooleanCap(CapID category) const;
|
||||
const IntRangeCap* findIntRangeCap(CapID category) const;
|
||||
const DoubleRangeCap* findDoubleRangeCap(CapID category) const;
|
||||
|
||||
int getProtocolClass() const;
|
||||
|
||||
protected:
|
||||
|
||||
Reference in New Issue
Block a user