Qt 6.x
The Qt SDK
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
qprintengine_mac.mm
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include <AppKit/AppKit.h>
5#include <ApplicationServices/ApplicationServices.h>
6
9#include <quuid.h>
10#include <QtGui/qpagelayout.h>
11#include <QtCore/qcoreapplication.h>
12#include <QtCore/qdebug.h>
13
14#include <QtCore/private/qcore_mac_p.h>
15
16#ifndef QT_NO_PRINTER
17
19
20extern QMarginsF qt_convertMargins(const QMarginsF &margins, QPageLayout::Unit fromUnits, QPageLayout::Unit toUnits);
21
24{
25 Q_D(QMacPrintEngine);
26 d->mode = mode;
27 QString id = deviceId;
28 if (id.isEmpty())
30 else
32 d->m_printDevice.reset(new QCocoaPrintDevice(id));
33 d->m_pageLayout.setPageSize(d->m_printDevice->defaultPageSize());
34 d->initialize();
35}
36
38{
39 Q_D(QMacPrintEngine);
40
41 Q_ASSERT(dev && dev->devType() == QInternal::Printer);
42 if (!static_cast<QPrinter *>(dev)->isValid())
43 return false;
44
45 if (d->state == QPrinter::Idle && !d->isPrintSessionInitialized()) // Need to reinitialize
46 d->initialize();
47
48 d->paintEngine->state = state;
49 d->paintEngine->begin(dev);
50 Q_ASSERT_X(d->state == QPrinter::Idle, "QMacPrintEngine", "printer already active");
51
52 if (PMSessionValidatePrintSettings(d->session(), d->settings(), kPMDontWantBoolean) != noErr
53 || PMSessionValidatePageFormat(d->session(), d->format(), kPMDontWantBoolean) != noErr) {
54 d->state = QPrinter::Error;
55 return false;
56 }
57
58 if (!d->outputFilename.isEmpty()) {
59 QCFType<CFURLRef> outFile = CFURLCreateWithFileSystemPath(kCFAllocatorSystemDefault,
60 QCFString(d->outputFilename),
61 kCFURLPOSIXPathStyle,
62 false);
63 if (PMSessionSetDestination(d->session(), d->settings(), kPMDestinationFile,
64 kPMDocumentFormatPDF, outFile) != noErr) {
65 qWarning("QMacPrintEngine::begin: Problem setting file [%s]", d->outputFilename.toUtf8().constData());
66 return false;
67 }
68 }
69
70 OSStatus status = PMSessionBeginCGDocumentNoDialog(d->session(), d->settings(), d->format());
71 if (status != noErr) {
72 d->state = QPrinter::Error;
73 return false;
74 }
75
76 d->state = QPrinter::Active;
77 setActive(true);
78 d->newPage_helper();
79 return true;
80}
81
83{
84 Q_D(QMacPrintEngine);
85 if (d->state == QPrinter::Aborted)
86 return true; // I was just here a function call ago :)
87 if (d->paintEngine->type() == QPaintEngine::CoreGraphics) {
88 // We don't need the paint engine to call restoreGraphicsState()
89 static_cast<QCoreGraphicsPaintEngine*>(d->paintEngine)->d_func()->stackCount = 0;
90 static_cast<QCoreGraphicsPaintEngine*>(d->paintEngine)->d_func()->hd = nullptr;
91 }
92 d->paintEngine->end();
93 if (d->state != QPrinter::Idle)
94 d->releaseSession();
95 d->state = QPrinter::Idle;
96 return true;
97}
98
101{
102 return d_func()->paintEngine;
103}
104
106{
108 return cgEngine->d_func()->hd;
109}
110
112{
114 delete paintEngine;
115}
116
118{
119 return d_func()->state;
120}
121
123{
124 Q_D(QMacPrintEngine);
125 Q_ASSERT(d->state == QPrinter::Active);
126 OSStatus err = PMSessionEndPageNoDialog(d->session());
127 if (err != noErr) {
128 if (err == kPMCancel) {
129 // User canceled, we need to abort!
130 abort();
131 } else {
132 // Not sure what the problem is...
133 qWarning("QMacPrintEngine::newPage: Cannot end current page. %ld", long(err));
134 d->state = QPrinter::Error;
135 }
136 return false;
137 }
138 return d->newPage_helper();
139}
140
142{
143 Q_D(QMacPrintEngine);
144 if (d->state != QPrinter::Active)
145 return false;
146 bool ret = end();
147 d->state = QPrinter::Aborted;
148 return ret;
149}
150
152{
153 Q_D(const QMacPrintEngine);
154 int val = 1;
155 switch (m) {
157 val = d->m_pageLayout.paintRectPixels(d->resolution.hRes).width();
158 break;
160 val = d->m_pageLayout.paintRectPixels(d->resolution.hRes).height();
161 break;
163 val = qRound(d->m_pageLayout.paintRect(QPageLayout::Millimeter).width());
164 break;
166 val = qRound(d->m_pageLayout.paintRect(QPageLayout::Millimeter).height());
167 break;
170 PMPrinter printer;
171 if (PMSessionGetCurrentPrinter(d->session(), &printer) == noErr) {
172 PMResolution resolution;
173 PMPrinterGetOutputResolution(printer, d->settings(), &resolution);
174 val = (int)resolution.vRes;
175 break;
176 }
178 }
180 val = (int)d->resolution.vRes;
181 break;
183 val = (int)d->resolution.hRes;
184 break;
187 break;
189 val = 24;
190 break;
192 val = 1;
193 break;
196 break;
197 default:
198 val = 0;
199 qWarning("QPrinter::metric: Invalid metric command");
200 }
201 return val;
202}
203
205{
206 Q_Q(QMacPrintEngine);
207
209
210 if (!paintEngine)
212
213 q->gccaps = paintEngine->gccaps;
214
216 printInfo = [[NSPrintInfo alloc] initWithDictionary:[NSDictionary dictionary]];
217
219 if (!resolutions.isEmpty() && mode != QPrinter::ScreenResolution) {
220 std::sort(resolutions.begin(), resolutions.end());
221 if (resolutions.count() > 1 && mode == QPrinter::HighResolution)
222 resolution.hRes = resolution.vRes = resolutions.last();
223 else
224 resolution.hRes = resolution.vRes = resolutions.first();
225 if (resolution.hRes == 0)
226 resolution.hRes = resolution.vRes = 600;
227 } else {
228 resolution.hRes = resolution.vRes = qt_defaultDpi();
229 }
230
232
234 for (propC = valueCache.constBegin(); propC != valueCache.constEnd(); ++propC) {
235 q->setProperty(propC.key(), propC.value());
236 }
237}
238
240{
241 PMSessionEndPageNoDialog(session());
242 PMSessionEndDocumentNoDialog(session());
244 printInfo = nil;
245}
246
248{
249 Q_Q(QMacPrintEngine);
251
252 if (PMSessionError(session()) != noErr) {
253 q->abort();
254 return false;
255 }
256
257 // pop the stack of saved graphic states, in case we get the same
258 // context back - either way, the stack count should be 0 when we
259 // get the new one
261 while (cgEngine->d_func()->stackCount > 0)
262 cgEngine->d_func()->restoreGraphicsState();
263
264 OSStatus status = PMSessionBeginPageNoDialog(session(), format(), nullptr);
265 if (status != noErr) {
267 return false;
268 }
269
272
273 CGContextRef cgContext;
274 OSStatus err = noErr;
275 err = PMSessionGetCGGraphicsContext(session(), &cgContext);
276 if (err != noErr) {
277 qWarning("QMacPrintEngine::newPage: Cannot retrieve CoreGraphics context: %ld", long(err));
279 return false;
280 }
281 cgEngine->d_func()->hd = cgContext;
282
283 // Set the resolution as a scaling ration of 72 (the default).
284 CGContextScaleCTM(cgContext, 72 / resolution.hRes, 72 / resolution.vRes);
285
286 CGContextScaleCTM(cgContext, 1, -1);
287 CGContextTranslateCTM(cgContext, 0, -paper.height());
289 CGContextTranslateCTM(cgContext, page.x() - paper.x(), page.y() - paper.y());
290 cgEngine->d_func()->orig_xform = CGContextGetCTM(cgContext);
291 cgEngine->d_func()->setClip(nullptr);
292 cgEngine->state->dirtyFlags = QPaintEngine::DirtyFlags(QPaintEngine::AllDirty)
296 if (cgEngine->painter()->hasClipping())
298 cgEngine->syncState();
299 return true;
300}
301
303{
304 if (!pageSize.isValid())
305 return;
306
307 // Get the matching printer paper
308 QPageSize printerPageSize = m_printDevice->supportedPageSize(pageSize);
309 QPageSize usePageSize = printerPageSize.isValid() ? printerPageSize : pageSize;
310
311 // Get the PMPaper and check it is valid
312 PMPaper macPaper = m_printDevice->macPaper(usePageSize);
313 if (!macPaper) {
314 qWarning() << "QMacPrintEngine: Invalid PMPaper returned for " << pageSize;
315 return;
316 }
317
320
321 // You cannot set the page size on a PMPageFormat, you must create a new PMPageFormat
322 PMPageFormat pageFormat;
323 PMCreatePageFormatWithPMPaper(&pageFormat, macPaper);
324 PMSetOrientation(pageFormat, m_pageLayout.orientation() == QPageLayout::Landscape ? kPMLandscape : kPMPortrait, kPMUnlocked);
325 PMCopyPageFormat(pageFormat, format());
326 if (PMSessionValidatePageFormat(session(), format(), kPMDontWantBoolean) != noErr)
327 qWarning("QMacPrintEngine: Invalid page format");
328 PMRelease(pageFormat);
329}
330
332{
333 d_func()->paintEngine->updateState(state);
334}
335
337{
338 Q_D(QMacPrintEngine);
339 Q_ASSERT(d->state == QPrinter::Active);
340 d->paintEngine->drawRects(r, num);
341}
342
343void QMacPrintEngine::drawPoints(const QPointF *points, int pointCount)
344{
345 Q_D(QMacPrintEngine);
346 Q_ASSERT(d->state == QPrinter::Active);
347 d->paintEngine->drawPoints(points, pointCount);
348}
349
351{
352 Q_D(QMacPrintEngine);
353 Q_ASSERT(d->state == QPrinter::Active);
354 d->paintEngine->drawEllipse(r);
355}
356
357void QMacPrintEngine::drawLines(const QLineF *lines, int lineCount)
358{
359 Q_D(QMacPrintEngine);
360 Q_ASSERT(d->state == QPrinter::Active);
361 d->paintEngine->drawLines(lines, lineCount);
362}
363
365{
366 Q_D(QMacPrintEngine);
367 Q_ASSERT(d->state == QPrinter::Active);
368 d->paintEngine->drawPolygon(points, pointCount, mode);
369}
370
371void QMacPrintEngine::drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr)
372{
373 Q_D(QMacPrintEngine);
374 Q_ASSERT(d->state == QPrinter::Active);
375 d->paintEngine->drawPixmap(r, pm, sr);
376}
377
378void QMacPrintEngine::drawImage(const QRectF &r, const QImage &pm, const QRectF &sr, Qt::ImageConversionFlags flags)
379{
380 Q_D(QMacPrintEngine);
381 Q_ASSERT(d->state == QPrinter::Active);
382 d->paintEngine->drawImage(r, pm, sr, flags);
383}
384
386{
387 Q_D(QMacPrintEngine);
388 Q_ASSERT(d->state == QPrinter::Active);
389 if (!d->embedFonts)
391 else
392 d->paintEngine->drawTextItem(p, ti);
393}
394
396{
397 Q_D(QMacPrintEngine);
398 Q_ASSERT(d->state == QPrinter::Active);
399 d->paintEngine->drawTiledPixmap(dr, pixmap, sr);
400}
401
403{
404 Q_D(QMacPrintEngine);
405 Q_ASSERT(d->state == QPrinter::Active);
406 d->paintEngine->drawPath(path);
407}
408
409
411{
412 Q_D(QMacPrintEngine);
413
414 d->valueCache.insert(key, value);
415 if (!d->printInfo)
416 return;
417
418 switch (key) {
419
420 // The following keys are properties or derived values and so cannot be set
421 case PPK_PageRect:
422 break;
423 case PPK_PaperRect:
424 break;
425 case PPK_PaperSources:
426 break;
428 break;
430 break;
431
432 // The following keys are settings that are unsupported by the Mac PrintEngine
433 case PPK_ColorMode:
434 break;
435 case PPK_CustomBase:
436 break;
437 case PPK_PageOrder:
438 // TODO Check if can be supported via Cups Options
439 break;
440 case PPK_PaperSource:
441 // TODO Check if can be supported via Cups Options
442 break;
444 break;
446 break;
447
448 // The following keys are properties and settings that are supported by the Mac PrintEngine
450 d->embedFonts = value.toBool();
451 break;
452 case PPK_Resolution: {
453 int bestResolution = 0;
454 int dpi = value.toInt();
455 int bestDistance = INT_MAX;
456 for (int resolution : d->m_printDevice->supportedResolutions()) {
457 if (dpi == resolution) {
458 bestResolution = resolution;
459 break;
460 } else {
461 int distance = qAbs(dpi - resolution);
462 if (distance < bestDistance) {
463 bestDistance = distance;
464 bestResolution = resolution;
465 }
466 }
467 }
468 PMResolution resolution;
469 resolution.hRes = resolution.vRes = bestResolution;
470 if (PMPrinterSetOutputResolution(d->m_printDevice->macPrinter(), d->settings(), &resolution) == noErr) {
471 // Setting the resolution succeeded.
472 // Now try to read the actual resolution selected by the OS.
473 if (PMPrinterGetOutputResolution(d->m_printDevice->macPrinter(), d->settings(), &d->resolution) != noErr) {
474 // Reading the resolution somehow failed; d->resolution is in undefined state.
475 // So use the value which was acceptable to PMPrinterSetOutputResolution.
476 d->resolution = resolution;
477 }
478 }
479 break;
480 }
482 PMSetCollate(d->settings(), value.toBool());
483 break;
484 case PPK_Creator:
485 d->m_creator = value.toString();
486 break;
487 case PPK_DocumentName:
488 PMPrintSettingsSetJobName(d->settings(), QCFString(value.toString()));
489 break;
490 case PPK_Duplex: {
492 if (mode == property(PPK_Duplex).toInt() || !d->m_printDevice->supportedDuplexModes().contains(mode))
493 break;
494 switch (mode) {
496 PMSetDuplex(d->settings(), kPMDuplexNone);
497 break;
499 PMSetDuplex(d->settings(), d->m_pageLayout.orientation() == QPageLayout::Landscape ? kPMDuplexTumble : kPMDuplexNoTumble);
500 break;
502 PMSetDuplex(d->settings(), kPMDuplexNoTumble);
503 break;
505 PMSetDuplex(d->settings(), kPMDuplexTumble);
506 break;
507 default:
508 // Don't change
509 break;
510 }
511 break;
512 }
513 case PPK_FullPage:
514 if (value.toBool())
515 d->m_pageLayout.setMode(QPageLayout::FullPageMode);
516 else
517 d->m_pageLayout.setMode(QPageLayout::StandardMode);
518 break;
519 case PPK_CopyCount: // fallthrough
521 PMSetCopies(d->settings(), value.toInt(), false);
522 break;
523 case PPK_Orientation: {
524 // First try set the Mac format orientation, then set our orientation to match result
526 PMOrientation macOrientation = (newOrientation == QPageLayout::Landscape) ? kPMLandscape : kPMPortrait;
527 PMSetOrientation(d->format(), macOrientation, kPMUnlocked);
528 PMSessionValidatePageFormat(d->session(), d->format(), kPMDontWantBoolean);
529 PMGetOrientation(d->format(), &macOrientation);
530 d->m_pageLayout.setOrientation(macOrientation == kPMLandscape ? QPageLayout::Landscape : QPageLayout::Portrait);
531 break;
532 }
534 d->outputFilename = value.toString();
535 break;
536 case PPK_PageSize:
537 d->setPageSize(QPageSize(QPageSize::PageSizeId(value.toInt())));
538 break;
539 case PPK_PaperName:
540 // Get the named page size from the printer if supported
541 d->setPageSize(d->m_printDevice->supportedPageSize(value.toString()));
542 break;
544 d->setPageSize(QPageSize(QPageSize::id(value.toInt())));
545 break;
546 case PPK_PrinterName: {
547 QVariant pageSize = QVariant::fromValue(d->m_pageLayout.pageSize());
548 const bool isFullPage = d->m_pageLayout.mode() == QPageLayout::FullPageMode;
549 QVariant orientation = QVariant::fromValue(d->m_pageLayout.orientation());
550 QVariant margins = QVariant::fromValue(QPair<QMarginsF, QPageLayout::Unit>(d->m_pageLayout.margins(),
551 d->m_pageLayout.units()));
552 QString id = value.toString();
553 if (id.isEmpty())
555 else if (!QCocoaPrinterSupport().availablePrintDeviceIds().contains(id))
556 break;
557 d->m_printDevice.reset(new QCocoaPrintDevice(id));
558 PMPrinter printer = d->m_printDevice->macPrinter();
559 PMRetain(printer);
560 PMSessionSetCurrentPMPrinter(d->session(), printer);
561 // Ensure the settings are up to date and valid
562 if (d->m_printDevice->supportedPageSize(pageSize.value<QPageSize>()).isValid())
563 setProperty(PPK_QPageSize, pageSize);
564 else
566 setProperty(PPK_FullPage, QVariant(isFullPage));
567 setProperty(PPK_Orientation, orientation);
569 break;
570 }
572 d->setPageSize(QPageSize(value.toSizeF(), QPageSize::Point));
573 break;
574 case PPK_PageMargins:
575 {
576 QList<QVariant> margins(value.toList());
577 Q_ASSERT(margins.size() == 4);
578 d->m_pageLayout.setMargins(QMarginsF(margins.at(0).toReal(), margins.at(1).toReal(),
579 margins.at(2).toReal(), margins.at(3).toReal()));
580 break;
581 }
582 case PPK_QPageSize:
583 d->setPageSize(value.value<QPageSize>());
584 break;
585 case PPK_QPageMargins: {
587 d->m_pageLayout.setUnits(pair.second);
588 d->m_pageLayout.setMargins(pair.first);
589 break;
590 }
591 case PPK_QPageLayout: {
592 QPageLayout pageLayout = value.value<QPageLayout>();
593 if (pageLayout.isValid() && d->m_printDevice->isValidPageLayout(pageLayout, d->resolution.hRes)) {
597 d->m_pageLayout.setUnits(pageLayout.units());
598 d->m_pageLayout.setMargins(pageLayout.margins());
599 }
600 break;
601 }
602 // No default so that compiler will complain if new keys added and not handled in this engine
603 }
604}
605
607{
608 Q_D(const QMacPrintEngine);
610
611 if (!d->printInfo && d->valueCache.contains(key))
612 return *d->valueCache.find(key);
613
614 switch (key) {
615
616 // The following keys are settings that are unsupported by the Mac PrintEngine
617 // Return sensible default values to ensure consistent behavior across platforms
618 case PPK_ColorMode:
620 break;
621 case PPK_CustomBase:
622 // Special case, leave null
623 break;
624 case PPK_PageOrder:
625 // TODO Check if can be supported via Cups Options
627 break;
628 case PPK_PaperSource:
629 // TODO Check if can be supported via Cups Options
631 break;
632 case PPK_PaperSources: {
633 // TODO Check if can be supported via Cups Options
635 out << int(QPrinter::Auto);
636 ret = out;
637 break;
638 }
640 ret = QString();
641 break;
643 ret = QString();
644 break;
645
646 // The following keys are properties and settings that are supported by the Mac PrintEngine
648 ret = d->embedFonts;
649 break;
650 case PPK_CollateCopies: {
651 Boolean status;
652 PMGetCollate(d->settings(), &status);
653 ret = bool(status);
654 break;
655 }
656 case PPK_Creator:
657 ret = d->m_creator;
658 break;
659 case PPK_DocumentName: {
660 CFStringRef name;
661 PMPrintSettingsGetJobName(d->settings(), &name);
662 ret = QString::fromCFString(name);
663 break;
664 }
665 case PPK_Duplex: {
666 PMDuplexMode mode = kPMDuplexNone;
667 PMGetDuplex(d->settings(), &mode);
668 switch (mode) {
669 case kPMDuplexNoTumble:
671 break;
672 case kPMDuplexTumble:
674 break;
675 case kPMDuplexNone:
676 default:
678 break;
679 }
680 break;
681 }
682 case PPK_FullPage:
683 ret = d->m_pageLayout.mode() == QPageLayout::FullPageMode;
684 break;
686 ret = 1;
687 break;
688 case PPK_CopyCount: {
689 UInt32 copies = 1;
690 PMGetCopies(d->settings(), &copies);
691 ret = (uint) copies;
692 break;
693 }
695 ret = true;
696 break;
697 case PPK_Orientation:
698 ret = d->m_pageLayout.orientation();
699 break;
701 ret = d->outputFilename;
702 break;
703 case PPK_PageRect:
704 // PageRect is returned in device pixels
705 ret = d->m_pageLayout.paintRectPixels(d->resolution.hRes);
706 break;
707 case PPK_PageSize:
708 ret = d->m_pageLayout.pageSize().id();
709 break;
710 case PPK_PaperName:
711 ret = d->m_pageLayout.pageSize().name();
712 break;
714 ret = d->m_pageLayout.pageSize().windowsId();
715 break;
716 case PPK_PaperRect:
717 // PaperRect is returned in device pixels
718 ret = d->m_pageLayout.fullRectPixels(d->resolution.hRes);
719 break;
720 case PPK_PrinterName:
721 return d->m_printDevice->id();
722 break;
723 case PPK_Resolution: {
724 ret = d->resolution.hRes;
725 break;
726 }
729 for (int resolution : d->m_printDevice->supportedResolutions())
730 list << resolution;
731 ret = list;
732 break;
733 }
735 ret = d->m_pageLayout.fullRectPoints().size();
736 break;
737 case PPK_PageMargins: {
739 QMarginsF margins = d->m_pageLayout.margins(QPageLayout::Point);
740 list << margins.left() << margins.top() << margins.right() << margins.bottom();
741 ret = list;
742 break;
743 }
744 case PPK_QPageSize:
745 ret.setValue(d->m_pageLayout.pageSize());
746 break;
747 case PPK_QPageMargins: {
748 QPair<QMarginsF, QPageLayout::Unit> pair = qMakePair(d->m_pageLayout.margins(), d->m_pageLayout.units());
749 ret.setValue(pair);
750 break;
751 }
752 case PPK_QPageLayout:
753 ret.setValue(d->m_pageLayout);
754 // No default so that compiler will complain if new keys added and not handled in this engine
755 }
756 return ret;
757}
758
760{
761 Q_D(QMacPrintEngine);
762 if (d->state == QPrinter::Idle && !d->isPrintSessionInitialized())
763 d->initialize();
764 return d->printInfo;
765}
766
768
769#endif // QT_NO_PRINTER
QMarginsF printableMargins(const QPageSize &pageSize, QPageLayout::Orientation orientation, int resolution) const override
PMPaper macPaper(const QPageSize &pageSize) const
QString defaultPrintDeviceId() const override
\inmodule QtCore
Definition qhash.h:1135
const T & value() const noexcept
Returns the current item's value.
Definition qhash.h:1154
const Key & key() const noexcept
Returns the current item's key.
Definition qhash.h:1153
const_iterator constEnd() const noexcept
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item after the ...
Definition qhash.h:1209
const_iterator constBegin() const noexcept
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first item in the hash.
Definition qhash.h:1205
\inmodule QtGui
Definition qimage.h:37
\inmodule QtCore
Definition qline.h:182
Definition qlist.h:74
qsizetype size() const noexcept
Definition qlist.h:386
bool isEmpty() const noexcept
Definition qlist.h:390
T & first()
Definition qlist.h:628
T & last()
Definition qlist.h:631
iterator end()
Definition qlist.h:609
const_reference at(qsizetype i) const noexcept
Definition qlist.h:429
qsizetype count() const noexcept
Definition qlist.h:387
iterator begin()
Definition qlist.h:608
PMPrintSession session() const
QPrinter::PrinterState state
QSharedPointer< QCocoaPrintDevice > m_printDevice
PMPageFormat format() const
void setPageSize(const QPageSize &pageSize)
QHash< QMacPrintEngine::PrintEnginePropertyKey, QVariant > valueCache
virtual void drawPoints(const QPointF *p, int pointCount)
Draws the first pointCount points in the buffer points.
void updateState(const QPaintEngineState &state)
Reimplement this function to update the state of a paint engine.
QPaintEngine * paintEngine() const
virtual void drawImage(const QRectF &r, const QImage &pm, const QRectF &sr, Qt::ImageConversionFlags flags)
Reimplement this function to draw the part of the image specified by the sr rectangle in the given re...
virtual void drawTextItem(const QPointF &p, const QTextItem &ti)
This function draws the text item textItem at position p.
QVariant property(PrintEnginePropertyKey key) const
Returns the print engine's property specified by key.
virtual void drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s)
Reimplement this function to draw the pixmap in the given rect, starting at the given p.
virtual void drawPath(const QPainterPath &)
The default implementation ignores the path and does nothing.
bool newPage()
Instructs the print engine to start a new page.
Qt::HANDLE handle() const
virtual void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode)
Reimplement this virtual function to draw the polygon defined by the pointCount first points in point...
QPrinter::PrinterState printerState() const
Returns the current state of the printer being used by the print engine.
virtual void drawRects(const QRectF *r, int num)
Draws the first rectCount rectangles in the buffer rects.
NSPrintInfo * printInfo()
bool end()
Reimplement this function to finish painting on the current paint device.
bool begin(QPaintDevice *dev)
Reimplement this function to initialise your paint engine when painting is to start on the paint devi...
virtual void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr)
Reimplement this function to draw the part of the pm specified by the sr rectangle in the given r.
bool abort()
Instructs the print engine to abort the printing process.
int metric(QPaintDevice::PaintDeviceMetric) const
Returns the metric for the given id.
virtual void drawEllipse(const QRectF &r)
Reimplement this function to draw the largest ellipse that can be contained within rectangle rect.
void setProperty(PrintEnginePropertyKey key, const QVariant &value)
Sets the print engine's property specified by key to the given value.
virtual void drawLines(const QLineF *lines, int lineCount)
The default implementation splits the list of lines in lines into lineCount separate calls to drawPat...
\inmodule QtCore
Definition qmargins.h:274
constexpr qreal right() const noexcept
Returns the right margin.
Definition qmargins.h:370
constexpr qreal left() const noexcept
Returns the left margin.
Definition qmargins.h:364
constexpr qreal top() const noexcept
Returns the top margin.
Definition qmargins.h:367
constexpr qreal bottom() const noexcept
Returns the bottom margin.
Definition qmargins.h:373
\inmodule QtGui
Definition qpagelayout.h:20
Mode mode() const
Returns the page layout mode.
Unit units() const
Returns the units the page layout is currently defined in.
bool isValid() const
Returns true if this page layout is valid.
Unit
This enum type is used to specify the measurement unit for page layout and margins.
Definition qpagelayout.h:24
QMarginsF margins() const
Returns the margins of the page layout using the currently set units.
Orientation orientation() const
Returns the page orientation of the page layout.
QRect paintRectPixels(int resolution) const
Returns the paintable rectangle in rounded device pixels for the given resolution.
void setPageSize(const QPageSize &pageSize, const QMarginsF &minMargins=QMarginsF(0, 0, 0, 0))
Sets the page size of the page layout to pageSize.
Orientation
This enum type defines the page orientation.
Definition qpagelayout.h:33
QRect fullRectPixels(int resolution) const
Returns the full page rectangle in device pixels for the given resolution.
QPageSize pageSize() const
Returns the page size of the page layout.
\inmodule QtGui
Definition qpagesize.h:22
bool isValid() const
Returns true if this page size is valid.
QSizeF size(Unit units) const
Returns the size of the page in the required units.
PageSizeId id() const
Returns the standard QPageSize::PageSizeId of the page, or QPageSize::Custom.
PageSizeId
This enum type lists the available page sizes as defined in the Postscript PPD standard.
Definition qpagesize.h:25
@ PdmDevicePixelRatioScaled
virtual int devType() const
static qreal devicePixelRatioFScale()
The QPaintEngineState class provides information about the active paint engine's current state....
QPaintEngine::DirtyFlags dirtyFlags
\inmodule QtGui
void setActive(bool newState)
Sets the active state of the paint engine to state.
virtual void drawTextItem(const QPointF &p, const QTextItem &textItem)
This function draws the text item textItem at position p.
PolygonDrawMode
\value OddEvenMode The polygon should be drawn using OddEven fill rule.
friend class QMacPrintEngine
QPainter * painter() const
Returns the paint engine's painter.
QPaintEngineState * state
PaintEngineFeatures gccaps
\inmodule QtGui
bool hasClipping() const
Returns true if clipping has been set; otherwise returns false.
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
Definition qpixmap.h:27
virtual QPageSize supportedPageSize(const QPageSize &pageSize) const
virtual QList< int > supportedResolutions() const
\inmodule QtCore\reentrant
Definition qpoint.h:214
PrintEnginePropertyKey
This enum is used to communicate properties between the print engine and QPrinter.
@ PPK_SupportedResolutions
@ PPK_SupportsMultipleCopies
\reentrant
Definition qprinter.h:28
@ DuplexLongSide
Definition qprinter.h:87
@ DuplexNone
Definition qprinter.h:85
@ DuplexShortSide
Definition qprinter.h:88
PrinterMode
This enum describes the mode the printer should work in.
Definition qprinter.h:31
@ ScreenResolution
Definition qprinter.h:31
@ HighResolution
Definition qprinter.h:31
PrinterState
\value Idle \value Active \value Aborted \value Error
Definition qprinter.h:64
@ Aborted
Definition qprinter.h:66
@ FirstPageFirst
Definition qprinter.h:39
\inmodule QtCore\reentrant
Definition qrect.h:483
\inmodule QtCore\reentrant
Definition qrect.h:30
constexpr int height() const noexcept
Returns the height of the rectangle.
Definition qrect.h:238
constexpr int x() const noexcept
Returns the x-coordinate of the rectangle's left edge.
Definition qrect.h:184
constexpr int y() const noexcept
Returns the y-coordinate of the rectangle's top edge.
Definition qrect.h:187
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
\inmodule QtGui
\inmodule QtCore
Definition qvariant.h:64
T value() const &
Definition qvariant.h:511
static auto fromValue(T &&value) noexcept(std::is_nothrow_copy_constructible_v< T > &&Private::CanUseInternalSpace< T >) -> std::enable_if_t< std::conjunction_v< std::is_copy_constructible< T >, std::is_destructible< T > >, QVariant >
Definition qvariant.h:531
else opt state
[0]
DuplexMode
Definition qprint_p.h:64
@ DuplexLongSide
Definition qprint_p.h:67
@ DuplexShortSide
Definition qprint_p.h:68
@ DuplexNone
Definition qprint_p.h:65
@ DuplexAuto
Definition qprint_p.h:66
Combined button and popup list for selecting options.
void * HANDLE
#define Q_FALLTHROUGH()
std::pair< T1, T2 > QPair
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
int qRound(qfloat16 d) noexcept
Definition qfloat16.h:281
Q_GUI_EXPORT int qt_defaultDpi()
Definition qfont.cpp:137
#define qWarning
Definition qlogging.h:162
return ret
constexpr T qAbs(const T &t)
Definition qnumeric.h:328
static bool contains(const QJsonArray &haystack, unsigned needle)
Definition qopengl.cpp:116
GLenum mode
const GLfloat * m
GLuint64 key
GLboolean r
[2]
GLsizei GLsizei GLfloat distance
GLbitfield flags
GLuint name
GLfixed GLfixed GLint GLint GLfixed points
GLuint GLfloat * val
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
GLsizei const GLchar *const * path
GLfloat GLfloat p
[1]
GLuint num
Q_GUI_EXPORT QMarginsF qt_convertMargins(const QMarginsF &margins, QPageLayout::Unit fromUnits, QPageLayout::Unit toUnits)
struct CGContext * CGContextRef
constexpr decltype(auto) qMakePair(T1 &&value1, T2 &&value2) noexcept(noexcept(std::make_pair(std::forward< T1 >(value1), std::forward< T2 >(value2))))
Definition qpair.h:19
QT_BEGIN_NAMESPACE QMarginsF qt_convertMargins(const QMarginsF &margins, QPageLayout::Unit fromUnits, QPageLayout::Unit toUnits)
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
#define Q_ASSERT_X(cond, x, msg)
Definition qrandom.cpp:48
unsigned int uint
Definition qtypes.h:29
static int toInt(const QChar &qc, int R)
const char property[13]
Definition qwizard.cpp:101
QList< int > list
[14]
QFuture< QSet< QString > > dictionary
QTextStream out(stdout)
[7]
QByteArray page
[45]
sem release()
widget render & pixmap