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