Rewrote scaling code for GNOME print backend. The inverted Y axis is now handled internally. Resulotion is not set to 600 dpi

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@48628 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2007-09-10 14:00:44 +00:00
parent e1ef6b5da5
commit 02255e07d7
5 changed files with 169 additions and 151 deletions

View File

@@ -733,28 +733,42 @@ wxRect wxPrintout::GetLogicalPageMarginsRect(const wxPageSetupDialogData& pageSe
// Return the rectangle in logical units that corresponds to the region
// within the page margins as specified by the given wxPageSetupDialogData
// object.
wxRect paperRect = GetPaperRectPixels();
// We get the paper size in device units and the margins in mm,
// so we need to calculate the conversion with this trick
wxCoord pw, ph;
GetPageSizePixels(&pw, &ph);
wxPoint topLeft = pageSetupData.GetMarginTopLeft();
wxPoint bottomRight = pageSetupData.GetMarginBottomRight();
wxCoord mw, mh;
GetPageSizeMM(&mw, &mh);
float mmToDeviceX = float(pw) / mw;
float mmToDeviceY = float(ph) / mh;
wxRect pageMarginsRect(paperRect.x + wxRound(mmToDeviceX * topLeft.x),
paperRect.y + wxRound(mmToDeviceY * topLeft.y),
paperRect.width - wxRound(mmToDeviceX * (topLeft.x + bottomRight.x)),
// paper size in device units
wxRect paperRect = GetPaperRectPixels();
// margins in mm
wxPoint topLeft = pageSetupData.GetMarginTopLeft();
wxPoint bottomRight = pageSetupData.GetMarginBottomRight();
// calculate margins in device units
wxRect pageMarginsRect(
paperRect.x + wxRound(mmToDeviceX * topLeft.x),
paperRect.y + wxRound(mmToDeviceY * topLeft.y),
paperRect.width - wxRound(mmToDeviceX * (topLeft.x + bottomRight.x)),
paperRect.height - wxRound(mmToDeviceY * (topLeft.y + bottomRight.y)));
wxCoord w, h;
m_printoutDC->GetSize(&w, &h);
if (w == pw && h == ph) {
if (w == pw && h == ph)
{
// this DC matches the printed page, so no scaling
return wxRect(m_printoutDC->DeviceToLogicalX(pageMarginsRect.x),
return wxRect(
m_printoutDC->DeviceToLogicalX(pageMarginsRect.x),
m_printoutDC->DeviceToLogicalY(pageMarginsRect.y),
m_printoutDC->DeviceToLogicalXRel(pageMarginsRect.width),
m_printoutDC->DeviceToLogicalYRel(pageMarginsRect.height));
}
// This DC doesn't match the printed page, so we have to scale.
float scaleX = float(w) / pw;
float scaleY = float(h) / ph;
@@ -767,17 +781,18 @@ wxRect wxPrintout::GetLogicalPageMarginsRect(const wxPageSetupDialogData& pageSe
void wxPrintout::SetLogicalOrigin(wxCoord x, wxCoord y)
{
// Set the device origin by specifying a point in logical coordinates.
m_printoutDC->SetDeviceOrigin(m_printoutDC->LogicalToDeviceX(x),
m_printoutDC->LogicalToDeviceY(y));
m_printoutDC->SetDeviceOrigin(
m_printoutDC->LogicalToDeviceX(x),
m_printoutDC->LogicalToDeviceY(y) );
}
void wxPrintout::OffsetLogicalOrigin(wxCoord xoff, wxCoord yoff)
{
// Offset the device origin by a specified distance in device coordinates.
wxCoord x = m_printoutDC->LogicalToDeviceX(0);
wxCoord y = m_printoutDC->LogicalToDeviceY(0);
m_printoutDC->SetDeviceOrigin(x + m_printoutDC->LogicalToDeviceXRel(xoff),
y + m_printoutDC->LogicalToDeviceYRel(yoff));
wxPoint dev_org = m_printoutDC->GetDeviceOrigin();
m_printoutDC->SetDeviceOrigin(
dev_org.x + m_printoutDC->LogicalToDeviceXRel(xoff),
dev_org.y + m_printoutDC->LogicalToDeviceYRel(yoff) );
}