qpagedpaintdevice.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/painting/qpagedpaintdevice.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2015 The Qt Company Ltd.-
4** Contact: http://www.qt.io/licensing/-
5**-
6** This file is part of the QtGui module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL21$-
9** Commercial License Usage-
10** Licensees holding valid commercial Qt licenses may use this file in-
11** accordance with the commercial license agreement provided with the-
12** Software or, alternatively, in accordance with the terms contained in-
13** a written agreement between you and The Qt Company. For licensing terms-
14** and conditions see http://www.qt.io/terms-conditions. For further-
15** information use the contact form at http://www.qt.io/contact-us.-
16**-
17** GNU Lesser General Public License Usage-
18** Alternatively, this file may be used under the terms of the GNU Lesser-
19** General Public License version 2.1 or version 3 as published by the Free-
20** Software Foundation and appearing in the file LICENSE.LGPLv21 and-
21** LICENSE.LGPLv3 included in the packaging of this file. Please review the-
22** following information to ensure the GNU Lesser General Public License-
23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and-
24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.-
25**-
26** As a special exception, The Qt Company gives you certain additional-
27** rights. These rights are described in The Qt Company LGPL Exception-
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.-
29**-
30** $QT_END_LICENSE$-
31**-
32****************************************************************************/-
33-
34#include "qpagedpaintdevice_p.h"-
35#include <qpagedpaintdevice.h>-
36-
37QT_BEGIN_NAMESPACE-
38-
39QPagedPaintDevicePrivate::~QPagedPaintDevicePrivate()-
40{-
41}-
42-
43/*!-
44 \class QPagedPaintDevice-
45 \inmodule QtGui-
46-
47 \brief The QPagedPaintDevice class is a represents a paintdevice that supports-
48 multiple pages.-
49-
50 \ingroup painting-
51-
52 Paged paint devices are used to generate output for printing or for formats like PDF.-
53 QPdfWriter and QPrinter inherit from it.-
54 */-
55-
56/*!-
57 Constructs a new paged paint device.-
58 */-
59QPagedPaintDevice::QPagedPaintDevice()-
60 : d(new QPagedPaintDevicePrivate)-
61{-
62}
never executed: end of block
0
63-
64/*!-
65 \internal-
66 Constructs a new paged paint device with the derived private class.-
67*/-
68QPagedPaintDevice::QPagedPaintDevice(QPagedPaintDevicePrivate *dd)-
69 : d(dd)-
70{-
71}
never executed: end of block
0
72-
73/*!-
74 Destroys the object.-
75 */-
76QPagedPaintDevice::~QPagedPaintDevice()-
77{-
78 delete d;-
79}
never executed: end of block
0
80-
81/*!-
82 \internal-
83 Returns the QPagedPaintDevicePrivate.-
84*/-
85QPagedPaintDevicePrivate *QPagedPaintDevice::dd()-
86{-
87 return d;
never executed: return d;
0
88}-
89-
90/*!-
91 \enum QPagedPaintDevice::PageSize-
92-
93 This enum type lists the available page sizes as defined in the Postscript-
94 PPD standard. These values are duplicated in QPageSize and QPrinter.-
95-
96 The defined sizes are:-
97-
98 \value A0 841 x 1189 mm-
99 \value A1 594 x 841 mm-
100 \value A2 420 x 594 mm-
101 \value A3 297 x 420 mm-
102 \value A4 210 x 297 mm, 8.26 x 11.69 inches-
103 \value A5 148 x 210 mm-
104 \value A6 105 x 148 mm-
105 \value A7 74 x 105 mm-
106 \value A8 52 x 74 mm-
107 \value A9 37 x 52 mm-
108 \value B0 1000 x 1414 mm-
109 \value B1 707 x 1000 mm-
110 \value B2 500 x 707 mm-
111 \value B3 353 x 500 mm-
112 \value B4 250 x 353 mm-
113 \value B5 176 x 250 mm, 6.93 x 9.84 inches-
114 \value B6 125 x 176 mm-
115 \value B7 88 x 125 mm-
116 \value B8 62 x 88 mm-
117 \value B9 33 x 62 mm-
118 \value B10 31 x 44 mm-
119 \value C5E 163 x 229 mm-
120 \value Comm10E 105 x 241 mm, U.S. Common 10 Envelope-
121 \value DLE 110 x 220 mm-
122 \value Executive 7.5 x 10 inches, 190.5 x 254 mm-
123 \value Folio 210 x 330 mm-
124 \value Ledger 431.8 x 279.4 mm-
125 \value Legal 8.5 x 14 inches, 215.9 x 355.6 mm-
126 \value Letter 8.5 x 11 inches, 215.9 x 279.4 mm-
127 \value Tabloid 279.4 x 431.8 mm-
128 \value Custom Unknown, or a user defined size.-
129 \value A10-
130 \value A3Extra-
131 \value A4Extra-
132 \value A4Plus-
133 \value A4Small-
134 \value A5Extra-
135 \value B5Extra-
136 \value JisB0-
137 \value JisB1-
138 \value JisB2-
139 \value JisB3-
140 \value JisB4-
141 \value JisB5-
142 \value JisB6,-
143 \value JisB7-
144 \value JisB8-
145 \value JisB9-
146 \value JisB10-
147 \value AnsiA = Letter-
148 \value AnsiB = Ledger-
149 \value AnsiC-
150 \value AnsiD-
151 \value AnsiE-
152 \value LegalExtra-
153 \value LetterExtra-
154 \value LetterPlus-
155 \value LetterSmall-
156 \value TabloidExtra-
157 \value ArchA-
158 \value ArchB-
159 \value ArchC-
160 \value ArchD-
161 \value ArchE-
162 \value Imperial7x9-
163 \value Imperial8x10-
164 \value Imperial9x11-
165 \value Imperial9x12-
166 \value Imperial10x11-
167 \value Imperial10x13-
168 \value Imperial10x14-
169 \value Imperial12x11-
170 \value Imperial15x11-
171 \value ExecutiveStandard-
172 \value Note-
173 \value Quarto-
174 \value Statement-
175 \value SuperA-
176 \value SuperB-
177 \value Postcard-
178 \value DoublePostcard-
179 \value Prc16K-
180 \value Prc32K-
181 \value Prc32KBig-
182 \value FanFoldUS-
183 \value FanFoldGerman-
184 \value FanFoldGermanLegal-
185 \value EnvelopeB4-
186 \value EnvelopeB5-
187 \value EnvelopeB6-
188 \value EnvelopeC0-
189 \value EnvelopeC1-
190 \value EnvelopeC2-
191 \value EnvelopeC3-
192 \value EnvelopeC4-
193 \value EnvelopeC5 = C5E-
194 \value EnvelopeC6-
195 \value EnvelopeC65-
196 \value EnvelopeC7-
197 \value EnvelopeDL = DLE-
198 \value Envelope9-
199 \value Envelope10 = Comm10E-
200 \value Envelope11-
201 \value Envelope12-
202 \value Envelope14-
203 \value EnvelopeMonarch-
204 \value EnvelopePersonal-
205 \value EnvelopeChou3-
206 \value EnvelopeChou4-
207 \value EnvelopeInvite-
208 \value EnvelopeItalian-
209 \value EnvelopeKaku2-
210 \value EnvelopeKaku3-
211 \value EnvelopePrc1-
212 \value EnvelopePrc2-
213 \value EnvelopePrc3-
214 \value EnvelopePrc4-
215 \value EnvelopePrc5-
216 \value EnvelopePrc6-
217 \value EnvelopePrc7-
218 \value EnvelopePrc8-
219 \value EnvelopePrc9-
220 \value EnvelopePrc10-
221 \value EnvelopeYou4-
222 \value LastPageSize = EnvelopeYou4-
223 \omitvalue NPageSize-
224 \omitvalue NPaperSize-
225-
226 Due to historic reasons QPageSize::Executive is not the same as the standard-
227 Postscript and Windows Executive size, use QPageSize::ExecutiveStandard instead.-
228-
229 The Postscript standard size QPageSize::Folio is different to the Windows-
230 DMPAPER_FOLIO size, use the Postscript standard size QPageSize::FanFoldGermanLegal-
231 if needed.-
232*/-
233-
234/*!-
235 \fn bool QPagedPaintDevice::newPage()-
236-
237 Starts a new page. Returns \c true on success.-
238*/-
239-
240-
241/*!-
242 Sets the size of the a page to \a size.-
243-
244 \sa setPageSizeMM()-
245 */-
246void QPagedPaintDevice::setPageSize(PageSize size)-
247{-
248 d->m_pageLayout.setPageSize(QPageSize(QPageSize::PageSizeId(size)));-
249}
never executed: end of block
0
250-
251/*!-
252 Returns the currently used page size.-
253 */-
254QPagedPaintDevice::PageSize QPagedPaintDevice::pageSize() const-
255{-
256 return PageSize(d->m_pageLayout.pageSize().id());
never executed: return PageSize(d->m_pageLayout.pageSize().id());
0
257}-
258-
259/*!-
260 Sets the page size to \a size. \a size is specified in millimeters.-
261-
262 If the size matches a standard QPagedPaintDevice::PageSize then that page-
263 size will be used, otherwise QPagedPaintDevice::Custom will be set.-
264*/-
265void QPagedPaintDevice::setPageSizeMM(const QSizeF &size)-
266{-
267 d->m_pageLayout.setPageSize(QPageSize(size, QPageSize::Millimeter));-
268}
never executed: end of block
0
269-
270/*!-
271 Returns the page size in millimeters.-
272 */-
273QSizeF QPagedPaintDevice::pageSizeMM() const-
274{-
275 return d->m_pageLayout.pageSize().size(QPageSize::Millimeter);
never executed: return d->m_pageLayout.pageSize().size(QPageSize::Millimeter);
0
276}-
277-
278/*!-
279 Sets the margins to be used to \a margins.-
280-
281 Margins are specified in millimeters.-
282-
283 The margins are purely a hint to the drawing method. They don't affect the-
284 coordinate system or clipping.-
285-
286 \sa margins()-
287 */-
288void QPagedPaintDevice::setMargins(const Margins &margins)-
289{-
290 d->m_pageLayout.setUnits(QPageLayout::Millimeter);-
291 d->m_pageLayout.setMargins(QMarginsF(margins.left, margins.top, margins.right, margins.bottom));-
292}
never executed: end of block
0
293-
294/*!-
295 Returns the current margins of the paint device. The default is 0.-
296-
297 Margins are specified in millimeters.-
298-
299 \sa setMargins()-
300 */-
301QPagedPaintDevice::Margins QPagedPaintDevice::margins() const-
302{-
303 QMarginsF margins = d->m_pageLayout.margins(QPageLayout::Millimeter);-
304 Margins result;-
305 result.left = margins.left();-
306 result.top = margins.top();-
307 result.right = margins.right();-
308 result.bottom = margins.bottom();-
309 return result;
never executed: return result;
0
310}-
311-
312/*!-
313 \since 5.3-
314-
315 Sets the page layout to \a newPageLayout.-
316-
317 You should call this before calling QPainter::begin(), or immediately-
318 before calling newPage() to apply the new page layout to a new page.-
319 You should not call any painting methods between a call to setPageLayout()-
320 and newPage() as the wrong paint metrics may be used.-
321-
322 Returns true if the page layout was successfully set to \a newPageLayout.-
323-
324 \sa pageLayout()-
325*/-
326-
327bool QPagedPaintDevice::setPageLayout(const QPageLayout &newPageLayout)-
328{-
329 return d->setPageLayout(newPageLayout);
never executed: return d->setPageLayout(newPageLayout);
0
330}-
331-
332/*!-
333 \since 5.3-
334-
335 Sets the page size to \a pageSize.-
336-
337 To get the current QPageSize use pageLayout().pageSize().-
338-
339 You should call this before calling QPainter::begin(), or immediately-
340 before calling newPage() to apply the new page size to a new page.-
341 You should not call any painting methods between a call to setPageSize()-
342 and newPage() as the wrong paint metrics may be used.-
343-
344 Returns true if the page size was successfully set to \a pageSize.-
345-
346 \sa pageLayout()-
347*/-
348-
349bool QPagedPaintDevice::setPageSize(const QPageSize &pageSize)-
350{-
351 return d->setPageSize(pageSize);
never executed: return d->setPageSize(pageSize);
0
352}-
353-
354/*!-
355 \since 5.3-
356-
357 Sets the page \a orientation.-
358-
359 The page orientation is used to define the orientation of the-
360 page size when obtaining the page rect.-
361-
362 You should call this before calling QPainter::begin(), or immediately-
363 before calling newPage() to apply the new orientation to a new page.-
364 You should not call any painting methods between a call to setPageOrientation()-
365 and newPage() as the wrong paint metrics may be used.-
366-
367 To get the current QPageLayout::Orientation use pageLayout().pageOrientation().-
368-
369 Returns true if the page orientation was successfully set to \a orientation.-
370-
371 \sa pageLayout()-
372*/-
373-
374bool QPagedPaintDevice::setPageOrientation(QPageLayout::Orientation orientation)-
375{-
376 return d->setPageOrientation(orientation);
never executed: return d->setPageOrientation(orientation);
0
377}-
378-
379/*!-
380 \since 5.3-
381-
382 Set the page \a margins in the current page layout units.-
383-
384 You should call this before calling QPainter::begin(), or immediately-
385 before calling newPage() to apply the new margins to a new page.-
386 You should not call any painting methods between a call to setPageMargins()-
387 and newPage() as the wrong paint metrics may be used.-
388-
389 To get the current page margins use pageLayout().pageMargins().-
390-
391 Returns true if the page margins were successfully set to \a margins.-
392-
393 \sa pageLayout()-
394*/-
395-
396bool QPagedPaintDevice::setPageMargins(const QMarginsF &margins)-
397{-
398 return d->setPageMargins(margins);
never executed: return d->setPageMargins(margins);
0
399}-
400-
401/*!-
402 \since 5.3-
403-
404 Set the page \a margins defined in the given \a units.-
405-
406 You should call this before calling QPainter::begin(), or immediately-
407 before calling newPage() to apply the new margins to a new page.-
408 You should not call any painting methods between a call to setPageMargins()-
409 and newPage() as the wrong paint metrics may be used.-
410-
411 To get the current page margins use pageLayout().pageMargins().-
412-
413 Returns true if the page margins were successfully set to \a margins.-
414-
415 \sa pageLayout()-
416*/-
417-
418bool QPagedPaintDevice::setPageMargins(const QMarginsF &margins, QPageLayout::Unit units)-
419{-
420 return d->setPageMargins(margins, units);
never executed: return d->setPageMargins(margins, units);
0
421}-
422-
423/*!-
424 \since 5.3-
425-
426 Returns the current page layout. Use this method to access the current-
427 QPageSize, QPageLayout::Orientation, QMarginsF, fullRect() and paintRect().-
428-
429 Note that you cannot use the setters on the returned object, you must either-
430 call the individual QPagedPaintDevice setters or use setPageLayout().-
431-
432 \sa setPageLayout(), setPageSize(), setPageOrientation(), setPageMargins()-
433*/-
434-
435QPageLayout QPagedPaintDevice::pageLayout() const-
436{-
437 return d->pageLayout();
never executed: return d->pageLayout();
0
438}-
439-
440/*!-
441 \internal-
442-
443 Returns the internal device page layout.-
444*/-
445-
446QPageLayout QPagedPaintDevice::devicePageLayout() const-
447{-
448 return d->m_pageLayout;
never executed: return d->m_pageLayout;
0
449}-
450-
451/*!-
452 \internal-
453-
454 Returns the internal device page layout.-
455*/-
456-
457QPageLayout &QPagedPaintDevice::devicePageLayout()-
458{-
459 return d->m_pageLayout;
never executed: return d->m_pageLayout;
0
460}-
461-
462QT_END_NAMESPACE-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9