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/trunk@55134 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -465,42 +465,48 @@ namespace
|
|||||||
class PageFragmentDCImpl : public wxMemoryDCImpl
|
class PageFragmentDCImpl : public wxMemoryDCImpl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PageFragmentDCImpl(wxMemoryDC *owner, wxDC *printer, const wxRect& rect)
|
PageFragmentDCImpl(wxMemoryDC *owner, wxDC *printer,
|
||||||
|
const wxPoint& offset,
|
||||||
|
const wxSize& fullSize)
|
||||||
: wxMemoryDCImpl(owner, printer),
|
: wxMemoryDCImpl(owner, printer),
|
||||||
m_rect(rect)
|
m_offset(offset),
|
||||||
|
m_fullSize(fullSize)
|
||||||
{
|
{
|
||||||
SetDeviceOrigin(0, 0);
|
SetDeviceOrigin(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void SetDeviceOrigin(wxCoord x, wxCoord y)
|
virtual void SetDeviceOrigin(wxCoord x, wxCoord y)
|
||||||
{
|
{
|
||||||
wxMemoryDCImpl::SetDeviceOrigin(x - m_rect.x, y - m_rect.y);
|
wxMemoryDCImpl::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
|
||||||
{
|
{
|
||||||
wxMemoryDCImpl::DoGetDeviceOrigin(x, y);
|
wxMemoryDCImpl::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;
|
||||||
};
|
};
|
||||||
|
|
||||||
class PageFragmentDC : public wxDC
|
class PageFragmentDC : public wxDC
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PageFragmentDC(wxDC* printer, wxBitmap& bmp, const wxRect& rect)
|
PageFragmentDC(wxDC* printer, wxBitmap& bmp,
|
||||||
: wxDC(new PageFragmentDCImpl((wxMemoryDC*)this, printer, rect))
|
const wxPoint& offset,
|
||||||
|
const wxSize& fullSize)
|
||||||
|
: wxDC(new PageFragmentDCImpl((wxMemoryDC*)this, printer, offset, fullSize))
|
||||||
{
|
{
|
||||||
wx_static_cast(PageFragmentDCImpl*, m_pimpl)->DoSelect(bmp);
|
wx_static_cast(PageFragmentDCImpl*, m_pimpl)->DoSelect(bmp);
|
||||||
}
|
}
|
||||||
@@ -583,7 +589,9 @@ bool wxWindowsPrintPreview::RenderPageFragment(float scaleX, float scaleY,
|
|||||||
|
|
||||||
// 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(m_pageWidth, m_pageHeight));
|
||||||
if ( !memoryDC.IsOk() )
|
if ( !memoryDC.IsOk() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user