diff --git a/docs/changes.txt b/docs/changes.txt index 9275e58a29..f59a0fd64e 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -69,6 +69,9 @@ Changes in behaviour which may result in build errors - wxHtmlDCRenderer::Render() arguments have changed, simply omit the ones not existing in the function signature any more to update the code using it. +- wxHtmlCell::AdjustPagebreak() has lost its "known_pagebreaks" argument, + update your code if you override this method (you shouldn't be calling it). + 3.1.2: (released 2018-??-??) ---------------------------- diff --git a/include/wx/html/htmlcell.h b/include/wx/html/htmlcell.h index 80535d39f3..282b7cd964 100644 --- a/include/wx/html/htmlcell.h +++ b/include/wx/html/htmlcell.h @@ -279,16 +279,20 @@ public: const wxPoint& pos, const wxMouseEvent& event); - // This method used to adjust pagebreak position. The parameter is variable - // that contains y-coordinate of page break (= horizontal line that should - // not be crossed by words, images etc.). If this cell cannot be divided - // into two pieces (each one on another page) then it moves the pagebreak - // few pixels up. + // This method is called when paginating HTML, e.g. when printing. + // + // On input, pagebreak contains y-coordinate of page break (i.e. the + // horizontal line that should not be crossed by words, images etc.) + // relative to the parent cell on entry and may be modified to request a + // page break at a position before it if this cell cannot be divided into + // two pieces (each one on its own page). + // + // Note that page break must still happen on the current page, i.e. the + // returned value must be strictly greater than "*pagebreak - pageHeight" + // and less or equal to "*pagebreak" for the value of pagebreak on input. // // Returned value : true if pagebreak was modified, false otherwise - virtual bool AdjustPagebreak(int *pagebreak, - const wxArrayInt& known_pagebreaks, - int pageHeight) const; + virtual bool AdjustPagebreak(int *pagebreak, int pageHeight) const; // Sets cell's behaviour on pagebreaks (see AdjustPagebreak). Default // is true - the cell can be split on two pages @@ -450,9 +454,7 @@ public: virtual void DrawInvisible(wxDC& dc, int x, int y, wxHtmlRenderingInfo& info) wxOVERRIDE; - virtual bool AdjustPagebreak(int *pagebreak, - const wxArrayInt& known_pagebreaks, - int pageHeight) const wxOVERRIDE; + virtual bool AdjustPagebreak(int *pagebreak, int pageHeight) const wxOVERRIDE; // insert cell at the end of m_Cells list void InsertCell(wxHtmlCell *cell); diff --git a/include/wx/html/htmprint.h b/include/wx/html/htmprint.h index 8bd6d67e91..7edfa808db 100644 --- a/include/wx/html/htmprint.h +++ b/include/wx/html/htmprint.h @@ -64,7 +64,7 @@ public: // 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); + int FindNextPageBreak(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 diff --git a/interface/wx/html/htmlcell.h b/interface/wx/html/htmlcell.h index 1ad5aa7382..18b05a8a00 100644 --- a/interface/wx/html/htmlcell.h +++ b/interface/wx/html/htmlcell.h @@ -187,28 +187,31 @@ public: wxHtmlCell(); /** - This method is used to adjust pagebreak position. - The first parameter is a variable that contains the y-coordinate of the page break - (= horizontal line that should not be crossed by words, images etc.). - If this cell cannot be divided into two pieces (each one on another page) - then it either moves the pagebreak a few pixels up, if possible, or, if - the cell cannot fit on the page at all, then the cell is forced to - split unconditionally. + This method is called when paginating HTML, e.g.\ when printing. - Returns @true if pagebreak was modified, @false otherwise. + User code should never call this function, but may need to override it + in custom HTML cell classes with any specific page breaking + requirements. + + On input, @a pagebreak contains y-coordinate of page break (i.e. the + horizontal line that should not be crossed by words, images etc.) + relative to the parent cell on entry and may be modified to request a + page break at a position before it if this cell cannot be divided into + two pieces (each one on its own page). + + Note that page break must still happen on the current page, i.e. the + returned value must be strictly greater than @code *pagebreak - + pageHeight @endcode and less or equal to @c *pagebreak for the value of + @a pagebreak on input. @param pagebreak position in pixels of the pagebreak. - - @param known_pagebreaks - the list of the previous pagebreaks - @param pageHeight the height in pixels of the page drawable area + + @return @true if pagebreak was modified, @false otherwise. */ - virtual bool AdjustPagebreak(int* pagebreak, - const wxArrayInt& known_pagebreaks, - int pageHeight) const; + virtual bool AdjustPagebreak(int* pagebreak, int pageHeight) const; /** Renders the cell. diff --git a/src/html/htmlcell.cpp b/src/html/htmlcell.cpp index 0f14760198..176c5e79c4 100644 --- a/src/html/htmlcell.cpp +++ b/src/html/htmlcell.cpp @@ -157,9 +157,7 @@ wxHtmlCell::GetMouseCursorAt(wxHtmlWindowInterface *window, bool -wxHtmlCell::AdjustPagebreak(int *pagebreak, - const wxArrayInt& WXUNUSED(known_pagebreaks), - int pageHeight) const +wxHtmlCell::AdjustPagebreak(int *pagebreak, int pageHeight) const { // Notice that we always break the cells bigger than the page height here // as otherwise we wouldn't be able to break them at all. @@ -697,19 +695,17 @@ int wxHtmlContainerCell::GetIndentUnits(int ind) const bool -wxHtmlContainerCell::AdjustPagebreak(int *pagebreak, - const wxArrayInt& known_pagebreaks, - int pageHeight) const +wxHtmlContainerCell::AdjustPagebreak(int *pagebreak, int pageHeight) const { if (!m_CanLiveOnPagebreak) - return wxHtmlCell::AdjustPagebreak(pagebreak, known_pagebreaks, pageHeight); + return wxHtmlCell::AdjustPagebreak(pagebreak, pageHeight); bool rt = false; int pbrk = *pagebreak - m_PosY; for ( wxHtmlCell *c = GetFirstChild(); c; c = c->GetNext() ) { - if (c->AdjustPagebreak(&pbrk, known_pagebreaks, pageHeight)) + if (c->AdjustPagebreak(&pbrk, pageHeight)) rt = true; } if (rt) diff --git a/src/html/htmprint.cpp b/src/html/htmprint.cpp index f42b008fff..199f89b835 100644 --- a/src/html/htmprint.cpp +++ b/src/html/htmprint.cpp @@ -140,8 +140,7 @@ void wxHtmlDCRenderer::SetStandardFonts(int size, // else: SetHtmlText() not yet called, no need for relayout } -int wxHtmlDCRenderer::FindNextPageBreak(const wxArrayInt& known_pagebreaks, - int pos) +int wxHtmlDCRenderer::FindNextPageBreak(int pos) { // Stop looking for page breaks if the previous one was already at the end // of the last page. @@ -152,7 +151,7 @@ int wxHtmlDCRenderer::FindNextPageBreak(const wxArrayInt& known_pagebreaks, return wxNOT_FOUND; int posNext = pos + m_Height; - if ( m_Cells->AdjustPagebreak(&posNext, known_pagebreaks, m_Height) ) + if ( m_Cells->AdjustPagebreak(&posNext, m_Height) ) { // Check that AdjustPagebreak() returns the page break at a strictly // greater position than that of the previous page, otherwise @@ -486,7 +485,7 @@ void wxHtmlPrintout::CountPages() for ( int pos = 0; pos != wxNOT_FOUND; ) { m_PageBreaks.Add( pos); - pos = m_Renderer.FindNextPageBreak(m_PageBreaks, pos); + pos = m_Renderer.FindNextPageBreak(pos); } } diff --git a/src/html/m_layout.cpp b/src/html/m_layout.cpp index 4dba82e6d1..95b0afbab2 100644 --- a/src/html/m_layout.cpp +++ b/src/html/m_layout.cpp @@ -65,9 +65,7 @@ class wxHtmlPageBreakCell : public wxHtmlCell public: wxHtmlPageBreakCell() {} - bool AdjustPagebreak(int* pagebreak, - const wxArrayInt& known_pagebreaks, - int pageHeight) const wxOVERRIDE; + bool AdjustPagebreak(int* pagebreak, int pageHeight) const wxOVERRIDE; void Draw(wxDC& WXUNUSED(dc), int WXUNUSED(x), int WXUNUSED(y), @@ -79,9 +77,7 @@ private: }; bool -wxHtmlPageBreakCell::AdjustPagebreak(int* pagebreak, - const wxArrayInt& WXUNUSED(known_pagebreaks), - int pageHeight) const +wxHtmlPageBreakCell::AdjustPagebreak(int* pagebreak, int pageHeight) const { // Request a page break at the position of this cell if it's on the current // page. Note that it's important not to do it unconditionally or we could