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