1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
|
/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** Commercial Usage
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in a
** written agreement between you and Nokia.
**
** GNU Free Documentation License
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of this
** file.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
** $QT_END_LICENSE$
**
****************************************************************************/
/*!
\class QPaintDevice
\brief The QPaintDevice class is the base class of objects that
can be painted.
\ingroup painting
A paint device is an abstraction of a two-dimensional space that
can be drawn using a QPainter. Its default coordinate system has
its origin located at the top-left position. X increases to the
right and Y increases downwards. The unit is one pixel.
The drawing capabilities of QPaintDevice are currently implemented
by the QWidget, QImage, QPixmap, QGLPixelBuffer, QPicture, and
QPrinter subclasses.
To implement support for a new backend, you must derive from
QPaintDevice and reimplement the virtual paintEngine() function to
tell QPainter which paint engine should be used to draw on this
particular device. Note that you also must create a corresponding
paint engine to be able to draw on the device, i.e derive from
QPaintEngine and reimplement its virtual functions.
\warning Qt requires that a QApplication object exists before
any paint devices can be created. Paint devices access window
system resources, and these resources are not initialized before
an application object is created.
The QPaintDevice class provides several functions returning the
various device metrics: The depth() function returns its bit depth
(number of bit planes). The height() function returns its height
in default coordinate system units (e.g. pixels for QPixmap and
QWidget) while heightMM() returns the height of the device in
millimeters. Similiarily, the width() and widthMM() functions
return the width of the device in default coordinate system units
and in millimeters, respectively. Alternatively, the protected
metric() function can be used to retrieve the metric information
by specifying the desired PaintDeviceMetric as argument.
The logicalDpiX() and logicalDpiY() functions return the
horizontal and vertical resolution of the device in dots per
inch. The physicalDpiX() and physicalDpiY() functions also return
the resolution of the device in dots per inch, but note that if
the logical and physical resolution differ, the corresponding
QPaintEngine must handle the mapping. Finally, the colorCount()
function returns the number of different colors available for the
paint device.
\sa QPaintEngine, QPainter, {Coordinate System}, {Paint System}
*/
/*!
\enum QPaintDevice::PaintDeviceMetric
Describes the various metrics of a paint device.
\value PdmWidth The width of the paint device in default
coordinate system units (e.g. pixels for QPixmap and QWidget). See
also width().
\value PdmHeight The height of the paint device in default
coordinate system units (e.g. pixels for QPixmap and QWidget). See
also height().
\value PdmWidthMM The width of the paint device in millimeters. See
also widthMM().
\value PdmHeightMM The height of the paint device in millimeters. See
also heightMM().
\value PdmNumColors The number of different colors available for
the paint device. See also colorCount().
\value PdmDepth The bit depth (number of bit planes) of the paint
device. See also depth().
\value PdmDpiX The horizontal resolution of the device in dots per
inch. See also logicalDpiX().
\value PdmDpiY The vertical resolution of the device in dots per inch. See
also logicalDpiY().
\value PdmPhysicalDpiX The horizontal resolution of the device in
dots per inch. See also physicalDpiX().
\value PdmPhysicalDpiY The vertical resolution of the device in
dots per inch. See also physicalDpiY().
\sa metric()
*/
/*!
\fn QPaintDevice::QPaintDevice()
Constructs a paint device. This constructor can be invoked only from
subclasses of QPaintDevice.
*/
/*!
\fn QPaintDevice::~QPaintDevice()
Destroys the paint device and frees window system resources.
*/
/*!
\fn int QPaintDevice::devType() const
\internal
Returns the device type identifier, which is QInternal::Widget
if the device is a QWidget, QInternal::Pixmap if it's a
QPixmap, QInternal::Printer if it's a QPrinter,
QInternal::Picture if it's a QPicture, or
QInternal::UnknownDevice in other cases.
*/
/*!
\fn bool QPaintDevice::paintingActive() const
Returns true if the device is currently being painted on, i.e. someone has
called QPainter::begin() but not yet called QPainter::end() for
this device; otherwise returns false.
\sa QPainter::isActive()
*/
/*!
\fn QPaintEngine *QPaintDevice::paintEngine() const
Returns a pointer to the paint engine used for drawing on the
device.
*/
/*!
\fn int QPaintDevice::metric(PaintDeviceMetric metric) const
Returns the metric information for the given paint device \a metric.
\sa PaintDeviceMetric
*/
/*!
\fn int QPaintDevice::width() const
Returns the width of the paint device in default coordinate system
units (e.g. pixels for QPixmap and QWidget).
\sa widthMM()
*/
/*!
\fn int QPaintDevice::height() const
Returns the height of the paint device in default coordinate
system units (e.g. pixels for QPixmap and QWidget).
\sa heightMM()
*/
/*!
\fn int QPaintDevice::widthMM() const
Returns the width of the paint device in millimeters. Due to platform
limitations it may not be possible to use this function to determine
the actual physical size of a widget on the screen.
\sa width()
*/
/*!
\fn int QPaintDevice::heightMM() const
Returns the height of the paint device in millimeters. Due to platform
limitations it may not be possible to use this function to determine
the actual physical size of a widget on the screen.
\sa height()
*/
/*!
\fn int QPaintDevice::numColors() const
\deprecated
Use colorCount() instead.
Returns the number of different colors available for the paint
device. Since this value is an int, it will not be sufficient to
represent the number of colors on 32 bit displays, in this case
INT_MAX is returned instead.
*/
/*!
\fn int QPaintDevice::colorCount() const
Returns the number of different colors available for the paint
device. Since this value is an int, it will not be sufficient to
represent the number of colors on 32 bit displays, in this case
INT_MAX is returned instead.
*/
/*!
\fn int QPaintDevice::depth() const
Returns the bit depth (number of bit planes) of the paint device.
*/
/*!
\fn int QPaintDevice::logicalDpiX() const
Returns the horizontal resolution of the device in dots per inch,
which is used when computing font sizes. For X11, this is usually
the same as could be computed from widthMM().
Note that if the logicalDpiX() doesn't equal the physicalDpiX(),
the corresponding QPaintEngine must handle the resolution mapping.
\sa logicalDpiY(), physicalDpiX()
*/
/*!
\fn int QPaintDevice::logicalDpiY() const
Returns the vertical resolution of the device in dots per inch,
which is used when computing font sizes. For X11, this is usually
the same as could be computed from heightMM().
Note that if the logicalDpiY() doesn't equal the physicalDpiY(),
the corresponding QPaintEngine must handle the resolution mapping.
\sa logicalDpiX(), physicalDpiY()
*/
/*!
\fn int QPaintDevice::physicalDpiX() const
Returns the horizontal resolution of the device in dots per inch.
For example, when printing, this resolution refers to the physical
printer's resolution. The logical DPI on the other hand, refers to
the resolution used by the actual paint engine.
Note that if the physicalDpiX() doesn't equal the logicalDpiX(),
the corresponding QPaintEngine must handle the resolution mapping.
\sa physicalDpiY(), logicalDpiX()
*/
/*!
\fn int QPaintDevice::physicalDpiY() const
Returns the horizontal resolution of the device in dots per inch.
For example, when printing, this resolution refers to the physical
printer's resolution. The logical DPI on the other hand, refers to
the resolution used by the actual paint engine.
Note that if the physicalDpiY() doesn't equal the logicalDpiY(),
the corresponding QPaintEngine must handle the resolution mapping.
\sa physicalDpiX(), logicalDpiY()
*/
|