Version: 3.1.1
wxHtmlEasyPrinting Class Reference

#include <wx/html/htmprint.h>

+ Inheritance diagram for wxHtmlEasyPrinting:

Detailed Description

This class provides very simple interface to printing architecture.

It allows you to print HTML documents using only a few commands.

Note
Do not create this class on the stack only. You should create an instance on app startup and use this instance for all printing operations. The reason is that this class stores various settings in it.

Library:  wxHTML
Category:  HTML, Printing Framework

Public Member Functions

 wxHtmlEasyPrinting (const wxString &name="Printing", wxWindow *parentWindow=NULL)
 Constructor. More...
 
const wxStringGetName () const
 Returns the current name being used for preview frames and setup dialogs. More...
 
wxPageSetupDialogDataGetPageSetupData ()
 Returns a pointer to wxPageSetupDialogData instance used by this class. More...
 
wxWindowGetParentWindow () const
 Gets the parent window for dialogs. More...
 
wxPrintDataGetPrintData ()
 Returns pointer to wxPrintData instance used by this class. More...
 
void PageSetup ()
 Display page setup dialog and allows the user to modify settings. More...
 
bool PreviewFile (const wxString &htmlfile)
 Preview HTML file. More...
 
bool PreviewText (const wxString &htmltext, const wxString &basepath=wxEmptyString)
 Preview HTML text (not file!). More...
 
bool PrintFile (const wxString &htmlfile)
 Print HTML file. More...
 
bool PrintText (const wxString &htmltext, const wxString &basepath=wxEmptyString)
 Print HTML text (not file!). More...
 
void SetFonts (const wxString &normal_face, const wxString &fixed_face, const int *sizes=NULL)
 Sets fonts. More...
 
void SetName (const wxString &name)
 Sets the name used for preview frames and setup dialogs. More...
 
void SetStandardFonts (int size=-1, const wxString &normal_face=wxEmptyString, const wxString &fixed_face=wxEmptyString)
 Sets default font sizes and/or default font size. More...
 
void SetFooter (const wxString &footer, int pg=wxPAGE_ALL)
 Set page footer. More...
 
void SetHeader (const wxString &header, int pg=wxPAGE_ALL)
 Set page header. More...
 
void SetParentWindow (wxWindow *window)
 Sets the parent window for dialogs. More...
 
- Public Member Functions inherited from wxObject
 wxObject ()
 Default ctor; initializes to NULL the internal reference data. More...
 
 wxObject (const wxObject &other)
 Copy ctor. More...
 
virtual ~wxObject ()
 Destructor. More...
 
virtual wxClassInfoGetClassInfo () const
 This virtual function is redefined for every class that requires run-time type information, when using the wxDECLARE_CLASS macro (or similar). More...
 
wxObjectRefDataGetRefData () const
 Returns the wxObject::m_refData pointer, i.e. the data referenced by this object. More...
 
bool IsKindOf (const wxClassInfo *info) const
 Determines whether this class is a subclass of (or the same class as) the given class. More...
 
bool IsSameAs (const wxObject &obj) const
 Returns true if this object has the same data pointer as obj. More...
 
void Ref (const wxObject &clone)
 Makes this object refer to the data in clone. More...
 
void SetRefData (wxObjectRefData *data)
 Sets the wxObject::m_refData pointer. More...
 
void UnRef ()
 Decrements the reference count in the associated data, and if it is zero, deletes the data. More...
 
void UnShare ()
 This is the same of AllocExclusive() but this method is public. More...
 
void operator delete (void *buf)
 The delete operator is defined for debugging versions of the library only, when the identifier WXDEBUG is defined. More...
 
void * operator new (size_t size, const wxString &filename=NULL, int lineNum=0)
 The new operator is defined for debugging versions of the library only, when the identifier WXDEBUG is defined. More...
 

Private Member Functions

virtual bool CheckFit (const wxSize &pageArea, const wxSize &docArea) const
 Check whether the document fits into the page area. More...
 

Additional Inherited Members

- Protected Member Functions inherited from wxObject
void AllocExclusive ()
 Ensure that this object's data is not shared with any other object. More...
 
virtual wxObjectRefDataCreateRefData () const
 Creates a new instance of the wxObjectRefData-derived class specific to this object and returns it. More...
 
virtual wxObjectRefDataCloneRefData (const wxObjectRefData *data) const
 Creates a new instance of the wxObjectRefData-derived class specific to this object and initializes it copying data. More...
 
- Protected Attributes inherited from wxObject
wxObjectRefDatam_refData
 Pointer to an object which is the object's reference-counted data. More...
 

Constructor & Destructor Documentation

wxHtmlEasyPrinting::wxHtmlEasyPrinting ( const wxString name = "Printing",
wxWindow parentWindow = NULL 
)

Constructor.

Parameters
nameName of the printing object. Used by preview frames and setup dialogs.
parentWindowpointer to the window that will own the preview frame and setup dialogs. May be NULL.

Member Function Documentation

virtual bool wxHtmlEasyPrinting::CheckFit ( const wxSize pageArea,
const wxSize docArea 
) const
privatevirtual

Check whether the document fits into the page area.

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 (presumably in order to change some layout options and retry it again).

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.

Returns
true if wxHtmlPrintout should continue or false to cancel printing.
Since
2.9.0
const wxString& wxHtmlEasyPrinting::GetName ( ) const

Returns the current name being used for preview frames and setup dialogs.

Since
2.8.11 / 2.9.1
wxPageSetupDialogData* wxHtmlEasyPrinting::GetPageSetupData ( )

Returns a pointer to wxPageSetupDialogData instance used by this class.

You can set its parameters (via SetXXXX methods).

wxWindow* wxHtmlEasyPrinting::GetParentWindow ( ) const

Gets the parent window for dialogs.

wxPrintData* wxHtmlEasyPrinting::GetPrintData ( )

Returns pointer to wxPrintData instance used by this class.

You can set its parameters (via SetXXXX methods).

void wxHtmlEasyPrinting::PageSetup ( )

Display page setup dialog and allows the user to modify settings.

bool wxHtmlEasyPrinting::PreviewFile ( const wxString htmlfile)

Preview HTML file.

Returns false in case of error – call wxPrinter::GetLastError to get detailed information about the kind of the error.

bool wxHtmlEasyPrinting::PreviewText ( const wxString htmltext,
const wxString basepath = wxEmptyString 
)

Preview HTML text (not file!).

Returns false in case of error – call wxPrinter::GetLastError to get detailed information about the kind of the error.

Parameters
htmltextHTML text.
basepathbase directory (html string would be stored there if it was in file). It is used to determine path for loading images, for example.
bool wxHtmlEasyPrinting::PrintFile ( const wxString htmlfile)

Print HTML file.

Returns false in case of error – call wxPrinter::GetLastError to get detailed information about the kind of the error.

bool wxHtmlEasyPrinting::PrintText ( const wxString htmltext,
const wxString basepath = wxEmptyString 
)

Print HTML text (not file!).

Returns false in case of error – call wxPrinter::GetLastError to get detailed information about the kind of the error.

Parameters
htmltextHTML text.
basepathbase directory (html string would be stored there if it was in file). It is used to determine path for loading images, for example.
void wxHtmlEasyPrinting::SetFonts ( const wxString normal_face,
const wxString fixed_face,
const int *  sizes = NULL 
)

Sets fonts.

See wxHtmlDCRenderer::SetFonts for detailed description.

void wxHtmlEasyPrinting::SetFooter ( const wxString footer,
int  pg = wxPAGE_ALL 
)

Set page footer.

The following macros can be used inside it: @DATE@ is replaced by the current date in default format @PAGENUM@ is replaced by page number @PAGESCNT@ is replaced by total number of pages @TIME@ is replaced by the current time in default format @TITLE@ is replaced with the title of the document

Parameters
footerHTML text to be used as footer.
pgone of wxPAGE_ODD, wxPAGE_EVEN and wxPAGE_ALL constants.
void wxHtmlEasyPrinting::SetHeader ( const wxString header,
int  pg = wxPAGE_ALL 
)

Set page header.

The following macros can be used inside it:

  • @DATE@ is replaced by the current date in default format
  • @PAGENUM@ is replaced by page number
  • @PAGESCNT@ is replaced by total number of pages
  • @TIME@ is replaced by the current time in default format
  • @TITLE@ is replaced with the title of the document
Parameters
headerHTML text to be used as header.
pgone of wxPAGE_ODD, wxPAGE_EVEN and wxPAGE_ALL constants.
void wxHtmlEasyPrinting::SetName ( const wxString name)

Sets the name used for preview frames and setup dialogs.

Since
2.8.11 / 2.9.1
void wxHtmlEasyPrinting::SetParentWindow ( wxWindow window)

Sets the parent window for dialogs.

void wxHtmlEasyPrinting::SetStandardFonts ( int  size = -1,
const wxString normal_face = wxEmptyString,
const wxString fixed_face = wxEmptyString 
)

Sets default font sizes and/or default font size.

See wxHtmlDCRenderer::SetStandardFonts for detailed description.

See also
SetFonts()