1 /////////////////////////////////////////////////////////////////////////////
2 // Name: richtext/richtextprint.h
3 // Purpose: interface of wxRichTextHeaderFooterData
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
10 @class wxRichTextHeaderFooterData
13 This class represents header and footer data to be passed to the
14 wxRichTextPrinting and
15 wxRichTextPrintout classes.
17 Headers and footers can be specified independently for odd, even or both page
18 sides. Different text can be specified
19 for left, centre and right locations on the page, and the font and text colour
21 be specified. You can specify the following keywords in header and footer text,
23 be substituted for the actual values during printing and preview.
25 @@DATE@: the current date.
26 @@PAGESCNT@: the total number of pages.
27 @@PAGENUM@: the current page number.
28 @@TIME@: the current time.
29 @@TITLE@: the title of the document, as passed to the wxRichTextPrinting or
30 wxRichTextLayout constructor.
35 class wxRichTextHeaderFooterData
: public wxObject
42 wxRichTextHeaderFooterData();
43 wxRichTextHeaderFooterData(const wxRichTextHeaderFooterData
& data
);
54 void Copy(const wxRichTextHeaderFooterData
& data
);
57 Returns the font specified for printing the header and footer.
59 const wxFont
GetFont() const;
62 Returns the margin between the text and the footer.
64 int GetFooterMargin() const;
67 Returns the footer text on odd or even pages, and at a given position on the
68 page (left, centre or right).
70 wxString
GetFooterText(wxRichTextOddEvenPage page
= wxRICHTEXT_PAGE_EVEN
,
71 wxRichTextPageLocation location
= wxRICHTEXT_PAGE_CENTRE
) const;
74 Returns the margin between the text and the header.
76 int GetHeaderMargin() const;
79 Returns the header text on odd or even pages, and at a given position on the
80 page (left, centre or right).
82 wxString
GetHeaderText(wxRichTextOddEvenPage page
= wxRICHTEXT_PAGE_EVEN
,
83 wxRichTextPageLocation location
= wxRICHTEXT_PAGE_CENTRE
) const;
86 Returns @true if the header and footer will be shown on the first page.
88 bool GetShowOnFirstPage() const;
91 Helper function for getting the header or footer text, odd or even pages, and
92 at a given position on the page (left, centre or right).
94 wxString
GetText(int headerFooter
, wxRichTextOddEvenPage page
,
95 wxRichTextPageLocation location
) const;
98 Returns the text colour for drawing the header and footer.
100 const wxColour
GetTextColour() const;
103 Initialises the object.
108 Sets the font for drawing the header and footer.
110 void SetFont(const wxFont
& font
);
113 Sets the footer text on odd or even pages, and at a given position on the page
114 (left, centre or right).
116 void SetFooterText(const wxString
& text
,
117 wxRichTextOddEvenPage page
= wxRICHTEXT_PAGE_ALL
,
118 wxRichTextPageLocation location
= wxRICHTEXT_PAGE_CENTRE
);
121 Sets the header text on odd or even pages, and at a given position on the page
122 (left, centre or right).
124 void SetHeaderText(const wxString
& text
,
125 wxRichTextOddEvenPage page
= wxRICHTEXT_PAGE_ALL
,
126 wxRichTextPageLocation location
= wxRICHTEXT_PAGE_CENTRE
);
129 Sets the margins between text and header or footer, in tenths of a millimeter.
131 void SetMargins(int headerMargin
, int footerMargin
);
134 Pass @true to show the header or footer on first page (the default).
136 void SetShowOnFirstPage(bool showOnFirstPage
);
139 Helper function for setting the header or footer text, odd or even pages, and
140 at a given position on the page (left, centre or right).
142 void SetText(const wxString
& text
, int headerFooter
,
143 wxRichTextOddEvenPage page
,
144 wxRichTextPageLocation location
);
147 Sets the text colour for drawing the header and footer.
149 void SetTextColour(const wxColour
& col
);
154 void operator operator=(const wxRichTextHeaderFooterData
& data
);
160 @class wxRichTextPrintout
162 This class implements print layout for wxRichTextBuffer. Instead of using it
164 should normally use the wxRichTextPrinting class.
169 class wxRichTextPrintout
: public wxPrintout
176 wxRichTextPrintout();
179 Calculates scaling and text, header and footer rectangles.
181 void CalculateScaling(wxDC
* dc
, wxRect
& textRect
,
186 Returns the header and footer data associated with the printout.
188 const wxRichTextHeaderFooterData
GetHeaderFooterData() const;
191 Gets the page information.
193 void GetPageInfo(int* minPage
, int* maxPage
, int* selPageFrom
,
197 Returns a pointer to the buffer being rendered.
199 wxRichTextBuffer
* GetRichTextBuffer() const;
202 Returns @true if the given page exists in the printout.
204 bool HasPage(int page
);
207 Prepares for printing, laying out the buffer and calculating pagination.
209 void OnPreparePrinting();
212 Does the actual printing for this page.
214 bool OnPrintPage(int page
);
217 Sets the header and footer data associated with the printout.
219 void SetHeaderFooterData(const wxRichTextHeaderFooterData
& data
);
222 Sets margins in 10ths of millimetre. Defaults to 1 inch for margins.
224 void SetMargins(int top
= 252, int bottom
= 252, int left
= 252,
228 Sets the buffer to print. wxRichTextPrintout does not manage this pointer; it
230 be managed by the calling code, such as wxRichTextPrinting.
232 void SetRichTextBuffer(wxRichTextBuffer
* buffer
);
238 @class wxRichTextPrinting
240 This class provides a simple interface for performing wxRichTextBuffer printing
241 and previewing. It uses wxRichTextPrintout for layout and rendering.
246 class wxRichTextPrinting
: public wxObject
250 , @b wxWindow*@e parentWindow = @NULL)
251 Constructor. Optionally pass a title to be used in the preview frame and
252 printing wait dialog, and
253 also a parent window for these windows.
255 wxRichTextPrinting();
258 A convenience function to get the footer text. See wxRichTextHeaderFooterData
261 wxString
GetFooterText(wxRichTextOddEvenPage page
= wxRICHTEXT_PAGE_EVEN
,
262 wxRichTextPageLocation location
= wxRICHTEXT_PAGE_CENTRE
) const;
265 Returns the internal wxRichTextHeaderFooterData object.
267 const wxRichTextHeaderFooterData
GetHeaderFooterData() const;
270 A convenience function to get the header text. See wxRichTextHeaderFooterData
273 wxString
GetHeaderText(wxRichTextOddEvenPage page
= wxRICHTEXT_PAGE_EVEN
,
274 wxRichTextPageLocation location
= wxRICHTEXT_PAGE_CENTRE
) const;
277 Returns a pointer to the internal page setup data.
279 wxPageSetupDialogData
* GetPageSetupData();
282 Returns the parent window to be used for the preview window and printing wait
285 wxWindow
* GetParentWindow() const;
288 Returns the dimensions to be used for the preview window.
290 const wxRect
GetPreviewRect() const;
293 Returns a pointer to the internal print data.
295 wxPrintData
* GetPrintData();
298 Returns the title of the preview window or printing wait caption.
300 const wxString
GetTitle() const;
303 Shows the page setup dialog.
308 Shows a preview window for the given buffer. The function takes its own copy of
311 bool PreviewBuffer(const wxRichTextBuffer
& buffer
);
314 Shows a preview window for the given file. @a richTextFile can be a text file
315 or XML file, or other file
316 depending on the available file handlers.
318 bool PreviewFile(const wxString
& richTextFile
);
321 Prints the given buffer. The function takes its own copy of @e buffer.
323 bool PrintBuffer(const wxRichTextBuffer
& buffer
);
326 Prints the given file. @a richTextFile can be a text file or XML file, or other
328 depending on the available file handlers.
330 bool PrintFile(const wxString
& richTextFile
);
333 A convenience function to set the footer text. See wxRichTextHeaderFooterData
336 void SetFooterText(const wxString
& text
,
337 wxRichTextOddEvenPage page
= wxRICHTEXT_PAGE_ALL
,
338 wxRichTextPageLocation location
= wxRICHTEXT_PAGE_CENTRE
);
341 Sets the internal wxRichTextHeaderFooterData object.
343 void SetHeaderFooterData(const wxRichTextHeaderFooterData
& data
);
346 Sets the wxRichTextHeaderFooterData font.
348 void SetHeaderFooterFont(const wxFont
& font
);
351 Sets the wxRichTextHeaderFooterData text colour.
353 void SetHeaderFooterTextColour(const wxColour
& colour
);
356 A convenience function to set the header text. See wxRichTextHeaderFooterData
359 void SetHeaderText(const wxString
& text
,
360 wxRichTextOddEvenPage page
= wxRICHTEXT_PAGE_ALL
,
361 wxRichTextPageLocation location
= wxRICHTEXT_PAGE_CENTRE
);
364 Sets the page setup data.
366 void SetPageSetupData(const wxPageSetupData
& pageSetupData
);
369 Sets the parent window to be used for the preview window and printing wait
372 void SetParentWindow(wxWindow
* parent
);
375 Sets the dimensions to be used for the preview window.
377 void SetPreviewRect(const wxRect
& rect
);
382 void SetPrintData(const wxPrintData
& printData
);
385 Pass @true to show the header and footer on the first page.
387 void SetShowOnFirstPage(bool show
);
390 Pass the title of the preview window or printing wait caption.
392 void SetTitle(const wxString
& title
);