+
+ // on the mac we have always pixels as addressing mode with 72 dpi
+
+ printout->SetPPIScreen(72, 72);
+ printout->SetPPIPrinter(72, 72);
+
+ // Set printout parameters
+ printout->SetDC(dc);
+
+ int w, h;
+ wxCoord 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();
+
+ wxWindow *win = CreateAbortWindow(parent, printout);
+ wxSafeYield(win,true);
+
+ if (!win)
+ {
+ wxEndBusyCursor();
+ wxMessageBox(wxT("Sorry, could not create an abort dialog."), wxT("Print Error"), wxOK, parent);
+ delete dc;
+ return FALSE;
+ }
+ sm_abortWindow = win;
+ sm_abortWindow->Show(TRUE);
+ wxSafeYield(win,true);
+
+ printout->OnBeginPrinting();
+
+ bool keepGoing = TRUE;
+
+ int copyCount;
+ for (copyCount = 1; copyCount <= m_printDialogData.GetNoCopies(); copyCount ++)
+ {
+ if (!printout->OnBeginDocument(m_printDialogData.GetFromPage(), m_printDialogData.GetToPage()))
+ {
+ wxEndBusyCursor();
+ wxMessageBox(wxT("Could not start printing."), wxT("Print Error"), wxOK, parent);
+ break;
+ }
+ if (sm_abortIt)
+ break;
+
+ int pn;
+ for (pn = m_printDialogData.GetFromPage(); keepGoing && (pn <= m_printDialogData.GetToPage()) && printout->HasPage(pn);
+ pn++)
+ {
+ if (sm_abortIt)
+ {
+ keepGoing = FALSE;
+ break;
+ }
+ else
+ {
+#if !TARGET_CARBON
+ GrafPtr thePort ;
+ GetPort( &thePort ) ;
+ wxSafeYield(win,true);
+ SetPort( thePort ) ;
+#endif
+ dc->StartPage();
+ keepGoing = printout->OnPrintPage(pn);
+ dc->EndPage();
+ }
+ }
+ printout->OnEndDocument();
+ }
+
+ printout->OnEndPrinting();
+
+ if (sm_abortWindow)
+ {
+ sm_abortWindow->Show(FALSE);
+ delete sm_abortWindow;
+ sm_abortWindow = NULL;
+ }
+
+ wxEndBusyCursor();
+
+ delete dc;
+
+ return TRUE;