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:
@@ -62,30 +62,19 @@ public:
|
||||
const wxString& normal_face = wxEmptyString,
|
||||
const wxString& fixed_face = wxEmptyString);
|
||||
|
||||
// Finds the next page break after the specified (vertical) position.
|
||||
// Returns wxNOT_FOUND if passed in position is the last page break.
|
||||
int FindNextPageBreak(const wxArrayInt& known_pagebreaks, int pos);
|
||||
|
||||
// [x,y] is position of upper-left corner of printing rectangle (see SetSize)
|
||||
// from is y-coordinate of the very first visible cell
|
||||
// to is y-coordinate of the next following page break, if any
|
||||
// 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 multiple pages
|
||||
// document
|
||||
// If dont_render is TRUE then nothing is rendered into DC and it only counts
|
||||
// pixels and return y coord of the next page
|
||||
//
|
||||
// known_pagebreaks and number_of_pages are used only when counting pages;
|
||||
// otherwise, their default values should be used. Their purpose is to
|
||||
// support pagebreaks using a subset of CSS2's <DIV>. The <DIV> handler
|
||||
// needs to know what pagebreaks have already been set so that it doesn't
|
||||
// set the same pagebreak twice.
|
||||
//
|
||||
// CAUTION! Render() changes DC's user scale and does NOT restore it!
|
||||
int Render(int x, int y, const 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);
|
||||
|
||||
// returns total width of the html document
|
||||
int GetTotalWidth() const;
|
||||
|
||||
// returns total height of the html document
|
||||
// (compare Render's return value with this)
|
||||
int GetTotalHeight() const;
|
||||
|
||||
private:
|
||||
|
Reference in New Issue
Block a user