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_win_p.h
Go to the documentation of this file.
1// Copyright (C) 2020 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#ifndef QPRINTENGINE_WIN_P_H
5#define QPRINTENGINE_WIN_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists for the convenience
12// of other Qt classes. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtPrintSupport/private/qtprintsupportglobal_p.h>
19
20#ifndef QT_NO_PRINTER
21
22#include <QtGui/qpaintengine.h>
23#include <QtGui/qpagelayout.h>
24#include <QtPrintSupport/QPrintEngine>
25#include <QtPrintSupport/QPrinter>
26#include <private/qpaintengine_alpha_p.h>
27#include <private/qprintdevice_p.h>
28#include <QtCore/qt_windows.h>
29
31
33class QPrinterPrivate;
34class QPainterState;
35
36class Q_PRINTSUPPORT_EXPORT QWin32PrintEngine : public QAlphaPaintEngine, public QPrintEngine
37{
38 Q_DECLARE_PRIVATE(QWin32PrintEngine)
39public:
41
42 // override QWin32PaintEngine
43 bool begin(QPaintDevice *dev) override;
44 bool end() override;
45
46 void updateState(const QPaintEngineState &state) override;
47
48 void updateMatrix(const QTransform &matrix);
49 void updateClipPath(const QPainterPath &clip, Qt::ClipOperation op);
50
51 void drawPath(const QPainterPath &path) override;
52 void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode) override;
53 void drawTextItem(const QPointF &p, const QTextItem &textItem) override;
54
55 void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr) override;
56 void drawTiledPixmap(const QRectF &r, const QPixmap &pm, const QPointF &p) override;
59
60 bool newPage() override;
61 bool abort() override;
62 int metric(QPaintDevice::PaintDeviceMetric) const override;
63
64 QPrinter::PrinterState printerState() const override;
65
66 QPaintEngine::Type type() const override { return Windows; }
67
68 HDC getDC() const;
69 void releaseDC(HDC) const;
70
71 /* Used by print/page setup dialogs */
72 void setGlobalDevMode(HGLOBAL globalDevNames, HGLOBAL globalDevMode);
73 HGLOBAL *createGlobalDevNames();
74 HGLOBAL globalDevMode();
75
76private:
77 friend class QPrintDialog;
78 friend class QPageSetupDialog;
79};
80
82{
83 Q_DECLARE_PUBLIC(QWin32PrintEngine)
84public:
91
93
94
95 /* Initializes the printer data based on the current printer name. This
96 function creates a DEVMODE struct, HDC and a printer handle. If these
97 structures are already in use, they are freed using release
98 */
99 void initialize();
100
101 /* Initializes data in the print engine whenever the HDC has been renewed
102 */
103 void initHDC();
104
105 /* Releases all the handles the printer currently holds, HDC, DEVMODE,
106 etc and resets the corresponding members to 0. */
107 void release();
108
109 /* Resets the DC with changes in devmode. If the printer is active
110 this function only sets the reinit variable to true so it
111 is handled in the next begin or newpage. */
112 void doReinit();
113
114 static void initializeDevMode(DEVMODE *);
115
116 bool resetDC();
117
118 void strokePath(const QPainterPath &path, const QColor &color);
119 void fillPath(const QPainterPath &path, const QColor &color);
120
121 void composeGdiPath(const QPainterPath &path);
122 void fillPath_dev(const QPainterPath &path, const QColor &color);
123 void strokePath_dev(const QPainterPath &path, const QColor &color, qreal width);
124
125 void setPageSize(const QPageSize &pageSize);
126 void updatePageLayout();
127 void updateMetrics();
128 void debugMetrics() const;
129
130 // Windows GDI printer references.
131 HANDLE hPrinter = nullptr;
132
133 HGLOBAL globalDevMode = nullptr;
134 DEVMODE *devMode = nullptr;
135 PRINTER_INFO_2 *pInfo = nullptr;
136 HGLOBAL hMem = nullptr;
137
138 HDC hdc = nullptr;
139
140 // True if devMode was allocated separately from pInfo.
141 bool ownsDevMode = false;
142
144
145 // Print Device
147
148 // Document info
152
154 int resolution = 0;
155
156 // Page Layout
159 // Page metrics cache
162
163 // Windows painting
166 int origin_x = 0;
167 int origin_y = 0;
168
169 int dpi_x = 96;
170 int dpi_y = 96;
171 int dpi_display = 96;
172 int num_copies = 1;
173
176
182
183 uint txop = 0; // QTransform::TxNone
184
188 QSizeF paper_size; // In points
189
192};
193
195
196#endif // QT_NO_PRINTER
197
198#endif // QPRINTENGINE_WIN_P_H
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
\inmodule QtCore
Definition qmargins.h:270
\inmodule QtGui
Definition qpagelayout.h:20
The QPageSetupDialog class provides a configuration dialog for the page-related options on a printer.
\inmodule QtGui
Definition qpagesize.h:22
The QPaintEngineState class provides information about the active paint engine's current state....
PolygonDrawMode
\value OddEvenMode The polygon should be drawn using OddEven fill rule.
Type
\value X11 \value Windows \value MacPrinter \value CoreGraphics \macos's Quartz2D (CoreGraphics) \val...
\inmodule QtGui
\inmodule QtGui
Definition qpen.h:28
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
Definition qpixmap.h:27
\inmodule QtCore\reentrant
Definition qpoint.h:217
The QPrintDialog class provides a dialog for specifying the printer's configuration.
\reentrant
PrintEnginePropertyKey
This enum is used to communicate properties between the print engine and QPrinter.
PrinterMode
This enum describes the mode the printer should work in.
Definition qprinter.h:31
@ ScreenResolution
Definition qprinter.h:31
PrinterState
\value Idle \value Active \value Aborted \value Error
Definition qprinter.h:64
\inmodule QtCore\reentrant
Definition qrect.h:484
\inmodule QtCore\reentrant
Definition qrect.h:30
\inmodule QtCore
Definition qsize.h:208
\inmodule QtCore
Definition qsize.h:25
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtGui
The QTransform class specifies 2D transformations of a coordinate system.
Definition qtransform.h:20
\inmodule QtCore
Definition qvariant.h:65
QPrinter::PrinterState state
void fillPath_dev(const QPainterPath &path, const QColor &color)
void strokePath_dev(const QPainterPath &path, const QColor &color, qreal width)
void composeGdiPath(const QPainterPath &path)
void strokePath(const QPainterPath &path, const QColor &color)
static void initializeDevMode(DEVMODE *)
void setPageSize(const QPageSize &pageSize)
void fillPath(const QPainterPath &path, const QColor &color)
QPaintEngine::Type type() const override
Reimplement this function to return the paint engine \l{Type}.
else opt state
[0]
Combined button and popup list for selecting options.
ClipOperation
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLenum mode
GLuint64 key
GLboolean r
[2]
GLuint GLuint end
GLint GLsizei width
GLuint color
[2]
GLfixed GLfixed GLint GLint GLfixed points
GLuint GLenum matrix
GLsizei const GLchar *const * path
GLfloat GLfloat p
[1]
QtPrivate::QRegularExpressionMatchIteratorRangeBasedForIterator begin(const QRegularExpressionMatchIterator &iterator)
unsigned int uint
Definition qtypes.h:34
double qreal
Definition qtypes.h:187
const char property[13]
Definition qwizard.cpp:101
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)