File: richtextprint.h

package info (click to toggle)
wxpython3.0 3.0.2.0%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 482,760 kB
  • ctags: 518,293
  • sloc: cpp: 2,127,226; python: 294,045; makefile: 51,942; ansic: 19,033; sh: 3,013; xml: 1,629; perl: 17
file content (416 lines) | stat: -rw-r--r-- 12,291 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
/////////////////////////////////////////////////////////////////////////////
// Name:        richtext/richtextprint.h
// Purpose:     interface of wxRichTextHeaderFooterData
// Author:      wxWidgets team
// Licence:     wxWindows licence
/////////////////////////////////////////////////////////////////////////////


/**
    These are the header and footer page identifiers, passed to functions such
    as wxRichTextHeaderFooterData::SetFooterText to specify the odd or even page
    for the text.
*/
enum wxRichTextOddEvenPage {
    wxRICHTEXT_PAGE_ODD,
    wxRICHTEXT_PAGE_EVEN,
    wxRICHTEXT_PAGE_ALL,
};


/**
    These are the location identifiers for passing to functions such as
    wxRichTextHeaderFooterData::SetFooterText(), to specify whether the text
    is on the left, centre or right of the page.
*/
enum wxRichTextPageLocation {
    wxRICHTEXT_PAGE_LEFT,
    wxRICHTEXT_PAGE_CENTRE,
    wxRICHTEXT_PAGE_RIGHT
};


/**
    @class wxRichTextHeaderFooterData


    This class represents header and footer data to be passed to the
    wxRichTextPrinting and wxRichTextPrintout classes.

    Headers and footers can be specified independently for odd, even or both page
    sides. Different text can be specified for left, centre and right locations
    on the page, and the font and text colour can also be specified.

    You can specify the following keywords in header and footer text, which will
    be substituted for the actual values during printing and preview.

    - @@DATE@: the current date.
    - @@PAGESCNT@: the total number of pages.
    - @@PAGENUM@: the current page number.
    - @@TIME@: the current time.
    - @@TITLE@: the title of the document, as passed to the wxRichTextPrinting or
      wxRichTextLayout constructor.

    @library{wxrichtext}
    @category{richtext}
*/
class wxRichTextHeaderFooterData : public wxObject
{
public:
    //@{
    /**
        Constructors.
    */
    wxRichTextHeaderFooterData();
    wxRichTextHeaderFooterData(const wxRichTextHeaderFooterData& data);
    //@}

    /**
        Clears all text.
    */
    void Clear();

    /**
        Copies the data.
    */
    void Copy(const wxRichTextHeaderFooterData& data);

    /**
        Returns the font specified for printing the header and footer.
    */
    const wxFont& GetFont() const;

    /**
        Returns the margin between the text and the footer.
    */
    int GetFooterMargin() const;

    /**
        Returns the footer text on odd or even pages, and at a given position on the
        page (left, centre or right).
    */
    wxString GetFooterText(wxRichTextOddEvenPage page = wxRICHTEXT_PAGE_EVEN,
                           wxRichTextPageLocation location = wxRICHTEXT_PAGE_CENTRE) const;

    /**
        Returns the margin between the text and the header.
    */
    int GetHeaderMargin() const;

    /**
        Returns the header text on odd or even pages, and at a given position on the
        page (left, centre or right).
    */
    wxString GetHeaderText(wxRichTextOddEvenPage page = wxRICHTEXT_PAGE_EVEN,
                           wxRichTextPageLocation location = wxRICHTEXT_PAGE_CENTRE) const;

    /**
        Returns @true if the header and footer will be shown on the first page.
    */
    bool GetShowOnFirstPage() const;

    /**
        Helper function for getting the header or footer text, odd or even pages, and
        at a given position on the page (left, centre or right).
    */
    wxString GetText(int headerFooter, wxRichTextOddEvenPage page,
                     wxRichTextPageLocation location) const;

    /**
        Returns the text colour for drawing the header and footer.
    */
    const wxColour& GetTextColour() const;

    /**
        Initialises the object.
    */
    void Init();

    /**
        Sets the font for drawing the header and footer.
    */
    void SetFont(const wxFont& font);

    /**
        Sets the footer text on odd or even pages, and at a given position on the page
        (left, centre or right).
    */
    void SetFooterText(const wxString& text,
                       wxRichTextOddEvenPage page = wxRICHTEXT_PAGE_ALL,
                       wxRichTextPageLocation location = wxRICHTEXT_PAGE_CENTRE);

    /**
        Sets the header text on odd or even pages, and at a given position on the page
        (left, centre or right).
    */
    void SetHeaderText(const wxString& text,
                       wxRichTextOddEvenPage page = wxRICHTEXT_PAGE_ALL,
                       wxRichTextPageLocation location = wxRICHTEXT_PAGE_CENTRE);

    /**
        Sets the margins between text and header or footer, in tenths of a millimeter.
    */
    void SetMargins(int headerMargin, int footerMargin);

    /**
        Pass @true to show the header or footer on first page (the default).
    */
    void SetShowOnFirstPage(bool showOnFirstPage);

    /**
        Helper function for setting the header or footer text, odd or even pages, and
        at a given position on the page (left, centre or right).
    */
    void SetText(const wxString& text, int headerFooter,
                 wxRichTextOddEvenPage page,
                 wxRichTextPageLocation location);

    /**
        Sets the text colour for drawing the header and footer.
    */
    void SetTextColour(const wxColour& col);

    /**
        Assignment operator.
    */
    void operator operator=(const wxRichTextHeaderFooterData& data);
};



/**
    @class wxRichTextPrintout

    This class implements print layout for wxRichTextBuffer.
    Instead of using it directly, you should normally use the wxRichTextPrinting class.

    @library{wxrichtext}
    @category{richtext}
*/
class wxRichTextPrintout : public wxPrintout
{
public:
    /**
        Constructor.
    */
    wxRichTextPrintout(const wxString& title = "Printout");

    /**
        Calculates scaling and text, header and footer rectangles.
    */
    void CalculateScaling(wxDC* dc, wxRect& textRect,
                          wxRect& headerRect,
                          wxRect& footerRect);

    /**
        Returns the header and footer data associated with the printout.
    */
    const wxRichTextHeaderFooterData& GetHeaderFooterData() const;

    /**
        Gets the page information.
    */
    virtual void GetPageInfo(int* minPage, int* maxPage, int* selPageFrom,
                             int* selPageTo);

    /**
        Returns a pointer to the buffer being rendered.
    */
    wxRichTextBuffer* GetRichTextBuffer() const;

    /**
        Returns @true if the given page exists in the printout.
    */
    virtual bool HasPage(int page);

    /**
        Prepares for printing, laying out the buffer and calculating pagination.
    */
    virtual void OnPreparePrinting();

    /**
        Does the actual printing for this page.
    */
    virtual bool OnPrintPage(int page);

    /**
        Sets the header and footer data associated with the printout.
    */
    void SetHeaderFooterData(const wxRichTextHeaderFooterData& data);

    /**
        Sets margins in 10ths of millimetre. Defaults to 1 inch for margins.
    */
    void SetMargins(int top = 254, int bottom = 254, int left = 254,
                    int right = 254);

    /**
        Sets the buffer to print. wxRichTextPrintout does not manage this pointer;
        it should be managed by the calling code, such as wxRichTextPrinting.
    */
    void SetRichTextBuffer(wxRichTextBuffer* buffer);
};



/**
    @class wxRichTextPrinting

    This class provides a simple interface for performing wxRichTextBuffer printing
    and previewing. It uses wxRichTextPrintout for layout and rendering.

    @library{wxrichtext}
    @category{richtext}
*/
class wxRichTextPrinting : public wxObject
{
public:
    /**
        Constructor.

        Optionally pass a title to be used in the preview frame and printing wait
        dialog, and also a parent window for these windows.
    */
    wxRichTextPrinting(const wxString& name = "Printing",
                       wxWindow* parentWindow = NULL);

    /**
        A convenience function to get the footer text.
        See wxRichTextHeaderFooterData for details.
    */
    wxString GetFooterText(wxRichTextOddEvenPage page = wxRICHTEXT_PAGE_EVEN,
                           wxRichTextPageLocation location = wxRICHTEXT_PAGE_CENTRE) const;

    /**
        Returns the internal wxRichTextHeaderFooterData object.
    */
    const wxRichTextHeaderFooterData& GetHeaderFooterData() const;

    /**
        A convenience function to get the header text.
        See wxRichTextHeaderFooterData for details.
    */
    wxString GetHeaderText(wxRichTextOddEvenPage page = wxRICHTEXT_PAGE_EVEN,
                           wxRichTextPageLocation location = wxRICHTEXT_PAGE_CENTRE) const;

    /**
        Returns a pointer to the internal page setup data.
    */
    wxPageSetupDialogData* GetPageSetupData();

    /**
        Returns the parent window to be used for the preview window and printing
        wait dialog.
    */
    wxWindow* GetParentWindow() const;

    /**
        Returns the dimensions to be used for the preview window.
    */
    const wxRect& GetPreviewRect() const;

    /**
        Returns a pointer to the internal print data.
    */
    wxPrintData* GetPrintData();

    /**
        Returns the title of the preview window or printing wait caption.
    */
    const wxString& GetTitle() const;

    /**
        Shows the page setup dialog.
    */
    void PageSetup();

    /**
        Shows a preview window for the given buffer.
        The function takes its own copy of @a buffer.
    */
    bool PreviewBuffer(const wxRichTextBuffer& buffer);

    /**
        Shows a preview window for the given file.

        @a richTextFile can be a text file or XML file, or other file
        depending on the available file handlers.
    */
    bool PreviewFile(const wxString& richTextFile);

    /**
        Prints the given buffer. The function takes its own copy of @a buffer.
        @a showPrintDialog can be @true to show the print dialog, or @false to print quietly.
    */
    bool PrintBuffer(const wxRichTextBuffer& buffer, bool showPrintDialog = true);

    /**
        Prints the given file. @a richTextFile can be a text file or XML file,
        or other file depending on the available file handlers. @a showPrintDialog
        can be @true to show the print dialog, or @false to print quietly.
    */
    bool PrintFile(const wxString& richTextFile, bool showPrintDialog = true);

    /**
        A convenience function to set the footer text.
        See wxRichTextHeaderFooterData for details.
    */
    void SetFooterText(const wxString& text,
                       wxRichTextOddEvenPage page = wxRICHTEXT_PAGE_ALL,
                       wxRichTextPageLocation location = wxRICHTEXT_PAGE_CENTRE);

    /**
        Sets the internal wxRichTextHeaderFooterData object.
    */
    void SetHeaderFooterData(const wxRichTextHeaderFooterData& data);

    /**
        Sets the wxRichTextHeaderFooterData font.
    */
    void SetHeaderFooterFont(const wxFont& font);

    /**
        Sets the wxRichTextHeaderFooterData text colour.
    */
    void SetHeaderFooterTextColour(const wxColour& colour);

    /**
        A convenience function to set the header text.
        See wxRichTextHeaderFooterData for details.
    */
    void SetHeaderText(const wxString& text,
                       wxRichTextOddEvenPage page = wxRICHTEXT_PAGE_ALL,
                       wxRichTextPageLocation location = wxRICHTEXT_PAGE_CENTRE);

    /**
        Sets the page setup data.
    */
    void SetPageSetupData(const wxPageSetupDialogData& pageSetupData);

    /**
        Sets the parent window to be used for the preview window and printing
        wait dialog.
    */
    void SetParentWindow(wxWindow* parent);

    /**
        Sets the dimensions to be used for the preview window.
    */
    void SetPreviewRect(const wxRect& rect);

    /**
        Sets the print data.
    */
    void SetPrintData(const wxPrintData& printData);

    /**
        Pass @true to show the header and footer on the first page.
    */
    void SetShowOnFirstPage(bool show);

    /**
        Pass the title of the preview window or printing wait caption.
    */
    void SetTitle(const wxString& title);
};