#include <qpaintdevice.h>
Inheritance diagram for QPaintDevice:

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.
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 vertical resolution differ, the corresponding QPaintEngine must handle the mapping. Finally, the numColors() function returns the number of different colors available for the paint device.
Definition at line 40 of file qpaintdevice.h.
Public Types | |
| enum | PaintDeviceMetric |
Public Member Functions | |
| virtual | ~QPaintDevice () |
| virtual int | devType () const |
| bool | paintingActive () const |
| virtual QPaintEngine * | paintEngine () const=0 |
| int | width () const |
| int | height () const |
| int | widthMM () const |
| int | heightMM () const |
| int | logicalDpiX () const |
| int | logicalDpiY () const |
| int | physicalDpiX () const |
| int | physicalDpiY () const |
| int | numColors () const |
| int | depth () const |
Protected Member Functions | |
| QPaintDevice () | |
| virtual int | metric (PaintDeviceMetric metric) const |
Protected Attributes | |
| ushort | painters |
Friends | |
| class | QPainter |
| class | QFontEngineMac |
| class | QX11PaintEngine |
Related Functions | |
| (Note that these are not member functions.) | |
| const Q_GUI_EXPORT QX11Info * | qt_x11Info (const QPaintDevice *pd) |
Describes the various metrics of a paint device.
PdmWidth The width of the paint device in default coordinate system units (e.g. pixels for QPixmap and QWidget). See also width().
PdmHeight The height of the paint device in default coordinate system units (e.g. pixels for QPixmap and QWidget). See also height().
PdmWidthMM The width of the paint device in millimeters. See also widthMM().
PdmHeightMM The height of the paint device in millimeters. See also heightMM().
PdmNumColors The number of different colors available for the paint device. See also numColors().
PdmDepth The bit depth (number of bit planes) of the paint device. See also depth().
PdmDpiX The horizontal resolution of the device in dots per inch. See also logicalDpiX().
PdmDpiY The vertical resolution of the device in dots per inch. See also logicalDpiY().
PdmPhysicalDpiX The horizontal resolution of the device in dots per inch. See also physicalDpiX().
PdmPhysicalDpiY The vertical resolution of the device in dots per inch. See also physicalDpiY().
Definition at line 43 of file qpaintdevice.h.
00043 { 00044 PdmWidth = 1, 00045 PdmHeight, 00046 PdmWidthMM, 00047 PdmHeightMM, 00048 PdmNumColors, 00049 PdmDepth, 00050 PdmDpiX, 00051 PdmDpiY, 00052 PdmPhysicalDpiX, 00053 PdmPhysicalDpiY 00054 };
| QPaintDevice::~QPaintDevice | ( | ) | [virtual] |
Destroys the paint device and frees window system resources.
Definition at line 138 of file qpaintdevice_x11.cpp.
References paintingActive(), qt_painter_removePaintDevice(), and qWarning().
00139 { 00140 if (paintingActive()) 00141 qWarning("QPaintDevice: Cannot destroy paint device that is being " 00142 "painted"); 00143 extern void qt_painter_removePaintDevice(QPaintDevice *); //qpainter.cpp 00144 qt_painter_removePaintDevice(this); 00145 }
Here is the call graph for this function:

| QPaintDevice::QPaintDevice | ( | ) | [protected] |
Constructs a paint device. This constructor can be invoked only from subclasses of QPaintDevice.
Definition at line 129 of file qpaintdevice_x11.cpp.
References painters.
00130 { 00131 painters = 0; 00132 }
| int QPaintDevice::devType | ( | ) | const [inline, virtual] |
Definition at line 143 of file qpaintdevice.h.
References QInternal::UnknownDevice.
Referenced by QPainter::begin(), QX11PaintEngine::begin(), QRasterPaintEngine::begin(), QX11Info::cloneX11Data(), QX11Info::copyX11Data(), QRasterPaintEngine::flush(), QFont::QFont(), qt_x11Handle(), qt_x11Info(), and QGLDrawable::setDevice().
00144 { return QInternal::UnknownDevice; }
| bool QPaintDevice::paintingActive | ( | ) | const [inline] |
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.
Definition at line 146 of file qpaintdevice.h.
References painters.
Referenced by QPixmap::operator=(), QPixmap::QPixmap(), QWidget::repaint(), Q3Picture::save(), QPicture::save(), QPixmap::setAlphaChannel(), QPixmap::setMask(), ~QPaintDevice(), and QWidget::~QWidget().
00147 { return painters != 0; }
| QPaintEngine * QPaintDevice::paintEngine | ( | ) | const [pure virtual] |
Returns a pointer to the paint engine used for drawing on the device.
Referenced by QWidgetPrivate::drawWidget().
| int QPaintDevice::width | ( | ) | const [inline] |
Returns the width of the paint device in default coordinate system units (e.g. pixels for QPixmap and QWidget).
Definition at line 71 of file qpaintdevice.h.
Referenced by QSvgTinyDocument::adjustWindowBounds(), QX11PaintEngine::begin(), QRasterPaintEngine::begin(), QPainterPrivate::draw_helper(), drawFrameDecoration(), QPainterPrivate::drawStretchToDevice(), QTreeView::drawTree(), QTextDocument::print(), PrintOut::PrintOut(), QGraphicsView::render(), and QGraphicsScene::render().
| int QPaintDevice::height | ( | ) | const [inline] |
Returns the height of the paint device in default coordinate system units (e.g. pixels for QPixmap and QWidget).
Definition at line 72 of file qpaintdevice.h.
Referenced by QSvgTinyDocument::adjustWindowBounds(), QX11PaintEngine::begin(), QRasterPaintEngine::begin(), QPainterPrivate::draw_helper(), drawFrameDecoration(), QPainterPrivate::drawStretchToDevice(), QTextDocument::print(), PrintOut::PrintOut(), QGraphicsView::render(), and QGraphicsScene::render().
| int QPaintDevice::widthMM | ( | ) | const [inline] |
Returns the width of the paint device in millimeters.
Definition at line 73 of file qpaintdevice.h.
Referenced by PrintOut::PrintOut().
00073 { return metric(PdmWidthMM); }
| int QPaintDevice::heightMM | ( | ) | const [inline] |
Returns the height of the paint device in millimeters.
Definition at line 74 of file qpaintdevice.h.
Referenced by PrintOut::PrintOut().
00074 { return metric(PdmHeightMM); }
| int QPaintDevice::logicalDpiX | ( | ) | const [inline] |
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(), but it varies on Windows.
Note that if the logicalDpiX() doesn't equal the physicalDpiX(), the corresponding QPaintEngine must handle the resolution mapping.
Definition at line 75 of file qpaintdevice.h.
Referenced by QPicture::exec(), Q3SVGPaintEnginePrivate::parseLen(), QTextDocument::print(), and PrintPreview::setup().
| int QPaintDevice::logicalDpiY | ( | ) | const [inline] |
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(), but it varies on Windows.
Note that if the logicalDpiY() doesn't equal the physicalDpiY(), the corresponding QPaintEngine must handle the resolution mapping.
Definition at line 76 of file qpaintdevice.h.
Referenced by QPicture::exec(), generateWavyPath(), getPixmapSize(), inchesToPixels(), QTextDocument::print(), QFont::QFont(), QFontMetrics::QFontMetrics(), QFontMetricsF::QFontMetricsF(), and PrintPreview::setup().
| int QPaintDevice::physicalDpiX | ( | ) | const [inline] |
Returns the horizontal resolution of the device in dots per inch.
Note that if the physicalDpiX() doesn't equal the logicalDpiX(), the corresponding QPaintEngine must handle the resolution mapping.
Definition at line 77 of file qpaintdevice.h.
00077 { return metric(PdmPhysicalDpiX); }
| int QPaintDevice::physicalDpiY | ( | ) | const [inline] |
Returns the horizontal resolution of the device in dots per inch.
Note that if the physicalDpiY() doesn't equal the logicalDpiY(), the corresponding QPaintEngine must handle the resolution mapping.
Definition at line 78 of file qpaintdevice.h.
00078 { return metric(PdmPhysicalDpiY); }
| int QPaintDevice::numColors | ( | ) | const [inline] |
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.
Definition at line 79 of file qpaintdevice.h.
00079 { return metric(PdmNumColors); }
| int QPaintDevice::depth | ( | ) | const [inline] |
Returns the bit depth (number of bit planes) of the paint device.
Definition at line 80 of file qpaintdevice.h.
Referenced by QRasterPaintEngine::begin(), qdesigner_internal::FormWindow::containerAt(), and HelpDialog::insertContents().
| int QPaintDevice::metric | ( | PaintDeviceMetric | metric | ) | const [protected, virtual] |
Returns the metric information for the given paint device metric.
Definition at line 216 of file qpaintdevice_x11.cpp.
References qWarning().
00217 { 00218 qWarning("QPaintDevice::metrics: Device has no metric information"); 00219 return 0; 00220 }
Here is the call graph for this function:

friend class QPainter [friend] |
Definition at line 117 of file qpaintdevice.h.
friend class QFontEngineMac [friend] |
Definition at line 118 of file qpaintdevice.h.
friend class QX11PaintEngine [friend] |
Definition at line 119 of file qpaintdevice.h.
| const Q_GUI_EXPORT QX11Info * qt_x11Info | ( | const QPaintDevice * | pd | ) | [related] |
Returns the QX11Info structure for the pd paint device. 0 is returned if it can't be obtained.
Definition at line 198 of file qpaintdevice_x11.cpp.
References devType(), QInternal::Pixmap, and QInternal::Widget.
00199 { 00200 if (!pd) return 0; 00201 if (pd->devType() == QInternal::Widget) 00202 return &static_cast<const QWidget *>(pd)->x11Info(); 00203 else if (pd->devType() == QInternal::Pixmap) 00204 return &static_cast<const QPixmap *>(pd)->x11Info(); 00205 return 0; 00206 }
Here is the call graph for this function:

ushort QPaintDevice::painters [protected] |
1.5.1