* Added field fKey to BaseCap (will be required for Gutenprint printer
driver add-on). * Added ability to search for a PrinterCap by ID to class PrinterCap (for Gutenprint driver add-on). * Moved code for searching a PrinterCap by name into class PrinterCap. * Refactored code in JobSetupDlg to use the new method. * Refactored duplicated code in JobSetupDlg. * There is still a lot of refactoring potential in libprint. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39141 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -12,6 +12,7 @@
|
|||||||
#include "JobData.h"
|
#include "JobData.h"
|
||||||
#include "Halftone.h"
|
#include "Halftone.h"
|
||||||
#include "JSDSlider.h"
|
#include "JSDSlider.h"
|
||||||
|
#include "PrinterCap.h"
|
||||||
|
|
||||||
class BTextControl;
|
class BTextControl;
|
||||||
class BTextView;
|
class BTextView;
|
||||||
@@ -34,13 +35,20 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void UpdateButtonEnabledState();
|
void UpdateButtonEnabledState();
|
||||||
|
void FillCapabilityMenu(BPopUpMenu* menu, uint32 message,
|
||||||
|
PrinterCap::CapID category, int id);
|
||||||
|
void FillCapabilityMenu(BPopUpMenu* menu, uint32 message,
|
||||||
|
const BaseCap** capabilities, int count, int id);
|
||||||
|
int GetID(const BaseCap** capabilities, int count, const char* label,
|
||||||
|
int defaultValue);
|
||||||
BRadioButton* CreatePageSelectionItem(const char* name, const char* label,
|
BRadioButton* CreatePageSelectionItem(const char* name, const char* label,
|
||||||
JobData::PageSelection pageSelection);
|
JobData::PageSelection pageSelection);
|
||||||
void AllowOnlyDigits(BTextView* textView, int maxDigits);
|
void AllowOnlyDigits(BTextView* textView, int maxDigits);
|
||||||
JobData::Color getColor();
|
JobData::Color Color();
|
||||||
Halftone::DitherType getDitherType();
|
Halftone::DitherType DitherType();
|
||||||
float getGamma();
|
float Gamma();
|
||||||
float getInkDensity();
|
float InkDensity();
|
||||||
|
JobData::PaperSource PaperSource();
|
||||||
|
|
||||||
BTextControl *fCopies;
|
BTextControl *fCopies;
|
||||||
BTextControl *fFromPage;
|
BTextControl *fFromPage;
|
||||||
|
|||||||
@@ -18,9 +18,13 @@ enum {
|
|||||||
|
|
||||||
struct BaseCap {
|
struct BaseCap {
|
||||||
BaseCap(const string &label, bool isDefault);
|
BaseCap(const string &label, bool isDefault);
|
||||||
|
virtual ~BaseCap();
|
||||||
|
|
||||||
|
virtual int ID() const = 0;
|
||||||
|
|
||||||
string fLabel;
|
string fLabel;
|
||||||
bool fIsDefault;
|
bool fIsDefault;
|
||||||
|
string fKey;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PaperCap : public BaseCap {
|
struct PaperCap : public BaseCap {
|
||||||
@@ -28,6 +32,8 @@ struct PaperCap : public BaseCap {
|
|||||||
JobData::Paper paper, const BRect &paperRect,
|
JobData::Paper paper, const BRect &paperRect,
|
||||||
const BRect &physicalRect);
|
const BRect &physicalRect);
|
||||||
|
|
||||||
|
int ID() const;
|
||||||
|
|
||||||
JobData::Paper fPaper;
|
JobData::Paper fPaper;
|
||||||
BRect fPaperRect;
|
BRect fPaperRect;
|
||||||
BRect fPhysicalRect;
|
BRect fPhysicalRect;
|
||||||
@@ -37,13 +43,18 @@ struct PaperSourceCap : public BaseCap {
|
|||||||
PaperSourceCap(const string &label, bool isDefault,
|
PaperSourceCap(const string &label, bool isDefault,
|
||||||
JobData::PaperSource paperSource);
|
JobData::PaperSource paperSource);
|
||||||
|
|
||||||
|
int ID() const;
|
||||||
|
|
||||||
JobData::PaperSource fPaperSource;
|
JobData::PaperSource fPaperSource;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ResolutionCap : public BaseCap {
|
struct ResolutionCap : public BaseCap {
|
||||||
ResolutionCap(const string &label, bool isDefault,
|
ResolutionCap(const string &label, bool isDefault,
|
||||||
int xResolution, int yResolution);
|
int id, int xResolution, int yResolution);
|
||||||
|
|
||||||
|
int ID() const;
|
||||||
|
|
||||||
|
int fID;
|
||||||
int fXResolution;
|
int fXResolution;
|
||||||
int fYResolution;
|
int fYResolution;
|
||||||
};
|
};
|
||||||
@@ -52,6 +63,8 @@ struct OrientationCap : public BaseCap {
|
|||||||
OrientationCap(const string &label, bool isDefault,
|
OrientationCap(const string &label, bool isDefault,
|
||||||
JobData::Orientation orientation);
|
JobData::Orientation orientation);
|
||||||
|
|
||||||
|
int ID() const;
|
||||||
|
|
||||||
JobData::Orientation fOrientation;
|
JobData::Orientation fOrientation;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -59,6 +72,8 @@ struct PrintStyleCap : public BaseCap {
|
|||||||
PrintStyleCap(const string &label, bool isDefault,
|
PrintStyleCap(const string &label, bool isDefault,
|
||||||
JobData::PrintStyle printStyle);
|
JobData::PrintStyle printStyle);
|
||||||
|
|
||||||
|
int ID() const;
|
||||||
|
|
||||||
JobData::PrintStyle fPrintStyle;
|
JobData::PrintStyle fPrintStyle;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -67,6 +82,8 @@ struct BindingLocationCap : public BaseCap {
|
|||||||
bool isDefault,
|
bool isDefault,
|
||||||
JobData::BindingLocation bindingLocation);
|
JobData::BindingLocation bindingLocation);
|
||||||
|
|
||||||
|
int ID() const;
|
||||||
|
|
||||||
JobData::BindingLocation fBindingLocation;
|
JobData::BindingLocation fBindingLocation;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -74,6 +91,8 @@ struct ColorCap : public BaseCap {
|
|||||||
ColorCap(const string &label, bool isDefault,
|
ColorCap(const string &label, bool isDefault,
|
||||||
JobData::Color color);
|
JobData::Color color);
|
||||||
|
|
||||||
|
int ID() const;
|
||||||
|
|
||||||
JobData::Color fColor;
|
JobData::Color fColor;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -82,6 +101,8 @@ struct ProtocolClassCap : public BaseCap {
|
|||||||
bool isDefault, int protocolClass,
|
bool isDefault, int protocolClass,
|
||||||
const string &description);
|
const string &description);
|
||||||
|
|
||||||
|
int ID() const;
|
||||||
|
|
||||||
int fProtocolClass;
|
int fProtocolClass;
|
||||||
string fDescription;
|
string fDescription;
|
||||||
};
|
};
|
||||||
@@ -108,16 +129,19 @@ public:
|
|||||||
kCopyCommand, // supports printer page copy command?
|
kCopyCommand, // supports printer page copy command?
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual int countCap(CapID) const = 0;
|
virtual int countCap(CapID category) const = 0;
|
||||||
virtual bool isSupport(CapID) const = 0;
|
virtual bool isSupport(CapID category) const = 0;
|
||||||
virtual const BaseCap** enumCap(CapID) const = 0;
|
virtual const BaseCap** enumCap(CapID category) const = 0;
|
||||||
const BaseCap* getDefaultCap(CapID) const;
|
const BaseCap* getDefaultCap(CapID category) const;
|
||||||
|
const BaseCap* findCap(CapID category, int id) const;
|
||||||
|
const BaseCap* findCap(CapID category, const char* label) const;
|
||||||
|
|
||||||
int getPrinterId() const;
|
int getPrinterId() const;
|
||||||
int getProtocolClass() const;
|
int getProtocolClass() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
PrinterCap(const PrinterCap &);
|
PrinterCap(const PrinterCap &printerCap);
|
||||||
PrinterCap& operator=(const PrinterCap &);
|
PrinterCap& operator=(const PrinterCap &printerCap);
|
||||||
|
|
||||||
const PrinterData* getPrinterData() const;
|
const PrinterData* getPrinterData() const;
|
||||||
void setPrinterId(int id);
|
void setPrinterId(int id);
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ const PaperSourceCap manual("Manual", false, JobData::kManual);
|
|||||||
const PaperSourceCap upper("Upper", false, JobData::kUpper);
|
const PaperSourceCap upper("Upper", false, JobData::kUpper);
|
||||||
const PaperSourceCap lower("Lower", false, JobData::kLower);
|
const PaperSourceCap lower("Lower", false, JobData::kLower);
|
||||||
|
|
||||||
const ResolutionCap dpi300("300dpi", true, 300, 300);
|
const ResolutionCap dpi300("300dpi", true, 0, 300, 300);
|
||||||
|
|
||||||
const PaperCap* papers[] = {
|
const PaperCap* papers[] = {
|
||||||
&a4,
|
&a4,
|
||||||
|
|||||||
@@ -98,9 +98,9 @@ const PaperSourceCap upper("Upper", false, JobData::kUpper);
|
|||||||
const PaperSourceCap middle("Middle", false, JobData::kMiddle);
|
const PaperSourceCap middle("Middle", false, JobData::kMiddle);
|
||||||
const PaperSourceCap lower("Lower", false, JobData::kLower);
|
const PaperSourceCap lower("Lower", false, JobData::kLower);
|
||||||
|
|
||||||
const ResolutionCap dpi1200("1200dpi", false, 1200, 1200);
|
const ResolutionCap dpi1200("1200dpi", false, 0, 1200, 1200);
|
||||||
const ResolutionCap dpi600("600dpi", true, 600, 600);
|
const ResolutionCap dpi600("600dpi", true, 1, 600, 600);
|
||||||
const ResolutionCap dpi300("300dpi", false, 300, 300);
|
const ResolutionCap dpi300("300dpi", false, 2, 300, 300);
|
||||||
|
|
||||||
const PrintStyleCap simplex("Simplex", true, JobData::kSimplex);
|
const PrintStyleCap simplex("Simplex", true, JobData::kSimplex);
|
||||||
const PrintStyleCap duplex("Duplex", false, JobData::kDuplex);
|
const PrintStyleCap duplex("Duplex", false, JobData::kDuplex);
|
||||||
|
|||||||
@@ -68,9 +68,9 @@ const PaperCap legal(
|
|||||||
|
|
||||||
const PaperSourceCap autobin("Auto", true, JobData::kAuto);
|
const PaperSourceCap autobin("Auto", true, JobData::kAuto);
|
||||||
|
|
||||||
const ResolutionCap dpi300("300dpi", true, 300, 300);
|
const ResolutionCap dpi300("300dpi", true, 0, 300, 300);
|
||||||
const ResolutionCap dpi600("600dpi", false, 600, 600);
|
const ResolutionCap dpi600("600dpi", false, 1, 600, 600);
|
||||||
const ResolutionCap dpi1200("1200dpi", false, 1200, 1200);
|
const ResolutionCap dpi1200("1200dpi", false, 2, 1200, 1200);
|
||||||
|
|
||||||
const PaperCap* papers[] = {
|
const PaperCap* papers[] = {
|
||||||
&a4,
|
&a4,
|
||||||
|
|||||||
@@ -145,10 +145,10 @@ const PaperSourceCap envelopeTray("Envelope Tray", false,
|
|||||||
// since 2.0:
|
// since 2.0:
|
||||||
const PaperSourceCap thridCassette("Thrid Cassette", false, JobData::kMiddle);
|
const PaperSourceCap thridCassette("Thrid Cassette", false, JobData::kMiddle);
|
||||||
|
|
||||||
const ResolutionCap dpi150("150dpi", false, 150, 150);
|
const ResolutionCap dpi150("150dpi", false, 0, 150, 150);
|
||||||
const ResolutionCap dpi300("300dpi", true, 300, 300);
|
const ResolutionCap dpi300("300dpi", true, 1, 300, 300);
|
||||||
const ResolutionCap dpi600("600dpi", false, 600, 600);
|
const ResolutionCap dpi600("600dpi", false, 2, 600, 600);
|
||||||
const ResolutionCap dpi1200("1200dpi", false, 1200, 1200);
|
const ResolutionCap dpi1200("1200dpi", false, 3, 1200, 1200);
|
||||||
|
|
||||||
const PrintStyleCap simplex("Simplex", true, JobData::kSimplex);
|
const PrintStyleCap simplex("Simplex", true, JobData::kSimplex);
|
||||||
const PrintStyleCap duplex("Duplex", false, JobData::kDuplex);
|
const PrintStyleCap duplex("Duplex", false, JobData::kDuplex);
|
||||||
|
|||||||
@@ -68,9 +68,9 @@ const PaperCap legal(
|
|||||||
|
|
||||||
const PaperSourceCap autobin("Auto", true, JobData::kAuto);
|
const PaperSourceCap autobin("Auto", true, JobData::kAuto);
|
||||||
|
|
||||||
const ResolutionCap dpi300("300dpi", true, 300, 300);
|
const ResolutionCap dpi300("300dpi", true, 0, 300, 300);
|
||||||
const ResolutionCap dpi600("600dpi", false, 600, 600);
|
const ResolutionCap dpi600("600dpi", false, 1, 600, 600);
|
||||||
const ResolutionCap dpi1200("1200dpi", false, 1200, 1200);
|
const ResolutionCap dpi1200("1200dpi", false, 2, 1200, 1200);
|
||||||
|
|
||||||
const PaperCap* papers[] = {
|
const PaperCap* papers[] = {
|
||||||
&a4,
|
&a4,
|
||||||
|
|||||||
@@ -56,6 +56,8 @@ struct NupCap : public BaseCap {
|
|||||||
fNup(nup)
|
fNup(nup)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
int ID() const { return fNup; }
|
||||||
|
|
||||||
int fNup;
|
int fNup;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -68,6 +70,8 @@ struct DitherCap : public BaseCap {
|
|||||||
fDitherType(ditherType)
|
fDitherType(ditherType)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
int ID() const { return fDitherType; }
|
||||||
|
|
||||||
Halftone::DitherType fDitherType;
|
Halftone::DitherType fDitherType;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -90,7 +94,7 @@ static const DitherCap gDitherFloydSteinberg("Floyd-Steinberg", false,
|
|||||||
Halftone::kTypeFloydSteinberg);
|
Halftone::kTypeFloydSteinberg);
|
||||||
|
|
||||||
|
|
||||||
const NupCap *gNups[] = {
|
const BaseCap *gNups[] = {
|
||||||
&gNup1,
|
&gNup1,
|
||||||
&gNup2,
|
&gNup2,
|
||||||
&gNup4,
|
&gNup4,
|
||||||
@@ -103,7 +107,7 @@ const NupCap *gNups[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const DitherCap *gDitherTypes[] = {
|
const BaseCap *gDitherTypes[] = {
|
||||||
&gDitherType1,
|
&gDitherType1,
|
||||||
&gDitherType2,
|
&gDitherType2,
|
||||||
&gDitherType3,
|
&gDitherType3,
|
||||||
@@ -121,6 +125,7 @@ enum {
|
|||||||
kMsgCollateChanged,
|
kMsgCollateChanged,
|
||||||
kMsgReverseChanged,
|
kMsgReverseChanged,
|
||||||
kMsgDuplexChanged,
|
kMsgDuplexChanged,
|
||||||
|
kMsgNone = 0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -172,48 +177,16 @@ JobSetupView::AttachedToWindow()
|
|||||||
// color
|
// color
|
||||||
fColorType = new BPopUpMenu("color");
|
fColorType = new BPopUpMenu("color");
|
||||||
fColorType->SetRadioMode(true);
|
fColorType->SetRadioMode(true);
|
||||||
|
FillCapabilityMenu(fColorType, kMsgQuality, PrinterCap::kColor,
|
||||||
int count = fPrinterCap->countCap(PrinterCap::kColor);
|
fJobData->getColor());
|
||||||
const ColorCap **color_cap = (const ColorCap **)fPrinterCap->enumCap(
|
|
||||||
PrinterCap::kColor);
|
|
||||||
bool marked = false;
|
|
||||||
BMenuItem* item = NULL;
|
|
||||||
while (count--) {
|
|
||||||
item = new BMenuItem((*color_cap)->fLabel.c_str(),
|
|
||||||
new BMessage(kMsgQuality));
|
|
||||||
fColorType->AddItem(item);
|
|
||||||
if ((*color_cap)->fColor == fJobData->getColor()) {
|
|
||||||
item->SetMarked(true);
|
|
||||||
marked = true;
|
|
||||||
}
|
|
||||||
color_cap++;
|
|
||||||
}
|
|
||||||
if (!marked && item)
|
|
||||||
item->SetMarked(true);
|
|
||||||
|
|
||||||
BMenuField* colorMenuField = new BMenuField("color", "Color:", fColorType);
|
BMenuField* colorMenuField = new BMenuField("color", "Color:", fColorType);
|
||||||
fColorType->SetTargetForItems(this);
|
fColorType->SetTargetForItems(this);
|
||||||
|
|
||||||
// dither type
|
// dither type
|
||||||
fDitherType = new BPopUpMenu("");
|
fDitherType = new BPopUpMenu("");
|
||||||
fDitherType->SetRadioMode(true);
|
fDitherType->SetRadioMode(true);
|
||||||
|
FillCapabilityMenu(fDitherType, kMsgQuality, gDitherTypes, sizeof(gDitherTypes) /
|
||||||
count = sizeof(gDitherTypes) / sizeof(gDitherTypes[0]);
|
sizeof(gDitherTypes[0]), fJobData->getDitherType());
|
||||||
const DitherCap **dither_cap = gDitherTypes;
|
|
||||||
marked = false;
|
|
||||||
item = NULL;
|
|
||||||
while (count--) {
|
|
||||||
item = new BMenuItem((*dither_cap)->fLabel.c_str(),
|
|
||||||
new BMessage(kMsgQuality));
|
|
||||||
fDitherType->AddItem(item);
|
|
||||||
if ((*dither_cap)->fDitherType == fJobData->getDitherType()) {
|
|
||||||
item->SetMarked(true);
|
|
||||||
marked = true;
|
|
||||||
}
|
|
||||||
dither_cap++;
|
|
||||||
}
|
|
||||||
if (!marked && item)
|
|
||||||
item->SetMarked(true);
|
|
||||||
BMenuField* ditherMenuField = new BMenuField("dithering", "Dot Pattern:",
|
BMenuField* ditherMenuField = new BMenuField("dithering", "Dot Pattern:",
|
||||||
fDitherType);
|
fDitherType);
|
||||||
fDitherType->SetTargetForItems(this);
|
fDitherType->SetTargetForItems(this);
|
||||||
@@ -297,43 +270,16 @@ JobSetupView::AttachedToWindow()
|
|||||||
// paper source
|
// paper source
|
||||||
fPaperFeed = new BPopUpMenu("");
|
fPaperFeed = new BPopUpMenu("");
|
||||||
fPaperFeed->SetRadioMode(true);
|
fPaperFeed->SetRadioMode(true);
|
||||||
count = fPrinterCap->countCap(PrinterCap::kPaperSource);
|
FillCapabilityMenu(fPaperFeed, kMsgNone, PrinterCap::kPaperSource,
|
||||||
const PaperSourceCap **paper_source_cap =
|
fJobData->getPaperSource());
|
||||||
(const PaperSourceCap **)fPrinterCap->enumCap(PrinterCap::kPaperSource);
|
|
||||||
marked = false;
|
|
||||||
item = NULL;
|
|
||||||
while (count--) {
|
|
||||||
item = new BMenuItem((*paper_source_cap)->fLabel.c_str(), NULL);
|
|
||||||
fPaperFeed->AddItem(item);
|
|
||||||
if ((*paper_source_cap)->fPaperSource == fJobData->getPaperSource()) {
|
|
||||||
item->SetMarked(true);
|
|
||||||
marked = true;
|
|
||||||
}
|
|
||||||
paper_source_cap++;
|
|
||||||
}
|
|
||||||
if (!marked)
|
|
||||||
item->SetMarked(true);
|
|
||||||
BMenuField* paperSourceMenufield = new BMenuField("paperSource",
|
BMenuField* paperSourceMenufield = new BMenuField("paperSource",
|
||||||
"Paper Source:", fPaperFeed);
|
"Paper Source:", fPaperFeed);
|
||||||
|
|
||||||
// Pages per sheet
|
// Pages per sheet
|
||||||
fNup = new BPopUpMenu("");
|
fNup = new BPopUpMenu("");
|
||||||
fNup->SetRadioMode(true);
|
fNup->SetRadioMode(true);
|
||||||
count = sizeof(gNups) / sizeof(gNups[0]);
|
FillCapabilityMenu(fNup, kMsgNone, gNups, sizeof(gNups) / sizeof(gNups[0]),
|
||||||
const NupCap **nup_cap = gNups;
|
fJobData->getNup());
|
||||||
marked = false;
|
|
||||||
item = NULL;
|
|
||||||
while (count--) {
|
|
||||||
item = new BMenuItem((*nup_cap)->fLabel.c_str(), NULL);
|
|
||||||
fNup->AddItem(item);
|
|
||||||
if ((*nup_cap)->fNup == fJobData->getNup()) {
|
|
||||||
item->SetMarked(true);
|
|
||||||
marked = true;
|
|
||||||
}
|
|
||||||
nup_cap++;
|
|
||||||
}
|
|
||||||
if (!marked)
|
|
||||||
item->SetMarked(true);
|
|
||||||
BMenuField* pagesPerSheet = new BMenuField("pagesPerSheet",
|
BMenuField* pagesPerSheet = new BMenuField("pagesPerSheet",
|
||||||
"Pages Per Sheet:", fNup);
|
"Pages Per Sheet:", fNup);
|
||||||
|
|
||||||
@@ -504,6 +450,72 @@ JobSetupView::AttachedToWindow()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
JobSetupView::FillCapabilityMenu(BPopUpMenu* menu, uint32 message,
|
||||||
|
PrinterCap::CapID category, int id)
|
||||||
|
{
|
||||||
|
int count = fPrinterCap->countCap(category);
|
||||||
|
const BaseCap **capabilities = fPrinterCap->enumCap(category);
|
||||||
|
FillCapabilityMenu(menu, message, capabilities, count, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
JobSetupView::FillCapabilityMenu(BPopUpMenu* menu, uint32 message,
|
||||||
|
const BaseCap** capabilities, int count, int id)
|
||||||
|
{
|
||||||
|
bool marked = false;
|
||||||
|
|
||||||
|
BMenuItem* firstItem = NULL;
|
||||||
|
BMenuItem* defaultItem = NULL;
|
||||||
|
BMenuItem* item = NULL;
|
||||||
|
while (count--) {
|
||||||
|
const BaseCap* capability = *capabilities;
|
||||||
|
if (message != kMsgNone)
|
||||||
|
item = new BMenuItem(capability->fLabel.c_str(),
|
||||||
|
new BMessage(kMsgQuality));
|
||||||
|
else
|
||||||
|
item = new BMenuItem(capability->fLabel.c_str(), NULL);
|
||||||
|
|
||||||
|
menu->AddItem(item);
|
||||||
|
|
||||||
|
if (firstItem == NULL)
|
||||||
|
firstItem = item;
|
||||||
|
|
||||||
|
if (capability->fIsDefault)
|
||||||
|
defaultItem = item;
|
||||||
|
|
||||||
|
|
||||||
|
if (capability->ID() == id) {
|
||||||
|
item->SetMarked(true);
|
||||||
|
marked = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
capabilities++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (marked)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (defaultItem != NULL)
|
||||||
|
defaultItem->SetMarked(true);
|
||||||
|
else if (firstItem != NULL)
|
||||||
|
firstItem->SetMarked(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
JobSetupView::GetID(const BaseCap** capabilities, int count, const char* label,
|
||||||
|
int defaultValue)
|
||||||
|
{
|
||||||
|
while (count--) {
|
||||||
|
const BaseCap* capability = *capabilities;
|
||||||
|
if (capability->fLabel == label)
|
||||||
|
return capability->ID();
|
||||||
|
}
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
JobSetupView::UpdateButtonEnabledState()
|
JobSetupView::UpdateButtonEnabledState()
|
||||||
{
|
{
|
||||||
@@ -530,7 +542,8 @@ JobSetupView::MessageReceived(BMessage *msg)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case kMsgQuality:
|
case kMsgQuality:
|
||||||
fHalftone->preview(getGamma(), getInkDensity(), getDitherType(), getColor() != JobData::kMonochrome);
|
fHalftone->preview(Gamma(), InkDensity(), DitherType(),
|
||||||
|
Color() != JobData::kMonochrome);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case kMsgCollateChanged:
|
case kMsgCollateChanged:
|
||||||
@@ -545,38 +558,29 @@ JobSetupView::MessageReceived(BMessage *msg)
|
|||||||
|
|
||||||
|
|
||||||
JobData::Color
|
JobData::Color
|
||||||
JobSetupView::getColor()
|
JobSetupView::Color()
|
||||||
{
|
{
|
||||||
int count = fPrinterCap->countCap(PrinterCap::kColor);
|
const char *label = fColorType->FindMarked()->Label();
|
||||||
const ColorCap **color_cap = (const ColorCap**)fPrinterCap->enumCap(PrinterCap::kColor);
|
const BaseCap* capability = fPrinterCap->findCap(PrinterCap::kColor, label);
|
||||||
const char *color_label = fColorType->FindMarked()->Label();
|
if (capability == NULL)
|
||||||
while (count--) {
|
return JobData::kMonochrome;
|
||||||
if (!strcmp((*color_cap)->fLabel.c_str(), color_label)) {
|
|
||||||
return (*color_cap)->fColor;
|
const ColorCap* colorCap = static_cast<const ColorCap*>(capability);
|
||||||
}
|
return colorCap->fColor;
|
||||||
color_cap++;
|
|
||||||
}
|
|
||||||
return JobData::kMonochrome;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Halftone::DitherType
|
Halftone::DitherType
|
||||||
JobSetupView::getDitherType()
|
JobSetupView::DitherType()
|
||||||
{
|
{
|
||||||
int count = sizeof(gDitherTypes) / sizeof(gDitherTypes[0]);
|
const char *label = fDitherType->FindMarked()->Label();
|
||||||
const DitherCap **dither_cap = gDitherTypes;
|
int id = GetID(gDitherTypes, sizeof(gDitherTypes) / sizeof(gDitherTypes[0]),
|
||||||
const char *dithering_label = fDitherType->FindMarked()->Label();
|
label, Halftone::kTypeFloydSteinberg);
|
||||||
while (count --) {
|
return static_cast<Halftone::DitherType>(id);
|
||||||
if (strcmp((*dither_cap)->fLabel.c_str(), dithering_label) == 0) {
|
|
||||||
return (*dither_cap)->fDitherType;
|
|
||||||
}
|
|
||||||
dither_cap ++;
|
|
||||||
}
|
|
||||||
return Halftone::kTypeFloydSteinberg;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float
|
float
|
||||||
JobSetupView::getGamma()
|
JobSetupView::Gamma()
|
||||||
{
|
{
|
||||||
const float value = (float)fGamma->Value();
|
const float value = (float)fGamma->Value();
|
||||||
return pow(2.0, value / 100.0);
|
return pow(2.0, value / 100.0);
|
||||||
@@ -584,23 +588,34 @@ JobSetupView::getGamma()
|
|||||||
|
|
||||||
|
|
||||||
float
|
float
|
||||||
JobSetupView::getInkDensity()
|
JobSetupView::InkDensity()
|
||||||
{
|
{
|
||||||
const float value = (float)(127 - fInkDensity->Value());
|
const float value = (float)(127 - fInkDensity->Value());
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
JobData::PaperSource
|
||||||
|
JobSetupView::PaperSource()
|
||||||
|
{
|
||||||
|
const char *label = fPaperFeed->FindMarked()->Label();
|
||||||
|
const BaseCap* capability = fPrinterCap->findCap(PrinterCap::kPaperSource,
|
||||||
|
label);
|
||||||
|
|
||||||
|
if (capability == NULL)
|
||||||
|
capability = fPrinterCap->getDefaultCap(PrinterCap::kPaperSource);
|
||||||
|
return static_cast<const PaperSourceCap*>(capability)->fPaperSource;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
JobSetupView::UpdateJobData(bool showPreview)
|
JobSetupView::UpdateJobData(bool showPreview)
|
||||||
{
|
{
|
||||||
int count;
|
|
||||||
|
|
||||||
fJobData->setShowPreview(showPreview);
|
fJobData->setShowPreview(showPreview);
|
||||||
fJobData->setColor(getColor());
|
fJobData->setColor(Color());
|
||||||
fJobData->setGamma(getGamma());
|
fJobData->setGamma(Gamma());
|
||||||
fJobData->setInkDensity(getInkDensity());
|
fJobData->setInkDensity(InkDensity());
|
||||||
fJobData->setDitherType(getDitherType());
|
fJobData->setDitherType(DitherType());
|
||||||
|
|
||||||
int first_page;
|
int first_page;
|
||||||
int last_page;
|
int last_page;
|
||||||
@@ -616,30 +631,14 @@ JobSetupView::UpdateJobData(bool showPreview)
|
|||||||
fJobData->setFirstPage(first_page);
|
fJobData->setFirstPage(first_page);
|
||||||
fJobData->setLastPage(last_page);
|
fJobData->setLastPage(last_page);
|
||||||
|
|
||||||
count = fPrinterCap->countCap(PrinterCap::kPaperSource);
|
fJobData->setPaperSource(PaperSource());
|
||||||
const PaperSourceCap **paper_source_cap = (const PaperSourceCap **)fPrinterCap->enumCap(PrinterCap::kPaperSource);
|
|
||||||
const char *paper_source_label = fPaperFeed->FindMarked()->Label();
|
|
||||||
while (count--) {
|
|
||||||
if (!strcmp((*paper_source_cap)->fLabel.c_str(), paper_source_label)) {
|
|
||||||
fJobData->setPaperSource((*paper_source_cap)->fPaperSource);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
paper_source_cap++;
|
|
||||||
}
|
|
||||||
|
|
||||||
count = sizeof(gNups) / sizeof(gNups[0]);
|
fJobData->setNup(GetID(gNups, sizeof(gNups) / sizeof(gNups[0]),
|
||||||
const NupCap **nup_cap = gNups;
|
fNup->FindMarked()->Label(), 1));
|
||||||
const char *nup_label = fNup->FindMarked()->Label();
|
|
||||||
while (count--) {
|
|
||||||
if (!strcmp((*nup_cap)->fLabel.c_str(), nup_label)) {
|
|
||||||
fJobData->setNup((*nup_cap)->fNup);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
nup_cap++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fPrinterCap->isSupport(PrinterCap::kPrintStyle)) {
|
if (fPrinterCap->isSupport(PrinterCap::kPrintStyle)) {
|
||||||
fJobData->setPrintStyle((B_CONTROL_ON == fDuplex->Value()) ? JobData::kDuplex : JobData::kSimplex);
|
fJobData->setPrintStyle((B_CONTROL_ON == fDuplex->Value())
|
||||||
|
? JobData::kDuplex : JobData::kSimplex);
|
||||||
}
|
}
|
||||||
|
|
||||||
fJobData->setCopies(atoi(fCopies->Text()));
|
fJobData->setCopies(atoi(fCopies->Text()));
|
||||||
|
|||||||
@@ -14,6 +14,11 @@ BaseCap::BaseCap(const string &label, bool isDefault)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BaseCap::~BaseCap()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
PaperCap::PaperCap(const string &label, bool isDefault, JobData::Paper paper,
|
PaperCap::PaperCap(const string &label, bool isDefault, JobData::Paper paper,
|
||||||
const BRect &paperRect, const BRect &physicalRect)
|
const BRect &paperRect, const BRect &physicalRect)
|
||||||
:
|
:
|
||||||
@@ -25,6 +30,13 @@ PaperCap::PaperCap(const string &label, bool isDefault, JobData::Paper paper,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
PaperCap::ID() const
|
||||||
|
{
|
||||||
|
return fPaper;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
PaperSourceCap::PaperSourceCap(const string &label, bool isDefault,
|
PaperSourceCap::PaperSourceCap(const string &label, bool isDefault,
|
||||||
JobData::PaperSource paperSource)
|
JobData::PaperSource paperSource)
|
||||||
:
|
:
|
||||||
@@ -34,16 +46,31 @@ PaperSourceCap::PaperSourceCap(const string &label, bool isDefault,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
PaperSourceCap::ID() const
|
||||||
|
{
|
||||||
|
return fPaperSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ResolutionCap::ResolutionCap(const string &label, bool isDefault,
|
ResolutionCap::ResolutionCap(const string &label, bool isDefault,
|
||||||
int xResolution, int yResolution)
|
int id, int xResolution, int yResolution)
|
||||||
:
|
:
|
||||||
BaseCap(label, isDefault),
|
BaseCap(label, isDefault),
|
||||||
|
fID(id),
|
||||||
fXResolution(xResolution),
|
fXResolution(xResolution),
|
||||||
fYResolution(yResolution)
|
fYResolution(yResolution)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
ResolutionCap::ID() const
|
||||||
|
{
|
||||||
|
return fID;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
OrientationCap::OrientationCap(const string &label, bool isDefault,
|
OrientationCap::OrientationCap(const string &label, bool isDefault,
|
||||||
JobData::Orientation orientation)
|
JobData::Orientation orientation)
|
||||||
:
|
:
|
||||||
@@ -53,6 +80,13 @@ OrientationCap::OrientationCap(const string &label, bool isDefault,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
OrientationCap::ID() const
|
||||||
|
{
|
||||||
|
return fOrientation;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
PrintStyleCap::PrintStyleCap(const string &label, bool isDefault,
|
PrintStyleCap::PrintStyleCap(const string &label, bool isDefault,
|
||||||
JobData::PrintStyle printStyle)
|
JobData::PrintStyle printStyle)
|
||||||
:
|
:
|
||||||
@@ -62,6 +96,13 @@ PrintStyleCap::PrintStyleCap(const string &label, bool isDefault,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
PrintStyleCap::ID() const
|
||||||
|
{
|
||||||
|
return fPrintStyle;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
BindingLocationCap::BindingLocationCap(const string &label, bool isDefault,
|
BindingLocationCap::BindingLocationCap(const string &label, bool isDefault,
|
||||||
JobData::BindingLocation bindingLocation)
|
JobData::BindingLocation bindingLocation)
|
||||||
:
|
:
|
||||||
@@ -71,6 +112,13 @@ BindingLocationCap::BindingLocationCap(const string &label, bool isDefault,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
BindingLocationCap::ID() const
|
||||||
|
{
|
||||||
|
return fBindingLocation;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ColorCap::ColorCap(const string &label, bool isDefault, JobData::Color color)
|
ColorCap::ColorCap(const string &label, bool isDefault, JobData::Color color)
|
||||||
:
|
:
|
||||||
BaseCap(label, isDefault),
|
BaseCap(label, isDefault),
|
||||||
@@ -79,6 +127,13 @@ ColorCap::ColorCap(const string &label, bool isDefault, JobData::Color color)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
ColorCap::ID() const
|
||||||
|
{
|
||||||
|
return fColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
ProtocolClassCap::ProtocolClassCap(const string &label, bool isDefault,
|
ProtocolClassCap::ProtocolClassCap(const string &label, bool isDefault,
|
||||||
int protocolClass, const string &description)
|
int protocolClass, const string &description)
|
||||||
:
|
:
|
||||||
@@ -89,6 +144,13 @@ ProtocolClassCap::ProtocolClassCap(const string &label, bool isDefault,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
ProtocolClassCap::ID() const
|
||||||
|
{
|
||||||
|
return fProtocolClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
PrinterCap::PrinterCap(const PrinterData *printer_data)
|
PrinterCap::PrinterCap(const PrinterData *printer_data)
|
||||||
: fPrinterData(printer_data),
|
: fPrinterData(printer_data),
|
||||||
fPrinterID(kUnknownPrinter)
|
fPrinterID(kUnknownPrinter)
|
||||||
@@ -101,22 +163,61 @@ PrinterCap::~PrinterCap()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const BaseCap *PrinterCap::getDefaultCap(CapID id) const
|
const BaseCap *
|
||||||
|
PrinterCap::getDefaultCap(CapID category) const
|
||||||
{
|
{
|
||||||
int count = countCap(id);
|
int count = countCap(category);
|
||||||
if (count > 0) {
|
if (count <= 0)
|
||||||
const BaseCap **base_cap = enumCap(id);
|
return NULL;
|
||||||
while (count--) {
|
|
||||||
if ((*base_cap)->fIsDefault) {
|
const BaseCap **base_cap = enumCap(category);
|
||||||
return *base_cap;
|
while (count--) {
|
||||||
}
|
if ((*base_cap)->fIsDefault) {
|
||||||
base_cap++;
|
return *base_cap;
|
||||||
}
|
}
|
||||||
|
base_cap++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return enumCap(category)[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const BaseCap*
|
||||||
|
PrinterCap::findCap(CapID category, int id) const
|
||||||
|
{
|
||||||
|
int count = countCap(category);
|
||||||
|
if (count <= 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
const BaseCap **base_cap = enumCap(category);
|
||||||
|
while (count--) {
|
||||||
|
if ((*base_cap)->ID() == id) {
|
||||||
|
return *base_cap;
|
||||||
|
}
|
||||||
|
base_cap++;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const BaseCap*
|
||||||
|
PrinterCap::findCap(CapID category, const char* label) const
|
||||||
|
{
|
||||||
|
int count = countCap(category);
|
||||||
|
if (count <= 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
const BaseCap **base_cap = enumCap(category);
|
||||||
|
while (count--) {
|
||||||
|
if ((*base_cap)->fLabel == label) {
|
||||||
|
return *base_cap;
|
||||||
|
}
|
||||||
|
base_cap++;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
PrinterCap::getProtocolClass() const {
|
PrinterCap::getProtocolClass() const {
|
||||||
return fPrinterData->getProtocolClass();
|
return fPrinterData->getProtocolClass();
|
||||||
|
|||||||
Reference in New Issue
Block a user