added asserts to check correct order of wxHtmlDCRenderer methods calls
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@59071 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -48,15 +48,17 @@ public:
|
|||||||
y-coordinate of the last visible cell.
|
y-coordinate of the last visible cell.
|
||||||
|
|
||||||
Returned value is y coordinate of first cell than didn't fit onto page.
|
Returned value is y coordinate of first cell than didn't fit onto page.
|
||||||
Use this value as from in next call to Render() in order to print multipages document.
|
Use this value as from in next call to Render() in order to print
|
||||||
|
multipages document.
|
||||||
|
|
||||||
@warning
|
@note
|
||||||
The Following three methods @b must always be called before any call to
|
The following three methods @b must always be called before any call to
|
||||||
Render() (preferably in this order):
|
Render(), in this order:
|
||||||
- SetDC()
|
- SetDC()
|
||||||
- SetSize()
|
- SetSize()
|
||||||
- SetHtmlText()
|
- SetHtmlText()
|
||||||
<b>Render() changes the DC's user scale and does NOT restore it.</b>
|
|
||||||
|
@note Render() changes the DC's user scale and does NOT restore it.
|
||||||
*/
|
*/
|
||||||
int Render(int x, int y, wxArrayInt& known_pagebreaks, int from = 0,
|
int Render(int x, int y, wxArrayInt& known_pagebreaks, int from = 0,
|
||||||
int dont_render = false, int to = INT_MAX);
|
int dont_render = false, int to = INT_MAX);
|
||||||
|
@@ -74,6 +74,9 @@ void wxHtmlDCRenderer::SetDC(wxDC *dc, double pixel_scale)
|
|||||||
|
|
||||||
void wxHtmlDCRenderer::SetSize(int width, int height)
|
void wxHtmlDCRenderer::SetSize(int width, int height)
|
||||||
{
|
{
|
||||||
|
wxCHECK_RET( width, "width must be non-zero" );
|
||||||
|
wxCHECK_RET( height, "height must be non-zero" );
|
||||||
|
|
||||||
m_Width = width;
|
m_Width = width;
|
||||||
m_Height = height;
|
m_Height = height;
|
||||||
}
|
}
|
||||||
@@ -81,9 +84,10 @@ void wxHtmlDCRenderer::SetSize(int width, int height)
|
|||||||
|
|
||||||
void wxHtmlDCRenderer::SetHtmlText(const wxString& html, const wxString& basepath, bool isdir)
|
void wxHtmlDCRenderer::SetHtmlText(const wxString& html, const wxString& basepath, bool isdir)
|
||||||
{
|
{
|
||||||
if (m_DC == NULL) return;
|
wxCHECK_RET( m_DC, "SetDC() must be called before SetHtmlText()" );
|
||||||
|
wxCHECK_RET( m_Width, "SetSize() must be called before SetHtmlText()" );
|
||||||
|
|
||||||
if (m_Cells != NULL) delete m_Cells;
|
wxDELETE(m_Cells);
|
||||||
|
|
||||||
m_FS->ChangePathTo(basepath, isdir);
|
m_FS->ChangePathTo(basepath, isdir);
|
||||||
m_Cells = (wxHtmlContainerCell*) m_Parser->Parse(html);
|
m_Cells = (wxHtmlContainerCell*) m_Parser->Parse(html);
|
||||||
@@ -96,8 +100,10 @@ void wxHtmlDCRenderer::SetFonts(const wxString& normal_face, const wxString& fix
|
|||||||
const int *sizes)
|
const int *sizes)
|
||||||
{
|
{
|
||||||
m_Parser->SetFonts(normal_face, fixed_face, sizes);
|
m_Parser->SetFonts(normal_face, fixed_face, sizes);
|
||||||
if (m_DC == NULL && m_Cells != NULL)
|
|
||||||
|
if ( m_Cells )
|
||||||
m_Cells->Layout(m_Width);
|
m_Cells->Layout(m_Width);
|
||||||
|
// else: SetHtmlText() not yet called, no need for relayout
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxHtmlDCRenderer::SetStandardFonts(int size,
|
void wxHtmlDCRenderer::SetStandardFonts(int size,
|
||||||
@@ -105,17 +111,20 @@ void wxHtmlDCRenderer::SetStandardFonts(int size,
|
|||||||
const wxString& fixed_face)
|
const wxString& fixed_face)
|
||||||
{
|
{
|
||||||
m_Parser->SetStandardFonts(size, normal_face, fixed_face);
|
m_Parser->SetStandardFonts(size, normal_face, fixed_face);
|
||||||
if (m_DC == NULL && m_Cells != NULL)
|
|
||||||
|
if ( m_Cells )
|
||||||
m_Cells->Layout(m_Width);
|
m_Cells->Layout(m_Width);
|
||||||
|
// else: SetHtmlText() not yet called, no need for relayout
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxHtmlDCRenderer::Render(int x, int y,
|
int wxHtmlDCRenderer::Render(int x, int y,
|
||||||
wxArrayInt& known_pagebreaks,
|
wxArrayInt& known_pagebreaks,
|
||||||
int from, int dont_render, int to)
|
int from, int dont_render, int to)
|
||||||
{
|
{
|
||||||
int pbreak, hght;
|
wxCHECK_MSG( m_Cells, 0, "SetHtmlText() must be called before Render()" );
|
||||||
|
wxCHECK_MSG( m_DC, 0, "SetDC() must be called before Render()" );
|
||||||
|
|
||||||
if (m_Cells == NULL || m_DC == NULL) return 0;
|
int pbreak, hght;
|
||||||
|
|
||||||
pbreak = (int)(from + m_Height);
|
pbreak = (int)(from + m_Height);
|
||||||
while (m_Cells->AdjustPagebreak(&pbreak, known_pagebreaks)) {}
|
while (m_Cells->AdjustPagebreak(&pbreak, known_pagebreaks)) {}
|
||||||
|
Reference in New Issue
Block a user