escape '@' symbols in the docs
[wxWidgets.git] / interface / wx / richtext / richtextprint.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: richtext/richtextprint.h
3 // Purpose: interface of wxRichTextHeaderFooterData
4 // Author: wxWidgets team
5 // RCS-ID: $Id$
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
8
9 /**
10 @class wxRichTextHeaderFooterData
11
12
13 This class represents header and footer data to be passed to the
14 wxRichTextPrinting and
15 wxRichTextPrintout classes.
16
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
20 can also
21 be specified. You can specify the following keywords in header and footer text,
22 which will
23 be substituted for the actual values during printing and preview.
24
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.
31
32 @library{wxrichtext}
33 @category{richtext}
34 */
35 class wxRichTextHeaderFooterData : public wxObject
36 {
37 public:
38 //@{
39 /**
40 Constructors.
41 */
42 wxRichTextHeaderFooterData();
43 wxRichTextHeaderFooterData(const wxRichTextHeaderFooterData& data);
44 //@}
45
46 /**
47 Clears all text.
48 */
49 void Clear();
50
51 /**
52 Copies the data.
53 */
54 void Copy(const wxRichTextHeaderFooterData& data);
55
56 /**
57 Returns the font specified for printing the header and footer.
58 */
59 const wxFont GetFont() const;
60
61 /**
62 Returns the margin between the text and the footer.
63 */
64 int GetFooterMargin() const;
65
66 /**
67 Returns the footer text on odd or even pages, and at a given position on the
68 page (left, centre or right).
69 */
70 wxString GetFooterText(wxRichTextOddEvenPage page = wxRICHTEXT_PAGE_EVEN,
71 wxRichTextPageLocation location = wxRICHTEXT_PAGE_CENTRE) const;
72
73 /**
74 Returns the margin between the text and the header.
75 */
76 int GetHeaderMargin() const;
77
78 /**
79 Returns the header text on odd or even pages, and at a given position on the
80 page (left, centre or right).
81 */
82 wxString GetHeaderText(wxRichTextOddEvenPage page = wxRICHTEXT_PAGE_EVEN,
83 wxRichTextPageLocation location = wxRICHTEXT_PAGE_CENTRE) const;
84
85 /**
86 Returns @true if the header and footer will be shown on the first page.
87 */
88 bool GetShowOnFirstPage() const;
89
90 /**
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).
93 */
94 wxString GetText(int headerFooter, wxRichTextOddEvenPage page,
95 wxRichTextPageLocation location) const;
96
97 /**
98 Returns the text colour for drawing the header and footer.
99 */
100 const wxColour GetTextColour() const;
101
102 /**
103 Initialises the object.
104 */
105 void Init();
106
107 /**
108 Sets the font for drawing the header and footer.
109 */
110 void SetFont(const wxFont& font);
111
112 /**
113 Sets the footer text on odd or even pages, and at a given position on the page
114 (left, centre or right).
115 */
116 void SetFooterText(const wxString& text,
117 wxRichTextOddEvenPage page = wxRICHTEXT_PAGE_ALL,
118 wxRichTextPageLocation location = wxRICHTEXT_PAGE_CENTRE);
119
120 /**
121 Sets the header text on odd or even pages, and at a given position on the page
122 (left, centre or right).
123 */
124 void SetHeaderText(const wxString& text,
125 wxRichTextOddEvenPage page = wxRICHTEXT_PAGE_ALL,
126 wxRichTextPageLocation location = wxRICHTEXT_PAGE_CENTRE);
127
128 /**
129 Sets the margins between text and header or footer, in tenths of a millimeter.
130 */
131 void SetMargins(int headerMargin, int footerMargin);
132
133 /**
134 Pass @true to show the header or footer on first page (the default).
135 */
136 void SetShowOnFirstPage(bool showOnFirstPage);
137
138 /**
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).
141 */
142 void SetText(const wxString& text, int headerFooter,
143 wxRichTextOddEvenPage page,
144 wxRichTextPageLocation location);
145
146 /**
147 Sets the text colour for drawing the header and footer.
148 */
149 void SetTextColour(const wxColour& col);
150
151 /**
152 Assignment operator.
153 */
154 void operator operator=(const wxRichTextHeaderFooterData& data);
155 };
156
157
158
159 /**
160 @class wxRichTextPrintout
161
162 This class implements print layout for wxRichTextBuffer. Instead of using it
163 directly, you
164 should normally use the wxRichTextPrinting class.
165
166 @library{wxrichtext}
167 @category{richtext}
168 */
169 class wxRichTextPrintout : public wxPrintout
170 {
171 public:
172 /**
173 )
174 Constructor.
175 */
176 wxRichTextPrintout();
177
178 /**
179 Calculates scaling and text, header and footer rectangles.
180 */
181 void CalculateScaling(wxDC* dc, wxRect& textRect,
182 wxRect& headerRect,
183 wxRect& footerRect);
184
185 /**
186 Returns the header and footer data associated with the printout.
187 */
188 const wxRichTextHeaderFooterData GetHeaderFooterData() const;
189
190 /**
191 Gets the page information.
192 */
193 void GetPageInfo(int* minPage, int* maxPage, int* selPageFrom,
194 int* selPageTo);
195
196 /**
197 Returns a pointer to the buffer being rendered.
198 */
199 wxRichTextBuffer* GetRichTextBuffer() const;
200
201 /**
202 Returns @true if the given page exists in the printout.
203 */
204 bool HasPage(int page);
205
206 /**
207 Prepares for printing, laying out the buffer and calculating pagination.
208 */
209 void OnPreparePrinting();
210
211 /**
212 Does the actual printing for this page.
213 */
214 bool OnPrintPage(int page);
215
216 /**
217 Sets the header and footer data associated with the printout.
218 */
219 void SetHeaderFooterData(const wxRichTextHeaderFooterData& data);
220
221 /**
222 Sets margins in 10ths of millimetre. Defaults to 1 inch for margins.
223 */
224 void SetMargins(int top = 252, int bottom = 252, int left = 252,
225 int right = 252);
226
227 /**
228 Sets the buffer to print. wxRichTextPrintout does not manage this pointer; it
229 should
230 be managed by the calling code, such as wxRichTextPrinting.
231 */
232 void SetRichTextBuffer(wxRichTextBuffer* buffer);
233 };
234
235
236
237 /**
238 @class wxRichTextPrinting
239
240 This class provides a simple interface for performing wxRichTextBuffer printing
241 and previewing. It uses wxRichTextPrintout for layout and rendering.
242
243 @library{wxrichtext}
244 @category{richtext}
245 */
246 class wxRichTextPrinting : public wxObject
247 {
248 public:
249 /**
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.
254 */
255 wxRichTextPrinting();
256
257 /**
258 A convenience function to get the footer text. See wxRichTextHeaderFooterData
259 for details.
260 */
261 wxString GetFooterText(wxRichTextOddEvenPage page = wxRICHTEXT_PAGE_EVEN,
262 wxRichTextPageLocation location = wxRICHTEXT_PAGE_CENTRE) const;
263
264 /**
265 Returns the internal wxRichTextHeaderFooterData object.
266 */
267 const wxRichTextHeaderFooterData GetHeaderFooterData() const;
268
269 /**
270 A convenience function to get the header text. See wxRichTextHeaderFooterData
271 for details.
272 */
273 wxString GetHeaderText(wxRichTextOddEvenPage page = wxRICHTEXT_PAGE_EVEN,
274 wxRichTextPageLocation location = wxRICHTEXT_PAGE_CENTRE) const;
275
276 /**
277 Returns a pointer to the internal page setup data.
278 */
279 wxPageSetupDialogData* GetPageSetupData();
280
281 /**
282 Returns the parent window to be used for the preview window and printing wait
283 dialog.
284 */
285 wxWindow* GetParentWindow() const;
286
287 /**
288 Returns the dimensions to be used for the preview window.
289 */
290 const wxRect GetPreviewRect() const;
291
292 /**
293 Returns a pointer to the internal print data.
294 */
295 wxPrintData* GetPrintData();
296
297 /**
298 Returns the title of the preview window or printing wait caption.
299 */
300 const wxString GetTitle() const;
301
302 /**
303 Shows the page setup dialog.
304 */
305 void PageSetup();
306
307 /**
308 Shows a preview window for the given buffer. The function takes its own copy of
309 @e buffer.
310 */
311 bool PreviewBuffer(const wxRichTextBuffer& buffer);
312
313 /**
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.
317 */
318 bool PreviewFile(const wxString& richTextFile);
319
320 /**
321 Prints the given buffer. The function takes its own copy of @e buffer.
322 */
323 bool PrintBuffer(const wxRichTextBuffer& buffer);
324
325 /**
326 Prints the given file. @a richTextFile can be a text file or XML file, or other
327 file
328 depending on the available file handlers.
329 */
330 bool PrintFile(const wxString& richTextFile);
331
332 /**
333 A convenience function to set the footer text. See wxRichTextHeaderFooterData
334 for details.
335 */
336 void SetFooterText(const wxString& text,
337 wxRichTextOddEvenPage page = wxRICHTEXT_PAGE_ALL,
338 wxRichTextPageLocation location = wxRICHTEXT_PAGE_CENTRE);
339
340 /**
341 Sets the internal wxRichTextHeaderFooterData object.
342 */
343 void SetHeaderFooterData(const wxRichTextHeaderFooterData& data);
344
345 /**
346 Sets the wxRichTextHeaderFooterData font.
347 */
348 void SetHeaderFooterFont(const wxFont& font);
349
350 /**
351 Sets the wxRichTextHeaderFooterData text colour.
352 */
353 void SetHeaderFooterTextColour(const wxColour& colour);
354
355 /**
356 A convenience function to set the header text. See wxRichTextHeaderFooterData
357 for details.
358 */
359 void SetHeaderText(const wxString& text,
360 wxRichTextOddEvenPage page = wxRICHTEXT_PAGE_ALL,
361 wxRichTextPageLocation location = wxRICHTEXT_PAGE_CENTRE);
362
363 /**
364 Sets the page setup data.
365 */
366 void SetPageSetupData(const wxPageSetupData& pageSetupData);
367
368 /**
369 Sets the parent window to be used for the preview window and printing wait
370 dialog.
371 */
372 void SetParentWindow(wxWindow* parent);
373
374 /**
375 Sets the dimensions to be used for the preview window.
376 */
377 void SetPreviewRect(const wxRect& rect);
378
379 /**
380 Sets the print data.
381 */
382 void SetPrintData(const wxPrintData& printData);
383
384 /**
385 Pass @true to show the header and footer on the first page.
386 */
387 void SetShowOnFirstPage(bool show);
388
389 /**
390 Pass the title of the preview window or printing wait caption.
391 */
392 void SetTitle(const wxString& title);
393 };
394