- GetRichTextBuffer()->Draw(*dc, rangeToDraw, wxRichTextRange(-1,-1), textRect, 0 /* descent */, wxRICHTEXT_DRAW_IGNORE_CACHE /* flags */);
+ wxPoint oldOrigin = dc->GetLogicalOrigin();
+ double scaleX, scaleY;
+ dc->GetUserScale(& scaleX, & scaleY);
+
+ int yOffset = 0;
+ if (page > 1)
+ yOffset = m_pageYOffsets[page-2];
+
+ if (yOffset != oldOrigin.y)
+ dc->SetLogicalOrigin(oldOrigin.x, oldOrigin.y + yOffset);
+
+ dc->SetClippingRegion(wxRect(textRect.x, textRect.y + yOffset, textRect.width, textRect.height));
+
+ wxRichTextDrawingContext context(GetRichTextBuffer());
+ GetRichTextBuffer()->Draw(*dc, context, rangeToDraw, wxRichTextSelection(), textRect, 0 /* descent */, wxRICHTEXT_DRAW_IGNORE_CACHE|wxRICHTEXT_DRAW_PRINT /* flags */);
+
+ dc->DestroyClippingRegion();
+
+ if (yOffset != oldOrigin.y)
+ dc->SetLogicalOrigin(oldOrigin.x, oldOrigin.y);