Added InkDensity and DitherType; distinguish between page and job settings
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6580 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
ef68644905
commit
7566478beb
@ -10,6 +10,8 @@
|
|||||||
#include <GraphicsDefs.h>
|
#include <GraphicsDefs.h>
|
||||||
#include <Rect.h>
|
#include <Rect.h>
|
||||||
|
|
||||||
|
#include "Halftone.h"
|
||||||
|
|
||||||
class BMessage;
|
class BMessage;
|
||||||
class PrinterCap;
|
class PrinterCap;
|
||||||
|
|
||||||
@ -206,6 +208,10 @@ public:
|
|||||||
kColor
|
kColor
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum Settings {
|
||||||
|
kPageSettings,
|
||||||
|
kJobSettings
|
||||||
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Paper fPaper;
|
Paper fPaper;
|
||||||
@ -218,7 +224,8 @@ private:
|
|||||||
int32 fNup;
|
int32 fNup;
|
||||||
int32 fFirstPage;
|
int32 fFirstPage;
|
||||||
int32 fLastPage;
|
int32 fLastPage;
|
||||||
float fGamma;
|
float fGamma; // 1 identiy, < 1 brigther, > 1 darker
|
||||||
|
float fInkDensity; // [0, 255] lower means higher density
|
||||||
PaperSource fPaperSource;
|
PaperSource fPaperSource;
|
||||||
int32 fCopies;
|
int32 fCopies;
|
||||||
bool fCollate;
|
bool fCollate;
|
||||||
@ -226,17 +233,19 @@ private:
|
|||||||
PrintStyle fPrintStyle;
|
PrintStyle fPrintStyle;
|
||||||
BindingLocation fBindingLocation;
|
BindingLocation fBindingLocation;
|
||||||
PageOrder fPageOrder;
|
PageOrder fPageOrder;
|
||||||
|
Settings fSettings;
|
||||||
BMessage *fMsg;
|
BMessage *fMsg;
|
||||||
bool fColor;
|
bool fColor;
|
||||||
|
Halftone::DitherType fDitherType;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
JobData(BMessage *msg, const PrinterCap *cap);
|
JobData(BMessage *msg, const PrinterCap *cap, Settings settings);
|
||||||
~JobData();
|
~JobData();
|
||||||
|
|
||||||
JobData(const JobData &job_data);
|
JobData(const JobData &job_data);
|
||||||
JobData &operator = (const JobData &job_data);
|
JobData &operator = (const JobData &job_data);
|
||||||
|
|
||||||
void load(BMessage *msg, const PrinterCap *cap);
|
void load(BMessage *msg, const PrinterCap *cap, Settings settings);
|
||||||
void save(BMessage *msg = NULL);
|
void save(BMessage *msg = NULL);
|
||||||
|
|
||||||
Paper getPaper() const { return fPaper; }
|
Paper getPaper() const { return fPaper; }
|
||||||
@ -278,6 +287,9 @@ public:
|
|||||||
float getGamma() const { return fGamma; }
|
float getGamma() const { return fGamma; }
|
||||||
void setGamma(float gamma) { fGamma = gamma; }
|
void setGamma(float gamma) { fGamma = gamma; }
|
||||||
|
|
||||||
|
float getInkDensity() const { return fInkDensity; }
|
||||||
|
void setInkDensity(float inkDensity) { fInkDensity = inkDensity; }
|
||||||
|
|
||||||
PaperSource getPaperSource() const { return fPaperSource; }
|
PaperSource getPaperSource() const { return fPaperSource; }
|
||||||
void setPaperSource(PaperSource paper_source) { fPaperSource = paper_source; };
|
void setPaperSource(PaperSource paper_source) { fPaperSource = paper_source; };
|
||||||
|
|
||||||
@ -298,11 +310,9 @@ public:
|
|||||||
|
|
||||||
Color getColor() const { return fColor ? kColor : kMonochrome; }
|
Color getColor() const { return fColor ? kColor : kMonochrome; }
|
||||||
void setColor(Color color) { fColor = color == kColor; }
|
void setColor(Color color) { fColor = color == kColor; }
|
||||||
/*
|
|
||||||
protected:
|
Halftone::DitherType getDitherType() const { return fDitherType; }
|
||||||
JobData(const JobData &job_data);
|
void setDitherType(Halftone::DitherType dither_type) { fDitherType = dither_type; }
|
||||||
JobData &operator = (const JobData &job_data);
|
|
||||||
*/
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* __JOBDATA_H */
|
#endif /* __JOBDATA_H */
|
||||||
|
@ -15,13 +15,14 @@ const char *kJDCopies = "copies";
|
|||||||
const char *kJDOrientation = "orientation";
|
const char *kJDOrientation = "orientation";
|
||||||
const char *kJDScaling = "scaling";
|
const char *kJDScaling = "scaling";
|
||||||
const char *kJDPaperRect = "paper_rect";
|
const char *kJDPaperRect = "paper_rect";
|
||||||
|
const char *kJDPrintableRect = "printable_rect";
|
||||||
const char *kJDFirstPage = "first_page";
|
const char *kJDFirstPage = "first_page";
|
||||||
const char *kJDLastPage = "last_page";
|
const char *kJDLastPage = "last_page";
|
||||||
const char *kJDPrintableRect = "printable_rect";
|
|
||||||
|
|
||||||
const char *kJDPaper = "JJJJ_paper";
|
const char *kJDPaper = "JJJJ_paper";
|
||||||
const char *kJDNup = "JJJJ_nup";
|
const char *kJDNup = "JJJJ_nup";
|
||||||
const char *kJDGamma = "JJJJ_gamma";
|
const char *kJDGamma = "JJJJ_gamma";
|
||||||
|
const char *kJDInkDensity = "JJJJ_ink_density";
|
||||||
const char *kJDPaperSource = "JJJJ_paper_source";
|
const char *kJDPaperSource = "JJJJ_paper_source";
|
||||||
const char *kJDCollate = "JJJJ_collate";
|
const char *kJDCollate = "JJJJ_collate";
|
||||||
const char *kJDReverse = "JJJJ_reverse";
|
const char *kJDReverse = "JJJJ_reverse";
|
||||||
@ -29,10 +30,11 @@ const char *kJDPrintStyle = "JJJJ_print_style";
|
|||||||
const char *kJDBindingLocation = "JJJJ_binding_location";
|
const char *kJDBindingLocation = "JJJJ_binding_location";
|
||||||
const char *kJDPageOrder = "JJJJ_page_order";
|
const char *kJDPageOrder = "JJJJ_page_order";
|
||||||
const char *kJDColor = "JJJJ_color";
|
const char *kJDColor = "JJJJ_color";
|
||||||
|
const char *kJDDitherType = "JJJJ_dither_type";
|
||||||
|
|
||||||
JobData::JobData(BMessage *msg, const PrinterCap *cap)
|
JobData::JobData(BMessage *msg, const PrinterCap *cap, Settings settings)
|
||||||
{
|
{
|
||||||
load(msg, cap);
|
load(msg, cap, settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
JobData::~JobData()
|
JobData::~JobData()
|
||||||
@ -52,6 +54,7 @@ JobData::JobData(const JobData &job_data)
|
|||||||
fFirstPage = job_data.fFirstPage;
|
fFirstPage = job_data.fFirstPage;
|
||||||
fLastPage = job_data.fLastPage;
|
fLastPage = job_data.fLastPage;
|
||||||
fGamma = job_data.fGamma;
|
fGamma = job_data.fGamma;
|
||||||
|
fInkDensity = job_data.fInkDensity;
|
||||||
fPaperSource = job_data.fPaperSource;
|
fPaperSource = job_data.fPaperSource;
|
||||||
fCopies = job_data.fCopies;
|
fCopies = job_data.fCopies;
|
||||||
fCollate = job_data.fCollate;
|
fCollate = job_data.fCollate;
|
||||||
@ -59,8 +62,10 @@ JobData::JobData(const JobData &job_data)
|
|||||||
fPrintStyle = job_data.fPrintStyle;
|
fPrintStyle = job_data.fPrintStyle;
|
||||||
fBindingLocation = job_data.fBindingLocation;
|
fBindingLocation = job_data.fBindingLocation;
|
||||||
fPageOrder = job_data.fPageOrder;
|
fPageOrder = job_data.fPageOrder;
|
||||||
|
fSettings = job_data.fSettings;
|
||||||
fMsg = job_data.fMsg;
|
fMsg = job_data.fMsg;
|
||||||
fColor = job_data.fColor;
|
fColor = job_data.fColor;
|
||||||
|
fDitherType = job_data.fDitherType;
|
||||||
}
|
}
|
||||||
|
|
||||||
JobData &JobData::operator = (const JobData &job_data)
|
JobData &JobData::operator = (const JobData &job_data)
|
||||||
@ -76,6 +81,7 @@ JobData &JobData::operator = (const JobData &job_data)
|
|||||||
fFirstPage = job_data.fFirstPage;
|
fFirstPage = job_data.fFirstPage;
|
||||||
fLastPage = job_data.fLastPage;
|
fLastPage = job_data.fLastPage;
|
||||||
fGamma = job_data.fGamma;
|
fGamma = job_data.fGamma;
|
||||||
|
fInkDensity = job_data.fInkDensity;
|
||||||
fPaperSource = job_data.fPaperSource;
|
fPaperSource = job_data.fPaperSource;
|
||||||
fCopies = job_data.fCopies;
|
fCopies = job_data.fCopies;
|
||||||
fCollate = job_data.fCollate;
|
fCollate = job_data.fCollate;
|
||||||
@ -83,14 +89,17 @@ JobData &JobData::operator = (const JobData &job_data)
|
|||||||
fPrintStyle = job_data.fPrintStyle;
|
fPrintStyle = job_data.fPrintStyle;
|
||||||
fBindingLocation = job_data.fBindingLocation;
|
fBindingLocation = job_data.fBindingLocation;
|
||||||
fPageOrder = job_data.fPageOrder;
|
fPageOrder = job_data.fPageOrder;
|
||||||
|
fSettings = job_data.fSettings;
|
||||||
fMsg = job_data.fMsg;
|
fMsg = job_data.fMsg;
|
||||||
fColor = job_data.fColor;
|
fColor = job_data.fColor;
|
||||||
|
fDitherType = job_data.fDitherType;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void JobData::load(BMessage *msg, const PrinterCap *cap)
|
void JobData::load(BMessage *msg, const PrinterCap *cap, Settings settings)
|
||||||
{
|
{
|
||||||
fMsg = msg;
|
fMsg = msg;
|
||||||
|
fSettings = settings;
|
||||||
|
|
||||||
if (msg->HasInt32(kJDPaper))
|
if (msg->HasInt32(kJDPaper))
|
||||||
fPaper = (Paper)msg->FindInt32(kJDPaper);
|
fPaper = (Paper)msg->FindInt32(kJDPaper);
|
||||||
@ -157,7 +166,12 @@ void JobData::load(BMessage *msg, const PrinterCap *cap)
|
|||||||
if (msg->HasFloat(kJDGamma))
|
if (msg->HasFloat(kJDGamma))
|
||||||
fGamma = fMsg->FindFloat(kJDGamma);
|
fGamma = fMsg->FindFloat(kJDGamma);
|
||||||
else
|
else
|
||||||
fGamma = 1.4f;
|
fGamma = 0.25f;
|
||||||
|
|
||||||
|
if (msg->HasFloat(kJDInkDensity))
|
||||||
|
fInkDensity = fMsg->FindFloat(kJDInkDensity);
|
||||||
|
else
|
||||||
|
fInkDensity = 0.0f;
|
||||||
|
|
||||||
if (msg->HasInt32(kJDPaperSource))
|
if (msg->HasInt32(kJDPaperSource))
|
||||||
fPaperSource = (PaperSource)fMsg->FindInt32(kJDPaperSource);
|
fPaperSource = (PaperSource)fMsg->FindInt32(kJDPaperSource);
|
||||||
@ -204,6 +218,11 @@ void JobData::load(BMessage *msg, const PrinterCap *cap)
|
|||||||
fColor = msg->FindBool(kJDColor);
|
fColor = msg->FindBool(kJDColor);
|
||||||
else
|
else
|
||||||
fColor = false;
|
fColor = false;
|
||||||
|
|
||||||
|
if (msg->HasInt32(kJDDitherType))
|
||||||
|
fDitherType = (Halftone::DitherType)msg->FindInt32(kJDDitherType);
|
||||||
|
else
|
||||||
|
fDitherType = Halftone::kTypeFloydSteinberg;
|
||||||
}
|
}
|
||||||
|
|
||||||
void JobData::save(BMessage *msg)
|
void JobData::save(BMessage *msg)
|
||||||
@ -212,6 +231,7 @@ void JobData::save(BMessage *msg)
|
|||||||
msg = fMsg;
|
msg = fMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// page settings
|
||||||
if (msg->HasInt32(kJDPaper))
|
if (msg->HasInt32(kJDPaper))
|
||||||
msg->ReplaceInt32(kJDPaper, fPaper);
|
msg->ReplaceInt32(kJDPaper, fPaper);
|
||||||
else
|
else
|
||||||
@ -247,6 +267,10 @@ void JobData::save(BMessage *msg)
|
|||||||
else
|
else
|
||||||
msg->AddRect(kJDPrintableRect, fPrintableRect);
|
msg->AddRect(kJDPrintableRect, fPrintableRect);
|
||||||
|
|
||||||
|
// page settings end here; don't store job settings in message
|
||||||
|
if (fSettings == kPageSettings) return;
|
||||||
|
|
||||||
|
// job settings
|
||||||
if (msg->HasInt32(kJDNup))
|
if (msg->HasInt32(kJDNup))
|
||||||
msg->ReplaceInt32(kJDNup, fNup);
|
msg->ReplaceInt32(kJDNup, fNup);
|
||||||
else
|
else
|
||||||
@ -267,6 +291,11 @@ void JobData::save(BMessage *msg)
|
|||||||
else
|
else
|
||||||
msg->AddFloat(kJDGamma, fGamma);
|
msg->AddFloat(kJDGamma, fGamma);
|
||||||
|
|
||||||
|
if (msg->HasFloat(kJDInkDensity))
|
||||||
|
msg->ReplaceFloat(kJDInkDensity, fInkDensity);
|
||||||
|
else
|
||||||
|
msg->AddFloat(kJDInkDensity, fInkDensity);
|
||||||
|
|
||||||
if (msg->HasInt32(kJDPaperSource))
|
if (msg->HasInt32(kJDPaperSource))
|
||||||
msg->ReplaceInt32(kJDPaperSource, fPaperSource);
|
msg->ReplaceInt32(kJDPaperSource, fPaperSource);
|
||||||
else
|
else
|
||||||
@ -306,4 +335,9 @@ void JobData::save(BMessage *msg)
|
|||||||
msg->ReplaceBool(kJDColor, fColor);
|
msg->ReplaceBool(kJDColor, fColor);
|
||||||
else
|
else
|
||||||
msg->AddBool(kJDColor, fColor);
|
msg->AddBool(kJDColor, fColor);
|
||||||
|
|
||||||
|
if (msg->HasInt32(kJDDitherType))
|
||||||
|
msg->ReplaceInt32(kJDDitherType, fDitherType);
|
||||||
|
else
|
||||||
|
msg->AddInt32(kJDDitherType, fDitherType);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user