112fd6cc2SKarsten Heimrich /* 212fd6cc2SKarsten Heimrich * JobSetupDlg.cpp 312fd6cc2SKarsten Heimrich * Copyright 1999-2000 Y.Takagi. All Rights Reserved. 412fd6cc2SKarsten Heimrich */ 512fd6cc2SKarsten Heimrich 612fd6cc2SKarsten Heimrich #include <cstdio> 712fd6cc2SKarsten Heimrich #include <cstring> 812fd6cc2SKarsten Heimrich #include <cstdlib> 912fd6cc2SKarsten Heimrich #include <string> 1012fd6cc2SKarsten Heimrich #include <fcntl.h> 1112fd6cc2SKarsten Heimrich #include <unistd.h> 1212fd6cc2SKarsten Heimrich #include <sys/stat.h> 1312fd6cc2SKarsten Heimrich #include <math.h> 1412fd6cc2SKarsten Heimrich 1512fd6cc2SKarsten Heimrich #include <Alert.h> 1612fd6cc2SKarsten Heimrich #include <Bitmap.h> 1712fd6cc2SKarsten Heimrich #include <Box.h> 1812fd6cc2SKarsten Heimrich #include <Button.h> 1912fd6cc2SKarsten Heimrich #include <CheckBox.h> 205a695bceSMichael Pfeiffer #include <GridView.h> 215a695bceSMichael Pfeiffer #include <GroupLayout.h> 225a695bceSMichael Pfeiffer #include <GroupLayoutBuilder.h> 2312fd6cc2SKarsten Heimrich #include <Looper.h> 2412fd6cc2SKarsten Heimrich #include <MessageFilter.h> 2512fd6cc2SKarsten Heimrich #include <MenuField.h> 2612fd6cc2SKarsten Heimrich #include <MenuItem.h> 2712fd6cc2SKarsten Heimrich #include <Message.h> 2812fd6cc2SKarsten Heimrich #include <Point.h> 2912fd6cc2SKarsten Heimrich #include <PopUpMenu.h> 3012fd6cc2SKarsten Heimrich #include <PrintJob.h> 3112fd6cc2SKarsten Heimrich #include <RadioButton.h> 3212fd6cc2SKarsten Heimrich #include <Rect.h> 3312fd6cc2SKarsten Heimrich #include <Slider.h> 3412fd6cc2SKarsten Heimrich #include <String.h> 3512fd6cc2SKarsten Heimrich #include <TextControl.h> 3612fd6cc2SKarsten Heimrich #include <TextView.h> 3712fd6cc2SKarsten Heimrich #include <View.h> 3812fd6cc2SKarsten Heimrich 3912fd6cc2SKarsten Heimrich #include "HalftoneView.h" 4012fd6cc2SKarsten Heimrich #include "JobSetupDlg.h" 4112fd6cc2SKarsten Heimrich #include "JobData.h" 4212fd6cc2SKarsten Heimrich #include "JSDSlider.h" 4312fd6cc2SKarsten Heimrich #include "PagesView.h" 4412fd6cc2SKarsten Heimrich #include "PrinterData.h" 4512fd6cc2SKarsten Heimrich #include "PrinterCap.h" 4612fd6cc2SKarsten Heimrich #include "DbgMsg.h" 4712fd6cc2SKarsten Heimrich 48a7dde370SMichael Pfeiffer 4912fd6cc2SKarsten Heimrich using namespace std; 5012fd6cc2SKarsten Heimrich 5112fd6cc2SKarsten Heimrich 5212fd6cc2SKarsten Heimrich struct NupCap : public BaseCap { 53a7dde370SMichael Pfeiffer NupCap(const string &label, bool isDefault, int nup) 54a7dde370SMichael Pfeiffer : 55a7dde370SMichael Pfeiffer BaseCap(label, isDefault), 56a7dde370SMichael Pfeiffer fNup(nup) 57a7dde370SMichael Pfeiffer {} 58a7dde370SMichael Pfeiffer 59*f53abcbdSMichael Pfeiffer int ID() const { return fNup; } 60*f53abcbdSMichael Pfeiffer 61a7dde370SMichael Pfeiffer int fNup; 6212fd6cc2SKarsten Heimrich }; 6312fd6cc2SKarsten Heimrich 64a7dde370SMichael Pfeiffer 6512fd6cc2SKarsten Heimrich struct DitherCap : public BaseCap { 66a7dde370SMichael Pfeiffer DitherCap(const string &label, bool isDefault, 67a7dde370SMichael Pfeiffer Halftone::DitherType ditherType) 68a7dde370SMichael Pfeiffer : 69a7dde370SMichael Pfeiffer BaseCap(label, isDefault), 70a7dde370SMichael Pfeiffer fDitherType(ditherType) 71a7dde370SMichael Pfeiffer {} 72a7dde370SMichael Pfeiffer 73*f53abcbdSMichael Pfeiffer int ID() const { return fDitherType; } 74*f53abcbdSMichael Pfeiffer 75a7dde370SMichael Pfeiffer Halftone::DitherType fDitherType; 7612fd6cc2SKarsten Heimrich }; 7712fd6cc2SKarsten Heimrich 7812fd6cc2SKarsten Heimrich 7912fd6cc2SKarsten Heimrich static const NupCap gNup1("1", true, 1); 8012fd6cc2SKarsten Heimrich static const NupCap gNup2("2", false, 2); 8112fd6cc2SKarsten Heimrich static const NupCap gNup4("4", false, 4); 8212fd6cc2SKarsten Heimrich static const NupCap gNup8("8", false, 8); 8312fd6cc2SKarsten Heimrich static const NupCap gNup9("9", false, 9); 8412fd6cc2SKarsten Heimrich static const NupCap gNup16("16", false, 16); 8512fd6cc2SKarsten Heimrich static const NupCap gNup25("25", false, 25); 8612fd6cc2SKarsten Heimrich static const NupCap gNup32("32", false, 32); 8712fd6cc2SKarsten Heimrich static const NupCap gNup36("36", false, 36); 8812fd6cc2SKarsten Heimrich 89a7dde370SMichael Pfeiffer 9012fd6cc2SKarsten Heimrich static const DitherCap gDitherType1("Crosshatch", false, Halftone::kType1); 9112fd6cc2SKarsten Heimrich static const DitherCap gDitherType2("Grid", false, Halftone::kType2); 9212fd6cc2SKarsten Heimrich static const DitherCap gDitherType3("Stipple", false, Halftone::kType3); 93a7dde370SMichael Pfeiffer static const DitherCap gDitherFloydSteinberg("Floyd-Steinberg", false, 94a7dde370SMichael Pfeiffer Halftone::kTypeFloydSteinberg); 9512fd6cc2SKarsten Heimrich 9612fd6cc2SKarsten Heimrich 97*f53abcbdSMichael Pfeiffer const BaseCap *gNups[] = { 9812fd6cc2SKarsten Heimrich &gNup1, 9912fd6cc2SKarsten Heimrich &gNup2, 10012fd6cc2SKarsten Heimrich &gNup4, 10112fd6cc2SKarsten Heimrich &gNup8, 10212fd6cc2SKarsten Heimrich &gNup9, 10312fd6cc2SKarsten Heimrich &gNup16, 10412fd6cc2SKarsten Heimrich &gNup25, 10512fd6cc2SKarsten Heimrich &gNup32, 10612fd6cc2SKarsten Heimrich &gNup36 10712fd6cc2SKarsten Heimrich }; 10812fd6cc2SKarsten Heimrich 109a7dde370SMichael Pfeiffer 110*f53abcbdSMichael Pfeiffer const BaseCap *gDitherTypes[] = { 11112fd6cc2SKarsten Heimrich &gDitherType1, 11212fd6cc2SKarsten Heimrich &gDitherType2, 11312fd6cc2SKarsten Heimrich &gDitherType3, 11412fd6cc2SKarsten Heimrich &gDitherFloydSteinberg 11512fd6cc2SKarsten Heimrich }; 11612fd6cc2SKarsten Heimrich 117a7dde370SMichael Pfeiffer 11812fd6cc2SKarsten Heimrich enum { 11912fd6cc2SKarsten Heimrich kMsgRangeAll = 'JSdl', 12012fd6cc2SKarsten Heimrich kMsgRangeSelection, 12112fd6cc2SKarsten Heimrich kMsgPreview, 12212fd6cc2SKarsten Heimrich kMsgCancel, 12312fd6cc2SKarsten Heimrich kMsgOK, 12412fd6cc2SKarsten Heimrich kMsgQuality, 12512fd6cc2SKarsten Heimrich kMsgCollateChanged, 12612fd6cc2SKarsten Heimrich kMsgReverseChanged, 12712fd6cc2SKarsten Heimrich kMsgDuplexChanged, 128*f53abcbdSMichael Pfeiffer kMsgNone = 0 12912fd6cc2SKarsten Heimrich }; 13012fd6cc2SKarsten Heimrich 131a7dde370SMichael Pfeiffer 1325a695bceSMichael Pfeiffer JobSetupView::JobSetupView(JobData *job_data, PrinterData *printer_data, 1335a695bceSMichael Pfeiffer const PrinterCap *printer_cap) 134a7dde370SMichael Pfeiffer : 135a7dde370SMichael Pfeiffer BView("jobSetup", B_WILL_DRAW), 136a7dde370SMichael Pfeiffer fJobData(job_data), 137a7dde370SMichael Pfeiffer fPrinterData(printer_data), 138a7dde370SMichael Pfeiffer fPrinterCap(printer_cap) 13912fd6cc2SKarsten Heimrich { 14012fd6cc2SKarsten Heimrich SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); 14112fd6cc2SKarsten Heimrich } 14212fd6cc2SKarsten Heimrich 143a7dde370SMichael Pfeiffer 14412fd6cc2SKarsten Heimrich BRadioButton* 1455a695bceSMichael Pfeiffer JobSetupView::CreatePageSelectionItem(const char* name, const char* label, 14612fd6cc2SKarsten Heimrich JobData::PageSelection pageSelection) 14712fd6cc2SKarsten Heimrich { 1485a695bceSMichael Pfeiffer BRadioButton* button = new BRadioButton(name, label, NULL); 14912fd6cc2SKarsten Heimrich if (fJobData->getPageSelection() == pageSelection) { 15012fd6cc2SKarsten Heimrich button->SetValue(B_CONTROL_ON); 15112fd6cc2SKarsten Heimrich } 15212fd6cc2SKarsten Heimrich return button; 15312fd6cc2SKarsten Heimrich } 15412fd6cc2SKarsten Heimrich 155a7dde370SMichael Pfeiffer 15612fd6cc2SKarsten Heimrich void 15712fd6cc2SKarsten Heimrich JobSetupView::AllowOnlyDigits(BTextView* textView, int maxDigits) 15812fd6cc2SKarsten Heimrich { 15912fd6cc2SKarsten Heimrich int num; 16012fd6cc2SKarsten Heimrich for (num = 0; num <= 255; num++) { 16112fd6cc2SKarsten Heimrich textView->DisallowChar(num); 16212fd6cc2SKarsten Heimrich } 16312fd6cc2SKarsten Heimrich for (num = 0; num <= 9; num++) { 16412fd6cc2SKarsten Heimrich textView->AllowChar('0' + num); 16512fd6cc2SKarsten Heimrich } 16612fd6cc2SKarsten Heimrich textView->SetMaxBytes(maxDigits); 16712fd6cc2SKarsten Heimrich } 16812fd6cc2SKarsten Heimrich 169a7dde370SMichael Pfeiffer 17012fd6cc2SKarsten Heimrich void 17112fd6cc2SKarsten Heimrich JobSetupView::AttachedToWindow() 17212fd6cc2SKarsten Heimrich { 1735a695bceSMichael Pfeiffer // quality 1745a695bceSMichael Pfeiffer BBox* qualityBox = new BBox("quality"); 1755a695bceSMichael Pfeiffer qualityBox->SetLabel("Quality"); 17612fd6cc2SKarsten Heimrich 1775a695bceSMichael Pfeiffer // color 1785a695bceSMichael Pfeiffer fColorType = new BPopUpMenu("color"); 17912fd6cc2SKarsten Heimrich fColorType->SetRadioMode(true); 180*f53abcbdSMichael Pfeiffer FillCapabilityMenu(fColorType, kMsgQuality, PrinterCap::kColor, 181*f53abcbdSMichael Pfeiffer fJobData->getColor()); 1825a695bceSMichael Pfeiffer BMenuField* colorMenuField = new BMenuField("color", "Color:", fColorType); 18312fd6cc2SKarsten Heimrich fColorType->SetTargetForItems(this); 18412fd6cc2SKarsten Heimrich 1855a695bceSMichael Pfeiffer // dither type 18612fd6cc2SKarsten Heimrich fDitherType = new BPopUpMenu(""); 18712fd6cc2SKarsten Heimrich fDitherType->SetRadioMode(true); 188*f53abcbdSMichael Pfeiffer FillCapabilityMenu(fDitherType, kMsgQuality, gDitherTypes, sizeof(gDitherTypes) / 189*f53abcbdSMichael Pfeiffer sizeof(gDitherTypes[0]), fJobData->getDitherType()); 1905a695bceSMichael Pfeiffer BMenuField* ditherMenuField = new BMenuField("dithering", "Dot Pattern:", 1915a695bceSMichael Pfeiffer fDitherType); 19212fd6cc2SKarsten Heimrich fDitherType->SetTargetForItems(this); 19312fd6cc2SKarsten Heimrich 1945a695bceSMichael Pfeiffer // halftone preview view 1955a695bceSMichael Pfeiffer BBox* halftoneBox = new BBox("halftoneBox"); 1965a695bceSMichael Pfeiffer halftoneBox->SetBorder(B_PLAIN_BORDER); 19712fd6cc2SKarsten Heimrich 1985a695bceSMichael Pfeiffer // TODO make layout compatible 1995a695bceSMichael Pfeiffer BSize size(240, 14 * 4); 2005a695bceSMichael Pfeiffer BRect rect(0, 0, size.width, size.height); 2015a695bceSMichael Pfeiffer fHalftone = new HalftoneView(rect, "halftone", 2025a695bceSMichael Pfeiffer B_FOLLOW_ALL, B_WILL_DRAW); 2035a695bceSMichael Pfeiffer fHalftone->SetExplicitMinSize(size); 2045a695bceSMichael Pfeiffer fHalftone->SetExplicitMaxSize(size); 20512fd6cc2SKarsten Heimrich 2065a695bceSMichael Pfeiffer // gamma 2075a695bceSMichael Pfeiffer fGamma = new JSDSlider("gamma", "Gamma", new BMessage(kMsgQuality), 2085a695bceSMichael Pfeiffer -300, 300); 20912fd6cc2SKarsten Heimrich 21012fd6cc2SKarsten Heimrich fGamma->SetLimitLabels("Lighter", "Darker"); 21112fd6cc2SKarsten Heimrich fGamma->SetValue((int32)(100 * log(fJobData->getGamma()) / log(2.0))); 21212fd6cc2SKarsten Heimrich fGamma->SetHashMarks(B_HASH_MARKS_BOTH); 21312fd6cc2SKarsten Heimrich fGamma->SetHashMarkCount(7); 21412fd6cc2SKarsten Heimrich fGamma->SetModificationMessage(new BMessage(kMsgQuality)); 21512fd6cc2SKarsten Heimrich fGamma->SetTarget(this); 21612fd6cc2SKarsten Heimrich 2175a695bceSMichael Pfeiffer // ink density 2185a695bceSMichael Pfeiffer fInkDensity = new JSDSlider("inkDensity", "Ink Usage", 2195a695bceSMichael Pfeiffer new BMessage(kMsgQuality), 0, 127); 22012fd6cc2SKarsten Heimrich 22112fd6cc2SKarsten Heimrich fInkDensity->SetLimitLabels("Min", "Max"); 22212fd6cc2SKarsten Heimrich fInkDensity->SetValue((int32)fJobData->getInkDensity()); 22312fd6cc2SKarsten Heimrich fInkDensity->SetHashMarks(B_HASH_MARKS_BOTH); 22412fd6cc2SKarsten Heimrich fInkDensity->SetHashMarkCount(10); 22512fd6cc2SKarsten Heimrich fInkDensity->SetModificationMessage(new BMessage(kMsgQuality)); 22612fd6cc2SKarsten Heimrich fInkDensity->SetTarget(this); 22712fd6cc2SKarsten Heimrich 2285a695bceSMichael Pfeiffer // page range 22912fd6cc2SKarsten Heimrich 2305a695bceSMichael Pfeiffer BBox* pageRangeBox = new BBox("pageRange"); 2315a695bceSMichael Pfeiffer pageRangeBox->SetLabel("Page Range"); 23212fd6cc2SKarsten Heimrich 2335a695bceSMichael Pfeiffer fAll = new BRadioButton("all", "Print all Pages", new BMessage(kMsgRangeAll)); 23412fd6cc2SKarsten Heimrich 2355a695bceSMichael Pfeiffer BRadioButton *range = new BRadioButton("selection", "Print selected Pages:", 2365a695bceSMichael Pfeiffer new BMessage(kMsgRangeSelection)); 23712fd6cc2SKarsten Heimrich 2385a695bceSMichael Pfeiffer fFromPage = new BTextControl("from", "From:", "", NULL); 23912fd6cc2SKarsten Heimrich fFromPage->SetAlignment(B_ALIGN_LEFT, B_ALIGN_RIGHT); 24012fd6cc2SKarsten Heimrich AllowOnlyDigits(fFromPage->TextView(), 6); 24112fd6cc2SKarsten Heimrich 2425a695bceSMichael Pfeiffer fToPage = new BTextControl("to", "To:", "", NULL); 24312fd6cc2SKarsten Heimrich fToPage->SetAlignment(B_ALIGN_LEFT, B_ALIGN_RIGHT); 24412fd6cc2SKarsten Heimrich AllowOnlyDigits(fToPage->TextView(), 6); 24512fd6cc2SKarsten Heimrich 24612fd6cc2SKarsten Heimrich int first_page = fJobData->getFirstPage(); 24712fd6cc2SKarsten Heimrich int last_page = fJobData->getLastPage(); 24812fd6cc2SKarsten Heimrich 24912fd6cc2SKarsten Heimrich if (first_page <= 1 && last_page <= 0) { 25012fd6cc2SKarsten Heimrich fAll->SetValue(B_CONTROL_ON); 25112fd6cc2SKarsten Heimrich } else { 2525a695bceSMichael Pfeiffer range->SetValue(B_CONTROL_ON); 25312fd6cc2SKarsten Heimrich if (first_page < 1) 25412fd6cc2SKarsten Heimrich first_page = 1; 25512fd6cc2SKarsten Heimrich if (first_page > last_page) 25612fd6cc2SKarsten Heimrich last_page = -1; 25712fd6cc2SKarsten Heimrich 25812fd6cc2SKarsten Heimrich BString oss1; 25912fd6cc2SKarsten Heimrich oss1 << first_page; 26012fd6cc2SKarsten Heimrich fFromPage->SetText(oss1.String()); 26112fd6cc2SKarsten Heimrich 26212fd6cc2SKarsten Heimrich BString oss2; 26312fd6cc2SKarsten Heimrich oss2 << last_page; 26412fd6cc2SKarsten Heimrich fToPage->SetText(oss2.String()); 26512fd6cc2SKarsten Heimrich } 26612fd6cc2SKarsten Heimrich 26712fd6cc2SKarsten Heimrich fAll->SetTarget(this); 2685a695bceSMichael Pfeiffer range->SetTarget(this); 26912fd6cc2SKarsten Heimrich 2705a695bceSMichael Pfeiffer // paper source 27112fd6cc2SKarsten Heimrich fPaperFeed = new BPopUpMenu(""); 27212fd6cc2SKarsten Heimrich fPaperFeed->SetRadioMode(true); 273*f53abcbdSMichael Pfeiffer FillCapabilityMenu(fPaperFeed, kMsgNone, PrinterCap::kPaperSource, 274*f53abcbdSMichael Pfeiffer fJobData->getPaperSource()); 2755a695bceSMichael Pfeiffer BMenuField* paperSourceMenufield = new BMenuField("paperSource", 2765a695bceSMichael Pfeiffer "Paper Source:", fPaperFeed); 27712fd6cc2SKarsten Heimrich 2785a695bceSMichael Pfeiffer // Pages per sheet 27912fd6cc2SKarsten Heimrich fNup = new BPopUpMenu(""); 28012fd6cc2SKarsten Heimrich fNup->SetRadioMode(true); 281*f53abcbdSMichael Pfeiffer FillCapabilityMenu(fNup, kMsgNone, gNups, sizeof(gNups) / sizeof(gNups[0]), 282*f53abcbdSMichael Pfeiffer fJobData->getNup()); 2835a695bceSMichael Pfeiffer BMenuField* pagesPerSheet = new BMenuField("pagesPerSheet", 2845a695bceSMichael Pfeiffer "Pages Per Sheet:", fNup); 28512fd6cc2SKarsten Heimrich 2865a695bceSMichael Pfeiffer // duplex 28712fd6cc2SKarsten Heimrich if (fPrinterCap->isSupport(PrinterCap::kPrintStyle)) { 2885a695bceSMichael Pfeiffer fDuplex = new BCheckBox("duplex", "Duplex", 2895a695bceSMichael Pfeiffer new BMessage(kMsgDuplexChanged)); 29012fd6cc2SKarsten Heimrich if (fJobData->getPrintStyle() != JobData::kSimplex) { 29112fd6cc2SKarsten Heimrich fDuplex->SetValue(B_CONTROL_ON); 29212fd6cc2SKarsten Heimrich } 29312fd6cc2SKarsten Heimrich fDuplex->SetTarget(this); 29412fd6cc2SKarsten Heimrich } else { 29512fd6cc2SKarsten Heimrich fDuplex = NULL; 29612fd6cc2SKarsten Heimrich } 29712fd6cc2SKarsten Heimrich 2985a695bceSMichael Pfeiffer // copies 2995a695bceSMichael Pfeiffer fCopies = new BTextControl("copies", "Number of Copies:", "", NULL); 30012fd6cc2SKarsten Heimrich AllowOnlyDigits(fCopies->TextView(), 3); 30112fd6cc2SKarsten Heimrich 3025a695bceSMichael Pfeiffer BString copies; 3035a695bceSMichael Pfeiffer copies << fJobData->getCopies(); 3045a695bceSMichael Pfeiffer fCopies->SetText(copies.String()); 30512fd6cc2SKarsten Heimrich 3065a695bceSMichael Pfeiffer // collate 3075a695bceSMichael Pfeiffer fCollate = new BCheckBox("collate", "Collate", 3085a695bceSMichael Pfeiffer new BMessage(kMsgCollateChanged)); 30912fd6cc2SKarsten Heimrich if (fJobData->getCollate()) { 31012fd6cc2SKarsten Heimrich fCollate->SetValue(B_CONTROL_ON); 31112fd6cc2SKarsten Heimrich } 31212fd6cc2SKarsten Heimrich fCollate->SetTarget(this); 31312fd6cc2SKarsten Heimrich 3145a695bceSMichael Pfeiffer // reverse 3155a695bceSMichael Pfeiffer fReverse = new BCheckBox("reverse", "Reverse Order", 3165a695bceSMichael Pfeiffer new BMessage(kMsgReverseChanged)); 31712fd6cc2SKarsten Heimrich if (fJobData->getReverse()) { 31812fd6cc2SKarsten Heimrich fReverse->SetValue(B_CONTROL_ON); 31912fd6cc2SKarsten Heimrich } 32012fd6cc2SKarsten Heimrich fReverse->SetTarget(this); 32112fd6cc2SKarsten Heimrich 3225a695bceSMichael Pfeiffer // pages view 3235a695bceSMichael Pfeiffer // TODO make layout API compatible 3245a695bceSMichael Pfeiffer fPages = new PagesView(BRect(0, 0, 150, 40), "pages", B_FOLLOW_ALL, 3255a695bceSMichael Pfeiffer B_WILL_DRAW); 32612fd6cc2SKarsten Heimrich fPages->setCollate(fJobData->getCollate()); 32712fd6cc2SKarsten Heimrich fPages->setReverse(fJobData->getReverse()); 3285a695bceSMichael Pfeiffer fPages->SetExplicitMinSize(BSize(150, 40)); 3295a695bceSMichael Pfeiffer fPages->SetExplicitMaxSize(BSize(150, 40)); 33012fd6cc2SKarsten Heimrich 3315a695bceSMichael Pfeiffer // page selection 3325a695bceSMichael Pfeiffer BBox* pageSelectionBox = new BBox("pageSelection"); 33312fd6cc2SKarsten Heimrich pageSelectionBox->SetLabel("Page Selection"); 33412fd6cc2SKarsten Heimrich 3355a695bceSMichael Pfeiffer fAllPages = CreatePageSelectionItem("allPages", "All Pages", 3365a695bceSMichael Pfeiffer JobData::kAllPages); 3375a695bceSMichael Pfeiffer fOddNumberedPages = CreatePageSelectionItem("oddPages", 3385a695bceSMichael Pfeiffer "Odd-Numbered Pages", JobData::kOddNumberedPages); 3395a695bceSMichael Pfeiffer fEvenNumberedPages = CreatePageSelectionItem("evenPages", 3405a695bceSMichael Pfeiffer "Even-Numbered Pages", JobData::kEvenNumberedPages); 3415a695bceSMichael Pfeiffer 3425a695bceSMichael Pfeiffer // separator line 3435a695bceSMichael Pfeiffer BBox *separator = new BBox("separator"); 3445a695bceSMichael Pfeiffer separator->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 1)); 3455a695bceSMichael Pfeiffer 3465a695bceSMichael Pfeiffer // buttons 3475a695bceSMichael Pfeiffer BButton* preview = new BButton("preview", "Preview" B_UTF8_ELLIPSIS, 3485a695bceSMichael Pfeiffer new BMessage(kMsgPreview)); 3495a695bceSMichael Pfeiffer BButton* cancel = new BButton("cancel", "Cancel", 3505a695bceSMichael Pfeiffer new BMessage(kMsgCancel)); 3515a695bceSMichael Pfeiffer BButton* ok = new BButton("ok", "OK", new BMessage(kMsgOK)); 3525a695bceSMichael Pfeiffer ok->MakeDefault(true); 3535a695bceSMichael Pfeiffer 3545a695bceSMichael Pfeiffer BGroupView* halftoneGroup = new BGroupView(B_VERTICAL, 0); 3555a695bceSMichael Pfeiffer BGroupLayout* halftoneLayout = halftoneGroup->GroupLayout(); 3565a695bceSMichael Pfeiffer halftoneLayout->AddView(fHalftone); 3575a695bceSMichael Pfeiffer halftoneBox->AddChild(halftoneGroup); 3585a695bceSMichael Pfeiffer 3595a695bceSMichael Pfeiffer BGridView* qualityGrid = new BGridView(); 3605a695bceSMichael Pfeiffer BGridLayout* qualityGridLayout = qualityGrid->GridLayout(); 3615a695bceSMichael Pfeiffer qualityGridLayout->AddItem(colorMenuField->CreateLabelLayoutItem(), 0, 0); 3625a695bceSMichael Pfeiffer qualityGridLayout->AddItem(colorMenuField->CreateMenuBarLayoutItem(), 1, 0); 3635a695bceSMichael Pfeiffer qualityGridLayout->AddItem(ditherMenuField->CreateLabelLayoutItem(), 0, 1); 3645a695bceSMichael Pfeiffer qualityGridLayout->AddItem(ditherMenuField->CreateMenuBarLayoutItem(), 1, 3655a695bceSMichael Pfeiffer 1); 3665a695bceSMichael Pfeiffer qualityGridLayout->AddView(fGamma, 0, 2, 2); 3675a695bceSMichael Pfeiffer qualityGridLayout->AddView(fInkDensity, 0, 3, 2); 3685a695bceSMichael Pfeiffer qualityGridLayout->AddView(halftoneBox, 0, 4, 2); 3695a695bceSMichael Pfeiffer qualityGridLayout->SetSpacing(0, 0); 3705a695bceSMichael Pfeiffer qualityGridLayout->SetInsets(5, 5, 5, 5); 3715a695bceSMichael Pfeiffer qualityBox->AddChild(qualityGrid); 3725a695bceSMichael Pfeiffer 3735a695bceSMichael Pfeiffer BGridView* pageRangeGrid = new BGridView(); 3745a695bceSMichael Pfeiffer BGridLayout* pageRangeLayout = pageRangeGrid->GridLayout(); 3755a695bceSMichael Pfeiffer pageRangeLayout->AddItem(fFromPage->CreateLabelLayoutItem(), 0, 0); 3765a695bceSMichael Pfeiffer pageRangeLayout->AddItem(fFromPage->CreateTextViewLayoutItem(), 1, 0); 3775a695bceSMichael Pfeiffer pageRangeLayout->AddItem(fToPage->CreateLabelLayoutItem(), 0, 1); 3785a695bceSMichael Pfeiffer pageRangeLayout->AddItem(fToPage->CreateTextViewLayoutItem(), 1, 1); 3795a695bceSMichael Pfeiffer pageRangeLayout->SetInsets(0, 0, 0, 0); 3805a695bceSMichael Pfeiffer pageRangeLayout->SetSpacing(0, 0); 3815a695bceSMichael Pfeiffer 3825a695bceSMichael Pfeiffer BGroupView* pageRangeGroup = new BGroupView(B_VERTICAL, 0); 3835a695bceSMichael Pfeiffer BGroupLayout* pageRangeGroupLayout = pageRangeGroup->GroupLayout(); 3845a695bceSMichael Pfeiffer pageRangeGroupLayout->AddView(fAll); 3855a695bceSMichael Pfeiffer pageRangeGroupLayout->AddView(range); 3865a695bceSMichael Pfeiffer pageRangeGroupLayout->AddView(pageRangeGrid); 3875a695bceSMichael Pfeiffer pageRangeGroupLayout->SetInsets(5, 5, 5, 5); 3885a695bceSMichael Pfeiffer pageRangeBox->AddChild(pageRangeGroup); 3895a695bceSMichael Pfeiffer 3905a695bceSMichael Pfeiffer BGridView* settings = new BGridView(); 3915a695bceSMichael Pfeiffer BGridLayout* settingsLayout = settings->GridLayout(); 3925a695bceSMichael Pfeiffer settingsLayout->AddItem(paperSourceMenufield->CreateLabelLayoutItem(), 0, 3935a695bceSMichael Pfeiffer 0); 3945a695bceSMichael Pfeiffer settingsLayout->AddItem(paperSourceMenufield->CreateMenuBarLayoutItem(), 1, 3955a695bceSMichael Pfeiffer 0); 3965a695bceSMichael Pfeiffer settingsLayout->AddItem(pagesPerSheet->CreateLabelLayoutItem(), 0, 1); 3975a695bceSMichael Pfeiffer settingsLayout->AddItem(pagesPerSheet->CreateMenuBarLayoutItem(), 1, 1); 3985a695bceSMichael Pfeiffer int row = 2; 3995a695bceSMichael Pfeiffer if (fDuplex != NULL) { 4005a695bceSMichael Pfeiffer settingsLayout->AddView(fDuplex, 0, row, 2); 4015a695bceSMichael Pfeiffer row ++; 4025a695bceSMichael Pfeiffer } 4035a695bceSMichael Pfeiffer settingsLayout->AddItem(fCopies->CreateLabelLayoutItem(), 0, row); 4045a695bceSMichael Pfeiffer settingsLayout->AddItem(fCopies->CreateTextViewLayoutItem(), 1, row); 4055a695bceSMichael Pfeiffer settingsLayout->SetSpacing(0, 0); 40612fd6cc2SKarsten Heimrich 40712fd6cc2SKarsten Heimrich 4085a695bceSMichael Pfeiffer BGroupView* pageSelectionGroup = new BGroupView(B_VERTICAL, 0); 4095a695bceSMichael Pfeiffer BGroupLayout* groupLayout = pageSelectionGroup->GroupLayout(); 4105a695bceSMichael Pfeiffer groupLayout->AddView(fAllPages); 4115a695bceSMichael Pfeiffer groupLayout->AddView(fOddNumberedPages); 4125a695bceSMichael Pfeiffer groupLayout->AddView(fEvenNumberedPages); 4135a695bceSMichael Pfeiffer groupLayout->SetInsets(5, 5, 5, 5); 4145a695bceSMichael Pfeiffer pageSelectionBox->AddChild(pageSelectionGroup); 41512fd6cc2SKarsten Heimrich 4165a695bceSMichael Pfeiffer SetLayout(new BGroupLayout(B_VERTICAL)); 4175a695bceSMichael Pfeiffer AddChild(BGroupLayoutBuilder(B_VERTICAL, 0) 4185a695bceSMichael Pfeiffer .AddGroup(B_HORIZONTAL, 10, 1.0f) 4195a695bceSMichael Pfeiffer .AddGroup(B_VERTICAL, 10, 1.0f) 4205a695bceSMichael Pfeiffer .Add(qualityBox) 4215a695bceSMichael Pfeiffer .Add(pageRangeBox) 4225a695bceSMichael Pfeiffer .AddGlue() 4235a695bceSMichael Pfeiffer .End() 4245a695bceSMichael Pfeiffer .AddGroup(B_VERTICAL, 0, 1.0f) 4255a695bceSMichael Pfeiffer .Add(settings) 4265a695bceSMichael Pfeiffer .AddStrut(5) 4275a695bceSMichael Pfeiffer .Add(fCollate) 4285a695bceSMichael Pfeiffer .Add(fReverse) 4295a695bceSMichael Pfeiffer .Add(fPages) 4305a695bceSMichael Pfeiffer .AddStrut(5) 4315a695bceSMichael Pfeiffer .Add(pageSelectionBox) 4325a695bceSMichael Pfeiffer .AddGlue() 4335a695bceSMichael Pfeiffer .End() 4345a695bceSMichael Pfeiffer .End() 4355a695bceSMichael Pfeiffer .AddGlue() 4365a695bceSMichael Pfeiffer .Add(separator) 4375a695bceSMichael Pfeiffer .AddGroup(B_HORIZONTAL, 10, 1.0f) 4385a695bceSMichael Pfeiffer .AddGlue() 4395a695bceSMichael Pfeiffer .Add(cancel) 4405a695bceSMichael Pfeiffer .Add(preview) 4415a695bceSMichael Pfeiffer .Add(ok) 4425a695bceSMichael Pfeiffer .End() 4435a695bceSMichael Pfeiffer .SetInsets(0, 0, 0, 0) 4445a695bceSMichael Pfeiffer ); 44512fd6cc2SKarsten Heimrich 4465a695bceSMichael Pfeiffer fHalftone->preview(fJobData->getGamma(), fJobData->getInkDensity(), 4475a695bceSMichael Pfeiffer fJobData->getDitherType(), fJobData->getColor() != JobData::kMonochrome); 44812fd6cc2SKarsten Heimrich 44912fd6cc2SKarsten Heimrich UpdateButtonEnabledState(); 45012fd6cc2SKarsten Heimrich } 45112fd6cc2SKarsten Heimrich 452a7dde370SMichael Pfeiffer 45312fd6cc2SKarsten Heimrich void 454*f53abcbdSMichael Pfeiffer JobSetupView::FillCapabilityMenu(BPopUpMenu* menu, uint32 message, 455*f53abcbdSMichael Pfeiffer PrinterCap::CapID category, int id) 456*f53abcbdSMichael Pfeiffer { 457*f53abcbdSMichael Pfeiffer int count = fPrinterCap->countCap(category); 458*f53abcbdSMichael Pfeiffer const BaseCap **capabilities = fPrinterCap->enumCap(category); 459*f53abcbdSMichael Pfeiffer FillCapabilityMenu(menu, message, capabilities, count, id); 460*f53abcbdSMichael Pfeiffer } 461*f53abcbdSMichael Pfeiffer 462*f53abcbdSMichael Pfeiffer void 463*f53abcbdSMichael Pfeiffer JobSetupView::FillCapabilityMenu(BPopUpMenu* menu, uint32 message, 464*f53abcbdSMichael Pfeiffer const BaseCap** capabilities, int count, int id) 465*f53abcbdSMichael Pfeiffer { 466*f53abcbdSMichael Pfeiffer bool marked = false; 467*f53abcbdSMichael Pfeiffer 468*f53abcbdSMichael Pfeiffer BMenuItem* firstItem = NULL; 469*f53abcbdSMichael Pfeiffer BMenuItem* defaultItem = NULL; 470*f53abcbdSMichael Pfeiffer BMenuItem* item = NULL; 471*f53abcbdSMichael Pfeiffer while (count--) { 472*f53abcbdSMichael Pfeiffer const BaseCap* capability = *capabilities; 473*f53abcbdSMichael Pfeiffer if (message != kMsgNone) 474*f53abcbdSMichael Pfeiffer item = new BMenuItem(capability->fLabel.c_str(), 475*f53abcbdSMichael Pfeiffer new BMessage(kMsgQuality)); 476*f53abcbdSMichael Pfeiffer else 477*f53abcbdSMichael Pfeiffer item = new BMenuItem(capability->fLabel.c_str(), NULL); 478*f53abcbdSMichael Pfeiffer 479*f53abcbdSMichael Pfeiffer menu->AddItem(item); 480*f53abcbdSMichael Pfeiffer 481*f53abcbdSMichael Pfeiffer if (firstItem == NULL) 482*f53abcbdSMichael Pfeiffer firstItem = item; 483*f53abcbdSMichael Pfeiffer 484*f53abcbdSMichael Pfeiffer if (capability->fIsDefault) 485*f53abcbdSMichael Pfeiffer defaultItem = item; 486*f53abcbdSMichael Pfeiffer 487*f53abcbdSMichael Pfeiffer 488*f53abcbdSMichael Pfeiffer if (capability->ID() == id) { 489*f53abcbdSMichael Pfeiffer item->SetMarked(true); 490*f53abcbdSMichael Pfeiffer marked = true; 491*f53abcbdSMichael Pfeiffer } 492*f53abcbdSMichael Pfeiffer 493*f53abcbdSMichael Pfeiffer capabilities++; 494*f53abcbdSMichael Pfeiffer } 495*f53abcbdSMichael Pfeiffer 496*f53abcbdSMichael Pfeiffer if (marked) 497*f53abcbdSMichael Pfeiffer return; 498*f53abcbdSMichael Pfeiffer 499*f53abcbdSMichael Pfeiffer if (defaultItem != NULL) 500*f53abcbdSMichael Pfeiffer defaultItem->SetMarked(true); 501*f53abcbdSMichael Pfeiffer else if (firstItem != NULL) 502*f53abcbdSMichael Pfeiffer firstItem->SetMarked(true); 503*f53abcbdSMichael Pfeiffer } 504*f53abcbdSMichael Pfeiffer 505*f53abcbdSMichael Pfeiffer 506*f53abcbdSMichael Pfeiffer int 507*f53abcbdSMichael Pfeiffer JobSetupView::GetID(const BaseCap** capabilities, int count, const char* label, 508*f53abcbdSMichael Pfeiffer int defaultValue) 509*f53abcbdSMichael Pfeiffer { 510*f53abcbdSMichael Pfeiffer while (count--) { 511*f53abcbdSMichael Pfeiffer const BaseCap* capability = *capabilities; 512*f53abcbdSMichael Pfeiffer if (capability->fLabel == label) 513*f53abcbdSMichael Pfeiffer return capability->ID(); 514*f53abcbdSMichael Pfeiffer } 515*f53abcbdSMichael Pfeiffer return defaultValue; 516*f53abcbdSMichael Pfeiffer } 517*f53abcbdSMichael Pfeiffer 518*f53abcbdSMichael Pfeiffer 519*f53abcbdSMichael Pfeiffer void 52012fd6cc2SKarsten Heimrich JobSetupView::UpdateButtonEnabledState() 52112fd6cc2SKarsten Heimrich { 52212fd6cc2SKarsten Heimrich bool pageRangeEnabled = fAll->Value() != B_CONTROL_ON; 52312fd6cc2SKarsten Heimrich fFromPage->SetEnabled(pageRangeEnabled); 52412fd6cc2SKarsten Heimrich fToPage->SetEnabled(pageRangeEnabled); 52512fd6cc2SKarsten Heimrich 52612fd6cc2SKarsten Heimrich bool pageSelectionEnabled = fDuplex == NULL || 52712fd6cc2SKarsten Heimrich fDuplex->Value() != B_CONTROL_ON; 52812fd6cc2SKarsten Heimrich fAllPages->SetEnabled(pageSelectionEnabled); 52912fd6cc2SKarsten Heimrich fOddNumberedPages->SetEnabled(pageSelectionEnabled); 53012fd6cc2SKarsten Heimrich fEvenNumberedPages->SetEnabled(pageSelectionEnabled); 53112fd6cc2SKarsten Heimrich } 53212fd6cc2SKarsten Heimrich 533a7dde370SMichael Pfeiffer 53412fd6cc2SKarsten Heimrich void 53512fd6cc2SKarsten Heimrich JobSetupView::MessageReceived(BMessage *msg) 53612fd6cc2SKarsten Heimrich { 53712fd6cc2SKarsten Heimrich switch (msg->what) { 53812fd6cc2SKarsten Heimrich case kMsgRangeAll: 53912fd6cc2SKarsten Heimrich case kMsgRangeSelection: 54012fd6cc2SKarsten Heimrich case kMsgDuplexChanged: 54112fd6cc2SKarsten Heimrich UpdateButtonEnabledState(); 54212fd6cc2SKarsten Heimrich break; 54312fd6cc2SKarsten Heimrich 54412fd6cc2SKarsten Heimrich case kMsgQuality: 545*f53abcbdSMichael Pfeiffer fHalftone->preview(Gamma(), InkDensity(), DitherType(), 546*f53abcbdSMichael Pfeiffer Color() != JobData::kMonochrome); 54712fd6cc2SKarsten Heimrich break; 54812fd6cc2SKarsten Heimrich 54912fd6cc2SKarsten Heimrich case kMsgCollateChanged: 55012fd6cc2SKarsten Heimrich fPages->setCollate(fCollate->Value() == B_CONTROL_ON); 55112fd6cc2SKarsten Heimrich break; 55212fd6cc2SKarsten Heimrich 55312fd6cc2SKarsten Heimrich case kMsgReverseChanged: 55412fd6cc2SKarsten Heimrich fPages->setReverse(fReverse->Value() == B_CONTROL_ON); 55512fd6cc2SKarsten Heimrich break; 55612fd6cc2SKarsten Heimrich } 55712fd6cc2SKarsten Heimrich } 55812fd6cc2SKarsten Heimrich 559a7dde370SMichael Pfeiffer 56012fd6cc2SKarsten Heimrich JobData::Color 561*f53abcbdSMichael Pfeiffer JobSetupView::Color() 56212fd6cc2SKarsten Heimrich { 563*f53abcbdSMichael Pfeiffer const char *label = fColorType->FindMarked()->Label(); 564*f53abcbdSMichael Pfeiffer const BaseCap* capability = fPrinterCap->findCap(PrinterCap::kColor, label); 565*f53abcbdSMichael Pfeiffer if (capability == NULL) 56612fd6cc2SKarsten Heimrich return JobData::kMonochrome; 567*f53abcbdSMichael Pfeiffer 568*f53abcbdSMichael Pfeiffer const ColorCap* colorCap = static_cast<const ColorCap*>(capability); 569*f53abcbdSMichael Pfeiffer return colorCap->fColor; 57012fd6cc2SKarsten Heimrich } 57112fd6cc2SKarsten Heimrich 572a7dde370SMichael Pfeiffer 57312fd6cc2SKarsten Heimrich Halftone::DitherType 574*f53abcbdSMichael Pfeiffer JobSetupView::DitherType() 57512fd6cc2SKarsten Heimrich { 576*f53abcbdSMichael Pfeiffer const char *label = fDitherType->FindMarked()->Label(); 577*f53abcbdSMichael Pfeiffer int id = GetID(gDitherTypes, sizeof(gDitherTypes) / sizeof(gDitherTypes[0]), 578*f53abcbdSMichael Pfeiffer label, Halftone::kTypeFloydSteinberg); 579*f53abcbdSMichael Pfeiffer return static_cast<Halftone::DitherType>(id); 58012fd6cc2SKarsten Heimrich } 58112fd6cc2SKarsten Heimrich 58212fd6cc2SKarsten Heimrich float 583*f53abcbdSMichael Pfeiffer JobSetupView::Gamma() 58412fd6cc2SKarsten Heimrich { 58512fd6cc2SKarsten Heimrich const float value = (float)fGamma->Value(); 58612fd6cc2SKarsten Heimrich return pow(2.0, value / 100.0); 58712fd6cc2SKarsten Heimrich } 58812fd6cc2SKarsten Heimrich 589a7dde370SMichael Pfeiffer 59012fd6cc2SKarsten Heimrich float 591*f53abcbdSMichael Pfeiffer JobSetupView::InkDensity() 59212fd6cc2SKarsten Heimrich { 59312fd6cc2SKarsten Heimrich const float value = (float)(127 - fInkDensity->Value()); 59412fd6cc2SKarsten Heimrich return value; 59512fd6cc2SKarsten Heimrich } 59612fd6cc2SKarsten Heimrich 597a7dde370SMichael Pfeiffer 598*f53abcbdSMichael Pfeiffer JobData::PaperSource 599*f53abcbdSMichael Pfeiffer JobSetupView::PaperSource() 600*f53abcbdSMichael Pfeiffer { 601*f53abcbdSMichael Pfeiffer const char *label = fPaperFeed->FindMarked()->Label(); 602*f53abcbdSMichael Pfeiffer const BaseCap* capability = fPrinterCap->findCap(PrinterCap::kPaperSource, 603*f53abcbdSMichael Pfeiffer label); 604*f53abcbdSMichael Pfeiffer 605*f53abcbdSMichael Pfeiffer if (capability == NULL) 606*f53abcbdSMichael Pfeiffer capability = fPrinterCap->getDefaultCap(PrinterCap::kPaperSource); 607*f53abcbdSMichael Pfeiffer return static_cast<const PaperSourceCap*>(capability)->fPaperSource; 608*f53abcbdSMichael Pfeiffer 609*f53abcbdSMichael Pfeiffer } 610*f53abcbdSMichael Pfeiffer 61112fd6cc2SKarsten Heimrich bool 61212fd6cc2SKarsten Heimrich JobSetupView::UpdateJobData(bool showPreview) 61312fd6cc2SKarsten Heimrich { 61412fd6cc2SKarsten Heimrich fJobData->setShowPreview(showPreview); 615*f53abcbdSMichael Pfeiffer fJobData->setColor(Color()); 616*f53abcbdSMichael Pfeiffer fJobData->setGamma(Gamma()); 617*f53abcbdSMichael Pfeiffer fJobData->setInkDensity(InkDensity()); 618*f53abcbdSMichael Pfeiffer fJobData->setDitherType(DitherType()); 61912fd6cc2SKarsten Heimrich 62012fd6cc2SKarsten Heimrich int first_page; 62112fd6cc2SKarsten Heimrich int last_page; 62212fd6cc2SKarsten Heimrich 62312fd6cc2SKarsten Heimrich if (B_CONTROL_ON == fAll->Value()) { 62412fd6cc2SKarsten Heimrich first_page = 1; 62512fd6cc2SKarsten Heimrich last_page = -1; 62612fd6cc2SKarsten Heimrich } else { 62712fd6cc2SKarsten Heimrich first_page = atoi(fFromPage->Text()); 62812fd6cc2SKarsten Heimrich last_page = atoi(fToPage->Text()); 62912fd6cc2SKarsten Heimrich } 63012fd6cc2SKarsten Heimrich 63112fd6cc2SKarsten Heimrich fJobData->setFirstPage(first_page); 63212fd6cc2SKarsten Heimrich fJobData->setLastPage(last_page); 63312fd6cc2SKarsten Heimrich 634*f53abcbdSMichael Pfeiffer fJobData->setPaperSource(PaperSource()); 63512fd6cc2SKarsten Heimrich 636*f53abcbdSMichael Pfeiffer fJobData->setNup(GetID(gNups, sizeof(gNups) / sizeof(gNups[0]), 637*f53abcbdSMichael Pfeiffer fNup->FindMarked()->Label(), 1)); 63812fd6cc2SKarsten Heimrich 63912fd6cc2SKarsten Heimrich if (fPrinterCap->isSupport(PrinterCap::kPrintStyle)) { 640*f53abcbdSMichael Pfeiffer fJobData->setPrintStyle((B_CONTROL_ON == fDuplex->Value()) 641*f53abcbdSMichael Pfeiffer ? JobData::kDuplex : JobData::kSimplex); 64212fd6cc2SKarsten Heimrich } 64312fd6cc2SKarsten Heimrich 64412fd6cc2SKarsten Heimrich fJobData->setCopies(atoi(fCopies->Text())); 64512fd6cc2SKarsten Heimrich 64612fd6cc2SKarsten Heimrich fJobData->setCollate((B_CONTROL_ON == fCollate->Value()) ? true : false); 64712fd6cc2SKarsten Heimrich fJobData->setReverse((B_CONTROL_ON == fReverse->Value()) ? true : false); 64812fd6cc2SKarsten Heimrich 64912fd6cc2SKarsten Heimrich JobData::PageSelection pageSelection = JobData::kAllPages; 65012fd6cc2SKarsten Heimrich if (fOddNumberedPages->Value() == B_CONTROL_ON) 65112fd6cc2SKarsten Heimrich pageSelection = JobData::kOddNumberedPages; 65212fd6cc2SKarsten Heimrich if (fEvenNumberedPages->Value() == B_CONTROL_ON) 65312fd6cc2SKarsten Heimrich pageSelection = JobData::kEvenNumberedPages; 65412fd6cc2SKarsten Heimrich fJobData->setPageSelection(pageSelection); 65512fd6cc2SKarsten Heimrich 65612fd6cc2SKarsten Heimrich fJobData->save(); 65712fd6cc2SKarsten Heimrich return true; 65812fd6cc2SKarsten Heimrich } 65912fd6cc2SKarsten Heimrich 66012fd6cc2SKarsten Heimrich 6615a695bceSMichael Pfeiffer JobSetupDlg::JobSetupDlg(JobData *job_data, PrinterData *printer_data, 6625a695bceSMichael Pfeiffer const PrinterCap *printer_cap) 663a7dde370SMichael Pfeiffer : 664a7dde370SMichael Pfeiffer DialogWindow(BRect(100, 100, 200, 200), "PrintJob Setup", 665a7dde370SMichael Pfeiffer B_TITLED_WINDOW_LOOK, B_MODAL_APP_WINDOW_FEEL, 6665a695bceSMichael Pfeiffer B_NOT_RESIZABLE | B_NOT_MINIMIZABLE | B_NOT_ZOOMABLE 6675a695bceSMichael Pfeiffer | B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS) 66812fd6cc2SKarsten Heimrich { 66912fd6cc2SKarsten Heimrich SetResult(B_ERROR); 67012fd6cc2SKarsten Heimrich AddShortcut('W', B_COMMAND_KEY, new BMessage(B_QUIT_REQUESTED)); 67112fd6cc2SKarsten Heimrich 6725a695bceSMichael Pfeiffer fJobSetup = new JobSetupView(job_data, printer_data, printer_cap); 6735a695bceSMichael Pfeiffer SetLayout(new BGroupLayout(B_VERTICAL)); 6745a695bceSMichael Pfeiffer AddChild(BGroupLayoutBuilder(B_VERTICAL, 0) 6755a695bceSMichael Pfeiffer .Add(fJobSetup) 6765a695bceSMichael Pfeiffer .SetInsets(10, 10, 10, 10) 6775a695bceSMichael Pfeiffer ); 67812fd6cc2SKarsten Heimrich } 67912fd6cc2SKarsten Heimrich 680a7dde370SMichael Pfeiffer 68112fd6cc2SKarsten Heimrich void 68212fd6cc2SKarsten Heimrich JobSetupDlg::MessageReceived(BMessage *msg) 68312fd6cc2SKarsten Heimrich { 68412fd6cc2SKarsten Heimrich switch (msg->what) { 68512fd6cc2SKarsten Heimrich case kMsgOK: 68612fd6cc2SKarsten Heimrich case kMsgPreview: 68712fd6cc2SKarsten Heimrich fJobSetup->UpdateJobData(msg->what == kMsgPreview); 68812fd6cc2SKarsten Heimrich SetResult(B_NO_ERROR); 68912fd6cc2SKarsten Heimrich PostMessage(B_QUIT_REQUESTED); 69012fd6cc2SKarsten Heimrich break; 69112fd6cc2SKarsten Heimrich 69212fd6cc2SKarsten Heimrich case kMsgCancel: 69312fd6cc2SKarsten Heimrich PostMessage(B_QUIT_REQUESTED); 69412fd6cc2SKarsten Heimrich break; 69512fd6cc2SKarsten Heimrich 69612fd6cc2SKarsten Heimrich default: 69712fd6cc2SKarsten Heimrich DialogWindow::MessageReceived(msg); 69812fd6cc2SKarsten Heimrich break; 69912fd6cc2SKarsten Heimrich } 70012fd6cc2SKarsten Heimrich } 701