Eneboo - Documentación para desarrolladores
src/qt/src/kernel/qpaintdevice.h
Ir a la documentación de este archivo.
00001 /****************************************************************************
00002 ** $Id: qt/qpaintdevice.h   3.3.8   edited Jan 11 14:38 $
00003 **
00004 ** Definition of QPaintDevice class
00005 **
00006 ** Created : 940721
00007 **
00008 ** Copyright (C) 1992-2007 Trolltech ASA.  All rights reserved.
00009 **
00010 ** This file is part of the kernel module of the Qt GUI Toolkit.
00011 **
00012 ** This file may be distributed under the terms of the Q Public License
00013 ** as defined by Trolltech ASA of Norway and appearing in the file
00014 ** LICENSE.QPL included in the packaging of this file.
00015 **
00016 ** This file may be distributed and/or modified under the terms of the
00017 ** GNU General Public License version 2 as published by the Free Software
00018 ** Foundation and appearing in the file LICENSE.GPL included in the
00019 ** packaging of this file.
00020 **
00021 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
00022 ** licenses may use this file in accordance with the Qt Commercial License
00023 ** Agreement provided with the Software.
00024 **
00025 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00026 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00027 **
00028 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
00029 **   information about Qt Commercial License Agreements.
00030 ** See http://www.trolltech.com/qpl/ for QPL licensing information.
00031 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00032 **
00033 ** Contact info@trolltech.com if any conditions of this licensing are
00034 ** not clear to you.
00035 **
00036 **********************************************************************/
00037 
00038 #ifndef QPAINTDEVICE_H
00039 #define QPAINTDEVICE_H
00040 
00041 #ifndef QT_H
00042 #include "qwindowdefs.h"
00043 #include "qrect.h"
00044 #endif // QT_H
00045 
00046 #if defined(Q_WS_QWS)
00047 class QWSDisplay;
00048 class QGfx;
00049 #endif
00050 
00051 class QIODevice;
00052 class QString;
00053 class QTextItem;
00054 
00055 
00056 #if defined(Q_WS_X11)
00057 struct QPaintDeviceX11Data;
00058 #endif
00059 
00060 union QPDevCmdParam {
00061     int                  ival;
00062     int                 *ivec;
00063     QString             *str;
00064     const QPoint        *point;
00065     const QRect         *rect;
00066     const QPointArray   *ptarr;
00067     const QPixmap       *pixmap;
00068     const QImage        *image;
00069     const QColor        *color;
00070     const QFont         *font;
00071     const QPen          *pen;
00072     const QBrush        *brush;
00073     const QRegion       *rgn;
00074     const QWMatrix      *matrix;
00075     const QTextItem     *textItem;
00076     QIODevice           *device;
00077 };
00078 
00079 
00080 
00081 class Q_EXPORT QPaintDevice                             // device for QPainter
00082 {
00083 public:
00084     virtual ~QPaintDevice();
00085 
00086     int         devType() const;
00087     bool        isExtDev() const;
00088     bool        paintingActive() const;
00089 
00090     virtual void setResolution( int );
00091     virtual int resolution() const;
00092 
00093     // Windows:   get device context
00094     // X-Windows: get drawable
00095 #if defined(Q_WS_WIN)
00096     virtual HDC         handle() const;
00097 #elif defined(Q_WS_X11)
00098     virtual Qt::HANDLE  handle() const;
00099     virtual Qt::HANDLE  x11RenderHandle() const;
00100 #elif defined(Q_WS_MAC)
00101     virtual Qt::HANDLE      handle() const;
00102 #elif defined(Q_WS_QWS)
00103     virtual Qt::HANDLE  handle() const;
00104 #endif
00105 
00106 #if defined(Q_WS_X11)
00107     Display        *x11Display() const;
00108     int             x11Screen() const;
00109     int             x11Depth() const;
00110     int             x11Cells() const;
00111     Qt::HANDLE      x11Colormap() const;
00112     bool            x11DefaultColormap() const;
00113     void           *x11Visual() const;
00114     bool            x11DefaultVisual() const;
00115 
00116     static Display *x11AppDisplay();
00117     static int      x11AppScreen();
00118 
00119     static int      x11AppDpiX();
00120     static int      x11AppDpiY();
00121     static void     x11SetAppDpiX(int);
00122     static void     x11SetAppDpiY(int);
00123     static int      x11AppDepth();
00124     static int      x11AppCells();
00125     static Qt::HANDLE   x11AppRootWindow();
00126     static Qt::HANDLE   x11AppColormap();
00127     static bool     x11AppDefaultColormap();
00128     static void    *x11AppVisual();
00129     static bool     x11AppDefaultVisual();
00130 
00131     // ### in 4.0, the above need to go away, the below needs to take a -1 default
00132     // argument, signifying the default screen...
00133     static int      x11AppDepth( int screen );
00134     static int      x11AppCells( int screen );
00135     static Qt::HANDLE   x11AppRootWindow( int screen );
00136     static Qt::HANDLE   x11AppColormap( int screen );
00137     static void    *x11AppVisual( int screen );
00138     static bool     x11AppDefaultColormap( int screen );
00139     static bool     x11AppDefaultVisual( int screen );
00140     static int      x11AppDpiX( int );
00141     static int      x11AppDpiY( int );
00142     static void     x11SetAppDpiX( int, int );
00143     static void     x11SetAppDpiY( int, int );
00144 #endif
00145 
00146 #if defined(Q_WS_QWS)
00147     static QWSDisplay *qwsDisplay();
00148     virtual unsigned char * scanLine(int) const;
00149     virtual int bytesPerLine() const;
00150     virtual QGfx * graphicsContext(bool clip_children=TRUE) const;
00151 #endif
00152 
00153     enum PDevCmd {
00154         PdcNOP = 0, //  <void>
00155         PdcDrawPoint = 1, // point
00156         PdcDrawFirst = PdcDrawPoint,
00157         PdcMoveTo = 2, // point
00158         PdcLineTo = 3, // point
00159         PdcDrawLine = 4, // point,point
00160         PdcDrawRect = 5, // rect
00161         PdcDrawRoundRect = 6, // rect,ival,ival
00162         PdcDrawEllipse = 7, // rect
00163         PdcDrawArc = 8, // rect,ival,ival
00164         PdcDrawPie = 9, // rect,ival,ival
00165         PdcDrawChord = 10, // rect,ival,ival
00166         PdcDrawLineSegments = 11, // ptarr
00167         PdcDrawPolyline = 12, // ptarr
00168         PdcDrawPolygon = 13, // ptarr,ival
00169         PdcDrawCubicBezier = 14, // ptarr
00170         PdcDrawText = 15, // point,str
00171         PdcDrawTextFormatted = 16, // rect,ival,str
00172         PdcDrawPixmap = 17, // rect,pixmap
00173         PdcDrawImage = 18, // rect,image
00174         PdcDrawText2 = 19, // point,str
00175         PdcDrawText2Formatted = 20, // rect,ival,str
00176         PdcDrawTextItem = 21,
00177         PdcDrawLast = PdcDrawTextItem,
00178 
00179         // no painting commands below PdcDrawLast.
00180 
00181         PdcBegin = 30, //  <void>
00182         PdcEnd = 31, //  <void>
00183         PdcSave = 32, //  <void>
00184         PdcRestore = 33, //  <void>
00185         PdcSetdev = 34, // device - PRIVATE
00186         PdcSetBkColor = 40, // color
00187         PdcSetBkMode = 41, // ival
00188         PdcSetROP = 42, // ival
00189         PdcSetBrushOrigin = 43, // point
00190         PdcSetFont = 45, // font
00191         PdcSetPen = 46, // pen
00192         PdcSetBrush = 47, // brush
00193         PdcSetTabStops = 48, // ival
00194         PdcSetTabArray = 49, // ival,ivec
00195         PdcSetUnit = 50, // ival
00196         PdcSetVXform = 51, // ival
00197         PdcSetWindow = 52, // rect
00198         PdcSetViewport = 53, // rect
00199         PdcSetWXform = 54, // ival
00200         PdcSetWMatrix = 55, // matrix,ival
00201         PdcSaveWMatrix = 56,
00202         PdcRestoreWMatrix = 57,
00203         PdcSetClip = 60, // ival
00204         PdcSetClipRegion = 61, // rgn
00205 
00206         PdcReservedStart = 0, // codes 0-199 are reserved
00207         PdcReservedStop = 199 //   for Qt
00208     };
00209 
00210 protected:
00211     QPaintDevice( uint devflags );
00212 
00213 #if defined(Q_WS_WIN)
00214     HDC         hdc;                            // device context
00215 #elif defined(Q_WS_X11)
00216     Qt::HANDLE  hd;                             // handle to drawable
00217     Qt::HANDLE  rendhd;                         // handle to RENDER pict
00218 
00219     void                 copyX11Data( const QPaintDevice * );
00220     void                 cloneX11Data( const QPaintDevice * );
00221     virtual void         setX11Data( const QPaintDeviceX11Data* );
00222     QPaintDeviceX11Data* getX11Data( bool def=FALSE ) const;
00223 #elif defined(Q_WS_MAC)
00224 #if !defined( QMAC_NO_QUARTZ )
00225     CGContextRef ctx;
00226 #endif
00227     void * hd;
00228 #elif defined(Q_WS_QWS)
00229     Qt::HANDLE hd;
00230 #endif
00231 
00232     virtual bool cmd( int, QPainter *, QPDevCmdParam * );
00233     virtual int  metric( int ) const;
00234     virtual int  fontMet( QFont *, int, const char * = 0, int = 0 ) const;
00235     virtual int  fontInf( QFont *, int ) const;
00236 
00237     ushort      devFlags;                       // device flags
00238     ushort      painters;                       // refcount
00239 
00240     friend class QPainter;
00241     friend class QPaintDeviceMetrics;
00242 #if defined(Q_WS_MAC)
00243 #ifndef QMAC_NO_QUARTZ
00244     virtual CGContextRef macCGContext(bool clipped=TRUE) const;
00245 #endif
00246     friend Q_EXPORT void unclippedScaledBitBlt( QPaintDevice *, int, int, int, int,
00247                                                 const QPaintDevice *, int, int, int, int, Qt::RasterOp, bool, bool );
00248 #else
00249     friend Q_EXPORT void bitBlt( QPaintDevice *, int, int,
00250                                  const QPaintDevice *,
00251                                  int, int, int, int, Qt::RasterOp, bool );
00252 #endif
00253 #if defined(Q_WS_X11)
00254     friend void qt_init_internal( int *, char **, Display *, Qt::HANDLE, Qt::HANDLE );
00255     friend void qt_cleanup();
00256 #endif
00257 
00258 private:
00259 #if defined(Q_WS_X11)
00260     static Display *x_appdisplay;
00261     static int      x_appscreen;
00262 
00263     static int      x_appdepth;
00264     static int      x_appcells;
00265     static Qt::HANDLE   x_approotwindow;
00266     static Qt::HANDLE   x_appcolormap;
00267     static bool     x_appdefcolormap;
00268     static void    *x_appvisual;
00269     static bool     x_appdefvisual;
00270 
00271     // ### in 4.0, remove the above, and replace with the below
00272     static int        *x_appdepth_arr;
00273     static int        *x_appcells_arr;
00274     static Qt::HANDLE *x_approotwindow_arr;
00275     static Qt::HANDLE *x_appcolormap_arr;
00276     static bool       *x_appdefcolormap_arr;
00277     static void      **x_appvisual_arr;
00278     static bool       *x_appdefvisual_arr;
00279 
00280     QPaintDeviceX11Data* x11Data;
00281 #endif
00282 
00283 private:        // Disabled copy constructor and operator=
00284 #if defined(Q_DISABLE_COPY)
00285     QPaintDevice( const QPaintDevice & );
00286     QPaintDevice &operator=( const QPaintDevice & );
00287 #endif
00288 };
00289 
00290 
00291 Q_EXPORT
00292 void bitBlt( QPaintDevice *dst, int dx, int dy,
00293              const QPaintDevice *src, int sx=0, int sy=0, int sw=-1, int sh=-1,
00294              Qt::RasterOp = Qt::CopyROP, bool ignoreMask=FALSE );
00295 
00296 Q_EXPORT
00297 void bitBlt( QPaintDevice *dst, int dx, int dy,
00298              const QImage *src, int sx=0, int sy=0, int sw=-1, int sh=-1,
00299              int conversion_flags=0 );
00300 
00301 
00302 #if defined(Q_WS_X11)
00303 
00304 struct Q_EXPORT QPaintDeviceX11Data : public QShared {
00305     Display*    x_display;
00306     int         x_screen;
00307     int         x_depth;
00308     int         x_cells;
00309     Qt::HANDLE  x_colormap;
00310     bool        x_defcolormap;
00311     void*       x_visual;
00312     bool        x_defvisual;
00313 };
00314 
00315 #endif
00316 
00317 /*****************************************************************************
00318   Inline functions
00319  *****************************************************************************/
00320 
00321 inline int QPaintDevice::devType() const
00322 { return devFlags & QInternal::DeviceTypeMask; }
00323 
00324 inline bool QPaintDevice::isExtDev() const
00325 { return (devFlags & QInternal::ExternalDevice) != 0; }
00326 
00327 inline bool QPaintDevice::paintingActive() const
00328 { return painters != 0; }
00329 
00330 #if defined(Q_WS_X11)
00331 inline Display *QPaintDevice::x11Display() const
00332 { return x11Data ? x11Data->x_display : x_appdisplay; }
00333 
00334 inline int QPaintDevice::x11Screen() const
00335 { return x11Data ? x11Data->x_screen : x_appscreen; }
00336 
00337 inline int QPaintDevice::x11Depth() const
00338 { return x11Data ? x11Data->x_depth : x_appdepth; }
00339 
00340 inline int QPaintDevice::x11Cells() const
00341 { return x11Data ? x11Data->x_cells : x_appcells; }
00342 
00343 inline Qt::HANDLE QPaintDevice::x11Colormap() const
00344 { return x11Data ? x11Data->x_colormap : x_appcolormap; }
00345 
00346 inline bool QPaintDevice::x11DefaultColormap() const
00347 { return x11Data ? x11Data->x_defcolormap : x_appdefcolormap; }
00348 
00349 inline void *QPaintDevice::x11Visual() const
00350 { return x11Data ? x11Data->x_visual : x_appvisual; }
00351 
00352 inline bool QPaintDevice::x11DefaultVisual() const
00353 { return x11Data ? x11Data->x_defvisual : x_appdefvisual; }
00354 
00355 inline Display *QPaintDevice::x11AppDisplay()
00356 { return x_appdisplay; }
00357 
00358 inline int QPaintDevice::x11AppScreen()
00359 { return x_appscreen; }
00360 
00361 inline int QPaintDevice::x11AppDepth( int screen )
00362 { return x_appdepth_arr[ screen == -1 ? x_appscreen : screen ]; }
00363 
00364 inline int QPaintDevice::x11AppCells( int screen )
00365 { return x_appcells_arr[ screen == -1 ? x_appscreen : screen ]; }
00366 
00367 inline Qt::HANDLE QPaintDevice::x11AppRootWindow( int screen )
00368 { return x_approotwindow_arr[ screen == -1 ? x_appscreen : screen ]; }
00369 
00370 inline Qt::HANDLE QPaintDevice::x11AppColormap( int screen )
00371 { return x_appcolormap_arr[ screen == -1 ? x_appscreen : screen ]; }
00372 
00373 inline bool QPaintDevice::x11AppDefaultColormap( int screen )
00374 { return x_appdefcolormap_arr[ screen == -1 ? x_appscreen : screen ]; }
00375 
00376 inline void *QPaintDevice::x11AppVisual( int screen )
00377 { return x_appvisual_arr[ screen == -1 ? x_appscreen : screen ]; }
00378 
00379 inline bool QPaintDevice::x11AppDefaultVisual( int screen )
00380 { return x_appdefvisual_arr[ screen == -1 ? x_appscreen : screen ]; }
00381 
00382 inline int QPaintDevice::x11AppDepth()
00383 { return x_appdepth; }
00384 
00385 inline int QPaintDevice::x11AppCells()
00386 { return x_appcells; }
00387 
00388 inline Qt::HANDLE QPaintDevice::x11AppRootWindow()
00389 { return x_approotwindow; }
00390 
00391 inline Qt::HANDLE QPaintDevice::x11AppColormap()
00392 { return x_appcolormap; }
00393 
00394 inline bool QPaintDevice::x11AppDefaultColormap()
00395 { return x_appdefcolormap; }
00396 
00397 inline void *QPaintDevice::x11AppVisual()
00398 { return x_appvisual; }
00399 
00400 inline bool QPaintDevice::x11AppDefaultVisual()
00401 { return x_appdefvisual; }
00402 
00403 #endif // Q_WS_X11
00404 
00405 
00406 Q_EXPORT
00407 inline void bitBlt( QPaintDevice *dst, const QPoint &dp,
00408                     const QPaintDevice *src, const QRect &sr =QRect(0,0,-1,-1),
00409                     Qt::RasterOp rop=Qt::CopyROP, bool ignoreMask=FALSE )
00410 {
00411     bitBlt( dst, dp.x(), dp.y(), src, sr.x(), sr.y(), sr.width(), sr.height(),
00412             rop, ignoreMask );
00413 }
00414 
00415 
00416 
00417 
00418 #endif // QPAINTDEVICE_H
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'