1 /////////////////////////////////////////////////////////////////////////////
2 // Name: richtext/richtextprint.h
3 // Purpose: interface of wxRichTextHeaderFooterData
4 // Author: wxWidgets team
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
11 These are the header and footer page identifiers, passed to functions such
12 as wxRichTextHeaderFooterData::SetFooterText to specify the odd or even page
15 enum wxRichTextOddEvenPage
{
23 These are the location identifiers for passing to functions such as
24 wxRichTextHeaderFooterData::SetFooterText(), to specify whether the text
25 is on the left, centre or right of the page.
27 enum wxRichTextPageLocation
{
29 wxRICHTEXT_PAGE_CENTRE
,
35 @class wxRichTextHeaderFooterData
38 This class represents header and footer data to be passed to the
39 wxRichTextPrinting and wxRichTextPrintout classes.
41 Headers and footers can be specified independently for odd, even or both page
42 sides. Different text can be specified for left, centre and right locations
43 on the page, and the font and text colour can also be specified.
45 You can specify the following keywords in header and footer text, which will
46 be substituted for the actual values during printing and preview.
48 - @@DATE@: the current date.
49 - @@PAGESCNT@: the total number of pages.
50 - @@PAGENUM@: the current page number.
51 - @@TIME@: the current time.
52 - @@TITLE@: the title of the document, as passed to the wxRichTextPrinting or
53 wxRichTextLayout constructor.
58 class wxRichTextHeaderFooterData
: public wxObject
65 wxRichTextHeaderFooterData();
66 wxRichTextHeaderFooterData(const wxRichTextHeaderFooterData
& data
);
77 void Copy(const wxRichTextHeaderFooterData
& data
);
80 Returns the font specified for printing the header and footer.
82 const wxFont
& GetFont() const;
85 Returns the margin between the text and the footer.
87 int GetFooterMargin() const;
90 Returns the footer text on odd or even pages, and at a given position on the
91 page (left, centre or right).
93 wxString
GetFooterText(wxRichTextOddEvenPage page
= wxRICHTEXT_PAGE_EVEN
,
94 wxRichTextPageLocation location
= wxRICHTEXT_PAGE_CENTRE
) const;
97 Returns the margin between the text and the header.
99 int GetHeaderMargin() const;
102 Returns the header text on odd or even pages, and at a given position on the
103 page (left, centre or right).
105 wxString
GetHeaderText(wxRichTextOddEvenPage page
= wxRICHTEXT_PAGE_EVEN
,
106 wxRichTextPageLocation location
= wxRICHTEXT_PAGE_CENTRE
) const;
109 Returns @true if the header and footer will be shown on the first page.
111 bool GetShowOnFirstPage() const;
114 Helper function for getting the header or footer text, odd or even pages, and
115 at a given position on the page (left, centre or right).
117 wxString
GetText(int headerFooter
, wxRichTextOddEvenPage page
,
118 wxRichTextPageLocation location
) const;
121 Returns the text colour for drawing the header and footer.
123 const wxColour
& GetTextColour() const;
126 Initialises the object.
131 Sets the font for drawing the header and footer.
133 void SetFont(const wxFont
& font
);
136 Sets the footer text on odd or even pages, and at a given position on the page
137 (left, centre or right).
139 void SetFooterText(const wxString
& text
,
140 wxRichTextOddEvenPage page
= wxRICHTEXT_PAGE_ALL
,
141 wxRichTextPageLocation location
= wxRICHTEXT_PAGE_CENTRE
);
144 Sets the header text on odd or even pages, and at a given position on the page
145 (left, centre or right).
147 void SetHeaderText(const wxString
& text
,
148 wxRichTextOddEvenPage page
= wxRICHTEXT_PAGE_ALL
,
149 wxRichTextPageLocation location
= wxRICHTEXT_PAGE_CENTRE
);
152 Sets the margins between text and header or footer, in tenths of a millimeter.
154 void SetMargins(int headerMargin
, int footerMargin
);
157 Pass @true to show the header or footer on first page (the default).
159 void SetShowOnFirstPage(bool showOnFirstPage
);
162 Helper function for setting the header or footer text, odd or even pages, and
163 at a given position on the page (left, centre or right).
165 void SetText(const wxString
& text
, int headerFooter
,
166 wxRichTextOddEvenPage page
,
167 wxRichTextPageLocation location
);
170 Sets the text colour for drawing the header and footer.
172 void SetTextColour(const wxColour
& col
);
177 void operator operator=(const wxRichTextHeaderFooterData
& data
);
183 @class wxRichTextPrintout
185 This class implements print layout for wxRichTextBuffer.
186 Instead of using it directly, you should normally use the wxRichTextPrinting class.
191 class wxRichTextPrintout
: public wxPrintout
197 wxRichTextPrintout(const wxString
& title
= "Printout");
200 Calculates scaling and text, header and footer rectangles.
202 void CalculateScaling(wxDC
* dc
, wxRect
& textRect
,
207 Returns the header and footer data associated with the printout.
209 const wxRichTextHeaderFooterData
& GetHeaderFooterData() const;
212 Gets the page information.
214 virtual void GetPageInfo(int* minPage
, int* maxPage
, int* selPageFrom
,
218 Returns a pointer to the buffer being rendered.
220 wxRichTextBuffer
* GetRichTextBuffer() const;
223 Returns @true if the given page exists in the printout.
225 virtual bool HasPage(int page
);
228 Prepares for printing, laying out the buffer and calculating pagination.
230 virtual void OnPreparePrinting();
233 Does the actual printing for this page.
235 virtual bool OnPrintPage(int page
);
238 Sets the header and footer data associated with the printout.
240 void SetHeaderFooterData(const wxRichTextHeaderFooterData
& data
);
243 Sets margins in 10ths of millimetre. Defaults to 1 inch for margins.
245 void SetMargins(int top
= 254, int bottom
= 254, int left
= 254,
249 Sets the buffer to print. wxRichTextPrintout does not manage this pointer;
250 it should be managed by the calling code, such as wxRichTextPrinting.
252 void SetRichTextBuffer(wxRichTextBuffer
* buffer
);
258 @class wxRichTextPrinting
260 This class provides a simple interface for performing wxRichTextBuffer printing
261 and previewing. It uses wxRichTextPrintout for layout and rendering.
266 class wxRichTextPrinting
: public wxObject
272 Optionally pass a title to be used in the preview frame and printing wait
273 dialog, and also a parent window for these windows.
275 wxRichTextPrinting(const wxString
& name
= "Printing",
276 wxWindow
* parentWindow
= NULL
);
279 A convenience function to get the footer text.
280 See wxRichTextHeaderFooterData for details.
282 wxString
GetFooterText(wxRichTextOddEvenPage page
= wxRICHTEXT_PAGE_EVEN
,
283 wxRichTextPageLocation location
= wxRICHTEXT_PAGE_CENTRE
) const;
286 Returns the internal wxRichTextHeaderFooterData object.
288 const wxRichTextHeaderFooterData
& GetHeaderFooterData() const;
291 A convenience function to get the header text.
292 See wxRichTextHeaderFooterData for details.
294 wxString
GetHeaderText(wxRichTextOddEvenPage page
= wxRICHTEXT_PAGE_EVEN
,
295 wxRichTextPageLocation location
= wxRICHTEXT_PAGE_CENTRE
) const;
298 Returns a pointer to the internal page setup data.
300 wxPageSetupDialogData
* GetPageSetupData();
303 Returns the parent window to be used for the preview window and printing
306 wxWindow
* GetParentWindow() const;
309 Returns the dimensions to be used for the preview window.
311 const wxRect
& GetPreviewRect() const;
314 Returns a pointer to the internal print data.
316 wxPrintData
* GetPrintData();
319 Returns the title of the preview window or printing wait caption.
321 const wxString
& GetTitle() const;
324 Shows the page setup dialog.
329 Shows a preview window for the given buffer.
330 The function takes its own copy of @a buffer.
332 bool PreviewBuffer(const wxRichTextBuffer
& buffer
);
335 Shows a preview window for the given file.
337 @a richTextFile can be a text file or XML file, or other file
338 depending on the available file handlers.
340 bool PreviewFile(const wxString
& richTextFile
);
343 Prints the given buffer. The function takes its own copy of @a buffer.
345 bool PrintBuffer(const wxRichTextBuffer
& buffer
);
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.
351 bool PrintFile(const wxString
& richTextFile
);
354 A convenience function to set the footer text.
355 See wxRichTextHeaderFooterData for details.
357 void SetFooterText(const wxString
& text
,
358 wxRichTextOddEvenPage page
= wxRICHTEXT_PAGE_ALL
,
359 wxRichTextPageLocation location
= wxRICHTEXT_PAGE_CENTRE
);
362 Sets the internal wxRichTextHeaderFooterData object.
364 void SetHeaderFooterData(const wxRichTextHeaderFooterData
& data
);
367 Sets the wxRichTextHeaderFooterData font.
369 void SetHeaderFooterFont(const wxFont
& font
);
372 Sets the wxRichTextHeaderFooterData text colour.
374 void SetHeaderFooterTextColour(const wxColour
& colour
);
377 A convenience function to set the header text.
378 See wxRichTextHeaderFooterData for details.
380 void SetHeaderText(const wxString
& text
,
381 wxRichTextOddEvenPage page
= wxRICHTEXT_PAGE_ALL
,
382 wxRichTextPageLocation location
= wxRICHTEXT_PAGE_CENTRE
);
385 Sets the page setup data.
387 void SetPageSetupData(const wxPageSetupDialogData
& pageSetupData
);
390 Sets the parent window to be used for the preview window and printing
393 void SetParentWindow(wxWindow
* parent
);
396 Sets the dimensions to be used for the preview window.
398 void SetPreviewRect(const wxRect
& rect
);
403 void SetPrintData(const wxPrintData
& printData
);
406 Pass @true to show the header and footer on the first page.
408 void SetShowOnFirstPage(bool show
);
411 Pass the title of the preview window or printing wait caption.
413 void SetTitle(const wxString
& title
);