1 /////////////////////////////////////////////////////////////////////////////
2 // Name: richtext/richtextprint.h
3 // Purpose: interface of wxRichTextHeaderFooterData
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
);
161 @class wxRichTextPrintout
162 @headerfile richtextprint.h wx/richtext/richtextprint.h
164 This class implements print layout for wxRichTextBuffer. Instead of using it
166 should normally use the wxRichTextPrinting class.
171 class wxRichTextPrintout
: public wxPrintout
178 wxRichTextPrintout();
181 Calculates scaling and text, header and footer rectangles.
183 void CalculateScaling(wxDC
* dc
, wxRect
& textRect
,
188 Returns the header and footer data associated with the printout.
190 const wxRichTextHeaderFooterData
GetHeaderFooterData() const;
193 Gets the page information.
195 void GetPageInfo(int* minPage
, int* maxPage
, int* selPageFrom
,
199 Returns a pointer to the buffer being rendered.
201 wxRichTextBuffer
* GetRichTextBuffer() const;
204 Returns @true if the given page exists in the printout.
206 bool HasPage(int page
);
209 Prepares for printing, laying out the buffer and calculating pagination.
211 void OnPreparePrinting();
214 Does the actual printing for this page.
216 bool OnPrintPage(int page
);
219 Sets the header and footer data associated with the printout.
221 void SetHeaderFooterData(const wxRichTextHeaderFooterData
& data
);
224 Sets margins in 10ths of millimetre. Defaults to 1 inch for margins.
226 void SetMargins(int top
= 252, int bottom
= 252, int left
= 252,
230 Sets the buffer to print. wxRichTextPrintout does not manage this pointer; it
232 be managed by the calling code, such as wxRichTextPrinting.
234 void SetRichTextBuffer(wxRichTextBuffer
* buffer
);
240 @class wxRichTextPrinting
241 @headerfile richtextprint.h wx/richtext/richtextprint.h
243 This class provides a simple interface for performing wxRichTextBuffer printing
244 and previewing. It uses wxRichTextPrintout for layout and rendering.
249 class wxRichTextPrinting
: public wxObject
253 , @b wxWindow*@e parentWindow = @NULL)
254 Constructor. Optionally pass a title to be used in the preview frame and
255 printing wait dialog, and
256 also a parent window for these windows.
258 wxRichTextPrinting();
261 A convenience function to get the footer text. See wxRichTextHeaderFooterData
264 wxString
GetFooterText(wxRichTextOddEvenPage page
= wxRICHTEXT_PAGE_EVEN
,
265 wxRichTextPageLocation location
= wxRICHTEXT_PAGE_CENTRE
) const;
268 Returns the internal wxRichTextHeaderFooterData object.
270 const wxRichTextHeaderFooterData
GetHeaderFooterData() const;
273 A convenience function to get the header text. See wxRichTextHeaderFooterData
276 wxString
GetHeaderText(wxRichTextOddEvenPage page
= wxRICHTEXT_PAGE_EVEN
,
277 wxRichTextPageLocation location
= wxRICHTEXT_PAGE_CENTRE
) const;
280 Returns a pointer to the internal page setup data.
282 wxPageSetupDialogData
* GetPageSetupData();
285 Returns the parent window to be used for the preview window and printing wait
288 wxWindow
* GetParentWindow() const;
291 Returns the dimensions to be used for the preview window.
293 const wxRect
GetPreviewRect() const;
296 Returns a pointer to the internal print data.
298 wxPrintData
* GetPrintData();
301 Returns the title of the preview window or printing wait caption.
303 const wxString
GetTitle() const;
306 Shows the page setup dialog.
311 Shows a preview window for the given buffer. The function takes its own copy of
314 bool PreviewBuffer(const wxRichTextBuffer
& buffer
);
317 Shows a preview window for the given file. @a richTextFile can be a text file
318 or XML file, or other file
319 depending on the available file handlers.
321 bool PreviewFile(const wxString
& richTextFile
);
324 Prints the given buffer. The function takes its own copy of @e buffer.
326 bool PrintBuffer(const wxRichTextBuffer
& buffer
);
329 Prints the given file. @a richTextFile can be a text file or XML file, or other
331 depending on the available file handlers.
333 bool PrintFile(const wxString
& richTextFile
);
336 A convenience function to set the footer text. See wxRichTextHeaderFooterData
339 void SetFooterText(const wxString
& text
,
340 wxRichTextOddEvenPage page
= wxRICHTEXT_PAGE_ALL
,
341 wxRichTextPageLocation location
= wxRICHTEXT_PAGE_CENTRE
);
344 Sets the internal wxRichTextHeaderFooterData object.
346 void SetHeaderFooterData(const wxRichTextHeaderFooterData
& data
);
349 Sets the wxRichTextHeaderFooterData font.
351 void SetHeaderFooterFont(const wxFont
& font
);
354 Sets the wxRichTextHeaderFooterData text colour.
356 void SetHeaderFooterTextColour(const wxColour
& colour
);
359 A convenience function to set the header text. See wxRichTextHeaderFooterData
362 void SetHeaderText(const wxString
& text
,
363 wxRichTextOddEvenPage page
= wxRICHTEXT_PAGE_ALL
,
364 wxRichTextPageLocation location
= wxRICHTEXT_PAGE_CENTRE
);
367 Sets the page setup data.
369 void SetPageSetupData(const wxPageSetupData
& pageSetupData
);
372 Sets the parent window to be used for the preview window and printing wait
375 void SetParentWindow(wxWindow
* parent
);
378 Sets the dimensions to be used for the preview window.
380 void SetPreviewRect(const wxRect
& rect
);
385 void SetPrintData(const wxPrintData
& printData
);
388 Pass @true to show the header and footer on the first page.
390 void SetShowOnFirstPage(bool show
);
393 Pass the title of the preview window or printing wait caption.
395 void SetTitle(const wxString
& title
);