CopperSpice API
1.9.2
|
The QPaintDevice class is the base class of objects that can be painted. More...
Public Types | |
enum | PaintDeviceMetric |
Public Methods | |
virtual | ~QPaintDevice () |
int | colorCount () const |
int | depth () const |
int | devicePixelRatio () const |
qreal | devicePixelRatioF () const |
int | height () const |
int | heightMM () const |
int | logicalDpiX () const |
int | logicalDpiY () const |
virtual QPaintEngine * | paintEngine () const = 0 |
bool | paintingActive () const |
int | physicalDpiX () const |
int | physicalDpiY () const |
int | width () const |
int | widthMM () const |
Protected Methods | |
QPaintDevice () | |
virtual int | metric (PaintDeviceMetric metric) const |
Friends | |
class | QPainter |
The QPaintDevice class is the base class of objects that can be painted.
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.
CopperSpice 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. 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.
Describes the various metrics of a paint device.
Constant | Value | Description |
---|---|---|
QPaintDevice::PdmWidth | 1 | The width of the paint device in default coordinate system units (e.g. pixels for QPixmap and QWidget). Refer to width(). |
QPaintDevice::PdmHeight | 2 | The height of the paint device in default coordinate system units (e.g. pixels for QPixmap and QWidget). Refer to height(). |
QPaintDevice::PdmWidthMM | 3 | The width of the paint device in millimeters. Refer to widthMM(). |
QPaintDevice::PdmHeightMM | 4 | The height of the paint device in millimeters. Refer to heightMM(). |
QPaintDevice::PdmNumColors | 5 | The number of different colors available for the paint device. Refer to colorCount(). |
QPaintDevice::PdmDepth | 6 | The bit depth (number of bit planes) of the paint device. Refer to depth(). |
QPaintDevice::PdmDpiX | 7 | The horizontal resolution of the device in dots per inch. Refer to logicalDpiX(). |
QPaintDevice::PdmDpiY | 8 | The vertical resolution of the device in dots per inch. Refer to logicalDpiY(). |
QPaintDevice::PdmPhysicalDpiX | 9 | The horizontal resolution of the device in dots per inch. Refer to physicalDpiX(). |
QPaintDevice::PdmPhysicalDpiY | 10 | The vertical resolution of the device in dots per inch. Refer to physicalDpiY(). |
|
virtual |
Destroys the paint device and frees window system resources.
|
protected |
Constructs a paint device. This constructor can be invoked only from subclasses of QPaintDevice.
|
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.
|
inline |
Returns the bit depth (number of bit planes) of the paint device.
|
inline |
Returns the device pixel ratio for device. Common values are 1 for normal DPI displays and 2 for high DPI displays.
|
inline |
Returns the device pixel ratio for the device as a floating point number.
|
inline |
Returns the height of the paint device in default coordinate system units (e.g. pixels for QPixmap and QWidget).
|
inline |
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.
|
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().
If the logicalDpiX() does not equal the physicalDpiX() then the corresponding QPaintEngine must handle the resolution mapping.
|
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().
If the logicalDpiY() does not equal the physicalDpiY() then the corresponding QPaintEngine must handle the resolution mapping.
|
protectedvirtual |
Returns the metric information for the given paint device metric.
Reimplemented in QSvgGenerator::metric(), QOpenGLWidget::metric(), QOpenGLPaintDevice::metric(), QPrinter::metric(), QPixmap::metric(), QWidget::metric(), QImage::metric(), QGLFramebufferObject::metric(), QOpenGLWindow::metric(), QGLPixelBuffer::metric(), QPaintDeviceWindow::metric(), QRasterWindow::metric(), QPicture::metric(), QPdfWriter::metric()
|
pure virtual |
Returns a pointer to the paint engine used for drawing on the device.
Implemented in QWidget::paintEngine(), QGLWidget::paintEngine(), QImage::paintEngine(), QPrinter::paintEngine(), QPixmap::paintEngine(), QSvgGenerator::paintEngine(), QOpenGLWidget::paintEngine(), QPicture::paintEngine(), QPdfWriter::paintEngine(), QGLFramebufferObject::paintEngine(), QGLPixelBuffer::paintEngine(), QOpenGLPaintDevice::paintEngine()
|
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.
|
inline |
Returns the horizontal resolution of the device in dots per inch. For example, when printing the 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.
If the physicalDpiX() does not equal the logicalDpiX() then the corresponding QPaintEngine must handle the resolution mapping.
|
inline |
Returns the horizontal resolution of the device in dots per inch. For example, when printing the 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.
If the physicalDpiY() does not equal the logicalDpiY() then the corresponding QPaintEngine must handle the resolution mapping.
|
inline |
|
inline |
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.