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