- sm_abortIt = FALSE;
- sm_abortWindow = (wxWindow *) 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;
-
- m_printData.SetMinPage(minPage);
- m_printData.SetMaxPage(maxPage);
- if (fromPage != 0)
- m_printData.SetFromPage(fromPage);
- if (toPage != 0)
- m_printData.SetToPage(toPage);
-
- if (minPage != 0)
- {
- m_printData.EnablePageNumbers(TRUE);
- if (m_printData.GetFromPage() < m_printData.GetMinPage())
- m_printData.SetFromPage(m_printData.GetMinPage());
- else if (m_printData.GetFromPage() > m_printData.GetMaxPage())
- m_printData.SetFromPage(m_printData.GetMaxPage());
- if (m_printData.GetToPage() > m_printData.GetMaxPage())
- m_printData.SetToPage(m_printData.GetMaxPage());
- else if (m_printData.GetToPage() < m_printData.GetMinPage())
- m_printData.SetToPage(m_printData.GetMinPage());
- }
- else
- m_printData.EnablePageNumbers(FALSE);
-
- // Create a suitable device context
- wxDC *dc = (wxDC *) NULL;
- if (prompt)
- {
- wxGenericPrintDialog dialog(parent, & m_printData);
- if (dialog.ShowModal() == wxID_OK)
- {
- dc = dialog.GetPrintDC();
- m_printData = dialog.GetPrintData();
- }
- }
- else
- {
- dc = new wxPostScriptDC(wxThePrintSetupData->GetPrinterFile(), FALSE, (wxWindow *) 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;
-
- logPPIScreenX = 100;
- logPPIScreenY = 100;
-
-/*
- // Correct values for X/PostScript?
- logPPIPrinterX = 100;
- logPPIPrinterY = 100;
-*/
-
- logPPIPrinterX = 72;
- logPPIPrinterY = 72;
-
- 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 <= m_printData.GetNoCopies(); copyCount ++)
- {
- if (!printout->OnBeginDocument(m_printData.GetFromPage(), m_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);
+ dc->GetSizeMM(&w, &h);
+ printout->SetPageSizeMM((int)w, (int)h);
+
+ // 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)