Add wxPrintout::SetUp() to reuse the same code in all ports
MSW, GTK, OSX and Postscript implementations all did almost exactly the same thing to initialize wxPrintout, so extract this common code into a new wxPrintout method and just call it instead. There should be no changes in behaviour.
This commit is contained in:
@@ -638,6 +638,33 @@ void wxPrintout::GetPageInfo(int *minPage, int *maxPage, int *fromPage, int *toP
|
||||
*toPage = 1;
|
||||
}
|
||||
|
||||
bool wxPrintout::SetUp(wxDC& dc)
|
||||
{
|
||||
SetPPIScreen(wxGetDisplayPPI());
|
||||
|
||||
// We need to know printer PPI. In most ports, this can be retrieved from
|
||||
// the printer DC, but in others it is computed (probably for legacy
|
||||
// reasons) outside of wxDC code, so don't override it if it had been
|
||||
// already set.
|
||||
if ( !m_PPIPrinterX || !m_PPIPrinterY )
|
||||
{
|
||||
SetPPIPrinter(dc.GetPPI());
|
||||
if ( !m_PPIPrinterX || !m_PPIPrinterY )
|
||||
{
|
||||
// But if we couldn't get it in any way, we can't continue.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
SetDC(&dc);
|
||||
|
||||
dc.GetSize(&m_pageWidthPixels, &m_pageHeightPixels);
|
||||
m_paperRectPixels = wxRect(0, 0, m_pageWidthPixels, m_pageHeightPixels);
|
||||
dc.GetSizeMM(&m_pageWidthMM, &m_pageHeightMM);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void wxPrintout::FitThisSizeToPaper(const wxSize& imageSize)
|
||||
{
|
||||
// Set the DC scale and origin so that the given image size fits within the
|
||||
|
||||
Reference in New Issue
Block a user