- 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)));
+
+ // 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)));
+