From db98870d823a8293e1cb91e852d830ba74374c2a Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Sun, 10 Oct 1999 20:17:42 +0000 Subject: [PATCH] preparing for HTML printing git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3919 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/html/htmlcell.h | 19 ++++++++++++++++++- include/wx/html/htmldefs.h | 6 ++++-- src/html/htmlcell.cpp | 38 ++++++++++++++++++++++++++++++++++++++ src/html/m_image.cpp | 1 + 4 files changed, 61 insertions(+), 3 deletions(-) diff --git a/include/wx/html/htmlcell.h b/include/wx/html/htmlcell.h index 7d725e29e1..862f7ebebb 100644 --- a/include/wx/html/htmlcell.h +++ b/include/wx/html/htmlcell.h @@ -38,7 +38,7 @@ class wxHtmlContainerCell; class WXDLLEXPORT wxHtmlCell : public wxObject { public: - wxHtmlCell() : wxObject() {m_Next = NULL; m_Parent = NULL; m_Width = m_Height = m_Descent = 0;}; + wxHtmlCell() : wxObject() {m_Next = NULL; m_Parent = NULL; m_Width = m_Height = m_Descent = 0; m_CanLiveOnPagebreak = TRUE;} virtual ~wxHtmlCell() {if (m_Next) delete m_Next;}; void SetParent(wxHtmlContainerCell *p) {m_Parent = p;} @@ -94,6 +94,20 @@ class WXDLLEXPORT wxHtmlCell : public wxObject // Parent is pointer to wxHtmlWindow that generated the event // HINT: if this handling is not enough for you you should use // wxHtmlBinderCell + + virtual bool AdjustPagebreak(int *pagebreak); + // 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. + // + // Returned value : true if pagebreak was modified, false otherwise + // Usage : while (container->AdjustPagebreak(&p)) {} + + void SetCanLiveOnPagebreak(bool can) {m_CanLiveOnPagebreak = can;} + // Sets cell's behaviour on pagebreaks (see AdjustPagebreak). Default + // is true - the cell can be split on two pages protected: @@ -108,6 +122,8 @@ class WXDLLEXPORT wxHtmlCell : public wxObject // position where the fragment is drawn wxString m_Link; // destination address if this fragment is hypertext link, "" otherwise + bool m_CanLiveOnPagebreak; + // true if this cell can be placed on pagebreak, false otherwise }; @@ -175,6 +191,7 @@ class WXDLLEXPORT wxHtmlContainerCell : public wxHtmlCell virtual void Layout(int w); virtual void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2); virtual void DrawInvisible(wxDC& dc, int x, int y); + virtual bool AdjustPagebreak(int *pagebreak); void InsertCell(wxHtmlCell *cell); // insert cell at the end of m_Cells list diff --git a/include/wx/html/htmldefs.h b/include/wx/html/htmldefs.h index 6b0e43dbaf..fb316d43ba 100644 --- a/include/wx/html/htmldefs.h +++ b/include/wx/html/htmldefs.h @@ -77,8 +77,8 @@ #define HTML_COND_ISIMAGEMAP 2 // Finds imagemap of 'param' name (pointer to wxString). - // (used exclusively by mod_image.cpp) - + // (used exclusively by m_image.cpp) + #define HTML_COND_USER 10000 // User-defined conditions should start from this number @@ -94,6 +94,8 @@ /* size of temporary buffer used during parsing */ #define HTML_REALLOC_STEP 32 /* steps of array reallocation */ +#define HTML_PRINT_MAX_PAGES 999 + /* maximum number of pages printable via html printing */ #endif #endif diff --git a/src/html/htmlcell.cpp b/src/html/htmlcell.cpp index dd4e4502a7..ac40ae3c7f 100644 --- a/src/html/htmlcell.cpp +++ b/src/html/htmlcell.cpp @@ -46,6 +46,25 @@ void wxHtmlCell::OnMouseClick(wxWindow *parent, int x, int y, +bool wxHtmlCell::AdjustPagebreak(int *pagebreak) +{ + + if ((!m_CanLiveOnPagebreak) && + m_PosY < *pagebreak && m_PosY + m_Height >= *pagebreak) { + *pagebreak = m_PosY; + if (m_Next != NULL) m_Next -> AdjustPagebreak(pagebreak); + return TRUE; + } + + else { + if (m_Next != NULL) return m_Next -> AdjustPagebreak(pagebreak); + else return FALSE; + } +} + + + + //----------------------------------------------------------------------------- // wxHtmlWordCell //----------------------------------------------------------------------------- @@ -59,6 +78,7 @@ wxHtmlWordCell::wxHtmlWordCell(const wxString& word, wxDC& dc) : wxHtmlCell() m_Word.Replace(">", ">", TRUE); m_Word.Replace("&", "&", TRUE); dc.GetTextExtent(m_Word, &m_Width, &m_Height, &m_Descent); + SetCanLiveOnPagebreak(FALSE); } @@ -129,6 +149,24 @@ int wxHtmlContainerCell::GetIndentUnits(int ind) const +bool wxHtmlContainerCell::AdjustPagebreak(int *pagebreak) +{ + if (!m_CanLiveOnPagebreak) + return wxHtmlCell::AdjustPagebreak(pagebreak); + else { + wxHtmlCell *c = GetFirstCell(); + bool rt = FALSE; + + while (c) { + if (c -> AdjustPagebreak(pagebreak)) rt = TRUE; + c = c -> GetNext(); + } + return rt; + } +} + + + void wxHtmlContainerCell::Layout(int w) { wxHtmlCell *cell = m_Cells, *line = m_Cells; diff --git a/src/html/m_image.cpp b/src/html/m_image.cpp index 60bb5f5734..5fb966afa4 100644 --- a/src/html/m_image.cpp +++ b/src/html/m_image.cpp @@ -321,6 +321,7 @@ wxHtmlImageCell::wxHtmlImageCell(wxFSFile *input, int w, int h, int align, wxStr m_ImageMap = NULL; m_MapName = mapname; + SetCanLiveOnPagebreak(FALSE); } -- 2.45.2