X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/6acba9a7194b30113636efb08e0b165f91011e79..032e024c1c6ab6a20226604baab9d00558620e72:/include/wx/html/htmprint.h diff --git a/include/wx/html/htmprint.h b/include/wx/html/htmprint.h index eabe41acf4..b5da2bad87 100644 --- a/include/wx/html/htmprint.h +++ b/include/wx/html/htmprint.h @@ -4,23 +4,20 @@ // Author: Vaclav Slavik // Created: 25/09/99 // RCS-ID: $Id$ -// Copyright: (c) +// Copyright: (c) Vaclav Slavik // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_HTMPRINT_H_ #define _WX_HTMPRINT_H_ -#if defined(__GNUG__) && !defined(__APPLE__) -#pragma interface "htmprint.h" -#endif - #include "wx/defs.h" #if wxUSE_HTML & wxUSE_PRINTING_ARCHITECTURE #include "wx/html/htmlcell.h" #include "wx/html/winpars.h" +#include "wx/html/htmlfilt.h" #include "wx/print.h" #include "wx/printdlg.h" @@ -29,7 +26,7 @@ //-------------------------------------------------------------------------------- // wxHtmlDCRenderer -// This class is capable of rendering HTML into specified +// This class is capable of rendering HTML into specified // portion of DC //-------------------------------------------------------------------------------- @@ -37,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: @@ -51,12 +48,18 @@ public: // Sets the text to be displayed. // Basepath is base directory (html string would be stored there if it was in // file). It is used to determine path for loading images, for example. - // isdir is FALSE if basepath is filename, TRUE if it is directory name + // isdir is false if basepath is filename, true if it is directory name // (see wxFileSystem for detailed explanation) - void SetHtmlText(const wxString& html, const wxString& basepath = wxEmptyString, bool isdir = TRUE); + 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 + void SetStandardFonts(int size = -1, + const wxString& normal_face = wxEmptyString, + const wxString& fixed_face = wxEmptyString); // [x,y] is position of upper-left corner of printing rectangle (see SetSize) // from is y-coordinate of the very first visible cell @@ -74,12 +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 to = 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; @@ -88,7 +94,7 @@ private: wxHtmlContainerCell *m_Cells; int m_MaxWidth, m_Width, m_Height; - DECLARE_NO_COPY_CLASS(wxHtmlDCRenderer) + wxDECLARE_NO_COPY_CLASS(wxHtmlDCRenderer); }; @@ -105,7 +111,7 @@ enum { //-------------------------------------------------------------------------------- // wxHtmlPrintout -// This class is derived from standard wxWindows printout class +// This class is derived from standard wxWidgets printout class // and is used to print HTML documents. //-------------------------------------------------------------------------------- @@ -114,15 +120,15 @@ 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); + void SetHtmlText(const wxString& html, const wxString &basepath = wxEmptyString, bool isdir = true); // prepares the class for printing this html document. // Must be called before using the class, in fact just after constructor // // basepath is base directory (html string would be stored there if it was in // file). It is used to determine path for loading images, for example. - // isdir is FALSE if basepath is filename, TRUE if it is directory name + // isdir is false if basepath is filename, true if it is directory name // (see wxFileSystem for detailed explanation) void SetHtmlFile(const wxString &htmlfile); @@ -139,20 +145,45 @@ 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 + void SetStandardFonts(int size = -1, + const wxString& normal_face = wxEmptyString, + const wxString& fixed_face = wxEmptyString); - void SetMargins(float top = 25.2, float bottom = 25.2, float left = 25.2, float right = 25.2, + void SetMargins(float top = 25.2, float bottom = 25.2, float left = 25.2, float right = 25.2, float spaces = 5); // sets margins in milimeters. Defaults to 1 inch for margins and 0.5cm for space // between text and header and/or footer - // wxPrintout stuff: + // wxPrintout stuff: bool OnPrintPage(int page); bool HasPage(int page); void GetPageInfo(int *minPage, int *maxPage, int *selPageFrom, int *selPageTo); bool OnBeginDocument(int startPage, int endPage); + void OnPreparePrinting(); + + // Adds input filter + static void AddFilter(wxHtmlFilter *filter); + + // Cleanup + 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 @@ -164,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; @@ -174,7 +206,10 @@ private: wxHtmlDCRenderer *m_Renderer, *m_RendererHdr; float m_MarginTop, m_MarginBottom, m_MarginLeft, m_MarginRight, m_MarginSpace; - DECLARE_NO_COPY_CLASS(wxHtmlPrintout) + // list of HTML filters + static wxList m_Filters; + + wxDECLARE_NO_COPY_CLASS(wxHtmlPrintout); }; @@ -183,12 +218,12 @@ private: //-------------------------------------------------------------------------------- // wxHtmlEasyPrinting -// This class provides very simple interface to printing +// This class provides very simple interface to printing // architecture. It allows you to print HTML documents only -// with very few commands. +// with very few commands. // // Note : do not create this class on stack only. -// You should create an instance on app startup and +// You should create an instance on app startup and // use this instance for all printing. Why? The class // stores page&printer settings in it. //-------------------------------------------------------------------------------- @@ -197,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); @@ -209,7 +244,6 @@ public: bool PrintText(const wxString &htmltext, const wxString& basepath = wxEmptyString); // Print file / html-text w/o preview - void PrinterSetup(); void PageSetup(); // pop up printer or page setup dialog @@ -223,14 +257,30 @@ 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) - wxPrintData *GetPrintData() {return m_PrintData;} + // Sets font sizes to be relative to the given size or the system + // default size; use either specified or default font + void SetStandardFonts(int size = -1, + const wxString& normal_face = wxEmptyString, + const wxString& fixed_face = wxEmptyString); + + wxPrintData *GetPrintData(); wxPageSetupDialogData *GetPageSetupData() {return m_PageSetupData;} - // return page setting data objects. + // 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 + + const wxString& GetName() const { return m_Name; } + // get the printout name + void SetName(const wxString& name) { m_Name = name; } + // set the printout name + protected: virtual wxHtmlPrintout *CreatePrintout(); virtual bool DoPreview(wxHtmlPrintout *printout1, wxHtmlPrintout *printout2); @@ -243,10 +293,18 @@ private: int m_FontsSizesArr[7]; int *m_FontsSizes; wxString m_FontFaceFixed, m_FontFaceNormal; + + enum FontMode + { + FontMode_Explicit, + FontMode_Standard + }; + FontMode m_fontMode; + wxString m_Headers[2], m_Footers[2]; wxWindow *m_ParentWindow; - DECLARE_NO_COPY_CLASS(wxHtmlEasyPrinting) + wxDECLARE_NO_COPY_CLASS(wxHtmlEasyPrinting); };