- abortIt = FALSE;
- abortWindow = NULL;
-
- if (!printout)
- return FALSE;
-
- printout->SetIsPreview(FALSE);
- printout->OnPreparePrinting();
-
- // Get some parameters from the printout, if defined
- int fromPage, toPage;
- int minPage, maxPage;
- printout->GetPageInfo(&minPage, &maxPage, &fromPage, &toPage);
-
- if (maxPage == 0)
- return FALSE;
-
- printData.SetMinPage(minPage);
- printData.SetMaxPage(maxPage);
- if (fromPage != 0)
- printData.SetFromPage(fromPage);
- if (toPage != 0)
- printData.SetToPage(toPage);
-
- if (minPage != 0)
- {
- printData.EnablePageNumbers(TRUE);
- if (printData.GetFromPage() < printData.GetMinPage())
- printData.SetFromPage(printData.GetMinPage());
- else if (printData.GetFromPage() > printData.GetMaxPage())
- printData.SetFromPage(printData.GetMaxPage());
- if (printData.GetToPage() > printData.GetMaxPage())
- printData.SetToPage(printData.GetMaxPage());
- else if (printData.GetToPage() < printData.GetMinPage())
- printData.SetToPage(printData.GetMinPage());
- }
- else
- printData.EnablePageNumbers(FALSE);
-
- // Create a suitable device context
- wxDC *dc = NULL;
- if (prompt)
- {
- wxGenericPrintDialog dialog(parent, & printData);
- if (dialog.ShowModal() == wxID_OK)
- {
- dc = dialog.GetPrintDC();
- printData = dialog.GetPrintData();
- }
- }
- else
- {
- dc = new wxPostScriptDC(wxThePrintSetupData->GetPrinterFile(), FALSE, NULL);
- }
-
- // May have pressed cancel.
- if (!dc || !dc->Ok())
- {
- if (dc) delete dc;
- return FALSE;
- }
-
- int logPPIScreenX = 0;
- int logPPIScreenY = 0;
- int logPPIPrinterX = 0;
- int logPPIPrinterY = 0;
-
- // Correct values for X/PostScript?
- logPPIScreenX = 100;
- logPPIScreenY = 100;
- logPPIPrinterX = 100;
- logPPIPrinterY = 100;
-
- printout->SetPPIScreen(logPPIScreenX, logPPIScreenY);
- printout->SetPPIPrinter(logPPIPrinterX, logPPIPrinterY);
-
- // Set printout parameters
- printout->SetDC(dc);
-
- int w, h;
- long ww, hh;
- dc->GetSize(&w, &h);
- printout->SetPageSizePixels((int)w, (int)h);
- dc->GetSizeMM(&ww, &hh);
- printout->SetPageSizeMM((int)ww, (int)hh);
-
- // Create an abort window
- wxBeginBusyCursor();
-
- printout->OnBeginPrinting();
-
- bool keepGoing = TRUE;
-
- int copyCount;
- for (copyCount = 1; copyCount <= printData.GetNoCopies(); copyCount ++)
- {
- if (!printout->OnBeginDocument(printData.GetFromPage(), printData.GetToPage()))
+ sm_abortIt = false;
+ sm_abortWindow = (wxWindow *) NULL;
+
+ if (!printout)
+ {
+ sm_lastError = wxPRINTER_ERROR;
+ return false;
+ }
+
+ printout->SetIsPreview(false);
+
+ if (m_printDialogData.GetMinPage() < 1)
+ m_printDialogData.SetMinPage(1);
+ if (m_printDialogData.GetMaxPage() < 1)
+ m_printDialogData.SetMaxPage(9999);
+
+ // Create a suitable device context
+ wxDC *dc;
+ if (prompt)
+ {
+ dc = PrintDialog(parent);
+ if (!dc)
+ return false;
+ }
+ else
+ {
+ dc = new wxPostScriptDC(GetPrintDialogData().GetPrintData());
+ }
+
+ // May have pressed cancel.
+ if (!dc || !dc->Ok())
+ {
+ if (dc) delete dc;
+ sm_lastError = wxPRINTER_ERROR;
+ return false;
+ }
+
+ wxSize ScreenPixels = wxGetDisplaySize();
+ wxSize ScreenMM = wxGetDisplaySizeMM();
+
+ printout->SetPPIScreen( (int) ((ScreenPixels.GetWidth() * 25.4) / ScreenMM.GetWidth()),
+ (int) ((ScreenPixels.GetHeight() * 25.4) / ScreenMM.GetHeight()) );
+ printout->SetPPIPrinter( wxPostScriptDC::GetResolution(),
+ wxPostScriptDC::GetResolution() );
+
+ // Set printout parameters
+ printout->SetDC(dc);
+
+ int w, h;
+ dc->GetSize(&w, &h);
+ printout->SetPageSizePixels((int)w, (int)h);
+ printout->SetPaperRectPixels(wxRect(0, 0, w, h));
+ int mw, mh;
+ dc->GetSizeMM(&mw, &mh);
+ printout->SetPageSizeMM((int)mw, (int)mh);
+
+ // Create an abort window
+ wxBeginBusyCursor();
+
+ printout->OnPreparePrinting();
+
+ // Get some parameters from the printout, if defined
+ int fromPage, toPage;
+ int minPage, maxPage;
+ printout->GetPageInfo(&minPage, &maxPage, &fromPage, &toPage);
+
+ if (maxPage == 0)