- sm_abortIt = FALSE;
- sm_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;
-
- 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 = NULL;
- if (prompt)
- {
- wxPrintDialog dialog(parent, & m_printData);
- if (dialog.ShowModal() == wxID_OK)
- {
- dc = dialog.GetPrintDC();
- m_printData = dialog.GetPrintData();
- }
- }
- else
- {
- dc = new wxPrinterDC("", "", "", FALSE, m_printData.GetOrientation());
- }
-
- // 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;
-
- HDC hdc = ::GetDC(NULL);
- logPPIScreenX = ::GetDeviceCaps(hdc, LOGPIXELSX);
- logPPIScreenY = ::GetDeviceCaps(hdc, LOGPIXELSY);
- ::ReleaseDC(NULL, hdc);
-
- logPPIPrinterX = ::GetDeviceCaps((HDC) dc->GetHDC(), LOGPIXELSX);
- logPPIPrinterY = ::GetDeviceCaps((HDC) dc->GetHDC(), LOGPIXELSY);
- if (logPPIPrinterX == 0 || logPPIPrinterY == 0)
- {
- delete dc;
- return FALSE;
- }