#include "wx/generic/printps.h"
#include "wx/printdlg.h"
#include "wx/generic/prntdlgg.h"
-#include "wx/generic/progdlgg.h"
+#include "wx/progdlg.h"
#include "wx/paper.h"
#include <stdlib.h>
bool wxPostScriptPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt)
{
sm_abortIt = false;
- sm_abortWindow = (wxWindow *) NULL;
+ sm_abortWindow = NULL;
if (!printout)
{
return false;
}
- printout->SetIsPreview(false);
-
if (m_printDialogData.GetMinPage() < 1)
m_printDialogData.SetMinPage(1);
if (m_printDialogData.GetMaxPage() < 1)
}
// May have pressed cancel.
- if (!dc || !dc->Ok())
+ if (!dc || !dc->IsOk())
{
if (dc) delete dc;
sm_lastError = wxPRINTER_ERROR;
printout->SetPPIScreen( (int) ((ScreenPixels.GetWidth() * 25.4) / ScreenMM.GetWidth()),
(int) ((ScreenPixels.GetHeight() * 25.4) / ScreenMM.GetHeight()) );
- printout->SetPPIPrinter( wxPostScriptDC::GetResolution(),
- wxPostScriptDC::GetResolution() );
+ printout->SetPPIPrinter( dc->GetResolution(),
+ dc->GetResolution() );
// Set printout parameters
printout->SetDC(dc);
wxDC* wxPostScriptPrinter::PrintDialog(wxWindow *parent)
{
- wxDC* dc = (wxDC*) NULL;
+ wxDC* dc = NULL;
wxGenericPrintDialog dialog( parent, &m_printDialogData );
if (dialog.ShowModal() == wxID_OK)
if (paper)
{
- wxSize ScreenPixels = wxGetDisplaySize();
- wxSize ScreenMM = wxGetDisplaySizeMM();
+ int resolution = 600; // TODO, this is correct, but get this from wxPSDC somehow
+
+ const wxSize screenPPI = wxGetDisplayPPI();
+ int logPPIScreenX = screenPPI.GetWidth();
+ int logPPIScreenY = screenPPI.GetHeight();
+ int logPPIPrinterX = resolution;
+ int logPPIPrinterY = resolution;
- m_previewPrintout->SetPPIScreen( (int) ((ScreenPixels.GetWidth() * 25.4) / ScreenMM.GetWidth()),
- (int) ((ScreenPixels.GetHeight() * 25.4) / ScreenMM.GetHeight()) );
- m_previewPrintout->SetPPIPrinter(wxPostScriptDC::GetResolution(), wxPostScriptDC::GetResolution());
+ m_previewPrintout->SetPPIScreen( logPPIScreenX, logPPIScreenY );
+ m_previewPrintout->SetPPIPrinter( logPPIPrinterX, logPPIPrinterY );
wxSize sizeDevUnits(paper->GetSizeDeviceUnits());
- sizeDevUnits.x = (wxCoord)((float)sizeDevUnits.x * wxPostScriptDC::GetResolution() / 72.0);
- sizeDevUnits.y = (wxCoord)((float)sizeDevUnits.y * wxPostScriptDC::GetResolution() / 72.0);
+ sizeDevUnits.x = (wxCoord)((float)sizeDevUnits.x * resolution / 72.0);
+ sizeDevUnits.y = (wxCoord)((float)sizeDevUnits.y * resolution / 72.0);
wxSize sizeTenthsMM(paper->GetSize());
wxSize sizeMM(sizeTenthsMM.x / 10, sizeTenthsMM.y / 10);
m_previewPrintout->SetPaperRectPixels(wxRect(0, 0, m_pageWidth, m_pageHeight));
// At 100%, the page should look about page-size on the screen.
- m_previewScaleX = (float)0.8 * 72.0 / (float)wxPostScriptDC::GetResolution();
- m_previewScaleY = m_previewScaleX;
+ m_previewScaleX = float(logPPIScreenX) / logPPIPrinterX;
+ m_previewScaleY = float(logPPIScreenY) / logPPIPrinterY;
}
}