home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / qt3_emx.zip / include / qpaintdevice.h < prev    next >
C/C++ Source or Header  |  2001-10-11  |  10KB  |  364 lines

  1. /****************************************************************************
  2. ** $Id:  qt/qpaintdevice.h   3.0.0   edited Aug 1 23:02 $
  3. **
  4. ** Definition of QPaintDevice class
  5. **
  6. ** Created : 940721
  7. **
  8. ** Copyright (C) 1992-2000 Trolltech AS.  All rights reserved.
  9. **
  10. ** This file is part of the kernel module of the Qt GUI Toolkit.
  11. **
  12. ** This file may be distributed under the terms of the Q Public License
  13. ** as defined by Trolltech AS of Norway and appearing in the file
  14. ** LICENSE.QPL included in the packaging of this file.
  15. **
  16. ** This file may be distributed and/or modified under the terms of the
  17. ** GNU General Public License version 2 as published by the Free Software
  18. ** Foundation and appearing in the file LICENSE.GPL included in the
  19. ** packaging of this file.
  20. **
  21. ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
  22. ** licenses may use this file in accordance with the Qt Commercial License
  23. ** Agreement provided with the Software.
  24. **
  25. ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  26. ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  27. **
  28. ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
  29. **   information about Qt Commercial License Agreements.
  30. ** See http://www.trolltech.com/qpl/ for QPL licensing information.
  31. ** See http://www.trolltech.com/gpl/ for GPL licensing information.
  32. **
  33. ** Contact info@trolltech.com if any conditions of this licensing are
  34. ** not clear to you.
  35. **
  36. **********************************************************************/
  37.  
  38. #ifndef QPAINTDEVICE_H
  39. #define QPAINTDEVICE_H
  40.  
  41. #ifndef QT_H
  42. #include "qwindowdefs.h"
  43. #include "qrect.h"
  44. #endif // QT_H
  45.  
  46. #if defined(Q_WS_QWS)
  47. class QWSDisplay;
  48. class QGfx;
  49. #endif
  50.  
  51. class QIODevice;
  52. class QString;
  53.  
  54.  
  55. #if defined(Q_WS_X11)
  56. struct QPaintDeviceX11Data;
  57. #endif
  58.  
  59. union QPDevCmdParam {
  60.     int             ival;
  61.     int            *ivec;
  62.     QString            *str;
  63.     const QPoint    *point;
  64.     const QRect        *rect;
  65.     const QPointArray    *ptarr;
  66.     const QPixmap    *pixmap;
  67.     const QImage    *image;
  68.     const QColor    *color;
  69.     const QFont        *font;
  70.     const QPen        *pen;
  71.     const QBrush    *brush;
  72.     const QRegion    *rgn;
  73.     const QWMatrix    *matrix;
  74.     QIODevice        *device;
  75. };
  76.  
  77.  
  78.  
  79. class Q_EXPORT QPaintDevice                // device for QPainter
  80. {
  81. public:
  82.     virtual ~QPaintDevice();
  83.  
  84.     int        devType() const;
  85.     bool    isExtDev() const;
  86.     bool    paintingActive() const;
  87.  
  88.     virtual void setResolution( int );
  89.     virtual int resolution() const;
  90.  
  91.     // Windows:      get device context
  92.     // X-Windows: get drawable
  93. #if defined(Q_WS_WIN)
  94.     virtual HDC        handle() const;
  95. #elif defined(Q_WS_X11)
  96.     virtual Qt::HANDLE    handle() const;
  97.     virtual Qt::HANDLE  x11RenderHandle() const;
  98. #elif defined(Q_WS_MAC)
  99.     virtual Qt::HANDLE      handle() const;
  100. #elif defined(Q_WS_QWS)
  101.     virtual Qt::HANDLE    handle() const;
  102. #endif
  103.  
  104. #if defined(Q_WS_X11)
  105.     Display        *x11Display() const;
  106.     int            x11Screen() const;
  107.     int            x11Depth() const;
  108.     int            x11Cells() const;
  109.     Qt::HANDLE        x11Colormap() const;
  110.     bool        x11DefaultColormap() const;
  111.     void       *x11Visual() const;
  112.     bool        x11DefaultVisual() const;
  113.  
  114.     static Display *x11AppDisplay();
  115.     static int        x11AppScreen();
  116.     static int        x11AppDepth();
  117.     static int        x11AppCells();
  118.     static int        x11AppDpiX();
  119.     static int        x11AppDpiY();
  120.     static Qt::HANDLE   x11AppColormap();
  121.     static bool     x11AppDefaultColormap();
  122.     static void    *x11AppVisual();
  123.     static bool        x11AppDefaultVisual();
  124.     static void        x11SetAppDpiX(int);
  125.     static void        x11SetAppDpiY(int);
  126. #endif
  127.  
  128. #if defined(Q_WS_QWS)
  129.     static QWSDisplay *qwsDisplay();
  130.     virtual unsigned char * scanLine(int) const;
  131.     virtual int bytesPerLine() const;
  132.     virtual QGfx * graphicsContext(bool clip_children=TRUE) const;
  133. #endif
  134.  
  135.     enum PDevCmd {
  136.     PdcNOP = 0, //  <void>
  137.     PdcDrawPoint = 1, // point
  138.     PdcDrawFirst = PdcDrawPoint,
  139.     PdcMoveTo = 2, // point
  140.     PdcLineTo = 3, // point
  141.     PdcDrawLine = 4, // point,point
  142.     PdcDrawRect = 5, // rect
  143.     PdcDrawRoundRect = 6, // rect,ival,ival
  144.     PdcDrawEllipse = 7, // rect
  145.     PdcDrawArc = 8, // rect,ival,ival
  146.     PdcDrawPie = 9, // rect,ival,ival
  147.     PdcDrawChord = 10, // rect,ival,ival
  148.     PdcDrawLineSegments = 11, // ptarr
  149.     PdcDrawPolyline = 12, // ptarr
  150.     PdcDrawPolygon = 13, // ptarr,ival
  151.     PdcDrawCubicBezier = 14, // ptarr
  152.     PdcDrawText = 15, // point,str
  153.     PdcDrawTextFormatted = 16, // rect,ival,str
  154.     PdcDrawPixmap = 17, // rect,pixmap
  155.     PdcDrawImage = 18, // rect,image
  156.     PdcDrawText2 = 19, // point,str
  157.     PdcDrawText2Formatted = 20, // rect,ival,str
  158.     PdcDrawLast = PdcDrawText2Formatted,
  159.  
  160.     // no painting commands below PdcDrawLast.
  161.  
  162.     PdcBegin = 30, //  <void>
  163.     PdcEnd = 31, //  <void>
  164.     PdcSave = 32, //  <void>
  165.     PdcRestore = 33, //  <void>
  166.     PdcSetdev = 34, // device - PRIVATE
  167.     PdcSetBkColor = 40, // color
  168.     PdcSetBkMode = 41, // ival
  169.     PdcSetROP = 42, // ival
  170.     PdcSetBrushOrigin = 43, // point
  171.     PdcSetFont = 45, // font
  172.     PdcSetPen = 46, // pen
  173.     PdcSetBrush = 47, // brush
  174.     PdcSetTabStops = 48, // ival
  175.     PdcSetTabArray = 49, // ival,ivec
  176.     PdcSetUnit = 50, // ival
  177.     PdcSetVXform = 51, // ival
  178.     PdcSetWindow = 52, // rect
  179.     PdcSetViewport = 53, // rect
  180.     PdcSetWXform = 54, // ival
  181.     PdcSetWMatrix = 55, // matrix,ival
  182.     PdcSaveWMatrix = 56,
  183.     PdcRestoreWMatrix = 57,
  184.     PdcSetClip = 60, // ival
  185.     PdcSetClipRegion = 61, // rgn
  186.  
  187.     PdcReservedStart = 0, // codes 0-199 are reserved
  188.     PdcReservedStop = 199 //   for Qt
  189.     };
  190.  
  191. protected:
  192.     QPaintDevice( uint devflags );
  193.  
  194. #if defined(Q_WS_WIN)
  195.     HDC        hdc;                // device context
  196. #elif defined(Q_WS_X11)
  197.     Qt::HANDLE    hd;                // handle to drawable
  198.     Qt::HANDLE  rendhd;                         // handle to RENDER pict
  199.  
  200.     void         copyX11Data( const QPaintDevice * );
  201.     void         cloneX11Data( const QPaintDevice * );
  202.     virtual void     setX11Data( const QPaintDeviceX11Data* );
  203.     QPaintDeviceX11Data* getX11Data( bool def=FALSE ) const;
  204. #elif defined(Q_WS_MAC)
  205. #if !defined( QMAC_NO_QUARTZ )
  206.     CGContextRef ctx;
  207. #endif
  208.     void * hd;
  209. #elif defined(Q_WS_QWS)
  210.     Qt::HANDLE hd;
  211. #endif
  212.  
  213.     virtual bool cmd( int, QPainter *, QPDevCmdParam * );
  214.     virtual int     metric( int ) const;
  215.     virtual int     fontMet( QFont *, int, const char * = 0, int = 0 ) const;
  216.     virtual int     fontInf( QFont *, int ) const;
  217.  
  218.     ushort    devFlags;            // device flags
  219.     ushort    painters;            // refcount
  220.  
  221.     friend class QPainter;
  222.     friend class QPaintDeviceMetrics;
  223. #if defined(Q_WS_MAC)
  224. #ifndef QMAC_NO_QUARTZ
  225.     virtual CGContextRef macCGContext() const;
  226. #endif
  227.     friend Q_EXPORT void unclippedScaledBitBlt( QPaintDevice *, int, int, int, int,
  228.                         const QPaintDevice *, int, int, int, int, Qt::RasterOp, bool );
  229. #else
  230.     friend Q_EXPORT void bitBlt( QPaintDevice *, int, int,
  231.                  const QPaintDevice *,
  232.                  int, int, int, int, Qt::RasterOp, bool );
  233. #endif
  234. #if defined(Q_WS_X11)
  235.     friend void qt_init_internal( int *, char **, Display *, Qt::HANDLE, Qt::HANDLE );
  236. #endif
  237.  
  238. private:
  239. #if defined(Q_WS_X11)
  240.     static Display *x_appdisplay;
  241.     static int        x_appscreen;
  242.     static int        x_appdepth;
  243.     static int        x_appcells;
  244.     static Qt::HANDLE   x_appcolormap;
  245.     static bool        x_appdefcolormap;
  246.     static void       *x_appvisual;
  247.     static bool     x_appdefvisual;
  248.  
  249.     QPaintDeviceX11Data* x11Data;
  250. #endif
  251.  
  252. private:    // Disabled copy constructor and operator=
  253. #if defined(Q_DISABLE_COPY)
  254.     QPaintDevice( const QPaintDevice & );
  255.     QPaintDevice &operator=( const QPaintDevice & );
  256. #endif
  257. };
  258.  
  259.  
  260. Q_EXPORT
  261. void bitBlt( QPaintDevice *dst, int dx, int dy,
  262.          const QPaintDevice *src, int sx=0, int sy=0, int sw=-1, int sh=-1,
  263.          Qt::RasterOp = Qt::CopyROP, bool ignoreMask=FALSE );
  264.  
  265. Q_EXPORT
  266. void bitBlt( QPaintDevice *dst, int dx, int dy,
  267.          const QImage *src, int sx=0, int sy=0, int sw=-1, int sh=-1,
  268.          int conversion_flags=0 );
  269.  
  270.  
  271. #if defined(Q_WS_X11)
  272.  
  273. struct Q_EXPORT QPaintDeviceX11Data : public QShared {
  274.     Display*    x_display;
  275.     int        x_screen;
  276.     int        x_depth;
  277.     int        x_cells;
  278.     Qt::HANDLE    x_colormap;
  279.     bool    x_defcolormap;
  280.     void*    x_visual;
  281.     bool    x_defvisual;
  282. };
  283.  
  284. #endif
  285.  
  286. /*****************************************************************************
  287.   Inline functions
  288.  *****************************************************************************/
  289.  
  290. inline int QPaintDevice::devType() const
  291. { return devFlags & QInternal::DeviceTypeMask; }
  292.  
  293. inline bool QPaintDevice::isExtDev() const
  294. { return (devFlags & QInternal::ExternalDevice) != 0; }
  295.  
  296. inline bool QPaintDevice::paintingActive() const
  297. { return painters != 0; }
  298.  
  299. #if defined(Q_WS_X11)
  300. inline Display *QPaintDevice::x11Display() const
  301. { return x11Data ? x11Data->x_display : x_appdisplay; }
  302.  
  303. inline int QPaintDevice::x11Screen() const
  304. { return x11Data ? x11Data->x_screen : x_appscreen; }
  305.  
  306. inline int QPaintDevice::x11Depth() const
  307. { return x11Data ? x11Data->x_depth : x_appdepth; }
  308.  
  309. inline int QPaintDevice::x11Cells() const
  310. { return x11Data ? x11Data->x_cells : x_appcells; }
  311.  
  312. inline Qt::HANDLE QPaintDevice::x11Colormap() const
  313. { return x11Data ? x11Data->x_colormap : x_appcolormap; }
  314.  
  315. inline bool QPaintDevice::x11DefaultColormap() const
  316. { return x11Data ? x11Data->x_defcolormap : x_appdefcolormap; }
  317.  
  318. inline void *QPaintDevice::x11Visual() const
  319. { return x11Data ? x11Data->x_visual : x_appvisual; }
  320.  
  321. inline bool QPaintDevice::x11DefaultVisual() const
  322. { return x11Data ? x11Data->x_defvisual : x_appdefvisual; }
  323.  
  324. inline Display *QPaintDevice::x11AppDisplay()
  325. { return x_appdisplay; }
  326.  
  327. inline int QPaintDevice::x11AppScreen()
  328. { return x_appscreen; }
  329.  
  330. inline int QPaintDevice::x11AppDepth()
  331. { return x_appdepth; }
  332.  
  333. inline int QPaintDevice::x11AppCells()
  334. { return x_appcells; }
  335.  
  336. inline Qt::HANDLE QPaintDevice::x11AppColormap()
  337. { return x_appcolormap; }
  338.  
  339. inline bool QPaintDevice::x11AppDefaultColormap()
  340. { return x_appdefcolormap; }
  341.  
  342. inline void *QPaintDevice::x11AppVisual()
  343. { return x_appvisual; }
  344.  
  345. inline bool QPaintDevice::x11AppDefaultVisual()
  346. { return x_appdefvisual; }
  347.  
  348. #endif // Q_WS_X11
  349.  
  350.  
  351. Q_EXPORT
  352. inline void bitBlt( QPaintDevice *dst, const QPoint &dp,
  353.             const QPaintDevice *src, const QRect &sr =QRect(0,0,-1,-1),
  354.             Qt::RasterOp rop=Qt::CopyROP, bool ignoreMask=FALSE )
  355. {
  356.     bitBlt( dst, dp.x(), dp.y(), src, sr.x(), sr.y(), sr.width(), sr.height(),
  357.         rop, ignoreMask );
  358. }
  359.  
  360.  
  361.  
  362.  
  363. #endif // QPAINTDEVICE_H
  364.