From 49ad7c51154c0e5abb5b8b2b99bb97704aae4a39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Wed, 20 Aug 2008 21:59:10 +0000 Subject: [PATCH] fixed scaling of print preview if there's not enough RAM for the full page git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@55135 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/prntbase.cpp | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/common/prntbase.cpp b/src/common/prntbase.cpp index b1dc6dde81..a17f45f5c7 100644 --- a/src/common/prntbase.cpp +++ b/src/common/prntbase.cpp @@ -1856,9 +1856,12 @@ namespace class PageFragmentDC : public wxMemoryDC { public: - PageFragmentDC(wxDC *printer, wxBitmap& bmp, const wxRect& rect) + PageFragmentDC(wxDC *printer, wxBitmap& bmp, + const wxPoint& offset, + const wxSize& fullSize) : wxMemoryDC(printer), - m_rect(rect) + m_offset(offset), + m_fullSize(fullSize) { SetDeviceOrigin(0, 0); SelectObject(bmp); @@ -1866,26 +1869,27 @@ public: virtual void SetDeviceOrigin(wxCoord x, wxCoord y) { - wxMemoryDC::SetDeviceOrigin(x - m_rect.x, y - m_rect.y); + wxMemoryDC::SetDeviceOrigin(x - m_offset.x, y - m_offset.y); } virtual void DoGetDeviceOrigin(wxCoord *x, wxCoord *y) const { wxMemoryDC::DoGetDeviceOrigin(x, y); - if ( x ) *x += m_rect.x; - if ( x ) *y += m_rect.y; + if ( x ) *x += m_offset.x; + if ( x ) *y += m_offset.y; } virtual void DoGetSize(int *width, int *height) const { if ( width ) - *width = m_rect.width; + *width = m_fullSize.x; if ( height ) - *height = m_rect.height; + *height = m_fullSize.y; } private: - wxRect m_rect; + wxPoint m_offset; + wxSize m_fullSize; }; // estimate how big chunks we can render, given available RAM @@ -1947,6 +1951,7 @@ static bool RenderPageFragment(wxPrintPreviewBase *preview, wxPrinterDC& printer, wxMemoryDC& finalDC, const wxRect& rect, + int pageHeight, int pageWidth, int pageNum) { // compute 'rect' equivalent in the small final bitmap: @@ -1967,7 +1972,9 @@ static bool RenderPageFragment(wxPrintPreviewBase *preview, // render part of the page into it: { - PageFragmentDC memoryDC(&printer, large, rect); + PageFragmentDC memoryDC(&printer, large, + rect.GetPosition(), + wxSize(pageWidth, pageHeight)); if ( !memoryDC.IsOk() ) return false; @@ -2045,6 +2052,7 @@ static bool RenderPageIntoBitmapHQ(wxPrintPreviewBase *preview, printerDC, bmpDC, todo, + pageWidth, pageHeight, pageNum) ) { if ( todo.height < 20 )