qpaintdevice.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 **
00003 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
00004 ** All rights reserved.
00005 ** Contact: Nokia Corporation (qt-info@nokia.com)
00006 **
00007 ** This file is part of the QtGui module of the Qt Toolkit.
00008 **
00009 ** $QT_BEGIN_LICENSE:LGPL$
00010 ** Commercial Usage
00011 ** Licensees holding valid Qt Commercial licenses may use this file in
00012 ** accordance with the Qt Commercial License Agreement provided with the
00013 ** Software or, alternatively, in accordance with the terms contained in
00014 ** a written agreement between you and Nokia.
00015 **
00016 ** GNU Lesser General Public License Usage
00017 ** Alternatively, this file may be used under the terms of the GNU Lesser
00018 ** General Public License version 2.1 as published by the Free Software
00019 ** Foundation and appearing in the file LICENSE.LGPL included in the
00020 ** packaging of this file.  Please review the following information to
00021 ** ensure the GNU Lesser General Public License version 2.1 requirements
00022 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
00023 **
00024 ** In addition, as a special exception, Nokia gives you certain additional
00025 ** rights.  These rights are described in the Nokia Qt LGPL Exception
00026 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this module.
00027 **
00028 ** GNU General Public License Usage
00029 ** Alternatively, this file may be used under the terms of the GNU
00030 ** General Public License version 3.0 as published by the Free Software
00031 ** Foundation and appearing in the file LICENSE.GPL included in the
00032 ** packaging of this file.  Please review the following information to
00033 ** ensure the GNU General Public License version 3.0 requirements will be
00034 ** met: http://www.gnu.org/copyleft/gpl.html.
00035 **
00036 ** If you have questions regarding the use of this file, please contact
00037 ** Nokia at qt-info@nokia.com.
00038 ** $QT_END_LICENSE$
00039 **
00040 ****************************************************************************/
00041 
00042 #ifndef QPAINTDEVICE_H
00043 #define QPAINTDEVICE_H
00044 
00045 #include <QtGui/qwindowdefs.h>
00046 #include <QtCore/qrect.h>
00047 
00048 QT_BEGIN_HEADER
00049 
00050 QT_BEGIN_NAMESPACE
00051 
00052 QT_MODULE(Gui)
00053 
00054 #if defined(Q_WS_QWS)
00055 class QWSDisplay;
00056 #endif
00057 
00058 class QPaintEngine;
00059 
00060 class Q_GUI_EXPORT QPaintDevice                                // device for QPainter
00061 {
00062 public:
00063     enum PaintDeviceMetric {
00064         PdmWidth = 1,
00065         PdmHeight,
00066         PdmWidthMM,
00067         PdmHeightMM,
00068         PdmNumColors,
00069         PdmDepth,
00070         PdmDpiX,
00071         PdmDpiY,
00072         PdmPhysicalDpiX,
00073         PdmPhysicalDpiY
00074     };
00075 
00076     virtual ~QPaintDevice();
00077 
00078     virtual int devType() const;
00079     bool paintingActive() const;
00080     virtual QPaintEngine *paintEngine() const = 0;
00081 
00082 #if defined(Q_WS_QWS)
00083     static QWSDisplay *qwsDisplay();
00084 #endif
00085 
00086 #ifdef Q_WS_WIN
00087     virtual HDC getDC() const;
00088     virtual void releaseDC(HDC hdc) const;
00089 #endif
00090 
00091     int width() const { return metric(PdmWidth); }
00092     int height() const { return metric(PdmHeight); }
00093     int widthMM() const { return metric(PdmWidthMM); }
00094     int heightMM() const { return metric(PdmHeightMM); }
00095     int logicalDpiX() const { return metric(PdmDpiX); }
00096     int logicalDpiY() const { return metric(PdmDpiY); }
00097     int physicalDpiX() const { return metric(PdmPhysicalDpiX); }
00098     int physicalDpiY() const { return metric(PdmPhysicalDpiY); }
00099 #ifdef QT_DEPRECATED
00100     QT_DEPRECATED int numColors() const { return metric(PdmNumColors); }
00101 #endif
00102     int colorCount() const { return metric(PdmNumColors); }
00103     int depth() const { return metric(PdmDepth); }
00104 
00105 protected:
00106     QPaintDevice();
00107     virtual int metric(PaintDeviceMetric metric) const;
00108 
00109     ushort        painters;                        // refcount
00110 
00111 private:
00112     Q_DISABLE_COPY(QPaintDevice)
00113 
00114 #if defined(Q_WS_X11) && defined(QT3_SUPPORT)
00115 public:
00116     QT3_SUPPORT Display *x11Display() const;
00117     QT3_SUPPORT int x11Screen() const;
00118     QT3_SUPPORT int x11Depth() const;
00119     QT3_SUPPORT int x11Cells() const;
00120     QT3_SUPPORT Qt::HANDLE x11Colormap() const;
00121     QT3_SUPPORT bool x11DefaultColormap() const;
00122     QT3_SUPPORT void *x11Visual() const;
00123     QT3_SUPPORT bool x11DefaultVisual() const;
00124 
00125     static QT3_SUPPORT Display *x11AppDisplay();
00126     static QT3_SUPPORT int x11AppScreen();
00127     static QT3_SUPPORT int x11AppDepth(int screen = -1);
00128     static QT3_SUPPORT int x11AppCells(int screen = -1);
00129     static QT3_SUPPORT Qt::HANDLE x11AppRootWindow(int screen = -1);
00130     static QT3_SUPPORT Qt::HANDLE x11AppColormap(int screen = -1);
00131     static QT3_SUPPORT void *x11AppVisual(int screen = -1);
00132     static QT3_SUPPORT bool x11AppDefaultColormap(int screen =-1);
00133     static QT3_SUPPORT bool x11AppDefaultVisual(int screen =-1);
00134     static QT3_SUPPORT int x11AppDpiX(int screen = -1);
00135     static QT3_SUPPORT int x11AppDpiY(int screen = -1);
00136     static QT3_SUPPORT void x11SetAppDpiX(int, int);
00137     static QT3_SUPPORT void x11SetAppDpiY(int, int);
00138 #endif
00139 
00140     friend class QPainter;
00141     friend class QFontEngineMac;
00142     friend class QX11PaintEngine;
00143     friend Q_GUI_EXPORT int qt_paint_device_metric(const QPaintDevice *device, PaintDeviceMetric metric);
00144 };
00145 
00146 #ifdef QT3_SUPPORT
00147 QT3_SUPPORT Q_GUI_EXPORT
00148 void bitBlt(QPaintDevice *dst, int dx, int dy,
00149              const QPaintDevice *src, int sx=0, int sy=0, int sw=-1, int sh=-1,
00150              bool ignoreMask=false);
00151 
00152 QT3_SUPPORT Q_GUI_EXPORT
00153 void bitBlt(QPaintDevice *dst, int dx, int dy,
00154              const QImage *src, int sx=0, int sy=0, int sw=-1, int sh=-1,
00155              int conversion_flags=0);
00156 
00157 QT3_SUPPORT Q_GUI_EXPORT
00158 void bitBlt(QPaintDevice *dst, const QPoint &dp,
00159             const QPaintDevice *src, const QRect &sr=QRect(0,0,-1,-1),
00160             bool ignoreMask=false);
00161 #endif
00162 
00163 /*****************************************************************************
00164   Inline functions
00165  *****************************************************************************/
00166 
00167 inline int QPaintDevice::devType() const
00168 { return QInternal::UnknownDevice; }
00169 
00170 inline bool QPaintDevice::paintingActive() const
00171 { return painters != 0; }
00172 
00173 QT_END_NAMESPACE
00174 
00175 QT_END_HEADER
00176 
00177 #endif // QPAINTDEVICE_H