1 /////////////////////////////////////////////////////////////////////////////
2 // Name: richtext/richtextprint.h
3 // Purpose: documentation for wxRichTextHeaderFooterData class
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
10 @class wxRichTextHeaderFooterData
11 @headerfile richtextprint.h wx/richtext/richtextprint.h
14 This class represents header and footer data to be passed to the
15 wxRichTextPrinting and
16 wxRichTextPrintout classes.
18 Headers and footers can be specified independently for odd, even or both page
19 sides. Different text can be specified
20 for left, centre and right locations on the page, and the font and text colour
22 be specified. You can specify the following keywords in header and footer text,
24 be substituted for the actual values during printing and preview.
26 @DATE@: the current date.
27 @PAGESCNT@: the total number of pages.
28 @PAGENUM@: the current page number.
29 @TIME@: the current time.
30 @TITLE@: the title of the document, as passed to the wxRichTextPrinting or
31 wxRichTextLayout constructor.
36 class wxRichTextHeaderFooterData
: public wxObject
43 wxRichTextHeaderFooterData();
44 wxRichTextHeaderFooterData(const wxRichTextHeaderFooterData
& data
);
55 void Copy(const wxRichTextHeaderFooterData
& data
);
58 Returns the font specified for printing the header and footer.
60 const wxFont
GetFont() const;
63 Returns the margin between the text and the footer.
65 int GetFooterMargin() const;
68 Returns the footer text on odd or even pages, and at a given position on the
69 page (left, centre or right).
71 wxString
GetFooterText(wxRichTextOddEvenPage page
= wxRICHTEXT_PAGE_EVEN
,
72 wxRichTextPageLocation location
= wxRICHTEXT_PAGE_CENTRE
) const;
75 Returns the margin between the text and the header.
77 int GetHeaderMargin() const;
80 Returns the header text on odd or even pages, and at a given position on the
81 page (left, centre or right).
83 wxString
GetHeaderText(wxRichTextOddEvenPage page
= wxRICHTEXT_PAGE_EVEN
,
84 wxRichTextPageLocation location
= wxRICHTEXT_PAGE_CENTRE
) const;
87 Returns @true if the header and footer will be shown on the first page.
89 bool GetShowOnFirstPage() const;
92 Helper function for getting the header or footer text, odd or even pages, and
93 at a given position on the page (left, centre or right).
95 wxString
GetText(int headerFooter
, wxRichTextOddEvenPage page
,
96 wxRichTextPageLocation location
) const;
99 Returns the text colour for drawing the header and footer.
101 const wxColour
GetTextColour() const;
104 Initialises the object.
109 Sets the font for drawing the header and footer.
111 void SetFont(const wxFont
& font
);
114 Sets the footer text on odd or even pages, and at a given position on the page
115 (left, centre or right).
117 void SetFooterText(const wxString
& text
,
118 wxRichTextOddEvenPage page
= wxRICHTEXT_PAGE_ALL
,
119 wxRichTextPageLocation location
= wxRICHTEXT_PAGE_CENTRE
);
122 Sets the header text on odd or even pages, and at a given position on the page
123 (left, centre or right).
125 void SetHeaderText(const wxString
& text
,
126 wxRichTextOddEvenPage page
= wxRICHTEXT_PAGE_ALL
,
127 wxRichTextPageLocation location
= wxRICHTEXT_PAGE_CENTRE
);
130 Sets the margins between text and header or footer, in tenths of a millimeter.
132 void SetMargins(int headerMargin
, int footerMargin
);
135 Pass @true to show the header or footer on first page (the default).
137 void SetShowOnFirstPage(bool showOnFirstPage
);
140 Helper function for setting the header or footer text, odd or even pages, and
141 at a given position on the page (left, centre or right).
143 void SetText(const wxString
& text
, int headerFooter
,
144 wxRichTextOddEvenPage page
,
145 wxRichTextPageLocation location
);
148 Sets the text colour for drawing the header and footer.
150 void SetTextColour(const wxColour
& col
);
155 void operator operator=(const wxRichTextHeaderFooterData
& data
);
160 @class wxRichTextPrintout
161 @headerfile richtextprint.h wx/richtext/richtextprint.h
163 This class implements print layout for wxRichTextBuffer. Instead of using it
165 should normally use the wxRichTextPrinting class.
170 class wxRichTextPrintout
: public wxPrintout
177 wxRichTextPrintout();
180 Calculates scaling and text, header and footer rectangles.
182 void CalculateScaling(wxDC
* dc
, wxRect
& textRect
,
187 Returns the header and footer data associated with the printout.
189 const wxRichTextHeaderFooterData
GetHeaderFooterData() const;
192 Gets the page information.
194 void GetPageInfo(int* minPage
, int* maxPage
, int* selPageFrom
,
198 Returns a pointer to the buffer being rendered.
200 wxRichTextBuffer
* GetRichTextBuffer() const;
203 Returns @true if the given page exists in the printout.
205 bool HasPage(int page
);
208 Prepares for printing, laying out the buffer and calculating pagination.
210 void OnPreparePrinting();
213 Does the actual printing for this page.
215 bool OnPrintPage(int page
);
218 Sets the header and footer data associated with the printout.
220 void SetHeaderFooterData(const wxRichTextHeaderFooterData
& data
);
223 Sets margins in 10ths of millimetre. Defaults to 1 inch for margins.
225 void SetMargins(int top
= 252, int bottom
= 252, int left
= 252,
229 Sets the buffer to print. wxRichTextPrintout does not manage this pointer; it
231 be managed by the calling code, such as wxRichTextPrinting.
233 void SetRichTextBuffer(wxRichTextBuffer
* buffer
);
238 @class wxRichTextPrinting
239 @headerfile richtextprint.h wx/richtext/richtextprint.h
241 This class provides a simple interface for performing wxRichTextBuffer printing
242 and previewing. It uses wxRichTextPrintout for layout and rendering.
247 class wxRichTextPrinting
: public wxObject
251 , @b wxWindow*@e parentWindow = @NULL)
252 Constructor. Optionally pass a title to be used in the preview frame and
253 printing wait dialog, and
254 also a parent window for these windows.
256 wxRichTextPrinting();
259 A convenience function to get the footer text. See wxRichTextHeaderFooterData
262 wxString
GetFooterText(wxRichTextOddEvenPage page
= wxRICHTEXT_PAGE_EVEN
,
263 wxRichTextPageLocation location
= wxRICHTEXT_PAGE_CENTRE
) const;
266 Returns the internal wxRichTextHeaderFooterData object.
268 const wxRichTextHeaderFooterData
GetHeaderFooterData() const;
271 A convenience function to get the header text. See wxRichTextHeaderFooterData
274 wxString
GetHeaderText(wxRichTextOddEvenPage page
= wxRICHTEXT_PAGE_EVEN
,
275 wxRichTextPageLocation location
= wxRICHTEXT_PAGE_CENTRE
) const;
278 Returns a pointer to the internal page setup data.
280 wxPageSetupDialogData
* GetPageSetupData();
283 Returns the parent window to be used for the preview window and printing wait
286 wxWindow
* GetParentWindow() const;
289 Returns the dimensions to be used for the preview window.
291 const wxRect
GetPreviewRect() const;
294 Returns a pointer to the internal print data.
296 wxPrintData
* GetPrintData();
299 Returns the title of the preview window or printing wait caption.
301 const wxString
GetTitle() const;
304 Shows the page setup dialog.
309 Shows a preview window for the given buffer. The function takes its own copy of
312 bool PreviewBuffer(const wxRichTextBuffer
& buffer
);
315 Shows a preview window for the given file. @a richTextFile can be a text file
316 or XML file, or other file
317 depending on the available file handlers.
319 bool PreviewFile(const wxString
& richTextFile
);
322 Prints the given buffer. The function takes its own copy of @e buffer.
324 bool PrintBuffer(const wxRichTextBuffer
& buffer
);
327 Prints the given file. @a richTextFile can be a text file or XML file, or other
329 depending on the available file handlers.
331 bool PrintFile(const wxString
& richTextFile
);
334 A convenience function to set the footer text. See wxRichTextHeaderFooterData
337 void SetFooterText(const wxString
& text
,
338 wxRichTextOddEvenPage page
= wxRICHTEXT_PAGE_ALL
,
339 wxRichTextPageLocation location
= wxRICHTEXT_PAGE_CENTRE
);
342 Sets the internal wxRichTextHeaderFooterData object.
344 void SetHeaderFooterData(const wxRichTextHeaderFooterData
& data
);
347 Sets the wxRichTextHeaderFooterData font.
349 void SetHeaderFooterFont(const wxFont
& font
);
352 Sets the wxRichTextHeaderFooterData text colour.
354 void SetHeaderFooterTextColour(const wxColour
& colour
);
357 A convenience function to set the header text. See wxRichTextHeaderFooterData
360 void SetHeaderText(const wxString
& text
,
361 wxRichTextOddEvenPage page
= wxRICHTEXT_PAGE_ALL
,
362 wxRichTextPageLocation location
= wxRICHTEXT_PAGE_CENTRE
);
365 Sets the page setup data.
367 void SetPageSetupData(const wxPageSetupData
& pageSetupData
);
370 Sets the parent window to be used for the preview window and printing wait
373 void SetParentWindow(wxWindow
* parent
);
376 Sets the dimensions to be used for the preview window.
378 void SetPreviewRect(const wxRect
& rect
);
383 void SetPrintData(const wxPrintData
& printData
);
386 Pass @true to show the header and footer on the first page.
388 void SetShowOnFirstPage(bool show
);
391 Pass the title of the preview window or printing wait caption.
393 void SetTitle(const wxString
& title
);