1 /////////////////////////////////////////////////////////////////////////////
2 // Name: richtext/richtextprint.h
3 // Purpose: interface of wxRichTextHeaderFooterData
4 // Author: wxWidgets team
5 // Licence: wxWindows licence
6 /////////////////////////////////////////////////////////////////////////////
10 These are the header and footer page identifiers, passed to functions such
11 as wxRichTextHeaderFooterData::SetFooterText to specify the odd or even page
14 enum wxRichTextOddEvenPage
{
22 These are the location identifiers for passing to functions such as
23 wxRichTextHeaderFooterData::SetFooterText(), to specify whether the text
24 is on the left, centre or right of the page.
26 enum wxRichTextPageLocation
{
28 wxRICHTEXT_PAGE_CENTRE
,
34 @class wxRichTextHeaderFooterData
37 This class represents header and footer data to be passed to the
38 wxRichTextPrinting and wxRichTextPrintout classes.
40 Headers and footers can be specified independently for odd, even or both page
41 sides. Different text can be specified for left, centre and right locations
42 on the page, and the font and text colour can also be specified.
44 You can specify the following keywords in header and footer text, which will
45 be substituted for the actual values during printing and preview.
47 - @@DATE@: the current date.
48 - @@PAGESCNT@: the total number of pages.
49 - @@PAGENUM@: the current page number.
50 - @@TIME@: the current time.
51 - @@TITLE@: the title of the document, as passed to the wxRichTextPrinting or
52 wxRichTextLayout constructor.
57 class wxRichTextHeaderFooterData
: public wxObject
64 wxRichTextHeaderFooterData();
65 wxRichTextHeaderFooterData(const wxRichTextHeaderFooterData
& data
);
76 void Copy(const wxRichTextHeaderFooterData
& data
);
79 Returns the font specified for printing the header and footer.
81 const wxFont
& GetFont() const;
84 Returns the margin between the text and the footer.
86 int GetFooterMargin() const;
89 Returns the footer text on odd or even pages, and at a given position on the
90 page (left, centre or right).
92 wxString
GetFooterText(wxRichTextOddEvenPage page
= wxRICHTEXT_PAGE_EVEN
,
93 wxRichTextPageLocation location
= wxRICHTEXT_PAGE_CENTRE
) const;
96 Returns the margin between the text and the header.
98 int GetHeaderMargin() const;
101 Returns the header text on odd or even pages, and at a given position on the
102 page (left, centre or right).
104 wxString
GetHeaderText(wxRichTextOddEvenPage page
= wxRICHTEXT_PAGE_EVEN
,
105 wxRichTextPageLocation location
= wxRICHTEXT_PAGE_CENTRE
) const;
108 Returns @true if the header and footer will be shown on the first page.
110 bool GetShowOnFirstPage() const;
113 Helper function for getting the header or footer text, odd or even pages, and
114 at a given position on the page (left, centre or right).
116 wxString
GetText(int headerFooter
, wxRichTextOddEvenPage page
,
117 wxRichTextPageLocation location
) const;
120 Returns the text colour for drawing the header and footer.
122 const wxColour
& GetTextColour() const;
125 Initialises the object.
130 Sets the font for drawing the header and footer.
132 void SetFont(const wxFont
& font
);
135 Sets the footer text on odd or even pages, and at a given position on the page
136 (left, centre or right).
138 void SetFooterText(const wxString
& text
,
139 wxRichTextOddEvenPage page
= wxRICHTEXT_PAGE_ALL
,
140 wxRichTextPageLocation location
= wxRICHTEXT_PAGE_CENTRE
);
143 Sets the header text on odd or even pages, and at a given position on the page
144 (left, centre or right).
146 void SetHeaderText(const wxString
& text
,
147 wxRichTextOddEvenPage page
= wxRICHTEXT_PAGE_ALL
,
148 wxRichTextPageLocation location
= wxRICHTEXT_PAGE_CENTRE
);
151 Sets the margins between text and header or footer, in tenths of a millimeter.
153 void SetMargins(int headerMargin
, int footerMargin
);
156 Pass @true to show the header or footer on first page (the default).
158 void SetShowOnFirstPage(bool showOnFirstPage
);
161 Helper function for setting the header or footer text, odd or even pages, and
162 at a given position on the page (left, centre or right).
164 void SetText(const wxString
& text
, int headerFooter
,
165 wxRichTextOddEvenPage page
,
166 wxRichTextPageLocation location
);
169 Sets the text colour for drawing the header and footer.
171 void SetTextColour(const wxColour
& col
);
176 void operator operator=(const wxRichTextHeaderFooterData
& data
);
182 @class wxRichTextPrintout
184 This class implements print layout for wxRichTextBuffer.
185 Instead of using it directly, you should normally use the wxRichTextPrinting class.
190 class wxRichTextPrintout
: public wxPrintout
196 wxRichTextPrintout(const wxString
& title
= "Printout");
199 Calculates scaling and text, header and footer rectangles.
201 void CalculateScaling(wxDC
* dc
, wxRect
& textRect
,
206 Returns the header and footer data associated with the printout.
208 const wxRichTextHeaderFooterData
& GetHeaderFooterData() const;
211 Gets the page information.
213 virtual void GetPageInfo(int* minPage
, int* maxPage
, int* selPageFrom
,
217 Returns a pointer to the buffer being rendered.
219 wxRichTextBuffer
* GetRichTextBuffer() const;
222 Returns @true if the given page exists in the printout.
224 virtual bool HasPage(int page
);
227 Prepares for printing, laying out the buffer and calculating pagination.
229 virtual void OnPreparePrinting();
232 Does the actual printing for this page.
234 virtual bool OnPrintPage(int page
);
237 Sets the header and footer data associated with the printout.
239 void SetHeaderFooterData(const wxRichTextHeaderFooterData
& data
);
242 Sets margins in 10ths of millimetre. Defaults to 1 inch for margins.
244 void SetMargins(int top
= 254, int bottom
= 254, int left
= 254,
248 Sets the buffer to print. wxRichTextPrintout does not manage this pointer;
249 it should be managed by the calling code, such as wxRichTextPrinting.
251 void SetRichTextBuffer(wxRichTextBuffer
* buffer
);
257 @class wxRichTextPrinting
259 This class provides a simple interface for performing wxRichTextBuffer printing
260 and previewing. It uses wxRichTextPrintout for layout and rendering.
265 class wxRichTextPrinting
: public wxObject
271 Optionally pass a title to be used in the preview frame and printing wait
272 dialog, and also a parent window for these windows.
274 wxRichTextPrinting(const wxString
& name
= "Printing",
275 wxWindow
* parentWindow
= NULL
);
278 A convenience function to get the footer text.
279 See wxRichTextHeaderFooterData for details.
281 wxString
GetFooterText(wxRichTextOddEvenPage page
= wxRICHTEXT_PAGE_EVEN
,
282 wxRichTextPageLocation location
= wxRICHTEXT_PAGE_CENTRE
) const;
285 Returns the internal wxRichTextHeaderFooterData object.
287 const wxRichTextHeaderFooterData
& GetHeaderFooterData() const;
290 A convenience function to get the header text.
291 See wxRichTextHeaderFooterData for details.
293 wxString
GetHeaderText(wxRichTextOddEvenPage page
= wxRICHTEXT_PAGE_EVEN
,
294 wxRichTextPageLocation location
= wxRICHTEXT_PAGE_CENTRE
) const;
297 Returns a pointer to the internal page setup data.
299 wxPageSetupDialogData
* GetPageSetupData();
302 Returns the parent window to be used for the preview window and printing
305 wxWindow
* GetParentWindow() const;
308 Returns the dimensions to be used for the preview window.
310 const wxRect
& GetPreviewRect() const;
313 Returns a pointer to the internal print data.
315 wxPrintData
* GetPrintData();
318 Returns the title of the preview window or printing wait caption.
320 const wxString
& GetTitle() const;
323 Shows the page setup dialog.
328 Shows a preview window for the given buffer.
329 The function takes its own copy of @a buffer.
331 bool PreviewBuffer(const wxRichTextBuffer
& buffer
);
334 Shows a preview window for the given file.
336 @a richTextFile can be a text file or XML file, or other file
337 depending on the available file handlers.
339 bool PreviewFile(const wxString
& richTextFile
);
342 Prints the given buffer. The function takes its own copy of @a buffer.
343 @a showPrintDialog can be @true to show the print dialog, or @false to print quietly.
345 bool PrintBuffer(const wxRichTextBuffer
& buffer
, bool showPrintDialog
= true);
348 Prints the given file. @a richTextFile can be a text file or XML file,
349 or other file depending on the available file handlers. @a showPrintDialog
350 can be @true to show the print dialog, or @false to print quietly.
352 bool PrintFile(const wxString
& richTextFile
, bool showPrintDialog
= true);
355 A convenience function to set the footer text.
356 See wxRichTextHeaderFooterData for details.
358 void SetFooterText(const wxString
& text
,
359 wxRichTextOddEvenPage page
= wxRICHTEXT_PAGE_ALL
,
360 wxRichTextPageLocation location
= wxRICHTEXT_PAGE_CENTRE
);
363 Sets the internal wxRichTextHeaderFooterData object.
365 void SetHeaderFooterData(const wxRichTextHeaderFooterData
& data
);
368 Sets the wxRichTextHeaderFooterData font.
370 void SetHeaderFooterFont(const wxFont
& font
);
373 Sets the wxRichTextHeaderFooterData text colour.
375 void SetHeaderFooterTextColour(const wxColour
& colour
);
378 A convenience function to set the header text.
379 See wxRichTextHeaderFooterData for details.
381 void SetHeaderText(const wxString
& text
,
382 wxRichTextOddEvenPage page
= wxRICHTEXT_PAGE_ALL
,
383 wxRichTextPageLocation location
= wxRICHTEXT_PAGE_CENTRE
);
386 Sets the page setup data.
388 void SetPageSetupData(const wxPageSetupDialogData
& pageSetupData
);
391 Sets the parent window to be used for the preview window and printing
394 void SetParentWindow(wxWindow
* parent
);
397 Sets the dimensions to be used for the preview window.
399 void SetPreviewRect(const wxRect
& rect
);
404 void SetPrintData(const wxPrintData
& printData
);
407 Pass @true to show the header and footer on the first page.
409 void SetShowOnFirstPage(bool show
);
412 Pass the title of the preview window or printing wait caption.
414 void SetTitle(const wxString
& title
);