Public Member Functions

# wxHtmlDCRenderer Class Reference
[HTML]

`#include <wx/html/htmprint.h>`

Inheritance diagram for wxHtmlDCRenderer:
[legend]

## Detailed Description

This class can render HTML document into a specified area of a DC.

You can use it in your own printing code, although use of wxHtmlEasyPrinting or wxHtmlPrintout is strongly recommended.

##

Library: wxHTML
Category: HTML

## Public Member Functions
| wxHtmlDCRenderer ()
| Constructor.
int | GetTotalWidth () const
| Returns the width of the HTML text in pixels.
int | GetTotalHeight () const
| Returns the height of the HTML text in pixels.
int | Render (int x, int y, wxArrayInt &known_pagebreaks, int from=0, int dont_render=false, int to=INT_MAX)
| Renders HTML text to the DC.
void | SetDC (wxDC *dc, double pixel_scale=1.0)
| Assign DC instance to the renderer.
void | SetFonts (const wxString &normal_face, const wxString &fixed_face, const int *sizes=NULL)
| This function sets font sizes and faces.
void | SetStandardFonts (int size=-1, const wxString &normal_face=wxEmptyString, const wxString &fixed_face=wxEmptyString)
| Sets font sizes to be relative to the given size or the system default size; use either specified or default font.
void | SetHtmlText (const wxString &html, const wxString &basepath=wxEmptyString, bool isdir=true)
| Assign text to the renderer.
void | SetSize (int width, int height)
| Set size of output rectangle, in pixels.

List of all members.

## Constructor & Destructor Documentation

wxHtmlDCRenderer::wxHtmlDCRenderer | ( |  | ) |

Constructor.

## Member Function Documentation

int wxHtmlDCRenderer::GetTotalHeight | ( |  | ) | const

Returns the height of the HTML text in pixels.

This is important if area height (see wxHtmlDCRenderer::SetSize) is smaller that total height and thus the page cannot fit into it. In that case you're supposed to call Render() as long as its return value is smaller than GetTotalHeight()'s.

See also:
  GetTotalWidth()

int wxHtmlDCRenderer::GetTotalWidth | ( |  | ) | const

Returns the width of the HTML text in pixels.

This can be compared with the width parameter of SetSize() to check if the document being printed fits into the page boundary.

See also:
  GetTotalHeight()

Since:
  2.9.0

int wxHtmlDCRenderer::Render | ( | int | x,
|  | int | y,
|  | wxArrayInt & | known_pagebreaks,
|  | int | from = `0`,
|  | int | dont_render = `false`,
|  | int | to = `INT_MAX` |
| ) |  |  |

Renders HTML text to the DC.

Parameters:

  | x,y | position of upper-left corner of printing rectangle (see SetSize()).
  | known_pagebreaks |

Todo:
  docme

Parameters:

  | from | y-coordinate of the very first visible cell.
  | dont_render | if true then this method only returns y coordinate of the next page and does not output anything.
  | to | y-coordinate of the last visible cell.

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 multipages document.

Note:
  The following three methods must always be called before any call to Render(), in this order:
  - SetDC()
  - SetSize()
  - SetHtmlText()
  Render() changes the DC's user scale and does NOT restore it.

void wxHtmlDCRenderer::SetDC | ( | wxDC * | dc,
|  | double | pixel_scale = `1.0` |
| ) |  |  |

Assign DC instance to the renderer.

pixel_scale can be used when rendering to high-resolution DCs (e.g. printer) to adjust size of pixel metrics. (Many dimensions in HTML are given in pixels -- e.g. image sizes. 300x300 image would be only one inch wide on typical printer. With pixel_scale = 3.0 it would be 3 inches.)

void wxHtmlDCRenderer::SetFonts | ( | const wxString & | normal_face,
|  | const wxString & | fixed_face,
|  | const int * | sizes = `NULL` |
| ) |  |  |

This function sets font sizes and faces.

Parameters:

  | normal_face | This is face name for normal (i.e. non-fixed) font. It can be either empty string (then the default face is chosen) or platform-specific face name. Examples are "helvetica" under Unix or "Times New Roman" under Windows.
  | fixed_face | The same thing for fixed face ( <TT>..</TT> )
  | sizes | This is an array of 7 items of int type. The values represent size of font with HTML size from -2 to +4 ( <FONT SIZE=-2> to <FONT SIZE=+4> ). Default sizes are used if sizes is NULL.

Default font sizes are defined by constants wxHTML_FONT_SIZE_1, wxHTML_FONT_SIZE_2, ..., wxHTML_FONT_SIZE_7. Note that they differ among platforms. Default face names are empty strings.

See also:
  SetSize()

void wxHtmlDCRenderer::SetHtmlText | ( | const wxString & | html,
|  | const wxString & | basepath = `wxEmptyString`,
|  | bool | isdir = `true` |
| ) |  |  |

Assign text to the renderer.

Render() then draws the text onto DC.

Parameters:

  | html | HTML text. This is not a filename.
  | basepath | 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 | false if basepath is filename, true if it is directory name (see wxFileSystem for detailed explanation).

void wxHtmlDCRenderer::SetSize | ( | int | width,
|  | int | height |
| ) |  |  |

Set size of output rectangle, in pixels.

Note that you can't change width of the rectangle between calls to Render() ! (You can freely change height.)

void wxHtmlDCRenderer::SetStandardFonts | ( | int | size = `-1`,
|  | const wxString & | normal_face = `wxEmptyString`,
|  | const wxString & | fixed_face = `wxEmptyString` |
| ) |  |  |

Sets font sizes to be relative to the given size or the system default size; use either specified or default font.

Parameters:

  | size | Point size of the default HTML text
  | normal_face | This is face name for normal (i.e. non-fixed) font. It can be either empty string (then the default face is chosen) or platform-specific face name. Examples are "helvetica" under Unix or "Times New Roman" under Windows.
  | fixed_face | The same thing for fixed face ( <TT>..</TT> )

See also:
  SetSize()

|  | [ top ]