]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/richtext/richtextprint.h
Make wxPGValidationInfo class instead of struct, re-document it (used at least by...
[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$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
9/**
10 @class wxRichTextHeaderFooterData
7c913512
FM
11
12
23324ae1
FM
13 This class represents header and footer data to be passed to the
14 wxRichTextPrinting and
15 wxRichTextPrintout classes.
7c913512 16
23324ae1
FM
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.
7c913512 24
2f663107
VZ
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
23324ae1 30 wxRichTextLayout constructor.
7c913512 31
23324ae1 32 @library{wxrichtext}
21b447dc 33 @category{richtext}
23324ae1
FM
34*/
35class wxRichTextHeaderFooterData : public wxObject
36{
37public:
38 //@{
39 /**
40 Constructors.
41 */
42 wxRichTextHeaderFooterData();
7c913512 43 wxRichTextHeaderFooterData(const wxRichTextHeaderFooterData& data);
23324ae1
FM
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 */
328f5751 59 const wxFont GetFont() const;
23324ae1
FM
60
61 /**
62 Returns the margin between the text and the footer.
63 */
328f5751 64 int GetFooterMargin() const;
23324ae1
FM
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,
328f5751 71 wxRichTextPageLocation location = wxRICHTEXT_PAGE_CENTRE) const;
23324ae1
FM
72
73 /**
74 Returns the margin between the text and the header.
75 */
328f5751 76 int GetHeaderMargin() const;
23324ae1
FM
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,
328f5751 83 wxRichTextPageLocation location = wxRICHTEXT_PAGE_CENTRE) const;
23324ae1
FM
84
85 /**
86 Returns @true if the header and footer will be shown on the first page.
87 */
328f5751 88 bool GetShowOnFirstPage() const;
23324ae1
FM
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,
328f5751 95 wxRichTextPageLocation location) const;
23324ae1
FM
96
97 /**
98 Returns the text colour for drawing the header and footer.
99 */
328f5751 100 const wxColour GetTextColour() const;
23324ae1
FM
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
e54c96f1 158
23324ae1
FM
159/**
160 @class wxRichTextPrintout
7c913512 161
23324ae1
FM
162 This class implements print layout for wxRichTextBuffer. Instead of using it
163 directly, you
164 should normally use the wxRichTextPrinting class.
7c913512 165
23324ae1 166 @library{wxrichtext}
21b447dc 167 @category{richtext}
23324ae1
FM
168*/
169class wxRichTextPrintout : public wxPrintout
170{
171public:
172 /**
173 )
23324ae1
FM
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 */
328f5751 188 const wxRichTextHeaderFooterData GetHeaderFooterData() const;
23324ae1
FM
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 */
328f5751 199 wxRichTextBuffer* GetRichTextBuffer() const;
23324ae1
FM
200
201 /**
202 Returns @true if the given page exists in the printout.
203 */
adaaa686 204 virtual bool HasPage(int page);
23324ae1
FM
205
206 /**
207 Prepares for printing, laying out the buffer and calculating pagination.
208 */
adaaa686 209 virtual void OnPreparePrinting();
23324ae1
FM
210
211 /**
212 Does the actual printing for this page.
213 */
adaaa686 214 virtual bool OnPrintPage(int page);
23324ae1
FM
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
e54c96f1 236
23324ae1
FM
237/**
238 @class wxRichTextPrinting
7c913512 239
23324ae1
FM
240 This class provides a simple interface for performing wxRichTextBuffer printing
241 and previewing. It uses wxRichTextPrintout for layout and rendering.
7c913512 242
23324ae1 243 @library{wxrichtext}
21b447dc 244 @category{richtext}
23324ae1
FM
245*/
246class wxRichTextPrinting : public wxObject
247{
248public:
249 /**
250 , @b wxWindow*@e parentWindow = @NULL)
23324ae1
FM
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,
328f5751 262 wxRichTextPageLocation location = wxRICHTEXT_PAGE_CENTRE) const;
23324ae1
FM
263
264 /**
265 Returns the internal wxRichTextHeaderFooterData object.
266 */
328f5751 267 const wxRichTextHeaderFooterData GetHeaderFooterData() const;
23324ae1
FM
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,
328f5751 274 wxRichTextPageLocation location = wxRICHTEXT_PAGE_CENTRE) const;
23324ae1
FM
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 */
328f5751 285 wxWindow* GetParentWindow() const;
23324ae1
FM
286
287 /**
288 Returns the dimensions to be used for the preview window.
289 */
328f5751 290 const wxRect GetPreviewRect() const;
23324ae1
FM
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 */
328f5751 300 const wxString GetTitle() const;
23324ae1
FM
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 /**
4cc4bfaf 314 Shows a preview window for the given file. @a richTextFile can be a text file
23324ae1
FM
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 /**
4cc4bfaf 326 Prints the given file. @a richTextFile can be a text file or XML file, or other
23324ae1
FM
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};
e54c96f1 394