source: trunk/src/gui/painting/qpaintdevice.h@ 478

Last change on this file since 478 was 2, checked in by Dmitry A. Kuminov, 16 years ago

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

File size: 5.7 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4** Contact: Qt Software Information (qt-info@nokia.com)
5**
6** This file is part of the QtGui module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial Usage
10** Licensees holding valid Qt Commercial licenses may use this file in
11** accordance with the Qt Commercial License Agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and Nokia.
14**
15** GNU Lesser General Public License Usage
16** Alternatively, this file may be used under the terms of the GNU Lesser
17** General Public License version 2.1 as published by the Free Software
18** Foundation and appearing in the file LICENSE.LGPL included in the
19** packaging of this file. Please review the following information to
20** ensure the GNU Lesser General Public License version 2.1 requirements
21** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
22**
23** In addition, as a special exception, Nokia gives you certain
24** additional rights. These rights are described in the Nokia Qt LGPL
25** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
26** 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 are unsure which license is appropriate for your use, please
37** contact the sales department at qt-sales@nokia.com.
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
48QT_BEGIN_HEADER
49
50QT_BEGIN_NAMESPACE
51
52QT_MODULE(Gui)
53
54#if defined(Q_WS_QWS)
55class QWSDisplay;
56#endif
57
58class QPaintEngine;
59
60class Q_GUI_EXPORT QPaintDevice // device for QPainter
61{
62public:
63 enum PaintDeviceMetric {
64 PdmWidth = 1,
65 PdmHeight,
66 PdmWidthMM,
67 PdmHeightMM,
68 PdmNumColors,
69 PdmDepth,
70 PdmDpiX,
71 PdmDpiY,
72 PdmPhysicalDpiX,
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 int numColors() const { return metric(PdmNumColors); }
100 int depth() const { return metric(PdmDepth); }
101
102protected:
103 QPaintDevice();
104 virtual int metric(PaintDeviceMetric metric) const;
105
106 ushort painters; // refcount
107
108private:
109 Q_DISABLE_COPY(QPaintDevice)
110
111#if defined(Q_WS_X11) && defined(QT3_SUPPORT)
112public:
113 QT3_SUPPORT Display *x11Display() const;
114 QT3_SUPPORT int x11Screen() const;
115 QT3_SUPPORT int x11Depth() const;
116 QT3_SUPPORT int x11Cells() const;
117 QT3_SUPPORT Qt::HANDLE x11Colormap() const;
118 QT3_SUPPORT bool x11DefaultColormap() const;
119 QT3_SUPPORT void *x11Visual() const;
120 QT3_SUPPORT bool x11DefaultVisual() const;
121
122 static QT3_SUPPORT Display *x11AppDisplay();
123 static QT3_SUPPORT int x11AppScreen();
124 static QT3_SUPPORT int x11AppDepth(int screen = -1);
125 static QT3_SUPPORT int x11AppCells(int screen = -1);
126 static QT3_SUPPORT Qt::HANDLE x11AppRootWindow(int screen = -1);
127 static QT3_SUPPORT Qt::HANDLE x11AppColormap(int screen = -1);
128 static QT3_SUPPORT void *x11AppVisual(int screen = -1);
129 static QT3_SUPPORT bool x11AppDefaultColormap(int screen =-1);
130 static QT3_SUPPORT bool x11AppDefaultVisual(int screen =-1);
131 static QT3_SUPPORT int x11AppDpiX(int screen = -1);
132 static QT3_SUPPORT int x11AppDpiY(int screen = -1);
133 static QT3_SUPPORT void x11SetAppDpiX(int, int);
134 static QT3_SUPPORT void x11SetAppDpiY(int, int);
135#endif
136
137 friend class QPainter;
138 friend class QFontEngineMac;
139 friend class QX11PaintEngine;
140};
141
142#ifdef QT3_SUPPORT
143QT3_SUPPORT Q_GUI_EXPORT
144void bitBlt(QPaintDevice *dst, int dx, int dy,
145 const QPaintDevice *src, int sx=0, int sy=0, int sw=-1, int sh=-1,
146 bool ignoreMask=false);
147
148QT3_SUPPORT Q_GUI_EXPORT
149void bitBlt(QPaintDevice *dst, int dx, int dy,
150 const QImage *src, int sx=0, int sy=0, int sw=-1, int sh=-1,
151 int conversion_flags=0);
152
153QT3_SUPPORT Q_GUI_EXPORT
154void bitBlt(QPaintDevice *dst, const QPoint &dp,
155 const QPaintDevice *src, const QRect &sr=QRect(0,0,-1,-1),
156 bool ignoreMask=false);
157#endif
158
159/*****************************************************************************
160 Inline functions
161 *****************************************************************************/
162
163inline int QPaintDevice::devType() const
164{ return QInternal::UnknownDevice; }
165
166inline bool QPaintDevice::paintingActive() const
167{ return painters != 0; }
168
169QT_END_NAMESPACE
170
171QT_END_HEADER
172
173#endif // QPAINTDEVICE_H
Note: See TracBrowser for help on using the repository browser.