2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: richtext/richtextprint.h
|
2008-03-09 13:09:29 -04:00
|
|
|
// Purpose: interface of wxRichTextHeaderFooterData
|
2008-03-08 08:52:38 -05:00
|
|
|
// Author: wxWidgets team
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Licence: wxWindows license
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2008-10-09 12:30:57 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
These are the header and footer page identifiers, passed to functions such
|
|
|
|
as wxRichTextHeaderFooterData::SetFooterText to specify the odd or even page
|
|
|
|
for the text.
|
|
|
|
*/
|
|
|
|
enum wxRichTextOddEvenPage {
|
|
|
|
wxRICHTEXT_PAGE_ODD,
|
|
|
|
wxRICHTEXT_PAGE_EVEN,
|
|
|
|
wxRICHTEXT_PAGE_ALL,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
These are the location identifiers for passing to functions such as
|
|
|
|
wxRichTextHeaderFooterData::SetFooterText(), to specify whether the text
|
|
|
|
is on the left, centre or right of the page.
|
|
|
|
*/
|
|
|
|
enum wxRichTextPageLocation {
|
|
|
|
wxRICHTEXT_PAGE_LEFT,
|
|
|
|
wxRICHTEXT_PAGE_CENTRE,
|
|
|
|
wxRICHTEXT_PAGE_RIGHT
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxRichTextHeaderFooterData
|
2008-03-08 09:43:31 -05:00
|
|
|
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
This class represents header and footer data to be passed to the
|
2008-10-09 12:30:57 -04:00
|
|
|
wxRichTextPrinting and wxRichTextPrintout classes.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
Headers and footers can be specified independently for odd, even or both page
|
2008-10-09 12:30:57 -04:00
|
|
|
sides. Different text can be specified for left, centre and right locations
|
|
|
|
on the page, and the font and text colour can also be specified.
|
|
|
|
|
|
|
|
You can specify the following keywords in header and footer text, which will
|
2008-03-08 08:52:38 -05:00
|
|
|
be substituted for the actual values during printing and preview.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-10-09 12:30:57 -04:00
|
|
|
- @@DATE@: the current date.
|
|
|
|
- @@PAGESCNT@: the total number of pages.
|
|
|
|
- @@PAGENUM@: the current page number.
|
|
|
|
- @@TIME@: the current time.
|
|
|
|
- @@TITLE@: the title of the document, as passed to the wxRichTextPrinting or
|
|
|
|
wxRichTextLayout constructor.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxrichtext}
|
2008-03-09 13:09:29 -04:00
|
|
|
@category{richtext}
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxRichTextHeaderFooterData : public wxObject
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
//@{
|
|
|
|
/**
|
|
|
|
Constructors.
|
|
|
|
*/
|
|
|
|
wxRichTextHeaderFooterData();
|
2008-03-08 09:43:31 -05:00
|
|
|
wxRichTextHeaderFooterData(const wxRichTextHeaderFooterData& data);
|
2008-03-08 08:52:38 -05:00
|
|
|
//@}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Clears all text.
|
|
|
|
*/
|
|
|
|
void Clear();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Copies the data.
|
|
|
|
*/
|
|
|
|
void Copy(const wxRichTextHeaderFooterData& data);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the font specified for printing the header and footer.
|
|
|
|
*/
|
2008-10-09 12:30:57 -04:00
|
|
|
const wxFont& GetFont() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the margin between the text and the footer.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
int GetFooterMargin() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the footer text on odd or even pages, and at a given position on the
|
|
|
|
page (left, centre or right).
|
|
|
|
*/
|
|
|
|
wxString GetFooterText(wxRichTextOddEvenPage page = wxRICHTEXT_PAGE_EVEN,
|
2008-03-09 12:24:26 -04:00
|
|
|
wxRichTextPageLocation location = wxRICHTEXT_PAGE_CENTRE) const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the margin between the text and the header.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
int GetHeaderMargin() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the header text on odd or even pages, and at a given position on the
|
|
|
|
page (left, centre or right).
|
|
|
|
*/
|
|
|
|
wxString GetHeaderText(wxRichTextOddEvenPage page = wxRICHTEXT_PAGE_EVEN,
|
2008-03-09 12:24:26 -04:00
|
|
|
wxRichTextPageLocation location = wxRICHTEXT_PAGE_CENTRE) const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if the header and footer will be shown on the first page.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
bool GetShowOnFirstPage() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Helper function for getting the header or footer text, odd or even pages, and
|
|
|
|
at a given position on the page (left, centre or right).
|
|
|
|
*/
|
|
|
|
wxString GetText(int headerFooter, wxRichTextOddEvenPage page,
|
2008-03-09 12:24:26 -04:00
|
|
|
wxRichTextPageLocation location) const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the text colour for drawing the header and footer.
|
|
|
|
*/
|
2008-10-29 11:34:31 -04:00
|
|
|
const wxColour& GetTextColour() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Initialises the object.
|
|
|
|
*/
|
|
|
|
void Init();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the font for drawing the header and footer.
|
|
|
|
*/
|
|
|
|
void SetFont(const wxFont& font);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the footer text on odd or even pages, and at a given position on the page
|
|
|
|
(left, centre or right).
|
|
|
|
*/
|
|
|
|
void SetFooterText(const wxString& text,
|
|
|
|
wxRichTextOddEvenPage page = wxRICHTEXT_PAGE_ALL,
|
|
|
|
wxRichTextPageLocation location = wxRICHTEXT_PAGE_CENTRE);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the header text on odd or even pages, and at a given position on the page
|
|
|
|
(left, centre or right).
|
|
|
|
*/
|
|
|
|
void SetHeaderText(const wxString& text,
|
|
|
|
wxRichTextOddEvenPage page = wxRICHTEXT_PAGE_ALL,
|
|
|
|
wxRichTextPageLocation location = wxRICHTEXT_PAGE_CENTRE);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the margins between text and header or footer, in tenths of a millimeter.
|
|
|
|
*/
|
|
|
|
void SetMargins(int headerMargin, int footerMargin);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Pass @true to show the header or footer on first page (the default).
|
|
|
|
*/
|
|
|
|
void SetShowOnFirstPage(bool showOnFirstPage);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Helper function for setting the header or footer text, odd or even pages, and
|
|
|
|
at a given position on the page (left, centre or right).
|
|
|
|
*/
|
|
|
|
void SetText(const wxString& text, int headerFooter,
|
|
|
|
wxRichTextOddEvenPage page,
|
|
|
|
wxRichTextPageLocation location);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the text colour for drawing the header and footer.
|
|
|
|
*/
|
|
|
|
void SetTextColour(const wxColour& col);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Assignment operator.
|
|
|
|
*/
|
|
|
|
void operator operator=(const wxRichTextHeaderFooterData& data);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxRichTextPrintout
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-10-09 12:30:57 -04:00
|
|
|
This class implements print layout for wxRichTextBuffer.
|
|
|
|
Instead of using it directly, you should normally use the wxRichTextPrinting class.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxrichtext}
|
2008-03-09 13:09:29 -04:00
|
|
|
@category{richtext}
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxRichTextPrintout : public wxPrintout
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
Constructor.
|
|
|
|
*/
|
2009-01-18 16:46:46 -05:00
|
|
|
wxRichTextPrintout(const wxString& title = "Printout");
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Calculates scaling and text, header and footer rectangles.
|
|
|
|
*/
|
|
|
|
void CalculateScaling(wxDC* dc, wxRect& textRect,
|
|
|
|
wxRect& headerRect,
|
|
|
|
wxRect& footerRect);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the header and footer data associated with the printout.
|
|
|
|
*/
|
2008-10-29 11:34:31 -04:00
|
|
|
const wxRichTextHeaderFooterData& GetHeaderFooterData() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Gets the page information.
|
|
|
|
*/
|
2008-10-27 17:26:54 -04:00
|
|
|
virtual void GetPageInfo(int* minPage, int* maxPage, int* selPageFrom,
|
|
|
|
int* selPageTo);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns a pointer to the buffer being rendered.
|
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
wxRichTextBuffer* GetRichTextBuffer() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if the given page exists in the printout.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual bool HasPage(int page);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Prepares for printing, laying out the buffer and calculating pagination.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual void OnPreparePrinting();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Does the actual printing for this page.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual bool OnPrintPage(int page);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the header and footer data associated with the printout.
|
|
|
|
*/
|
|
|
|
void SetHeaderFooterData(const wxRichTextHeaderFooterData& data);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets margins in 10ths of millimetre. Defaults to 1 inch for margins.
|
|
|
|
*/
|
2008-10-29 11:34:31 -04:00
|
|
|
void SetMargins(int top = 254, int bottom = 254, int left = 254,
|
|
|
|
int right = 254);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-10-09 12:30:57 -04:00
|
|
|
Sets the buffer to print. wxRichTextPrintout does not manage this pointer;
|
|
|
|
it should be managed by the calling code, such as wxRichTextPrinting.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void SetRichTextBuffer(wxRichTextBuffer* buffer);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxRichTextPrinting
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
This class provides a simple interface for performing wxRichTextBuffer printing
|
|
|
|
and previewing. It uses wxRichTextPrintout for layout and rendering.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxrichtext}
|
2008-03-09 13:09:29 -04:00
|
|
|
@category{richtext}
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxRichTextPrinting : public wxObject
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
2008-10-09 12:30:57 -04:00
|
|
|
Constructor.
|
|
|
|
|
|
|
|
Optionally pass a title to be used in the preview frame and printing wait
|
|
|
|
dialog, and also a parent window for these windows.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2009-01-18 16:46:46 -05:00
|
|
|
wxRichTextPrinting(const wxString& name = "Printing",
|
2008-10-09 12:30:57 -04:00
|
|
|
wxWindow* parentWindow = NULL);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-10-09 12:30:57 -04:00
|
|
|
A convenience function to get the footer text.
|
|
|
|
See wxRichTextHeaderFooterData for details.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
wxString GetFooterText(wxRichTextOddEvenPage page = wxRICHTEXT_PAGE_EVEN,
|
2008-03-09 12:24:26 -04:00
|
|
|
wxRichTextPageLocation location = wxRICHTEXT_PAGE_CENTRE) const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the internal wxRichTextHeaderFooterData object.
|
|
|
|
*/
|
2008-10-29 11:34:31 -04:00
|
|
|
const wxRichTextHeaderFooterData& GetHeaderFooterData() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-10-09 12:30:57 -04:00
|
|
|
A convenience function to get the header text.
|
|
|
|
See wxRichTextHeaderFooterData for details.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
wxString GetHeaderText(wxRichTextOddEvenPage page = wxRICHTEXT_PAGE_EVEN,
|
2008-03-09 12:24:26 -04:00
|
|
|
wxRichTextPageLocation location = wxRICHTEXT_PAGE_CENTRE) const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns a pointer to the internal page setup data.
|
|
|
|
*/
|
|
|
|
wxPageSetupDialogData* GetPageSetupData();
|
|
|
|
|
|
|
|
/**
|
2008-10-09 12:30:57 -04:00
|
|
|
Returns the parent window to be used for the preview window and printing
|
|
|
|
wait dialog.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
wxWindow* GetParentWindow() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the dimensions to be used for the preview window.
|
|
|
|
*/
|
2008-10-29 11:34:31 -04:00
|
|
|
const wxRect& GetPreviewRect() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns a pointer to the internal print data.
|
|
|
|
*/
|
|
|
|
wxPrintData* GetPrintData();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the title of the preview window or printing wait caption.
|
|
|
|
*/
|
2008-10-29 11:34:31 -04:00
|
|
|
const wxString& GetTitle() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Shows the page setup dialog.
|
|
|
|
*/
|
|
|
|
void PageSetup();
|
|
|
|
|
|
|
|
/**
|
2008-10-09 12:30:57 -04:00
|
|
|
Shows a preview window for the given buffer.
|
|
|
|
The function takes its own copy of @a buffer.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
bool PreviewBuffer(const wxRichTextBuffer& buffer);
|
|
|
|
|
|
|
|
/**
|
2008-10-09 12:30:57 -04:00
|
|
|
Shows a preview window for the given file.
|
|
|
|
|
|
|
|
@a richTextFile can be a text file or XML file, or other file
|
2008-03-08 08:52:38 -05:00
|
|
|
depending on the available file handlers.
|
|
|
|
*/
|
|
|
|
bool PreviewFile(const wxString& richTextFile);
|
|
|
|
|
|
|
|
/**
|
2008-10-09 12:30:57 -04:00
|
|
|
Prints the given buffer. The function takes its own copy of @a buffer.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
bool PrintBuffer(const wxRichTextBuffer& buffer);
|
|
|
|
|
|
|
|
/**
|
2008-10-09 12:30:57 -04:00
|
|
|
Prints the given file. @a richTextFile can be a text file or XML file,
|
|
|
|
or other file depending on the available file handlers.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
bool PrintFile(const wxString& richTextFile);
|
|
|
|
|
|
|
|
/**
|
2008-10-09 12:30:57 -04:00
|
|
|
A convenience function to set the footer text.
|
|
|
|
See wxRichTextHeaderFooterData for details.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void SetFooterText(const wxString& text,
|
|
|
|
wxRichTextOddEvenPage page = wxRICHTEXT_PAGE_ALL,
|
|
|
|
wxRichTextPageLocation location = wxRICHTEXT_PAGE_CENTRE);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the internal wxRichTextHeaderFooterData object.
|
|
|
|
*/
|
|
|
|
void SetHeaderFooterData(const wxRichTextHeaderFooterData& data);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the wxRichTextHeaderFooterData font.
|
|
|
|
*/
|
|
|
|
void SetHeaderFooterFont(const wxFont& font);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the wxRichTextHeaderFooterData text colour.
|
|
|
|
*/
|
|
|
|
void SetHeaderFooterTextColour(const wxColour& colour);
|
|
|
|
|
|
|
|
/**
|
2008-10-09 12:30:57 -04:00
|
|
|
A convenience function to set the header text.
|
|
|
|
See wxRichTextHeaderFooterData for details.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void SetHeaderText(const wxString& text,
|
|
|
|
wxRichTextOddEvenPage page = wxRICHTEXT_PAGE_ALL,
|
|
|
|
wxRichTextPageLocation location = wxRICHTEXT_PAGE_CENTRE);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the page setup data.
|
|
|
|
*/
|
2008-10-29 11:34:31 -04:00
|
|
|
void SetPageSetupData(const wxPageSetupDialogData& pageSetupData);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-10-09 12:30:57 -04:00
|
|
|
Sets the parent window to be used for the preview window and printing
|
|
|
|
wait dialog.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void SetParentWindow(wxWindow* parent);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the dimensions to be used for the preview window.
|
|
|
|
*/
|
|
|
|
void SetPreviewRect(const wxRect& rect);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the print data.
|
|
|
|
*/
|
|
|
|
void SetPrintData(const wxPrintData& printData);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Pass @true to show the header and footer on the first page.
|
|
|
|
*/
|
|
|
|
void SetShowOnFirstPage(bool show);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Pass the title of the preview window or printing wait caption.
|
|
|
|
*/
|
|
|
|
void SetTitle(const wxString& title);
|
|
|
|
};
|
2008-03-10 11:24:38 -04:00
|
|
|
|