Split and simplify wxHtmlDCRenderer::Render()
This function was difficult to understand as it did two quite different things depending on the value of its "dont_render" argument and using it also made CountPages() logic more complicated than necessary. Simplify the code by splitting Render() into FindNextPageBreak(), which is used by CountPages(), and Render() itself, which doesn't need to deal with pagination at all as it's either already provided the page start and end positions or can just assume that everything fits on a single page (the latter is the case for the headers and footers renderer). This is a notionally backwards-incompatible change, but no code using wxHtmlDCRenderer could be found in the wild and the new API is so much simpler that it seems to be worth switching to it.
This commit is contained in:
@@ -38,10 +38,9 @@ public:
|
||||
/**
|
||||
Returns the height of the HTML text in pixels.
|
||||
|
||||
This is important if area height (see wxHtmlDCRenderer::SetSize) is
|
||||
smaller that total height and thus the page cannot fit into it. In that
|
||||
case you're supposed to call Render() as long as its return value is
|
||||
smaller than GetTotalHeight()'s.
|
||||
If the height of the area used with this renderer (see
|
||||
wxHtmlDCRenderer::SetSize) is smaller that total height, the renderer
|
||||
will produce more than one page of output.
|
||||
|
||||
@see GetTotalWidth()
|
||||
*/
|
||||
@@ -52,19 +51,11 @@ public:
|
||||
|
||||
@param x,y
|
||||
position of upper-left corner of printing rectangle (see SetSize()).
|
||||
@param known_pagebreaks
|
||||
@todo docme
|
||||
@param from
|
||||
y-coordinate of the very first visible cell.
|
||||
@param dont_render
|
||||
if @true then this method only returns y coordinate of the next page
|
||||
and does not output anything.
|
||||
@param to
|
||||
y-coordinate of the last visible cell.
|
||||
|
||||
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.
|
||||
y-coordinate of the last visible cell or @c INT_MAX to use the full
|
||||
page height.
|
||||
|
||||
@note
|
||||
The following three methods @b must always be called before any call to
|
||||
@@ -72,11 +63,8 @@ public:
|
||||
- SetDC()
|
||||
- SetSize()
|
||||
- SetHtmlText()
|
||||
|
||||
@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 dont_render = false, int to = INT_MAX);
|
||||
void Render(int x, int y, int from = 0, int to = INT_MAX);
|
||||
|
||||
/**
|
||||
Assign DC instance to the renderer.
|
||||
|
Reference in New Issue
Block a user