Applied patch 1586499: wxCoordRound function
Centralises rounding and adds nearest-value rounding to prntbase.cpp. by Robert J. Lang git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42624 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -617,10 +617,10 @@ void wxPrintout::FitThisSizeToPageMargins(const wxSize& imageSize, const wxPageS
|
||||
GetPageSizeMM(&mw, &mh);
|
||||
float mmToDeviceX = float(pw) / mw;
|
||||
float mmToDeviceY = float(ph) / mh;
|
||||
wxRect pageMarginsRect(paperRect.x + wxCoord(mmToDeviceX * topLeft.x),
|
||||
paperRect.y + wxCoord(mmToDeviceY * topLeft.y),
|
||||
paperRect.width - wxCoord(mmToDeviceX * (topLeft.x + bottomRight.x)),
|
||||
paperRect.height - wxCoord(mmToDeviceY * (topLeft.y + bottomRight.y)));
|
||||
wxRect pageMarginsRect(paperRect.x + wxCoordRound(mmToDeviceX * topLeft.x),
|
||||
paperRect.y + wxCoordRound(mmToDeviceY * topLeft.y),
|
||||
paperRect.width - wxCoordRound(mmToDeviceX * (topLeft.x + bottomRight.x)),
|
||||
paperRect.height - wxCoordRound(mmToDeviceY * (topLeft.y + bottomRight.y)));
|
||||
wxCoord w, h;
|
||||
m_printoutDC->GetSize(&w, &h);
|
||||
float scaleX = (float(pageMarginsRect.width) * w) / (float(pw) * imageSize.x);
|
||||
@@ -708,10 +708,10 @@ wxRect wxPrintout::GetLogicalPaperRect() const
|
||||
// This DC doesn't match the printed page, so we have to scale.
|
||||
float scaleX = float(w) / pw;
|
||||
float scaleY = float(h) / ph;
|
||||
return wxRect(m_printoutDC->DeviceToLogicalX(wxCoord(paperRect.x * scaleX)),
|
||||
m_printoutDC->DeviceToLogicalY(wxCoord(paperRect.y * scaleY)),
|
||||
m_printoutDC->DeviceToLogicalXRel(wxCoord(paperRect.width * scaleX)),
|
||||
m_printoutDC->DeviceToLogicalYRel(wxCoord(paperRect.height * scaleY)));
|
||||
return wxRect(m_printoutDC->DeviceToLogicalX(wxCoordRound(paperRect.x * scaleX)),
|
||||
m_printoutDC->DeviceToLogicalY(wxCoordRound(paperRect.y * scaleY)),
|
||||
m_printoutDC->DeviceToLogicalXRel(wxCoordRound(paperRect.width * scaleX)),
|
||||
m_printoutDC->DeviceToLogicalYRel(wxCoordRound(paperRect.height * scaleY)));
|
||||
}
|
||||
|
||||
wxRect wxPrintout::GetLogicalPageRect() const
|
||||
@@ -740,10 +740,10 @@ wxRect wxPrintout::GetLogicalPageMarginsRect(const wxPageSetupDialogData& pageSe
|
||||
GetPageSizeMM(&mw, &mh);
|
||||
float mmToDeviceX = float(pw) / mw;
|
||||
float mmToDeviceY = float(ph) / mh;
|
||||
wxRect pageMarginsRect(paperRect.x + wxCoord(mmToDeviceX * topLeft.x),
|
||||
paperRect.y + wxCoord(mmToDeviceY * topLeft.y),
|
||||
paperRect.width - wxCoord(mmToDeviceX * (topLeft.x + bottomRight.x)),
|
||||
paperRect.height - wxCoord(mmToDeviceY * (topLeft.y + bottomRight.y)));
|
||||
wxRect pageMarginsRect(paperRect.x + wxCoordRound(mmToDeviceX * topLeft.x),
|
||||
paperRect.y + wxCoordRound(mmToDeviceY * topLeft.y),
|
||||
paperRect.width - wxCoordRound(mmToDeviceX * (topLeft.x + bottomRight.x)),
|
||||
paperRect.height - wxCoordRound(mmToDeviceY * (topLeft.y + bottomRight.y)));
|
||||
wxCoord w, h;
|
||||
m_printoutDC->GetSize(&w, &h);
|
||||
if (w == pw && h == ph) {
|
||||
@@ -756,10 +756,10 @@ wxRect wxPrintout::GetLogicalPageMarginsRect(const wxPageSetupDialogData& pageSe
|
||||
// This DC doesn't match the printed page, so we have to scale.
|
||||
float scaleX = float(w) / pw;
|
||||
float scaleY = float(h) / ph;
|
||||
return wxRect(m_printoutDC->DeviceToLogicalX(wxCoord(pageMarginsRect.x * scaleX)),
|
||||
m_printoutDC->DeviceToLogicalY(wxCoord(pageMarginsRect.y * scaleY)),
|
||||
m_printoutDC->DeviceToLogicalXRel(wxCoord(pageMarginsRect.width * scaleX)),
|
||||
m_printoutDC->DeviceToLogicalYRel(wxCoord(pageMarginsRect.height * scaleY)));
|
||||
return wxRect(m_printoutDC->DeviceToLogicalX(wxCoordRound(pageMarginsRect.x * scaleX)),
|
||||
m_printoutDC->DeviceToLogicalY(wxCoordRound(pageMarginsRect.y * scaleY)),
|
||||
m_printoutDC->DeviceToLogicalXRel(wxCoordRound(pageMarginsRect.width * scaleX)),
|
||||
m_printoutDC->DeviceToLogicalYRel(wxCoordRound(pageMarginsRect.height * scaleY)));
|
||||
}
|
||||
|
||||
void wxPrintout::SetLogicalOrigin(wxCoord x, wxCoord y)
|
||||
|
Reference in New Issue
Block a user