diff --git a/src/add-ons/print/drivers/preview/JobSetupWindow.cpp b/src/add-ons/print/drivers/preview/JobSetupWindow.cpp index 5f205318aa..439c7575fb 100644 --- a/src/add-ons/print/drivers/preview/JobSetupWindow.cpp +++ b/src/add-ons/print/drivers/preview/JobSetupWindow.cpp @@ -70,10 +70,10 @@ JobSetupWindow::JobSetupWindow(BMessage *msg, const char * printerName) fFrom->SetDivider(be_plain_font->StringWidth("From: ")); fFrom->SetEnabled(!allPages); + rect = fFrom->Frame(); fTo = new BTextControl(rect, "to", "To:", "SomeSpaceHere", NULL); panel->AddChild(fTo); fTo->SetAlignment(B_ALIGN_LEFT, B_ALIGN_RIGHT); - fTo->ResizeToPreferred(); fTo->SetDivider(be_plain_font->StringWidth("To: ")); fTo->MoveTo(fFrom->Frame().right + 10.0, fTo->Frame().top); fTo->SetEnabled(!allPages); diff --git a/src/add-ons/print/drivers/preview/PageSetupWindow.cpp b/src/add-ons/print/drivers/preview/PageSetupWindow.cpp index e0b8cf8f9f..68eed76cf0 100644 --- a/src/add-ons/print/drivers/preview/PageSetupWindow.cpp +++ b/src/add-ons/print/drivers/preview/PageSetupWindow.cpp @@ -101,20 +101,23 @@ PageSetupWindow::PageSetupWindow(BMessage *msg, const char *printerName) SetTitle(BString(printerName).Append(" Page Setup").String()); // load orientation - int32 orient = 0; - fSetupMsg->FindInt32("orientation", &orient); + if (fSetupMsg->FindInt32("orientation", &fCurrentOrientation) != B_OK) + fCurrentOrientation = 0; // load page rect + BRect page; float width = letter_width; float height = letter_height; - BRect page(0, 0, width, height); if (fSetupMsg->FindRect("preview:paper_rect", &page) == B_OK) { width = page.Width(); height = page.Height(); + } else { + page.Set(0, 0, width, height); } - BString label("Letter"); - fSetupMsg->FindString("preview:paper_size", &label); + BString label; + if (fSetupMsg->FindString("preview:paper_size", &label) != B_OK) + label = "Letter"; // Load units int32 units; @@ -183,7 +186,7 @@ PageSetupWindow::PageSetupWindow(BMessage *msg, const char *printerName) BMenuItem* item = new BMenuItem(orientation[i].label, message); m->AddItem(item); - if (orient == orientation[i].orientation) + if (fCurrentOrientation == orientation[i].orientation) item->SetMarked(true); } @@ -247,13 +250,9 @@ PageSetupWindow::PageSetupWindow(BMessage *msg, const char *printerName) void PageSetupWindow::UpdateSetupMessage() { - int32 orientation = 0; - BMenuItem *item = fOrientationMenu->Menu()->FindMarked(); - if (item) { - BMessage *msg = item->Message(); - msg->FindInt32("orientation", &orientation); - SetInt32(fSetupMsg, "orientation", orientation); - } + SetInt32(fSetupMsg, "xres", 300); + SetInt32(fSetupMsg, "yres", 300); + SetInt32(fSetupMsg, "orientation", fCurrentOrientation); // Save scaling factor float scale = atoi(fScaleControl->Text()); @@ -262,14 +261,14 @@ PageSetupWindow::UpdateSetupMessage() SetFloat(fSetupMsg, "scale", scale); float scaleR = 100.0 / scale; - item = fPageSizeMenu->Menu()->FindMarked(); + BMenuItem *item = fPageSizeMenu->Menu()->FindMarked(); if (item) { float w, h; BMessage *msg = item->Message(); msg->FindFloat("width", &w); msg->FindFloat("height", &h); BRect r(0, 0, w, h); - if (orientation != 0) + if (fCurrentOrientation != 0) r.Set(0, 0, h, w); SetRect(fSetupMsg, "preview:paper_rect", r); @@ -290,9 +289,6 @@ PageSetupWindow::UpdateSetupMessage() SetInt32(fSetupMsg, "units", fMarginView->GetMarginUnit()); } - - SetInt32(fSetupMsg, "xres", 300); - SetInt32(fSetupMsg, "yres", 300); } @@ -313,23 +309,22 @@ PageSetupWindow::MessageReceived(BMessage *msg) float w, h; msg->FindFloat("width", &w); msg->FindFloat("height", &h); - BMenuItem *item = fOrientationMenu->Menu()->FindMarked(); - if (item) { - int32 orientation = 0; - item->Message()->FindInt32("orientation", &orientation); - if (orientation == PrinterDriver::PORTRAIT_ORIENTATION) { - fMarginView->SetPageSize(w, h); - } else { - fMarginView->SetPageSize(h, w); - } - fMarginView->UpdateView(MARGIN_CHANGED); + if (fCurrentOrientation == PrinterDriver::PORTRAIT_ORIENTATION) { + fMarginView->SetPageSize(w, h); + } else { + fMarginView->SetPageSize(h, w); } + fMarginView->UpdateView(MARGIN_CHANGED); } break; case ORIENTATION_CHANGED: { int32 orientation; msg->FindInt32("orientation", &orientation); + if (fCurrentOrientation == orientation) + break; + + fCurrentOrientation = orientation; BPoint p = fMarginView->GetPageSize(); if (orientation == PrinterDriver::LANDSCAPE_ORIENTATION) { fMarginView->SetPageSize(p.y, p.x); diff --git a/src/add-ons/print/drivers/preview/PageSetupWindow.h b/src/add-ons/print/drivers/preview/PageSetupWindow.h index 706d595077..74817b7630 100644 --- a/src/add-ons/print/drivers/preview/PageSetupWindow.h +++ b/src/add-ons/print/drivers/preview/PageSetupWindow.h @@ -49,6 +49,7 @@ private: BTextControl * fScaleControl; MarginView * fMarginView; BString fPrinterDirName; + int32 fCurrentOrientation; }; #endif diff --git a/src/add-ons/print/drivers/preview/PreviewDriver.cpp b/src/add-ons/print/drivers/preview/PreviewDriver.cpp index 37e7903adf..914916f443 100644 --- a/src/add-ons/print/drivers/preview/PreviewDriver.cpp +++ b/src/add-ons/print/drivers/preview/PreviewDriver.cpp @@ -27,7 +27,7 @@ status_t PreviewDriver::PrintJob(BFile *jobFile, BMessage *jobMsg) { #if PREVIEW_DRIVER_DEBUG - return PrinterDriver::PrintJob(jobFile, jobMsg) + return PrinterDriver::PrintJob(jobFile, jobMsg); #else PreviewWindow* w = new PreviewWindow(jobFile); return w->Go(); diff --git a/src/add-ons/print/drivers/preview/PrinterDriver.cpp b/src/add-ons/print/drivers/preview/PrinterDriver.cpp index 58e474444b..6548bde35d 100644 --- a/src/add-ons/print/drivers/preview/PrinterDriver.cpp +++ b/src/add-ons/print/drivers/preview/PrinterDriver.cpp @@ -70,8 +70,15 @@ PrinterDriver::PrintJob(BFile *spoolFile, BMessage *jobMsg) BeginJob(); fPrinting = true; + printf("PrinterDriver::PrintJob, print massage read from spool file\n"); + jobMsg->PrintToStream(); + + printf("\nPrinterDriver::PrintJob, print massage passed to print job\n"); + msg.PrintToStream(); + printf("\n"); + for (int32 page = 1; page <= pfh.page_count; ++page) { - printf("PrinterDriver::PrintPage(): Faking print of page %ld/ %ld", + printf("PrinterDriver::PrintPage(): Faking print of page %ld/ %ld\n", page, pfh.page_count); } @@ -79,7 +86,7 @@ PrinterDriver::PrintJob(BFile *spoolFile, BMessage *jobMsg) PrintJobReader reader(fJobFile); status_t status = reader.InitCheck(); - printf("PrintJobReader::InitCheck(): %s\n", status == B_OK ? "B_OK" : "B_ERROR"); + printf("\nPrintJobReader::InitCheck(): %s\n", status == B_OK ? "B_OK" : "B_ERROR"); printf("PrintJobReader::NumberOfPages(): %ld\n", reader.NumberOfPages()); printf("PrintJobReader::FirstPage(): %ld\n", reader.FirstPage()); printf("PrintJobReader::LastPage(): %ld\n", reader.LastPage());