Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
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
// Qt-Security score:significant reason:default
4
5
#
ifndef
QPRINTENGINE_WIN_P_H
6
#
define
QPRINTENGINE_WIN_P_H
7
8
//
9
// W A R N I N G
10
// -------------
11
//
12
// This file is not part of the Qt API. It exists for the convenience
13
// of other Qt classes. This header file may change from version to
14
// version without notice, or even be removed.
15
//
16
// We mean it.
17
//
18
19
#
include
<
QtPrintSupport
/
private
/
qtprintsupportglobal_p
.
h
>
20
21
#
ifndef
QT_NO_PRINTER
22
23
#
include
<
QtGui
/
qpaintengine
.
h
>
24
#
include
<
QtGui
/
qpagelayout
.
h
>
25
#
include
<
QtPrintSupport
/
QPrintEngine
>
26
#
include
<
QtPrintSupport
/
QPrinter
>
27
#
include
<
private
/
qpaintengine_alpha_p
.
h
>
28
#
include
<
private
/
qprintdevice_p
.
h
>
29
#
include
<
QtCore
/
qt_windows
.
h
>
30
31
QT_BEGIN_NAMESPACE
32
33
class
QWin32PrintEnginePrivate;
34
class
QPrinterPrivate;
35
class
QPainterState;
36
37
class
Q_PRINTSUPPORT_EXPORT
QWin32PrintEngine
:
public
QAlphaPaintEngine,
public
QPrintEngine
38
{
39
Q_DECLARE_PRIVATE(QWin32PrintEngine)
40
public
:
41
QWin32PrintEngine(QPrinter::PrinterMode mode,
const
QString &deviceId);
42
43
// override QWin32PaintEngine
44
bool
begin(QPaintDevice *dev) override;
45
bool
end() override;
46
47
void
updateState(
const
QPaintEngineState &state) override;
48
49
void
updateMatrix(
const
QTransform &matrix);
50
void
updateClipPath(
const
QPainterPath &clip, Qt::ClipOperation op);
51
52
void
drawPath(
const
QPainterPath &path) override;
53
void
drawPolygon(
const
QPointF *points,
int
pointCount, PolygonDrawMode mode) override;
54
void
drawTextItem(
const
QPointF &p,
const
QTextItem &textItem) override;
55
56
void
drawPixmap(
const
QRectF &r,
const
QPixmap &pm,
const
QRectF &sr) override;
57
void
drawTiledPixmap(
const
QRectF &r,
const
QPixmap &pm,
const
QPointF &p) override;
58
void
setProperty(PrintEnginePropertyKey key,
const
QVariant &value) override;
59
QVariant property(PrintEnginePropertyKey key)
const
override;
60
61
bool
newPage() override;
62
bool
abort() override;
63
int
metric(QPaintDevice::PaintDeviceMetric)
const
override;
64
65
QPrinter::PrinterState printerState()
const
override;
66
67
QPaintEngine::Type type()
const
override {
return
Windows; }
68
69
HDC getDC()
const
;
70
void
releaseDC(HDC)
const
;
71
72
/* Used by print/page setup dialogs */
73
void
setGlobalDevMode(HGLOBAL globalDevNames, HGLOBAL globalDevMode);
74
HGLOBAL *createGlobalDevNames();
75
HGLOBAL globalDevMode();
76
77
private
:
78
friend
class
QPrintDialog;
79
friend
class
QPageSetupDialog;
80
};
81
82
class
QWin32PrintEnginePrivate
:
public
QAlphaPaintEnginePrivate
83
{
84
Q_DECLARE_PUBLIC(QWin32PrintEngine)
85
public
:
86
QWin32PrintEnginePrivate
() :
87
printToFile
(
false
),
reinit
(
false
),
88
complex_xform
(
false
),
has_pen
(
false
),
has_brush
(
false
),
has_custom_paper_size
(
false
),
89
embed_fonts
(
true
)
90
{
91
}
92
93
~
QWin32PrintEnginePrivate
();
94
95
96
/* Initializes the printer data based on the current printer name. This
97
function creates a DEVMODE struct, HDC and a printer handle. If these
98
structures are already in use, they are freed using release
99
*/
100
void
initialize
();
101
102
/* Initializes data in the print engine whenever the HDC has been renewed
103
*/
104
void
initHDC
();
105
106
/* Releases all the handles the printer currently holds, HDC, DEVMODE,
107
etc and resets the corresponding members to 0. */
108
void
release
();
109
110
/* Resets the DC with changes in devmode. If the printer is active
111
this function only sets the reinit variable to true so it
112
is handled in the next begin or newpage. */
113
void
doReinit
();
114
115
static
void
initializeDevMode
(DEVMODE *);
116
117
bool
resetDC
();
118
119
void
strokePath
(
const
QPainterPath &path,
const
QColor &color);
120
void
fillPath
(
const
QPainterPath &path,
const
QColor &color);
121
122
void
composeGdiPath
(
const
QPainterPath &path);
123
void
fillPath_dev
(
const
QPainterPath &path,
const
QColor &color);
124
void
strokePath_dev
(
const
QPainterPath &path,
const
QColor &color, qreal width);
125
126
void
setPageSize
(
const
QPageSize &pageSize);
127
void
updatePageLayout
();
128
void
updateMetrics
();
129
void
debugMetrics
()
const
;
130
131
// Windows GDI printer references.
132
HANDLE
hPrinter
=
nullptr
;
133
134
HGLOBAL
globalDevMode
=
nullptr
;
135
DEVMODE
*
devMode
=
nullptr
;
136
PRINTER_INFO_2
*
pInfo
=
nullptr
;
137
HGLOBAL
hMem
=
nullptr
;
138
139
HDC
hdc
=
nullptr
;
140
141
// True if devMode was allocated separately from pInfo.
142
bool
ownsDevMode
=
false
;
143
144
QPrinter
::
PrinterMode
mode
=
QPrinter
::
ScreenResolution
;
145
146
// Print Device
147
QPrintDevice
m_printDevice
;
148
149
// Document info
150
QString
docName
;
151
QString
m_creator
;
152
QString
fileName
;
153
154
QPrinter
::
PrinterState
state
=
QPrinter
::
Idle
;
155
int
resolution
= 0;
156
157
// Page Layout
158
QPageLayout
m_pageLayout
{
QPageSize
(
QPageSize
::
A4
),
159
QPageLayout
::
Portrait
,
QMarginsF
{0, 0, 0, 0}};
160
// Page metrics cache
161
QRect
m_paintRectPixels
;
162
QSize
m_paintSizeMM
;
163
164
// Windows painting
165
qreal
stretch_x
= 1;
166
qreal
stretch_y
= 1;
167
int
origin_x
= 0;
168
int
origin_y
= 0;
169
170
int
dpi_x
= 96;
171
int
dpi_y
= 96;
172
int
dpi_display
= 96;
173
int
num_copies
= 1;
174
175
uint
printToFile
: 1;
176
uint
reinit
: 1;
177
178
uint
complex_xform
: 1;
179
uint
has_pen
: 1;
180
uint
has_brush
: 1;
181
uint
has_custom_paper_size
: 1;
182
uint
embed_fonts
: 1;
183
184
uint
txop
= 0;
// QTransform::TxNone
185
186
QColor
brush_color
;
187
QPen
pen
;
188
QColor
pen_color
;
189
QSizeF
paper_size
;
// In points
190
191
QTransform
painterMatrix
;
192
QTransform
matrix
;
193
};
194
195
QT_END_NAMESPACE
196
197
#
endif
// QT_NO_PRINTER
198
199
#
endif
// QPRINTENGINE_WIN_P_H
QWin32PrintEnginePrivate
Definition
qprintengine_win_p.h:83
QWin32PrintEnginePrivate::state
QPrinter::PrinterState state
Definition
qprintengine_win_p.h:154
QWin32PrintEnginePrivate::fillPath_dev
void fillPath_dev(const QPainterPath &path, const QColor &color)
Definition
qprintengine_win.cpp:698
QWin32PrintEnginePrivate::doReinit
void doReinit()
Definition
qprintengine_win.cpp:992
QWin32PrintEnginePrivate::fileName
QString fileName
Definition
qprintengine_win_p.h:152
QWin32PrintEnginePrivate::m_paintSizeMM
QSize m_paintSizeMM
Definition
qprintengine_win_p.h:162
QWin32PrintEnginePrivate::strokePath_dev
void strokePath_dev(const QPainterPath &path, const QColor &color, qreal width)
Definition
qprintengine_win.cpp:712
QWin32PrintEnginePrivate::stretch_y
qreal stretch_y
Definition
qprintengine_win_p.h:166
QWin32PrintEnginePrivate::composeGdiPath
void composeGdiPath(const QPainterPath &path)
Definition
qprintengine_win.cpp:650
QWin32PrintEnginePrivate::m_paintRectPixels
QRect m_paintRectPixels
Definition
qprintengine_win_p.h:161
QWin32PrintEnginePrivate::pen
QPen pen
Definition
qprintengine_win_p.h:187
QWin32PrintEnginePrivate::m_printDevice
QPrintDevice m_printDevice
Definition
qprintengine_win_p.h:147
QWin32PrintEnginePrivate::debugMetrics
void debugMetrics() const
Definition
qprintengine_win.cpp:1734
QWin32PrintEnginePrivate::num_copies
int num_copies
Definition
qprintengine_win_p.h:173
QWin32PrintEnginePrivate::pInfo
PRINTER_INFO_2 * pInfo
Definition
qprintengine_win_p.h:136
QWin32PrintEnginePrivate::printToFile
uint printToFile
Definition
qprintengine_win_p.h:175
QWin32PrintEnginePrivate::has_brush
uint has_brush
Definition
qprintengine_win_p.h:180
QWin32PrintEnginePrivate::dpi_x
int dpi_x
Definition
qprintengine_win_p.h:170
QWin32PrintEnginePrivate::txop
uint txop
Definition
qprintengine_win_p.h:184
QWin32PrintEnginePrivate::ownsDevMode
bool ownsDevMode
Definition
qprintengine_win_p.h:142
QWin32PrintEnginePrivate::initHDC
void initHDC()
Definition
qprintengine_win.cpp:933
QWin32PrintEnginePrivate::has_pen
uint has_pen
Definition
qprintengine_win_p.h:179
QWin32PrintEnginePrivate::dpi_display
int dpi_display
Definition
qprintengine_win_p.h:172
QWin32PrintEnginePrivate::painterMatrix
QTransform painterMatrix
Definition
qprintengine_win_p.h:191
QWin32PrintEnginePrivate::matrix
QTransform matrix
Definition
qprintengine_win_p.h:192
QWin32PrintEnginePrivate::devMode
DEVMODE * devMode
Definition
qprintengine_win_p.h:135
QWin32PrintEnginePrivate::hPrinter
HANDLE hPrinter
Definition
qprintengine_win_p.h:132
QWin32PrintEnginePrivate::dpi_y
int dpi_y
Definition
qprintengine_win_p.h:171
QWin32PrintEnginePrivate::hdc
HDC hdc
Definition
qprintengine_win_p.h:139
QWin32PrintEnginePrivate::has_custom_paper_size
uint has_custom_paper_size
Definition
qprintengine_win_p.h:181
QWin32PrintEnginePrivate::stretch_x
qreal stretch_x
Definition
qprintengine_win_p.h:165
QWin32PrintEnginePrivate::strokePath
void strokePath(const QPainterPath &path, const QColor &color)
Definition
qprintengine_win.cpp:744
QWin32PrintEnginePrivate::release
void release()
Definition
qprintengine_win.cpp:967
QWin32PrintEnginePrivate::reinit
uint reinit
Definition
qprintengine_win_p.h:176
QWin32PrintEnginePrivate::embed_fonts
uint embed_fonts
Definition
qprintengine_win_p.h:182
QWin32PrintEnginePrivate::resetDC
bool resetDC()
Definition
qprintengine_win.cpp:1003
QWin32PrintEnginePrivate::complex_xform
uint complex_xform
Definition
qprintengine_win_p.h:178
QWin32PrintEnginePrivate::origin_y
int origin_y
Definition
qprintengine_win_p.h:168
QWin32PrintEnginePrivate::docName
QString docName
Definition
qprintengine_win_p.h:150
QWin32PrintEnginePrivate::brush_color
QColor brush_color
Definition
qprintengine_win_p.h:186
QWin32PrintEnginePrivate::initializeDevMode
static void initializeDevMode(DEVMODE *)
Definition
qprintengine_win.cpp:926
QWin32PrintEnginePrivate::updateMetrics
void updateMetrics()
Definition
qprintengine_win.cpp:1703
QWin32PrintEnginePrivate::paper_size
QSizeF paper_size
Definition
qprintengine_win_p.h:189
QWin32PrintEnginePrivate::globalDevMode
HGLOBAL globalDevMode
Definition
qprintengine_win_p.h:134
QWin32PrintEnginePrivate::setPageSize
void setPageSize(const QPageSize &pageSize)
Definition
qprintengine_win.cpp:1626
QWin32PrintEnginePrivate::resolution
int resolution
Definition
qprintengine_win_p.h:155
QWin32PrintEnginePrivate::initialize
void initialize()
Definition
qprintengine_win.cpp:836
QWin32PrintEnginePrivate::updatePageLayout
void updatePageLayout()
Definition
qprintengine_win.cpp:1660
QWin32PrintEnginePrivate::m_creator
QString m_creator
Definition
qprintengine_win_p.h:151
QWin32PrintEnginePrivate::fillPath
void fillPath(const QPainterPath &path, const QColor &color)
Definition
qprintengine_win.cpp:739
QWin32PrintEnginePrivate::hMem
HGLOBAL hMem
Definition
qprintengine_win_p.h:137
QWin32PrintEnginePrivate::m_pageLayout
QPageLayout m_pageLayout
Definition
qprintengine_win_p.h:158
QWin32PrintEnginePrivate::origin_x
int origin_x
Definition
qprintengine_win_p.h:167
QWin32PrintEnginePrivate::pen_color
QColor pen_color
Definition
qprintengine_win_p.h:188
QWin32PrintEnginePrivate::mode
QPrinter::PrinterMode mode
Definition
qprintengine_win_p.h:144
QWin32PrintEngine
Definition
qprintengine_win_p.h:38
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
std
[33]
Definition
src_corelib_tools_qhash.cpp:421
qt_convertMargins
QMarginsF qt_convertMargins(const QMarginsF &margins, QPageLayout::Unit fromUnits, QPageLayout::Unit toUnits)
Definition
qpagelayout.cpp:43
HBitmapFormat
HBitmapFormat
Definition
qpixmap_win.cpp:192
HBitmapPremultipliedAlpha
@ HBitmapPremultipliedAlpha
Definition
qpixmap_win.cpp:194
HBitmapNoAlpha
@ HBitmapNoAlpha
Definition
qpixmap_win.cpp:193
HBitmapAlpha
@ HBitmapAlpha
Definition
qpixmap_win.cpp:195
draw_text_item_win
static void draw_text_item_win(const QPointF &_pos, const QTextItemInt &ti, HDC hdc, const QTransform &xform, const QPointF &topLeft)
Definition
qprintengine_win.cpp:1746
indexOfWindowsId
static int indexOfWindowsId(const QList< QPrint::InputSlot > &inputSlots, int windowsId)
Definition
qprintengine_win.cpp:1027
qt_regionToPath
QT_BEGIN_NAMESPACE QPainterPath qt_regionToPath(const QRegion ®ion)
Definition
qregion.cpp:1011
msgBeginFailed
static QByteArray msgBeginFailed(const char *function, const DOCINFO &d)
Definition
qprintengine_win.cpp:65
indexOfId
static int indexOfId(const QList< QPrint::InputSlot > &inputSlots, QPrint::InputSlotId id)
Definition
qprintengine_win.cpp:1018
qtbase
src
printsupport
platform
windows
qprintengine_win_p.h
Generated on
for Qt by
1.18.0