* Enable halftone configuration options if requested by printer driver

only.
* WIP: Driver specific generic capabilities.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39153 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Pfeiffer 2010-10-26 09:48:36 +00:00
parent 2ca94d9be9
commit 308f0e195d
9 changed files with 179 additions and 63 deletions

View File

@ -35,6 +35,8 @@ public:
private:
void UpdateButtonEnabledState();
bool IsHalftoneConfigurationNeeded();
void CreateHalftoneConfigurationUI();
void FillCapabilityMenu(BPopUpMenu* menu, uint32 message,
PrinterCap::CapID category, int id);
void FillCapabilityMenu(BPopUpMenu* menu, uint32 message,
@ -44,6 +46,7 @@ private:
BRadioButton* CreatePageSelectionItem(const char* name, const char* label,
JobData::PageSelection pageSelection);
void AllowOnlyDigits(BTextView* textView, int maxDigits);
void UpdateHalftonePreview();
JobData::Color Color();
Halftone::DitherType DitherType();
float Gamma();
@ -58,9 +61,11 @@ private:
const PrinterCap *fPrinterCap;
BPopUpMenu *fColorType;
BPopUpMenu *fDitherType;
BMenuField *fDitherMenuField;
JSDSlider *fGamma;
JSDSlider *fInkDensity;
HalftoneView *fHalftone;
BBox *fHalftoneBox;
BRadioButton *fAll;
BCheckBox *fCollate;
BCheckBox *fReverse;

View File

@ -21,6 +21,7 @@ struct BaseCap {
virtual ~BaseCap();
virtual int ID() const = 0;
const char* Key() const;
string fLabel;
bool fIsDefault;
@ -108,6 +109,23 @@ struct ProtocolClassCap : public BaseCap {
};
struct DriverSpecificCap : public BaseCap {
enum Type {
kList,
kCheckBox,
kRange
};
DriverSpecificCap(const string& label,
bool isDefault, int category, Type type);
int ID() const;
int fCategory;
Type fType;
};
class PrinterData;
class PrinterCap {
@ -124,9 +142,16 @@ public:
kBindingLocation,
kColor,
kProtocolClass,
kDriverSpecifcCapababilities,
// Static boolean settings follow.
// For them isSupport() has to be implemented only.
kCopyCommand, // supports printer page copy command?
kCopyCommand, // supports printer page copy command?
kHalftone, // needs the printer driver the configuration
// for class Halftone?
// The driver specific generic capabilities start here
kDriverSpecificCapabablitiesBegin = 100
};
virtual int countCap(CapID category) const = 0;

View File

@ -155,6 +155,7 @@ Lips3Cap::isSupport(CapID capid) const
case kResolution:
case kColor:
case kCopyCommand:
case kHalftone:
return true;
default:
return false;

View File

@ -220,6 +220,7 @@ Lips4Cap::isSupport(CapID capid) const
case kBindingLocation:
case kColor:
case kCopyCommand:
case kHalftone:
return true;
default:
return false;

View File

@ -152,6 +152,7 @@ PCL5Cap::isSupport(CapID capid) const
case kPaperSource:
case kResolution:
case kColor:
case kHalftone:
return true;
default:
return false;

View File

@ -335,6 +335,7 @@ PCL6Cap::isSupport(CapID capid) const
case kCopyCommand:
case kPrintStyle:
case kProtocolClass:
case kHalftone:
return true;
default:
return false;

View File

@ -151,6 +151,7 @@ PSCap::isSupport(CapID capid) const
case kPaperSource:
case kResolution:
case kColor:
case kHalftone:
return true;
default:
return false;

View File

@ -133,9 +133,27 @@ JobSetupView::JobSetupView(JobData *job_data, PrinterData *printer_data,
const PrinterCap *printer_cap)
:
BView("jobSetup", B_WILL_DRAW),
fCopies(NULL),
fFromPage(NULL),
fToPage(NULL),
fJobData(job_data),
fPrinterData(printer_data),
fPrinterCap(printer_cap)
fPrinterCap(printer_cap),
fColorType(NULL),
fDitherType(NULL),
fGamma(NULL),
fInkDensity(NULL),
fHalftone(NULL),
fAll(NULL),
fCollate(NULL),
fReverse(NULL),
fPages(NULL),
fPaperFeed(NULL),
fDuplex(NULL),
fNup(NULL),
fAllPages(NULL),
fOddNumberedPages(NULL),
fEvenNumberedPages(NULL)
{
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
}
@ -182,48 +200,8 @@ JobSetupView::AttachedToWindow()
BMenuField* colorMenuField = new BMenuField("color", "Color:", fColorType);
fColorType->SetTargetForItems(this);
// dither type
fDitherType = new BPopUpMenu("");
fDitherType->SetRadioMode(true);
FillCapabilityMenu(fDitherType, kMsgQuality, gDitherTypes, sizeof(gDitherTypes) /
sizeof(gDitherTypes[0]), fJobData->getDitherType());
BMenuField* ditherMenuField = new BMenuField("dithering", "Dot Pattern:",
fDitherType);
fDitherType->SetTargetForItems(this);
// halftone preview view
BBox* halftoneBox = new BBox("halftoneBox");
halftoneBox->SetBorder(B_PLAIN_BORDER);
// TODO make layout compatible
BSize size(240, 14 * 4);
BRect rect(0, 0, size.width, size.height);
fHalftone = new HalftoneView(rect, "halftone",
B_FOLLOW_ALL, B_WILL_DRAW);
fHalftone->SetExplicitMinSize(size);
fHalftone->SetExplicitMaxSize(size);
// gamma
fGamma = new JSDSlider("gamma", "Gamma", new BMessage(kMsgQuality),
-300, 300);
fGamma->SetLimitLabels("Lighter", "Darker");
fGamma->SetValue((int32)(100 * log(fJobData->getGamma()) / log(2.0)));
fGamma->SetHashMarks(B_HASH_MARKS_BOTH);
fGamma->SetHashMarkCount(7);
fGamma->SetModificationMessage(new BMessage(kMsgQuality));
fGamma->SetTarget(this);
// ink density
fInkDensity = new JSDSlider("inkDensity", "Ink Usage",
new BMessage(kMsgQuality), 0, 127);
fInkDensity->SetLimitLabels("Min", "Max");
fInkDensity->SetValue((int32)fJobData->getInkDensity());
fInkDensity->SetHashMarks(B_HASH_MARKS_BOTH);
fInkDensity->SetHashMarkCount(10);
fInkDensity->SetModificationMessage(new BMessage(kMsgQuality));
fInkDensity->SetTarget(this);
if (IsHalftoneConfigurationNeeded())
CreateHalftoneConfigurationUI();
// page range
@ -351,21 +329,26 @@ JobSetupView::AttachedToWindow()
BButton* ok = new BButton("ok", "OK", new BMessage(kMsgOK));
ok->MakeDefault(true);
BGroupView* halftoneGroup = new BGroupView(B_VERTICAL, 0);
BGroupLayout* halftoneLayout = halftoneGroup->GroupLayout();
halftoneLayout->AddView(fHalftone);
halftoneBox->AddChild(halftoneGroup);
if (IsHalftoneConfigurationNeeded()) {
BGroupView* halftoneGroup = new BGroupView(B_VERTICAL, 0);
BGroupLayout* halftoneLayout = halftoneGroup->GroupLayout();
halftoneLayout->AddView(fHalftone);
fHalftoneBox->AddChild(halftoneGroup);
}
BGridView* qualityGrid = new BGridView();
BGridLayout* qualityGridLayout = qualityGrid->GridLayout();
qualityGridLayout->AddItem(colorMenuField->CreateLabelLayoutItem(), 0, 0);
qualityGridLayout->AddItem(colorMenuField->CreateMenuBarLayoutItem(), 1, 0);
qualityGridLayout->AddItem(ditherMenuField->CreateLabelLayoutItem(), 0, 1);
qualityGridLayout->AddItem(ditherMenuField->CreateMenuBarLayoutItem(), 1,
1);
qualityGridLayout->AddView(fGamma, 0, 2, 2);
qualityGridLayout->AddView(fInkDensity, 0, 3, 2);
qualityGridLayout->AddView(halftoneBox, 0, 4, 2);
if (IsHalftoneConfigurationNeeded()) {
qualityGridLayout->AddItem(fDitherMenuField->CreateLabelLayoutItem(),
0, 1);
qualityGridLayout->AddItem(fDitherMenuField->CreateMenuBarLayoutItem(),
1, 1);
qualityGridLayout->AddView(fGamma, 0, 2, 2);
qualityGridLayout->AddView(fInkDensity, 0, 3, 2);
qualityGridLayout->AddView(fHalftoneBox, 0, 4, 2);
}
qualityGridLayout->SetSpacing(0, 0);
qualityGridLayout->SetInsets(5, 5, 5, 5);
qualityBox->AddChild(qualityGrid);
@ -443,13 +426,75 @@ JobSetupView::AttachedToWindow()
.SetInsets(0, 0, 0, 0)
);
fHalftone->preview(fJobData->getGamma(), fJobData->getInkDensity(),
fJobData->getDitherType(), fJobData->getColor() != JobData::kMonochrome);
/* TODO remove
if (IsHalftoneConfigurationNeeded())
fHalftone->preview(fJobData->getGamma(), fJobData->getInkDensity(),
fJobData->getDitherType(),
fJobData->getColor() != JobData::kMonochrome);
*/
UpdateHalftonePreview();
UpdateButtonEnabledState();
}
bool
JobSetupView::IsHalftoneConfigurationNeeded()
{
return fPrinterCap->isSupport(PrinterCap::kHalftone);
}
void
JobSetupView::CreateHalftoneConfigurationUI()
{
// dither type
fDitherType = new BPopUpMenu("");
fDitherType->SetRadioMode(true);
FillCapabilityMenu(fDitherType, kMsgQuality, gDitherTypes,
sizeof(gDitherTypes) / sizeof(gDitherTypes[0]),
fJobData->getDitherType());
fDitherMenuField = new BMenuField("dithering", "Dot Pattern:",
fDitherType);
fDitherType->SetTargetForItems(this);
// halftone preview view
fHalftoneBox = new BBox("halftoneBox");
fHalftoneBox->SetBorder(B_PLAIN_BORDER);
// TODO make layout compatible
BSize size(240, 14 * 4);
BRect rect(0, 0, size.width, size.height);
fHalftone = new HalftoneView(rect, "halftone",
B_FOLLOW_ALL, B_WILL_DRAW);
fHalftone->SetExplicitMinSize(size);
fHalftone->SetExplicitMaxSize(size);
// gamma
fGamma = new JSDSlider("gamma", "Gamma", new BMessage(kMsgQuality),
-300, 300);
fGamma->SetLimitLabels("Lighter", "Darker");
fGamma->SetValue((int32)(100 * log(fJobData->getGamma()) / log(2.0)));
fGamma->SetHashMarks(B_HASH_MARKS_BOTH);
fGamma->SetHashMarkCount(7);
fGamma->SetModificationMessage(new BMessage(kMsgQuality));
fGamma->SetTarget(this);
// ink density
fInkDensity = new JSDSlider("inkDensity", "Ink Usage",
new BMessage(kMsgQuality), 0, 127);
fInkDensity->SetLimitLabels("Min", "Max");
fInkDensity->SetValue((int32)fJobData->getInkDensity());
fInkDensity->SetHashMarks(B_HASH_MARKS_BOTH);
fInkDensity->SetHashMarkCount(10);
fInkDensity->SetModificationMessage(new BMessage(kMsgQuality));
fInkDensity->SetTarget(this);
}
void
JobSetupView::FillCapabilityMenu(BPopUpMenu* menu, uint32 message,
PrinterCap::CapID category, int id)
@ -472,7 +517,7 @@ JobSetupView::FillCapabilityMenu(BPopUpMenu* menu, uint32 message,
const BaseCap* capability = *capabilities;
if (message != kMsgNone)
item = new BMenuItem(capability->fLabel.c_str(),
new BMessage(kMsgQuality));
new BMessage(message));
else
item = new BMenuItem(capability->fLabel.c_str(), NULL);
@ -542,8 +587,7 @@ JobSetupView::MessageReceived(BMessage *msg)
break;
case kMsgQuality:
fHalftone->preview(Gamma(), InkDensity(), DitherType(),
Color() != JobData::kMonochrome);
UpdateHalftonePreview();
break;
case kMsgCollateChanged:
@ -557,6 +601,17 @@ JobSetupView::MessageReceived(BMessage *msg)
}
void
JobSetupView::UpdateHalftonePreview()
{
if (!IsHalftoneConfigurationNeeded())
return;
fHalftone->preview(Gamma(), InkDensity(), DitherType(),
Color() != JobData::kMonochrome);
}
JobData::Color
JobSetupView::Color()
{
@ -613,9 +668,11 @@ JobSetupView::UpdateJobData(bool showPreview)
{
fJobData->setShowPreview(showPreview);
fJobData->setColor(Color());
fJobData->setGamma(Gamma());
fJobData->setInkDensity(InkDensity());
fJobData->setDitherType(DitherType());
if (IsHalftoneConfigurationNeeded()) {
fJobData->setGamma(Gamma());
fJobData->setInkDensity(InkDensity());
fJobData->setDitherType(DitherType());
}
int first_page;
int last_page;

View File

@ -19,6 +19,13 @@ BaseCap::~BaseCap()
}
const char*
BaseCap::Key() const
{
return fKey.c_str();
}
PaperCap::PaperCap(const string &label, bool isDefault, JobData::Paper paper,
const BRect &paperRect, const BRect &physicalRect)
:
@ -151,6 +158,23 @@ ProtocolClassCap::ID() const
}
DriverSpecificCap::DriverSpecificCap(const string& label, bool isDefault,
int category, Type type)
:
BaseCap(label, isDefault),
fCategory(category),
fType(type)
{
}
int
DriverSpecificCap::ID() const
{
return fCategory;
}
PrinterCap::PrinterCap(const PrinterData *printer_data)
: fPrinterData(printer_data),
fPrinterID(kUnknownPrinter)
@ -163,7 +187,7 @@ PrinterCap::~PrinterCap()
}
const BaseCap *
const BaseCap*
PrinterCap::getDefaultCap(CapID category) const
{
int count = countCap(category);