]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/richtext/richtextprint.h
synchronize GTK2 minimum version in docs
[wxWidgets.git] / interface / wx / richtext / richtextprint.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: richtext/richtextprint.h
21b447dc 3// Purpose: interface of wxRichTextHeaderFooterData
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
526954c5 6// Licence: wxWindows licence
23324ae1
FM
7/////////////////////////////////////////////////////////////////////////////
8
9e7ad1ca
FM
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*/
15enum 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*/
27enum wxRichTextPageLocation {
28 wxRICHTEXT_PAGE_LEFT,
29 wxRICHTEXT_PAGE_CENTRE,
30 wxRICHTEXT_PAGE_RIGHT
31};
32
33
23324ae1
FM
34/**
35 @class wxRichTextHeaderFooterData
7c913512
FM
36
37
23324ae1 38 This class represents header and footer data to be passed to the
9e7ad1ca 39 wxRichTextPrinting and wxRichTextPrintout classes.
7c913512 40
23324ae1 41 Headers and footers can be specified independently for odd, even or both page
9e7ad1ca
FM
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
23324ae1 46 be substituted for the actual values during printing and preview.
7c913512 47
9e7ad1ca
FM
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.
7c913512 54
23324ae1 55 @library{wxrichtext}
21b447dc 56 @category{richtext}
23324ae1
FM
57*/
58class wxRichTextHeaderFooterData : public wxObject
59{
60public:
61 //@{
62 /**
63 Constructors.
64 */
65 wxRichTextHeaderFooterData();
7c913512 66 wxRichTextHeaderFooterData(const wxRichTextHeaderFooterData& data);
23324ae1
FM
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 */
9e7ad1ca 82 const wxFont& GetFont() const;
23324ae1
FM
83
84 /**
85 Returns the margin between the text and the footer.
86 */
328f5751 87 int GetFooterMargin() const;
23324ae1
FM
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,
328f5751 94 wxRichTextPageLocation location = wxRICHTEXT_PAGE_CENTRE) const;
23324ae1
FM
95
96 /**
97 Returns the margin between the text and the header.
98 */
328f5751 99 int GetHeaderMargin() const;
23324ae1
FM
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,
328f5751 106 wxRichTextPageLocation location = wxRICHTEXT_PAGE_CENTRE) const;
23324ae1
FM
107
108 /**
109 Returns @true if the header and footer will be shown on the first page.
110 */
328f5751 111 bool GetShowOnFirstPage() const;
23324ae1
FM
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,
328f5751 118 wxRichTextPageLocation location) const;
23324ae1
FM
119
120 /**
121 Returns the text colour for drawing the header and footer.
122 */
5267aefd 123 const wxColour& GetTextColour() const;
23324ae1
FM
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
e54c96f1 181
23324ae1
FM
182/**
183 @class wxRichTextPrintout
7c913512 184
9e7ad1ca
FM
185 This class implements print layout for wxRichTextBuffer.
186 Instead of using it directly, you should normally use the wxRichTextPrinting class.
7c913512 187
23324ae1 188 @library{wxrichtext}
21b447dc 189 @category{richtext}
23324ae1
FM
190*/
191class wxRichTextPrintout : public wxPrintout
192{
193public:
194 /**
23324ae1
FM
195 Constructor.
196 */
f8ebb70d 197 wxRichTextPrintout(const wxString& title = "Printout");
23324ae1
FM
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 */
5267aefd 209 const wxRichTextHeaderFooterData& GetHeaderFooterData() const;
23324ae1
FM
210
211 /**
212 Gets the page information.
213 */
fadc2df6
FM
214 virtual void GetPageInfo(int* minPage, int* maxPage, int* selPageFrom,
215 int* selPageTo);
23324ae1
FM
216
217 /**
218 Returns a pointer to the buffer being rendered.
219 */
328f5751 220 wxRichTextBuffer* GetRichTextBuffer() const;
23324ae1
FM
221
222 /**
223 Returns @true if the given page exists in the printout.
224 */
adaaa686 225 virtual bool HasPage(int page);
23324ae1
FM
226
227 /**
228 Prepares for printing, laying out the buffer and calculating pagination.
229 */
adaaa686 230 virtual void OnPreparePrinting();
23324ae1
FM
231
232 /**
233 Does the actual printing for this page.
234 */
adaaa686 235 virtual bool OnPrintPage(int page);
23324ae1
FM
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 */
5267aefd
FM
245 void SetMargins(int top = 254, int bottom = 254, int left = 254,
246 int right = 254);
23324ae1
FM
247
248 /**
9e7ad1ca
FM
249 Sets the buffer to print. wxRichTextPrintout does not manage this pointer;
250 it should be managed by the calling code, such as wxRichTextPrinting.
23324ae1
FM
251 */
252 void SetRichTextBuffer(wxRichTextBuffer* buffer);
253};
254
255
e54c96f1 256
23324ae1
FM
257/**
258 @class wxRichTextPrinting
7c913512 259
23324ae1
FM
260 This class provides a simple interface for performing wxRichTextBuffer printing
261 and previewing. It uses wxRichTextPrintout for layout and rendering.
7c913512 262
23324ae1 263 @library{wxrichtext}
21b447dc 264 @category{richtext}
23324ae1
FM
265*/
266class wxRichTextPrinting : public wxObject
267{
268public:
269 /**
9e7ad1ca
FM
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.
23324ae1 274 */
f8ebb70d 275 wxRichTextPrinting(const wxString& name = "Printing",
9e7ad1ca 276 wxWindow* parentWindow = NULL);
23324ae1
FM
277
278 /**
9e7ad1ca
FM
279 A convenience function to get the footer text.
280 See wxRichTextHeaderFooterData for details.
23324ae1
FM
281 */
282 wxString GetFooterText(wxRichTextOddEvenPage page = wxRICHTEXT_PAGE_EVEN,
328f5751 283 wxRichTextPageLocation location = wxRICHTEXT_PAGE_CENTRE) const;
23324ae1
FM
284
285 /**
286 Returns the internal wxRichTextHeaderFooterData object.
287 */
5267aefd 288 const wxRichTextHeaderFooterData& GetHeaderFooterData() const;
23324ae1
FM
289
290 /**
9e7ad1ca
FM
291 A convenience function to get the header text.
292 See wxRichTextHeaderFooterData for details.
23324ae1
FM
293 */
294 wxString GetHeaderText(wxRichTextOddEvenPage page = wxRICHTEXT_PAGE_EVEN,
328f5751 295 wxRichTextPageLocation location = wxRICHTEXT_PAGE_CENTRE) const;
23324ae1
FM
296
297 /**
298 Returns a pointer to the internal page setup data.
299 */
300 wxPageSetupDialogData* GetPageSetupData();
301
302 /**
9e7ad1ca
FM
303 Returns the parent window to be used for the preview window and printing
304 wait dialog.
23324ae1 305 */
328f5751 306 wxWindow* GetParentWindow() const;
23324ae1
FM
307
308 /**
309 Returns the dimensions to be used for the preview window.
310 */
5267aefd 311 const wxRect& GetPreviewRect() const;
23324ae1
FM
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 */
5267aefd 321 const wxString& GetTitle() const;
23324ae1
FM
322
323 /**
324 Shows the page setup dialog.
325 */
326 void PageSetup();
327
328 /**
9e7ad1ca
FM
329 Shows a preview window for the given buffer.
330 The function takes its own copy of @a buffer.
23324ae1
FM
331 */
332 bool PreviewBuffer(const wxRichTextBuffer& buffer);
333
334 /**
9e7ad1ca
FM
335 Shows a preview window for the given file.
336
337 @a richTextFile can be a text file or XML file, or other file
23324ae1
FM
338 depending on the available file handlers.
339 */
340 bool PreviewFile(const wxString& richTextFile);
341
342 /**
9e7ad1ca 343 Prints the given buffer. The function takes its own copy of @a buffer.
148d83b5 344 @showPrintDialog can be @true to show the print dialog, or @false to print quietly.
23324ae1 345 */
148d83b5 346 bool PrintBuffer(const wxRichTextBuffer& buffer, bool showPrintDialog = true);
23324ae1
FM
347
348 /**
9e7ad1ca 349 Prints the given file. @a richTextFile can be a text file or XML file,
148d83b5
JS
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.
23324ae1 352 */
148d83b5 353 bool PrintFile(const wxString& richTextFile, bool showPrintDialog = true);
23324ae1
FM
354
355 /**
9e7ad1ca
FM
356 A convenience function to set the footer text.
357 See wxRichTextHeaderFooterData for details.
23324ae1
FM
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 /**
9e7ad1ca
FM
379 A convenience function to set the header text.
380 See wxRichTextHeaderFooterData for details.
23324ae1
FM
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 */
5267aefd 389 void SetPageSetupData(const wxPageSetupDialogData& pageSetupData);
23324ae1
FM
390
391 /**
9e7ad1ca
FM
392 Sets the parent window to be used for the preview window and printing
393 wait dialog.
23324ae1
FM
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};
e54c96f1 417