| [556] | 1 | /****************************************************************************
|
|---|
| 2 | **
|
|---|
| 3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|---|
| 4 | ** All rights reserved.
|
|---|
| 5 | ** Contact: Nokia Corporation ([email protected])
|
|---|
| 6 | **
|
|---|
| 7 | ** This file is part of the documentation of the Qt Toolkit.
|
|---|
| 8 | **
|
|---|
| 9 | ** $QT_BEGIN_LICENSE:LGPL$
|
|---|
| 10 | ** Commercial Usage
|
|---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
|---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the
|
|---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in
|
|---|
| 14 | ** a written agreement between you and Nokia.
|
|---|
| 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 | ** GNU General Public License Usage
|
|---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
|---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
|---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
|---|
| 32 | ** packaging of this file. Please review the following information to
|
|---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
|---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
|---|
| 35 | **
|
|---|
| 36 | ** If you have questions regarding the use of this file, please contact
|
|---|
| 37 | ** Nokia at [email protected].
|
|---|
| 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
|
|---|
| 85 | the logical and physical resolution differ, the corresponding
|
|---|
| 86 | QPaintEngine must handle the mapping. Finally, the colorCount()
|
|---|
| 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
|
|---|
| 114 | the paint device. See also colorCount().
|
|---|
| 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 |
|
|---|
| |
|---|