X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8907154c1a8a6882c6797d1f16393ddfb23e7f3a..86ac84b8ce086e6bbda58f422d41f84268606e35:/include/wx/html/htmprint.h diff --git a/include/wx/html/htmprint.h b/include/wx/html/htmprint.h index 558f24130f..cf0a18fb12 100644 --- a/include/wx/html/htmprint.h +++ b/include/wx/html/htmprint.h @@ -34,7 +34,7 @@ class WXDLLIMPEXP_HTML wxHtmlDCRenderer : public wxObject { public: wxHtmlDCRenderer(); - ~wxHtmlDCRenderer(); + virtual ~wxHtmlDCRenderer(); // Following 3 methods *must* be called before any call to Render: @@ -53,7 +53,7 @@ public: void SetHtmlText(const wxString& html, const wxString& basepath = wxEmptyString, bool isdir = true); // Sets fonts to be used when displaying HTML page. (if size null then default sizes used). - void SetFonts(wxString normal_face, wxString fixed_face, const int *sizes = NULL); + void SetFonts(const wxString& normal_face, const wxString& fixed_face, const int *sizes = NULL); // Sets font sizes to be relative to the given size or the system // default size; use either specified or default font @@ -77,13 +77,15 @@ public: // set the same pagebreak twice. // // CAUTION! Render() changes DC's user scale and does NOT restore it! - int Render(int x, int y, int from = 0, int dont_render = FALSE, - int maxHeight = INT_MAX, - int *known_pagebreaks = NULL, int number_of_pages = 0); + int Render(int x, int y, wxArrayInt& known_pagebreaks, int from = 0, + int dont_render = false, 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(); + int GetTotalHeight() const; private: wxDC *m_DC; @@ -92,7 +94,7 @@ private: wxHtmlContainerCell *m_Cells; int m_MaxWidth, m_Width, m_Height; - DECLARE_NO_COPY_CLASS(wxHtmlDCRenderer) + wxDECLARE_NO_COPY_CLASS(wxHtmlDCRenderer); }; @@ -118,7 +120,7 @@ class WXDLLIMPEXP_HTML wxHtmlPrintout : public wxPrintout { public: wxHtmlPrintout(const wxString& title = wxT("Printout")); - ~wxHtmlPrintout(); + virtual ~wxHtmlPrintout(); void SetHtmlText(const wxString& html, const wxString &basepath = wxEmptyString, bool isdir = true); // prepares the class for printing this html document. @@ -143,7 +145,7 @@ public: // You can set different header/footer for odd and even pages // Sets fonts to be used when displaying HTML page. (if size null then default sizes used). - void SetFonts(wxString normal_face, wxString fixed_face, const int *sizes = NULL); + void SetFonts(const wxString& normal_face, const wxString& fixed_face, const int *sizes = NULL); // Sets font sizes to be relative to the given size or the system // default size; use either specified or default font @@ -170,6 +172,18 @@ public: static void CleanUpStatics(); private: + // this function is called by the base class OnPreparePrinting() + // implementation and by default checks whether the document fits into + // pageArea horizontally and warns the user if it does not, giving him + // the possibility to cancel printing in this case + // + // you may override it to either suppress this check if truncation of the + // HTML being printed is acceptable or, on the contrary, add more checks to + // it, e.g. for the fit in the vertical direction if the document should + // always appear on a single page + // + // return true if printing should go ahead or false to cancel it + virtual bool CheckFit(const wxSize& pageArea, const wxSize& docArea) const; void RenderPage(wxDC *dc, int page); // renders one page into dc @@ -181,7 +195,8 @@ private: private: int m_NumPages; - int m_PageBreaks[wxHTML_PRINT_MAX_PAGES]; + //int m_PageBreaks[wxHTML_PRINT_MAX_PAGES]; + wxArrayInt m_PageBreaks; wxString m_Document, m_BasePath; bool m_BasePathIsDir; @@ -194,7 +209,7 @@ private: // list of HTML filters static wxList m_Filters; - DECLARE_NO_COPY_CLASS(wxHtmlPrintout) + wxDECLARE_NO_COPY_CLASS(wxHtmlPrintout); }; @@ -217,7 +232,7 @@ class WXDLLIMPEXP_HTML wxHtmlEasyPrinting : public wxObject { public: wxHtmlEasyPrinting(const wxString& name = wxT("Printing"), wxWindow *parentWindow = NULL); - ~wxHtmlEasyPrinting(); + virtual ~wxHtmlEasyPrinting(); bool PreviewFile(const wxString &htmlfile); bool PreviewText(const wxString &htmltext, const wxString& basepath = wxEmptyString); @@ -242,7 +257,7 @@ public: // pg is one of wxPAGE_ODD, wxPAGE_EVEN and wx_PAGE_ALL constants. // You can set different header/footer for odd and even pages - void SetFonts(wxString normal_face, wxString fixed_face, const int *sizes = 0); + void SetFonts(const wxString& normal_face, const wxString& fixed_face, const int *sizes = 0); // Sets fonts to be used when displaying HTML page. (if size null then default sizes used) // Sets font sizes to be relative to the given size or the system @@ -256,6 +271,11 @@ public: // return page setting data objects. // (You can set their parameters.) + wxWindow* GetParentWindow() const { return m_ParentWindow; } + // get the parent window + void SetParentWindow(wxWindow* window) { m_ParentWindow = window; } + // set the parent window + protected: virtual wxHtmlPrintout *CreatePrintout(); virtual bool DoPreview(wxHtmlPrintout *printout1, wxHtmlPrintout *printout2); @@ -279,7 +299,7 @@ private: wxString m_Headers[2], m_Footers[2]; wxWindow *m_ParentWindow; - DECLARE_NO_COPY_CLASS(wxHtmlEasyPrinting) + wxDECLARE_NO_COPY_CLASS(wxHtmlEasyPrinting); };