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
This commit is contained in:
Václav Slavík
2008-08-20 21:59:10 +00:00
parent b43a0635a2
commit 49ad7c5115

View File

@@ -1856,9 +1856,12 @@ namespace
class PageFragmentDC : public wxMemoryDC class PageFragmentDC : public wxMemoryDC
{ {
public: public:
PageFragmentDC(wxDC *printer, wxBitmap& bmp, const wxRect& rect) PageFragmentDC(wxDC *printer, wxBitmap& bmp,
const wxPoint& offset,
const wxSize& fullSize)
: wxMemoryDC(printer), : wxMemoryDC(printer),
m_rect(rect) m_offset(offset),
m_fullSize(fullSize)
{ {
SetDeviceOrigin(0, 0); SetDeviceOrigin(0, 0);
SelectObject(bmp); SelectObject(bmp);
@@ -1866,26 +1869,27 @@ public:
virtual void SetDeviceOrigin(wxCoord x, wxCoord y) 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 virtual void DoGetDeviceOrigin(wxCoord *x, wxCoord *y) const
{ {
wxMemoryDC::DoGetDeviceOrigin(x, y); wxMemoryDC::DoGetDeviceOrigin(x, y);
if ( x ) *x += m_rect.x; if ( x ) *x += m_offset.x;
if ( x ) *y += m_rect.y; if ( x ) *y += m_offset.y;
} }
virtual void DoGetSize(int *width, int *height) const virtual void DoGetSize(int *width, int *height) const
{ {
if ( width ) if ( width )
*width = m_rect.width; *width = m_fullSize.x;
if ( height ) if ( height )
*height = m_rect.height; *height = m_fullSize.y;
} }
private: private:
wxRect m_rect; wxPoint m_offset;
wxSize m_fullSize;
}; };
// estimate how big chunks we can render, given available RAM // estimate how big chunks we can render, given available RAM
@@ -1947,6 +1951,7 @@ static bool RenderPageFragment(wxPrintPreviewBase *preview,
wxPrinterDC& printer, wxPrinterDC& printer,
wxMemoryDC& finalDC, wxMemoryDC& finalDC,
const wxRect& rect, const wxRect& rect,
int pageHeight, int pageWidth,
int pageNum) int pageNum)
{ {
// compute 'rect' equivalent in the small final bitmap: // compute 'rect' equivalent in the small final bitmap:
@@ -1967,7 +1972,9 @@ static bool RenderPageFragment(wxPrintPreviewBase *preview,
// render part of the page into it: // render part of the page into it:
{ {
PageFragmentDC memoryDC(&printer, large, rect); PageFragmentDC memoryDC(&printer, large,
rect.GetPosition(),
wxSize(pageWidth, pageHeight));
if ( !memoryDC.IsOk() ) if ( !memoryDC.IsOk() )
return false; return false;
@@ -2045,6 +2052,7 @@ static bool RenderPageIntoBitmapHQ(wxPrintPreviewBase *preview,
printerDC, printerDC,
bmpDC, bmpDC,
todo, todo,
pageWidth, pageHeight,
pageNum) ) pageNum) )
{ {
if ( todo.height < 20 ) if ( todo.height < 20 )