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