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;}
// 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:
// 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
};
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
#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
/* 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
+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
//-----------------------------------------------------------------------------
m_Word.Replace(">", ">", TRUE);
m_Word.Replace("&", "&", TRUE);
dc.GetTextExtent(m_Word, &m_Width, &m_Height, &m_Descent);
+ SetCanLiveOnPagebreak(FALSE);
}
+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;