X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a2e9bc18a899b69d88cd5224d0ff5b72fe72cab2..a9102b3671a45d116d781b0c8e90d2e9a84fbdcb:/include/wx/html/htmprint.h?ds=sidebyside diff --git a/include/wx/html/htmprint.h b/include/wx/html/htmprint.h index a68eb03f2f..df90a47dce 100644 --- a/include/wx/html/htmprint.h +++ b/include/wx/html/htmprint.h @@ -11,7 +11,7 @@ #ifndef _WX_HTMPRINT_H_ #define _WX_HTMPRINT_H_ -#ifdef __GNUG__ +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #pragma interface "htmprint.h" #endif @@ -21,17 +21,20 @@ #include "wx/html/htmlcell.h" #include "wx/html/winpars.h" +#include "wx/html/htmlfilt.h" #include "wx/print.h" #include "wx/printdlg.h" +#include // INT_MAX + //-------------------------------------------------------------------------------- // wxHtmlDCRenderer -// This class is capable of rendering HTML into specified +// This class is capable of rendering HTML into specified // portion of DC //-------------------------------------------------------------------------------- -class WXDLLEXPORT wxHtmlDCRenderer : public wxObject +class WXDLLIMPEXP_HTML wxHtmlDCRenderer : public wxObject { public: wxHtmlDCRenderer(); @@ -39,7 +42,7 @@ public: // Following 3 methods *must* be called before any call to Render: - // Asign DC to this render + // Assign DC to this render void SetDC(wxDC *dc, double pixel_scale = 1.0); // Sets size of output rectangle, in pixels. Note that you *can't* change @@ -49,20 +52,38 @@ 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); + + // 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 + // from is y-coordinate of the very first visible cell + // to is y-coordinate of the next following page break, if any // Returned value is y coordinate of first cell than didn't fit onto page. // Use this value as 'from' in next call to Render in order to print multiple pages // document // If dont_render is TRUE then nothing is rendered into DC and it only counts // pixels and return y coord of the next page // - // 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); + // known_pagebreaks and number_of_pages are used only when counting pages; + // otherwise, their default values should be used. Their purpose is to + // support pagebreaks using a subset of CSS2's
. The
handler + // needs to know what pagebreaks have already been set so that it doesn't + // 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); // returns total height of the html document // (compare Render's return value with this) @@ -74,6 +95,8 @@ private: wxFileSystem *m_FS; wxHtmlContainerCell *m_Cells; int m_MaxWidth, m_Width, m_Height; + + DECLARE_NO_COPY_CLASS(wxHtmlDCRenderer) }; @@ -90,24 +113,24 @@ 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. //-------------------------------------------------------------------------------- -class WXDLLEXPORT wxHtmlPrintout : public wxPrintout +class WXDLLIMPEXP_HTML wxHtmlPrintout : public wxPrintout { public: - wxHtmlPrintout(const wxString& title = "Printout"); + wxHtmlPrintout(const wxString& title = wxT("Printout")); ~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); @@ -123,16 +146,32 @@ 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 SetMargins(float top = 25.2, float bottom = 25.2, float left = 25.2, float right = 25.2, + // 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); + + // 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, 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: @@ -155,6 +194,11 @@ private: int m_HeaderHeight, m_FooterHeight; wxHtmlDCRenderer *m_Renderer, *m_RendererHdr; float m_MarginTop, m_MarginBottom, m_MarginLeft, m_MarginRight, m_MarginSpace; + + // list of HTML filters + static wxList m_Filters; + + DECLARE_NO_COPY_CLASS(wxHtmlPrintout) }; @@ -163,20 +207,20 @@ 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. //-------------------------------------------------------------------------------- -class WXDLLEXPORT wxHtmlEasyPrinting : public wxObject +class WXDLLIMPEXP_HTML wxHtmlEasyPrinting : public wxObject { public: - wxHtmlEasyPrinting(const wxString& name = "Printing", wxFrame *parent_frame = NULL); + wxHtmlEasyPrinting(const wxString& name = wxT("Printing"), wxWindow *parentWindow = NULL); ~wxHtmlEasyPrinting(); bool PreviewFile(const wxString &htmlfile); @@ -189,7 +233,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 @@ -203,12 +246,21 @@ 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 - wxPrintData *GetPrintData() {return m_PrintData;} + void SetFonts(wxString normal_face, 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 + // 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.) -protected: +protected: virtual wxHtmlPrintout *CreatePrintout(); virtual bool DoPreview(wxHtmlPrintout *printout1, wxHtmlPrintout *printout2); virtual bool DoPrint(wxHtmlPrintout *printout); @@ -217,8 +269,21 @@ private: wxPrintData *m_PrintData; wxPageSetupDialogData *m_PageSetupData; wxString m_Name; + 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]; - wxFrame *m_Frame; + wxWindow *m_ParentWindow; + + DECLARE_NO_COPY_CLASS(wxHtmlEasyPrinting) };