Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
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
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
218 QList<int> resolutions = m_printDevice->supportedResolutions();
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.constLast();
223 else
224 resolution.hRes = resolution.vRes = resolutions.constFirst();
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())
297 cgEngine->state->dirtyFlags |= QPaintEngine::DirtyClipEnabled;
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()),
581 break;
582 }
583 case PPK_QPageSize:
584 d->setPageSize(value.value<QPageSize>());
585 break;
586 case PPK_QPageMargins: {
587 QPair<QMarginsF, QPageLayout::Unit> pair = value.value<QPair<QMarginsF, QPageLayout::Unit> >();
588 d->m_pageLayout.setUnits(pair.second);
589 d->m_pageLayout.setMargins(pair.first, QPageLayout::OutOfBoundsPolicy::Clamp);
590 break;
591 }
592 case PPK_QPageLayout: {
593 QPageLayout pageLayout = value.value<QPageLayout>();
594 if (pageLayout.isValid() && d->m_printDevice->isValidPageLayout(pageLayout, d->resolution.hRes)) {
598 d->m_pageLayout.setUnits(pageLayout.units());
599 d->m_pageLayout.setMargins(pageLayout.margins(), QPageLayout::OutOfBoundsPolicy::Clamp);
600 }
601 break;
602 }
603 // No default so that compiler will complain if new keys added and not handled in this engine
604 }
605}
606
608{
609 Q_D(const QMacPrintEngine);
611
612 if (!d->printInfo && d->valueCache.contains(key))
613 return *d->valueCache.find(key);
614
615 switch (key) {
616
617 // The following keys are settings that are unsupported by the Mac PrintEngine
618 // Return sensible default values to ensure consistent behavior across platforms
619 case PPK_ColorMode:
621 break;
622 case PPK_CustomBase:
623 // Special case, leave null
624 break;
625 case PPK_PageOrder:
626 // TODO Check if can be supported via Cups Options
628 break;
629 case PPK_PaperSource:
630 // TODO Check if can be supported via Cups Options
632 break;
633 case PPK_PaperSources: {
634 // TODO Check if can be supported via Cups Options
635 QList<QVariant> out;
636 out << int(QPrinter::Auto);
637 ret = out;
638 break;
639 }
641 ret = QString();
642 break;
644 ret = QString();
645 break;
646
647 // The following keys are properties and settings that are supported by the Mac PrintEngine
649 ret = d->embedFonts;
650 break;
651 case PPK_CollateCopies: {
652 Boolean status;
653 PMGetCollate(d->settings(), &status);
654 ret = bool(status);
655 break;
656 }
657 case PPK_Creator:
658 ret = d->m_creator;
659 break;
660 case PPK_DocumentName: {
661 CFStringRef name;
662 PMPrintSettingsGetJobName(d->settings(), &name);
663 ret = QString::fromCFString(name);
664 break;
665 }
666 case PPK_Duplex: {
667 PMDuplexMode mode = kPMDuplexNone;
668 PMGetDuplex(d->settings(), &mode);
669 switch (mode) {
670 case kPMDuplexNoTumble:
672 break;
673 case kPMDuplexTumble:
675 break;
676 case kPMDuplexNone:
677 default:
679 break;
680 }
681 break;
682 }
683 case PPK_FullPage:
684 ret = d->m_pageLayout.mode() == QPageLayout::FullPageMode;
685 break;
687 ret = 1;
688 break;
689 case PPK_CopyCount: {
690 UInt32 copies = 1;
691 PMGetCopies(d->settings(), &copies);
692 ret = (uint) copies;
693 break;
694 }
696 ret = true;
697 break;
698 case PPK_Orientation:
699 ret = d->m_pageLayout.orientation();
700 break;
702 ret = d->outputFilename;
703 break;
704 case PPK_PageRect:
705 // PageRect is returned in device pixels
706 ret = d->m_pageLayout.paintRectPixels(d->resolution.hRes);
707 break;
708 case PPK_PageSize:
709 ret = d->m_pageLayout.pageSize().id();
710 break;
711 case PPK_PaperName:
712 ret = d->m_pageLayout.pageSize().name();
713 break;
715 ret = d->m_pageLayout.pageSize().windowsId();
716 break;
717 case PPK_PaperRect:
718 // PaperRect is returned in device pixels
719 ret = d->m_pageLayout.fullRectPixels(d->resolution.hRes);
720 break;
721 case PPK_PrinterName:
722 return d->m_printDevice->id();
723 break;
724 case PPK_Resolution: {
725 ret = d->resolution.hRes;
726 break;
727 }
729 QList<QVariant> list;
730 for (int resolution : d->m_printDevice->supportedResolutions())
731 list << resolution;
732 ret = list;
733 break;
734 }
736 ret = d->m_pageLayout.fullRectPoints().size();
737 break;
738 case PPK_PageMargins: {
739 QList<QVariant> list;
740 QMarginsF margins = d->m_pageLayout.margins(QPageLayout::Point);
741 list << margins.left() << margins.top() << margins.right() << margins.bottom();
742 ret = list;
743 break;
744 }
745 case PPK_QPageSize:
746 ret.setValue(d->m_pageLayout.pageSize());
747 break;
748 case PPK_QPageMargins: {
749 QPair<QMarginsF, QPageLayout::Unit> pair = qMakePair(d->m_pageLayout.margins(), d->m_pageLayout.units());
750 ret.setValue(pair);
751 break;
752 }
753 case PPK_QPageLayout:
754 ret.setValue(d->m_pageLayout);
755 // No default so that compiler will complain if new keys added and not handled in this engine
756 }
757 return ret;
758}
759
761{
762 Q_D(QMacPrintEngine);
763 if (d->state == QPrinter::Idle && !d->isPrintSessionInitialized())
764 d->initialize();
765 return d->printInfo;
766}
767
769
770#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
bool end()
Reimplement this function to finish painting on the current paint device.
\inmodule QtCore
Definition qhash.h:1145
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:1219
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:1215
\inmodule QtGui
Definition qimage.h:37
\inmodule QtCore\compares equality \compareswith equality QLine \endcompareswith
Definition qline.h:192
qsizetype size() const noexcept
Definition qlist.h:397
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:270
constexpr qreal right() const noexcept
Returns the right margin.
Definition qmargins.h:383
constexpr qreal left() const noexcept
Returns the left margin.
Definition qmargins.h:377
constexpr qreal top() const noexcept
Returns the top margin.
Definition qmargins.h:380
constexpr qreal bottom() const noexcept
Returns the bottom margin.
Definition qmargins.h:386
\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....
\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
QPaintEngineState * state
PaintEngineFeatures gccaps
\inmodule QtGui
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:217
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:484
\inmodule QtCore\reentrant
Definition qrect.h:30
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtGui
\inmodule QtCore
Definition qvariant.h:65
T value() const &
Definition qvariant.h:516
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:536
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()
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
int qRound(qfloat16 d) noexcept
Definition qfloat16.h:327
Q_GUI_EXPORT int qt_defaultDpi()
Definition qfont.cpp:140
#define qWarning
Definition qlogging.h:166
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
QT_BEGIN_NAMESPACE 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:34
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
args<< 1<< 2;QJSValue threeAgain=fun.call(args);QString fileName="helloworld.qs";QFile scriptFile(fileName);if(!scriptFile.open(QIODevice::ReadOnly)) QTextStream stream(&scriptFile);QString contents=stream.readAll();scriptFile.close();myEngine.evaluate(contents, fileName);myEngine.globalObject().setProperty("myNumber", 123);...QJSValue myNumberPlusOne=myEngine.evaluate("myNumber + 1");QJSValue result=myEngine.evaluate(...);if(result.isError()) qDebug()<< "Uncaught exception at line"<< result.property("lineNumber").toInt()<< ":"<< result.toString();QPushButton *button=new QPushButton;QJSValue scriptButton=myEngine.newQObject(button);myEngine.globalObject().setProperty("button", scriptButton);myEngine.evaluate("button.checkable = true");qDebug()<< scriptButton.property("checkable").toBool();scriptButton.property("show").call();QJSEngine engine;QObject *myQObject=new QObject();myQObject- setProperty)("dynamicProperty", 3)