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