Qt 4.8
qpaintdevice.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QPAINTDEVICE_H
43 #define QPAINTDEVICE_H
44 
45 #include <QtGui/qwindowdefs.h>
46 #include <QtCore/qrect.h>
47 
49 
51 
52 QT_MODULE(Gui)
53 
54 #if defined(Q_WS_QWS)
55 class QWSDisplay;
56 #endif
57 
58 class QPaintEngine;
59 
60 class Q_GUI_EXPORT QPaintDevice // device for QPainter
61 {
62 public:
64  PdmWidth = 1,
73  PdmPhysicalDpiY
74  };
75 
76  virtual ~QPaintDevice();
77 
78  virtual int devType() const;
79  bool paintingActive() const;
80  virtual QPaintEngine *paintEngine() const = 0;
81 
82 #if defined(Q_WS_QWS)
83  static QWSDisplay *qwsDisplay();
84 #endif
85 
86 #ifdef Q_WS_WIN
87  virtual HDC getDC() const;
88  virtual void releaseDC(HDC hdc) const;
89 #endif
90 
91  int width() const { return metric(PdmWidth); }
92  int height() const { return metric(PdmHeight); }
93  int widthMM() const { return metric(PdmWidthMM); }
94  int heightMM() const { return metric(PdmHeightMM); }
95  int logicalDpiX() const { return metric(PdmDpiX); }
96  int logicalDpiY() const { return metric(PdmDpiY); }
97  int physicalDpiX() const { return metric(PdmPhysicalDpiX); }
98  int physicalDpiY() const { return metric(PdmPhysicalDpiY); }
99 #ifdef QT_DEPRECATED
100  QT_DEPRECATED int numColors() const { return metric(PdmNumColors); }
101 #endif
102  int colorCount() const { return metric(PdmNumColors); }
103  int depth() const { return metric(PdmDepth); }
104 
105 protected:
106  QPaintDevice();
107  virtual int metric(PaintDeviceMetric metric) const;
108 
109  ushort painters; // refcount
110 
111 private:
113 
114 #if defined(Q_WS_X11) && defined(QT3_SUPPORT)
115 public:
116  QT3_SUPPORT Display *x11Display() const;
117  QT3_SUPPORT int x11Screen() const;
118  QT3_SUPPORT int x11Depth() const;
119  QT3_SUPPORT int x11Cells() const;
120  QT3_SUPPORT Qt::HANDLE x11Colormap() const;
121  QT3_SUPPORT bool x11DefaultColormap() const;
122  QT3_SUPPORT void *x11Visual() const;
123  QT3_SUPPORT bool x11DefaultVisual() const;
124 
125  static QT3_SUPPORT Display *x11AppDisplay();
126  static QT3_SUPPORT int x11AppScreen();
127  static QT3_SUPPORT int x11AppDepth(int screen = -1);
128  static QT3_SUPPORT int x11AppCells(int screen = -1);
129  static QT3_SUPPORT Qt::HANDLE x11AppRootWindow(int screen = -1);
130  static QT3_SUPPORT Qt::HANDLE x11AppColormap(int screen = -1);
131  static QT3_SUPPORT void *x11AppVisual(int screen = -1);
132  static QT3_SUPPORT bool x11AppDefaultColormap(int screen =-1);
133  static QT3_SUPPORT bool x11AppDefaultVisual(int screen =-1);
134  static QT3_SUPPORT int x11AppDpiX(int screen = -1);
135  static QT3_SUPPORT int x11AppDpiY(int screen = -1);
136  static QT3_SUPPORT void x11SetAppDpiX(int, int);
137  static QT3_SUPPORT void x11SetAppDpiY(int, int);
138 #endif
139 
140  friend class QPainter;
141  friend class QFontEngineMac;
142  friend class QX11PaintEngine;
143  friend Q_GUI_EXPORT int qt_paint_device_metric(const QPaintDevice *device, PaintDeviceMetric metric);
144 };
145 
146 #ifdef QT3_SUPPORT
147 QT3_SUPPORT Q_GUI_EXPORT
148 void bitBlt(QPaintDevice *dst, int dx, int dy,
149  const QPaintDevice *src, int sx=0, int sy=0, int sw=-1, int sh=-1,
150  bool ignoreMask=false);
151 
152 QT3_SUPPORT Q_GUI_EXPORT
153 void bitBlt(QPaintDevice *dst, int dx, int dy,
154  const QImage *src, int sx=0, int sy=0, int sw=-1, int sh=-1,
155  int conversion_flags=0);
156 
157 QT3_SUPPORT Q_GUI_EXPORT
158 void bitBlt(QPaintDevice *dst, const QPoint &dp,
159  const QPaintDevice *src, const QRect &sr=QRect(0,0,-1,-1),
160  bool ignoreMask=false);
161 #endif
162 
163 /*****************************************************************************
164  Inline functions
165  *****************************************************************************/
166 
167 inline int QPaintDevice::devType() const
168 { return QInternal::UnknownDevice; }
169 
170 inline bool QPaintDevice::paintingActive() const
171 { return painters != 0; }
172 
174 
176 
177 #endif // QPAINTDEVICE_H
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
The QWSDisplay class provides a display for QWS; it is an internal class.
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
ushort painters
Definition: qpaintdevice.h:109
#define QT_MODULE(x)
Definition: qglobal.h:2783
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
int logicalDpiY() const
Definition: qpaintdevice.h:96
#define Q_GUI_EXPORT
Definition: qglobal.h:1450
int height() const
Definition: qpaintdevice.h:92
#define Q_DISABLE_COPY(Class)
Disables the use of copy constructors and assignment operators for the given Class.
Definition: qglobal.h:2523
virtual int devType() const
Definition: qpaintdevice.h:167
bool paintingActive() const
Definition: qpaintdevice.h:170
int colorCount() const
Definition: qpaintdevice.h:102
int logicalDpiX() const
Definition: qpaintdevice.h:95
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
int width() const
Definition: qpaintdevice.h:91
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
void * HANDLE
Definition: qnamespace.h:1671
The QPaintEngine class provides an abstract definition of how QPainter draws to a given device on a g...
Definition: qpaintengine.h:90
QT_DEPRECATED int numColors() const
Definition: qpaintdevice.h:100
int physicalDpiX() const
Definition: qpaintdevice.h:97
struct _XDisplay Display
Definition: qwindowdefs.h:115
unsigned short ushort
Definition: qglobal.h:995
int physicalDpiY() const
Definition: qpaintdevice.h:98
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
int depth() const
Definition: qpaintdevice.h:103
#define QT_DEPRECATED
Definition: qglobal.h:1094
#define QT_END_HEADER
Definition: qglobal.h:137
int heightMM() const
Definition: qpaintdevice.h:94
int widthMM() const
Definition: qpaintdevice.h:93
Q_GUI_EXPORT int qt_paint_device_metric(const QPaintDevice *device, QPaintDevice::PaintDeviceMetric metric)