| 1 | /****************************************************************************
 | 
|---|
| 2 | ** $Id: qpainter.h 8 2005-11-16 19:36:46Z dmik $
 | 
|---|
| 3 | **
 | 
|---|
| 4 | ** Definition of QPainter class
 | 
|---|
| 5 | **
 | 
|---|
| 6 | ** Created : 940112
 | 
|---|
| 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 QPAINTER_H
 | 
|---|
| 39 | #define QPAINTER_H
 | 
|---|
| 40 | 
 | 
|---|
| 41 | 
 | 
|---|
| 42 | #ifndef QT_H
 | 
|---|
| 43 | #include "qcolor.h"
 | 
|---|
| 44 | #include "qfontmetrics.h"
 | 
|---|
| 45 | #include "qfontinfo.h"
 | 
|---|
| 46 | #include "qregion.h"
 | 
|---|
| 47 | #include "qpen.h"
 | 
|---|
| 48 | #include "qbrush.h"
 | 
|---|
| 49 | #include "qpointarray.h"
 | 
|---|
| 50 | #include "qwmatrix.h"
 | 
|---|
| 51 | #endif // QT_H
 | 
|---|
| 52 | 
 | 
|---|
| 53 | class QGfx;
 | 
|---|
| 54 | class QTextCodec;
 | 
|---|
| 55 | class QTextParag;
 | 
|---|
| 56 | class QPaintDevice;
 | 
|---|
| 57 | class QTextItem;
 | 
|---|
| 58 | #if defined( Q_WS_MAC )
 | 
|---|
| 59 | class QMacSavedPortInfo;
 | 
|---|
| 60 | #endif
 | 
|---|
| 61 | class QPainterPrivate;
 | 
|---|
| 62 | 
 | 
|---|
| 63 | class Q_EXPORT QPainter : public Qt
 | 
|---|
| 64 | {
 | 
|---|
| 65 | public:
 | 
|---|
| 66 |     enum CoordinateMode { CoordDevice, CoordPainter };
 | 
|---|
| 67 | 
 | 
|---|
| 68 |     QPainter();
 | 
|---|
| 69 |     QPainter( const QPaintDevice *, bool unclipped = FALSE );
 | 
|---|
| 70 |     QPainter( const QPaintDevice *, const QWidget *, bool unclipped = FALSE );
 | 
|---|
| 71 |    ~QPainter();
 | 
|---|
| 72 | 
 | 
|---|
| 73 |     bool        begin( const QPaintDevice *, bool unclipped = FALSE );
 | 
|---|
| 74 |     bool        begin( const QPaintDevice *, const QWidget *, bool unclipped = FALSE );
 | 
|---|
| 75 |     bool        end();
 | 
|---|
| 76 |     QPaintDevice *device() const;
 | 
|---|
| 77 | 
 | 
|---|
| 78 | #ifdef Q_WS_QWS
 | 
|---|
| 79 |     QGfx * internalGfx();
 | 
|---|
| 80 | #endif
 | 
|---|
| 81 | 
 | 
|---|
| 82 |     static void redirect( QPaintDevice *pdev, QPaintDevice *replacement );
 | 
|---|
| 83 |     static QPaintDevice *redirect( QPaintDevice *pdev );
 | 
|---|
| 84 | 
 | 
|---|
| 85 |     bool        isActive() const;
 | 
|---|
| 86 | 
 | 
|---|
| 87 |     void        flush( const QRegion ®ion, CoordinateMode cm = CoordDevice );
 | 
|---|
| 88 |     void        flush();
 | 
|---|
| 89 |     void        save();
 | 
|---|
| 90 |     void        restore();
 | 
|---|
| 91 | 
 | 
|---|
| 92 |   // Drawing tools
 | 
|---|
| 93 | 
 | 
|---|
| 94 |     QFontMetrics fontMetrics()  const;
 | 
|---|
| 95 |     QFontInfo    fontInfo()     const;
 | 
|---|
| 96 | 
 | 
|---|
| 97 |     const QFont &font()         const;
 | 
|---|
| 98 |     void        setFont( const QFont & );
 | 
|---|
| 99 |     const QPen &pen()           const;
 | 
|---|
| 100 |     void        setPen( const QPen & );
 | 
|---|
| 101 |     void        setPen( PenStyle );
 | 
|---|
| 102 |     void        setPen( const QColor & );
 | 
|---|
| 103 |     const QBrush &brush()       const;
 | 
|---|
| 104 |     void        setBrush( const QBrush & );
 | 
|---|
| 105 |     void        setBrush( BrushStyle );
 | 
|---|
| 106 |     void        setBrush( const QColor & );
 | 
|---|
| 107 |     QPoint      pos() const;
 | 
|---|
| 108 | 
 | 
|---|
| 109 |   // Drawing attributes/modes
 | 
|---|
| 110 | 
 | 
|---|
| 111 |     const QColor &backgroundColor() const;
 | 
|---|
| 112 |     void        setBackgroundColor( const QColor & );
 | 
|---|
| 113 |     BGMode      backgroundMode() const;
 | 
|---|
| 114 |     void        setBackgroundMode( BGMode );
 | 
|---|
| 115 |     RasterOp    rasterOp()      const;
 | 
|---|
| 116 |     void        setRasterOp( RasterOp );
 | 
|---|
| 117 |     const QPoint &brushOrigin() const;
 | 
|---|
| 118 |     void        setBrushOrigin( int x, int y );
 | 
|---|
| 119 |     void        setBrushOrigin( const QPoint & );
 | 
|---|
| 120 | 
 | 
|---|
| 121 |   // Scaling and transformations
 | 
|---|
| 122 | 
 | 
|---|
| 123 | //    PaintUnit unit()         const;           // get set painter unit
 | 
|---|
| 124 | //    void      setUnit( PaintUnit );           // NOT IMPLEMENTED!!!
 | 
|---|
| 125 | 
 | 
|---|
| 126 |     bool        hasViewXForm() const;
 | 
|---|
| 127 |     bool        hasWorldXForm() const;
 | 
|---|
| 128 | 
 | 
|---|
| 129 | #ifndef QT_NO_TRANSFORMATIONS
 | 
|---|
| 130 |     void        setViewXForm( bool );           // set xform on/off
 | 
|---|
| 131 |     QRect       window()       const;           // get window
 | 
|---|
| 132 |     void        setWindow( const QRect & );     // set window
 | 
|---|
| 133 |     void        setWindow( int x, int y, int w, int h );
 | 
|---|
| 134 |     QRect       viewport()   const;             // get viewport
 | 
|---|
| 135 |     void        setViewport( const QRect & );   // set viewport
 | 
|---|
| 136 |     void        setViewport( int x, int y, int w, int h );
 | 
|---|
| 137 | 
 | 
|---|
| 138 |     void        setWorldXForm( bool );          // set world xform on/off
 | 
|---|
| 139 |     const QWMatrix &worldMatrix() const;        // get/set world xform matrix
 | 
|---|
| 140 |     void        setWorldMatrix( const QWMatrix &, bool combine=FALSE );
 | 
|---|
| 141 | 
 | 
|---|
| 142 |     void        saveWorldMatrix();
 | 
|---|
| 143 |     void        restoreWorldMatrix();
 | 
|---|
| 144 | 
 | 
|---|
| 145 |     void        scale( double sx, double sy );
 | 
|---|
| 146 |     void        shear( double sh, double sv );
 | 
|---|
| 147 |     void        rotate( double a );
 | 
|---|
| 148 | #endif
 | 
|---|
| 149 |     void        translate( double dx, double dy );
 | 
|---|
| 150 |     void        resetXForm();
 | 
|---|
| 151 |     double      translationX() const;
 | 
|---|
| 152 |     double      translationY() const;
 | 
|---|
| 153 | 
 | 
|---|
| 154 |     QPoint      xForm( const QPoint & ) const;  // map virtual -> device
 | 
|---|
| 155 |     QRect       xForm( const QRect & )  const;
 | 
|---|
| 156 |     QPointArray xForm( const QPointArray & ) const;
 | 
|---|
| 157 |     QPointArray xForm( const QPointArray &, int index, int npoints ) const;
 | 
|---|
| 158 |     QPoint      xFormDev( const QPoint & ) const; // map device -> virtual
 | 
|---|
| 159 |     QRect       xFormDev( const QRect & )  const;
 | 
|---|
| 160 |     QPointArray xFormDev( const QPointArray & ) const;
 | 
|---|
| 161 |     QPointArray xFormDev( const QPointArray &, int index, int npoints ) const;
 | 
|---|
| 162 | 
 | 
|---|
| 163 |   // Clipping
 | 
|---|
| 164 | 
 | 
|---|
| 165 |     void        setClipping( bool );            // set clipping on/off
 | 
|---|
| 166 |     bool        hasClipping() const;
 | 
|---|
| 167 |     QRegion clipRegion( CoordinateMode = CoordDevice ) const;
 | 
|---|
| 168 |     void        setClipRect( const QRect &, CoordinateMode = CoordDevice );     // set clip rectangle
 | 
|---|
| 169 |     void        setClipRect( int x, int y, int w, int h, CoordinateMode = CoordDevice );
 | 
|---|
| 170 |     void        setClipRegion( const QRegion &, CoordinateMode = CoordDevice );// set clip region
 | 
|---|
| 171 | 
 | 
|---|
| 172 |   // Graphics drawing functions
 | 
|---|
| 173 | 
 | 
|---|
| 174 |     void        drawPoint( int x, int y );
 | 
|---|
| 175 |     void        drawPoint( const QPoint & );
 | 
|---|
| 176 |     void        drawPoints( const QPointArray& a,
 | 
|---|
| 177 |                             int index=0, int npoints=-1 );
 | 
|---|
| 178 |     void        moveTo( int x, int y );
 | 
|---|
| 179 |     void        moveTo( const QPoint & );
 | 
|---|
| 180 |     void        lineTo( int x, int y );
 | 
|---|
| 181 |     void        lineTo( const QPoint & );
 | 
|---|
| 182 |     void        drawLine( int x1, int y1, int x2, int y2 );
 | 
|---|
| 183 |     void        drawLine( const QPoint &, const QPoint & );
 | 
|---|
| 184 |     void        drawRect( int x, int y, int w, int h );
 | 
|---|
| 185 |     void        drawRect( const QRect & );
 | 
|---|
| 186 |     void        drawWinFocusRect( int x, int y, int w, int h );
 | 
|---|
| 187 |     void        drawWinFocusRect( int x, int y, int w, int h,
 | 
|---|
| 188 |                                   const QColor &bgColor );
 | 
|---|
| 189 |     void        drawWinFocusRect( const QRect & );
 | 
|---|
| 190 |     void        drawWinFocusRect( const QRect &,
 | 
|---|
| 191 |                                   const QColor &bgColor );
 | 
|---|
| 192 |     void        drawRoundRect( int x, int y, int w, int h, int = 25, int = 25 );
 | 
|---|
| 193 |     void        drawRoundRect( const QRect &, int = 25, int = 25 );
 | 
|---|
| 194 |     void        drawEllipse( int x, int y, int w, int h );
 | 
|---|
| 195 |     void        drawEllipse( const QRect & );
 | 
|---|
| 196 |     void        drawArc( int x, int y, int w, int h, int a, int alen );
 | 
|---|
| 197 |     void        drawArc( const QRect &, int a, int alen );
 | 
|---|
| 198 |     void        drawPie( int x, int y, int w, int h, int a, int alen );
 | 
|---|
| 199 |     void        drawPie( const QRect &, int a, int alen );
 | 
|---|
| 200 |     void        drawChord( int x, int y, int w, int h, int a, int alen );
 | 
|---|
| 201 |     void        drawChord( const QRect &, int a, int alen );
 | 
|---|
| 202 |     void        drawLineSegments( const QPointArray &,
 | 
|---|
| 203 |                                   int index=0, int nlines=-1 );
 | 
|---|
| 204 |     void        drawPolyline( const QPointArray &,
 | 
|---|
| 205 |                               int index=0, int npoints=-1 );
 | 
|---|
| 206 |     void        drawPolygon( const QPointArray &, bool winding=FALSE,
 | 
|---|
| 207 |                              int index=0, int npoints=-1 );
 | 
|---|
| 208 |     void        drawConvexPolygon( const QPointArray &,
 | 
|---|
| 209 |                              int index=0, int npoints=-1 );
 | 
|---|
| 210 | #ifndef QT_NO_BEZIER
 | 
|---|
| 211 |     void        drawCubicBezier( const QPointArray &, int index=0 );
 | 
|---|
| 212 | #endif
 | 
|---|
| 213 |     void        drawPixmap( int x, int y, const QPixmap &,
 | 
|---|
| 214 |                             int sx=0, int sy=0, int sw=-1, int sh=-1 );
 | 
|---|
| 215 |     void        drawPixmap( const QPoint &, const QPixmap &,
 | 
|---|
| 216 |                             const QRect &sr );
 | 
|---|
| 217 |     void        drawPixmap( const QPoint &, const QPixmap & );
 | 
|---|
| 218 |     void        drawPixmap( const QRect &, const QPixmap & );
 | 
|---|
| 219 |     void        drawImage( int x, int y, const QImage &,
 | 
|---|
| 220 |                            int sx = 0, int sy = 0, int sw = -1, int sh = -1,
 | 
|---|
| 221 |                            int conversionFlags = 0 );
 | 
|---|
| 222 |     void        drawImage( const QPoint &, const QImage &,
 | 
|---|
| 223 |                            const QRect &sr, int conversionFlags = 0 );
 | 
|---|
| 224 |     void        drawImage( const QPoint &, const QImage &,
 | 
|---|
| 225 |                            int conversion_flags = 0 );
 | 
|---|
| 226 |     void        drawImage( const QRect &, const QImage & );
 | 
|---|
| 227 |     void        drawTiledPixmap( int x, int y, int w, int h, const QPixmap &,
 | 
|---|
| 228 |                                  int sx=0, int sy=0 );
 | 
|---|
| 229 |     void        drawTiledPixmap( const QRect &, const QPixmap &,
 | 
|---|
| 230 |                                  const QPoint & );
 | 
|---|
| 231 |     void        drawTiledPixmap( const QRect &, const QPixmap & );
 | 
|---|
| 232 | #ifndef QT_NO_PICTURE
 | 
|---|
| 233 |     void        drawPicture( const QPicture & );
 | 
|---|
| 234 |     void        drawPicture( int x, int y, const QPicture & );
 | 
|---|
| 235 |     void        drawPicture( const QPoint &, const QPicture & );
 | 
|---|
| 236 | #endif
 | 
|---|
| 237 | 
 | 
|---|
| 238 |     void        fillRect( int x, int y, int w, int h, const QBrush & );
 | 
|---|
| 239 |     void        fillRect( const QRect &, const QBrush & );
 | 
|---|
| 240 |     void        eraseRect( int x, int y, int w, int h );
 | 
|---|
| 241 |     void        eraseRect( const QRect & );
 | 
|---|
| 242 | 
 | 
|---|
| 243 |   // Text drawing functions
 | 
|---|
| 244 | 
 | 
|---|
| 245 |     enum TextDirection {
 | 
|---|
| 246 |         Auto,
 | 
|---|
| 247 |         RTL,
 | 
|---|
| 248 |         LTR
 | 
|---|
| 249 |     };
 | 
|---|
| 250 | 
 | 
|---|
| 251 |     void        drawText( int x, int y, const QString &, int len = -1, TextDirection dir = Auto );
 | 
|---|
| 252 |     void        drawText( const QPoint &, const QString &, int len = -1, TextDirection dir = Auto );
 | 
|---|
| 253 | 
 | 
|---|
| 254 |     void     drawText( int x, int y, const QString &, int pos, int len, TextDirection dir = Auto );
 | 
|---|
| 255 |     void     drawText( const QPoint &p, const QString &, int pos, int len, TextDirection dir = Auto );
 | 
|---|
| 256 | 
 | 
|---|
| 257 |     void        drawText( int x, int y, int w, int h, int flags,
 | 
|---|
| 258 |                           const QString&, int len = -1, QRect *br=0,
 | 
|---|
| 259 |                           QTextParag **intern=0 );
 | 
|---|
| 260 |     void        drawText( const QRect &, int flags,
 | 
|---|
| 261 |                           const QString&, int len = -1, QRect *br=0,
 | 
|---|
| 262 |                           QTextParag **intern=0 );
 | 
|---|
| 263 | 
 | 
|---|
| 264 |     void drawTextItem( int x, int y, const QTextItem &ti, int textflags = 0 );
 | 
|---|
| 265 |     void drawTextItem( const QPoint& p, const QTextItem &ti, int textflags = 0 );
 | 
|---|
| 266 | 
 | 
|---|
| 267 |     QRect       boundingRect( int x, int y, int w, int h, int flags,
 | 
|---|
| 268 |                               const QString&, int len = -1, QTextParag **intern=0 );
 | 
|---|
| 269 |     QRect       boundingRect( const QRect &, int flags,
 | 
|---|
| 270 |                               const QString&, int len = -1, QTextParag **intern=0 );
 | 
|---|
| 271 | 
 | 
|---|
| 272 |     int         tabStops() const;
 | 
|---|
| 273 |     void        setTabStops( int );
 | 
|---|
| 274 |     int        *tabArray() const;
 | 
|---|
| 275 |     void        setTabArray( int * );
 | 
|---|
| 276 | 
 | 
|---|
| 277 |     // Other functions
 | 
|---|
| 278 | 
 | 
|---|
| 279 | #if defined(Q_WS_WIN)
 | 
|---|
| 280 |     HDC         handle() const;
 | 
|---|
| 281 | #elif defined(Q_WS_PM)
 | 
|---|
| 282 |     HPS         handle() const;
 | 
|---|
| 283 | #elif defined(Q_WS_X11) || defined(Q_WS_MAC)
 | 
|---|
| 284 |     HANDLE      handle() const;
 | 
|---|
| 285 | #endif
 | 
|---|
| 286 | 
 | 
|---|
| 287 | 
 | 
|---|
| 288 |     static void initialize();
 | 
|---|
| 289 |     static void cleanup();
 | 
|---|
| 290 | 
 | 
|---|
| 291 | private:
 | 
|---|
| 292 |     void        init();
 | 
|---|
| 293 |     void        destroy();
 | 
|---|
| 294 |     void        updateFont();
 | 
|---|
| 295 |     void        updatePen();
 | 
|---|
| 296 |     void        updateBrush();
 | 
|---|
| 297 | #ifndef QT_NO_TRANSFORMATIONS
 | 
|---|
| 298 |     void        updateXForm();
 | 
|---|
| 299 |     void        updateInvXForm();
 | 
|---|
| 300 | #endif
 | 
|---|
| 301 |     void        map( int, int, int *rx, int *ry ) const;
 | 
|---|
| 302 |     void        map( int, int, int, int, int *, int *, int *, int * ) const;
 | 
|---|
| 303 |     void        mapInv( int, int, int *, int * ) const;
 | 
|---|
| 304 |     void        mapInv( int, int, int, int, int *, int *, int *, int * ) const;
 | 
|---|
| 305 | #if defined(Q_WS_PM)
 | 
|---|
| 306 |     void        drawPolyInternal( const QPointArray &, bool close=TRUE,
 | 
|---|
| 307 |                                   bool winding=FALSE, int index=0, int npoints=-1,
 | 
|---|
| 308 |                                   bool disjoint=FALSE );
 | 
|---|
| 309 |     enum        ArcClose { CloseNone, CloseChord, ClosePie };                                      
 | 
|---|
| 310 |     void        drawArcInternal( int x, int y, int w, int h, int a = 0,
 | 
|---|
| 311 |                                  int alen = 360*16, ArcClose close = CloseChord );
 | 
|---|
| 312 |     void        drawWinFocusRectInternal( int x, int y, int w, int h,
 | 
|---|
| 313 |                                           const QColor &bgCol, bool xormode );
 | 
|---|
| 314 |     void        drawRectInternal( int x, int y, int w, int h, int wRnd, int hRnd ); 
 | 
|---|
| 315 | #else    
 | 
|---|
| 316 |     void        drawPolyInternal( const QPointArray &, bool close=TRUE );
 | 
|---|
| 317 | #endif    
 | 
|---|
| 318 |     void        drawWinFocusRect( int x, int y, int w, int h, bool xorPaint,
 | 
|---|
| 319 |                                   const QColor &penColor );
 | 
|---|
| 320 | 
 | 
|---|
| 321 |     enum { IsActive=0x01, ExtDev=0x02, IsStartingUp=0x04, NoCache=0x08,
 | 
|---|
| 322 |            VxF=0x10, WxF=0x20, ClipOn=0x40, SafePolygon=0x80, MonoDev=0x100,
 | 
|---|
| 323 |            DirtyFont=0x200, DirtyPen=0x400, DirtyBrush=0x800,
 | 
|---|
| 324 |            RGBColor=0x1000, FontMet=0x2000, FontInf=0x4000, CtorBegin=0x8000,
 | 
|---|
| 325 |            UsePrivateCx = 0x10000, VolatileDC = 0x20000, Qt2Compat = 0x40000 };
 | 
|---|
| 326 |     uint        flags;
 | 
|---|
| 327 |     bool        testf( uint b ) const { return (flags&b)!=0; }
 | 
|---|
| 328 |     void        setf( uint b )  { flags |= b; }
 | 
|---|
| 329 |     void        setf( uint b, bool v );
 | 
|---|
| 330 |     void        clearf( uint b )        { flags &= (uint)(~b); }
 | 
|---|
| 331 |     void        fix_neg_rect( int *x, int *y, int *w, int *h );
 | 
|---|
| 332 | 
 | 
|---|
| 333 |     QPainterPrivate *d;
 | 
|---|
| 334 |     QPaintDevice *pdev;
 | 
|---|
| 335 |     QColor      bg_col;
 | 
|---|
| 336 |     uchar       bg_mode;
 | 
|---|
| 337 |     uchar       rop;
 | 
|---|
| 338 |     uchar       pu;
 | 
|---|
| 339 |     QPoint      bro;
 | 
|---|
| 340 |     QFont       cfont;
 | 
|---|
| 341 |     QFont *pfont;       // font used for metrics (might be different for printers)
 | 
|---|
| 342 |     QPen        cpen;
 | 
|---|
| 343 |     QBrush      cbrush;
 | 
|---|
| 344 |     QRegion     crgn;
 | 
|---|
| 345 |     int         tabstops;
 | 
|---|
| 346 |     int        *tabarray;
 | 
|---|
| 347 |     int         tabarraylen;
 | 
|---|
| 348 |     bool        block_ext;      // for temporary blocking of external devices
 | 
|---|
| 349 | 
 | 
|---|
| 350 |     // Transformations
 | 
|---|
| 351 | #ifndef QT_NO_TRANSFORMATIONS
 | 
|---|
| 352 |     QCOORD      wx, wy, ww, wh;
 | 
|---|
| 353 |     QCOORD      vx, vy, vw, vh;
 | 
|---|
| 354 |     QWMatrix    wxmat;
 | 
|---|
| 355 | 
 | 
|---|
| 356 |     // Cached composition (and inverse) of transformations
 | 
|---|
| 357 |     QWMatrix    xmat;
 | 
|---|
| 358 |     QWMatrix    ixmat;
 | 
|---|
| 359 | 
 | 
|---|
| 360 | 
 | 
|---|
| 361 | 
 | 
|---|
| 362 |     double      m11() const { return xmat.m11(); }
 | 
|---|
| 363 |     double      m12() const { return xmat.m12(); }
 | 
|---|
| 364 |     double      m21() const { return xmat.m21(); }
 | 
|---|
| 365 |     double      m22() const { return xmat.m22(); }
 | 
|---|
| 366 |     double      dx() const { return xmat.dx(); }
 | 
|---|
| 367 |     double      dy() const { return xmat.dy(); }
 | 
|---|
| 368 |     double      im11() const { return ixmat.m11(); }
 | 
|---|
| 369 |     double      im12() const { return ixmat.m12(); }
 | 
|---|
| 370 |     double      im21() const { return ixmat.m21(); }
 | 
|---|
| 371 |     double      im22() const { return ixmat.m22(); }
 | 
|---|
| 372 |     double      idx() const { return ixmat.dx(); }
 | 
|---|
| 373 |     double      idy() const { return ixmat.dy(); }
 | 
|---|
| 374 | 
 | 
|---|
| 375 |     int         txop;
 | 
|---|
| 376 |     bool        txinv;
 | 
|---|
| 377 | 
 | 
|---|
| 378 | #else
 | 
|---|
| 379 |     // even without transformations we still have translations
 | 
|---|
| 380 |     int         xlatex;
 | 
|---|
| 381 |     int         xlatey;
 | 
|---|
| 382 | #endif
 | 
|---|
| 383 | 
 | 
|---|
| 384 | #if !defined(Q_WS_PM)
 | 
|---|
| 385 |     void       *penRef;                         // pen cache ref
 | 
|---|
| 386 |     void       *brushRef;                       // brush cache ref
 | 
|---|
| 387 | #endif    
 | 
|---|
| 388 |     void       *ps_stack;
 | 
|---|
| 389 |     void       *wm_stack;
 | 
|---|
| 390 |     void        killPStack();
 | 
|---|
| 391 | 
 | 
|---|
| 392 | protected:
 | 
|---|
| 393 | #ifdef Q_OS_TEMP
 | 
|---|
| 394 |     QPoint      internalCurrentPos;
 | 
|---|
| 395 |     uint        old_pix;                        // ### All win platforms in 4.0
 | 
|---|
| 396 | #endif
 | 
|---|
| 397 | #if defined(Q_WS_WIN)
 | 
|---|
| 398 |     friend class QFontEngineWin;
 | 
|---|
| 399 |     friend class QFontEngineBox;
 | 
|---|
| 400 |     QT_WIN_PAINTER_MEMBERS
 | 
|---|
| 401 | #elif defined(Q_WS_PM)
 | 
|---|
| 402 |     bool setNativeXForm( bool assumeYNegation );
 | 
|---|
| 403 |     void clearNativeXForm();
 | 
|---|
| 404 |     friend class QFontEnginePM;
 | 
|---|
| 405 |     HPS         hps;
 | 
|---|
| 406 |     HPAL        holdpal;
 | 
|---|
| 407 |     HRGN        holdrgn;
 | 
|---|
| 408 |     HBITMAP     hbrushbm;
 | 
|---|
| 409 |     uint        nocolBrush  : 1;
 | 
|---|
| 410 |     uint        pixmapBrush : 1;
 | 
|---|
| 411 |     int         devh;
 | 
|---|
| 412 |     QRegion     repaintRgn;
 | 
|---|
| 413 | #elif defined(Q_WS_X11)
 | 
|---|
| 414 |     friend class QFontEngineXLFD;
 | 
|---|
| 415 |     friend class QFontEngineXft;
 | 
|---|
| 416 |     friend class QFontEngineBox;
 | 
|---|
| 417 |     Display    *dpy;                            // current display
 | 
|---|
| 418 |     int         scrn;                           // current screen
 | 
|---|
| 419 |     Qt::HANDLE  hd;                             // handle to drawable
 | 
|---|
| 420 |     Qt::HANDLE  rendhd;                         // handle to Xft draw
 | 
|---|
| 421 |     GC          gc;                             // graphics context (standard)
 | 
|---|
| 422 |     GC          gc_brush;                       // graphics contect for brush
 | 
|---|
| 423 |     QPoint      curPt;                          // current point
 | 
|---|
| 424 |     uint        clip_serial;                    // clipping serial number
 | 
|---|
| 425 | #elif defined(Q_WS_MAC)
 | 
|---|
| 426 |     Qt::HANDLE  hd;                             // handle to drawable
 | 
|---|
| 427 |     void initPaintDevice(bool force=FALSE, QPoint *off=NULL, QRegion *rgn=NULL);
 | 
|---|
| 428 |     friend const QRegion &qt_mac_update_painter(QPainter *, bool);
 | 
|---|
| 429 |     friend class QFontEngineMac;
 | 
|---|
| 430 |     friend class QMacPainter;
 | 
|---|
| 431 | #elif defined(Q_WS_QWS)
 | 
|---|
| 432 |     friend class QFontEngine;
 | 
|---|
| 433 |     QGfx * gfx;
 | 
|---|
| 434 |     friend void qwsUpdateActivePainters();
 | 
|---|
| 435 | #endif
 | 
|---|
| 436 |     friend class QFontMetrics;
 | 
|---|
| 437 |     friend class QFontInfo;
 | 
|---|
| 438 |     friend class QTextLayout;
 | 
|---|
| 439 |     friend void qt_format_text( const QFont &, const QRect &r,
 | 
|---|
| 440 |                      int tf, const QString& str, int len, QRect *brect,
 | 
|---|
| 441 |                      int tabstops, int* tabarray, int tabarraylen,
 | 
|---|
| 442 |                      QTextParag **internal, QPainter* painter );
 | 
|---|
| 443 |     friend void qt_draw_background( QPainter *p, int x, int y, int w,  int h );
 | 
|---|
| 444 |     friend void qt_draw_transformed_rect( QPainter *p,  int x, int y, int w,  int h, bool fill );
 | 
|---|
| 445 |     friend class QPrinter;
 | 
|---|
| 446 | 
 | 
|---|
| 447 | private:        // Disabled copy constructor and operator=
 | 
|---|
| 448 | #if defined(Q_DISABLE_COPY)
 | 
|---|
| 449 |     QPainter( const QPainter & );
 | 
|---|
| 450 |     QPainter &operator=( const QPainter & );
 | 
|---|
| 451 | #endif
 | 
|---|
| 452 | 
 | 
|---|
| 453 |     enum TransformationCodes {
 | 
|---|
| 454 |         TxNone      = 0,                // transformation codes
 | 
|---|
| 455 |         TxTranslate = 1,                // copy in qpainter_*.cpp
 | 
|---|
| 456 |         TxScale     = 2,
 | 
|---|
| 457 |         TxRotShear  = 3
 | 
|---|
| 458 |     };
 | 
|---|
| 459 | };
 | 
|---|
| 460 | 
 | 
|---|
| 461 | 
 | 
|---|
| 462 | /*****************************************************************************
 | 
|---|
| 463 |   QPainter member functions
 | 
|---|
| 464 |  *****************************************************************************/
 | 
|---|
| 465 | 
 | 
|---|
| 466 | inline QPaintDevice *QPainter::device() const
 | 
|---|
| 467 | {
 | 
|---|
| 468 |     return pdev;
 | 
|---|
| 469 | }
 | 
|---|
| 470 | 
 | 
|---|
| 471 | inline bool QPainter::isActive() const
 | 
|---|
| 472 | {
 | 
|---|
| 473 |     return testf(IsActive);
 | 
|---|
| 474 | }
 | 
|---|
| 475 | 
 | 
|---|
| 476 | inline const QFont &QPainter::font() const
 | 
|---|
| 477 | {
 | 
|---|
| 478 |     return cfont;
 | 
|---|
| 479 | }
 | 
|---|
| 480 | 
 | 
|---|
| 481 | inline const QPen &QPainter::pen() const
 | 
|---|
| 482 | {
 | 
|---|
| 483 |     return cpen;
 | 
|---|
| 484 | }
 | 
|---|
| 485 | 
 | 
|---|
| 486 | inline const QBrush &QPainter::brush() const
 | 
|---|
| 487 | {
 | 
|---|
| 488 |     return cbrush;
 | 
|---|
| 489 | }
 | 
|---|
| 490 | 
 | 
|---|
| 491 | /*
 | 
|---|
| 492 | inline PaintUnit QPainter::unit() const
 | 
|---|
| 493 | {
 | 
|---|
| 494 |     return (PaintUnit)pu;
 | 
|---|
| 495 | }
 | 
|---|
| 496 | */
 | 
|---|
| 497 | 
 | 
|---|
| 498 | inline const QColor &QPainter::backgroundColor() const
 | 
|---|
| 499 | {
 | 
|---|
| 500 |     return bg_col;
 | 
|---|
| 501 | }
 | 
|---|
| 502 | 
 | 
|---|
| 503 | inline Qt::BGMode QPainter::backgroundMode() const
 | 
|---|
| 504 | {
 | 
|---|
| 505 |     return (BGMode)bg_mode;
 | 
|---|
| 506 | }
 | 
|---|
| 507 | 
 | 
|---|
| 508 | inline Qt::RasterOp QPainter::rasterOp() const
 | 
|---|
| 509 | {
 | 
|---|
| 510 |     return (RasterOp)rop;
 | 
|---|
| 511 | }
 | 
|---|
| 512 | 
 | 
|---|
| 513 | inline const QPoint &QPainter::brushOrigin() const
 | 
|---|
| 514 | {
 | 
|---|
| 515 |     return bro;
 | 
|---|
| 516 | }
 | 
|---|
| 517 | 
 | 
|---|
| 518 | inline bool QPainter::hasViewXForm() const
 | 
|---|
| 519 | {
 | 
|---|
| 520 | #ifndef QT_NO_TRANSFORMATIONS
 | 
|---|
| 521 |     return testf(VxF);
 | 
|---|
| 522 | #else
 | 
|---|
| 523 |     return xlatex || xlatey;
 | 
|---|
| 524 | #endif
 | 
|---|
| 525 | }
 | 
|---|
| 526 | 
 | 
|---|
| 527 | inline bool QPainter::hasWorldXForm() const
 | 
|---|
| 528 | {
 | 
|---|
| 529 | #ifndef QT_NO_TRANSFORMATIONS
 | 
|---|
| 530 |     return testf(WxF);
 | 
|---|
| 531 | #else
 | 
|---|
| 532 |     return xlatex || xlatey;
 | 
|---|
| 533 | #endif
 | 
|---|
| 534 | }
 | 
|---|
| 535 | 
 | 
|---|
| 536 | inline double QPainter::translationX() const
 | 
|---|
| 537 | {
 | 
|---|
| 538 | #ifndef QT_NO_TRANSFORMATIONS
 | 
|---|
| 539 |     return worldMatrix().dx();
 | 
|---|
| 540 | #else
 | 
|---|
| 541 |     return xlatex;
 | 
|---|
| 542 | #endif
 | 
|---|
| 543 | }
 | 
|---|
| 544 | 
 | 
|---|
| 545 | inline double QPainter::translationY() const
 | 
|---|
| 546 | {
 | 
|---|
| 547 | #ifndef QT_NO_TRANSFORMATIONS
 | 
|---|
| 548 |     return worldMatrix().dy();
 | 
|---|
| 549 | #else
 | 
|---|
| 550 |     return xlatey;
 | 
|---|
| 551 | #endif
 | 
|---|
| 552 | }
 | 
|---|
| 553 | 
 | 
|---|
| 554 | 
 | 
|---|
| 555 | inline bool QPainter::hasClipping() const
 | 
|---|
| 556 | {
 | 
|---|
| 557 |     return testf(ClipOn);
 | 
|---|
| 558 | }
 | 
|---|
| 559 | 
 | 
|---|
| 560 | inline int QPainter::tabStops() const
 | 
|---|
| 561 | {
 | 
|---|
| 562 |     return tabstops;
 | 
|---|
| 563 | }
 | 
|---|
| 564 | 
 | 
|---|
| 565 | inline int *QPainter::tabArray() const
 | 
|---|
| 566 | {
 | 
|---|
| 567 |     return tabarray;
 | 
|---|
| 568 | }
 | 
|---|
| 569 | 
 | 
|---|
| 570 | #if defined(Q_WS_WIN)
 | 
|---|
| 571 | inline HDC QPainter::handle() const
 | 
|---|
| 572 | {
 | 
|---|
| 573 |     return hdc;
 | 
|---|
| 574 | }
 | 
|---|
| 575 | #elif defined(Q_WS_PM)
 | 
|---|
| 576 | inline HPS QPainter::handle() const
 | 
|---|
| 577 | {
 | 
|---|
| 578 |     return hps;
 | 
|---|
| 579 | }
 | 
|---|
| 580 | #elif defined(Q_WS_X11) || defined(Q_WS_MAC)
 | 
|---|
| 581 | inline Qt::HANDLE QPainter::handle() const
 | 
|---|
| 582 | {
 | 
|---|
| 583 |     return hd;
 | 
|---|
| 584 | }
 | 
|---|
| 585 | #endif
 | 
|---|
| 586 | 
 | 
|---|
| 587 | inline void QPainter::setBrushOrigin( const QPoint &p )
 | 
|---|
| 588 | {
 | 
|---|
| 589 |     setBrushOrigin( p.x(), p.y() );
 | 
|---|
| 590 | }
 | 
|---|
| 591 | 
 | 
|---|
| 592 | #ifndef QT_NO_TRANSFORMATIONS
 | 
|---|
| 593 | inline void QPainter::setWindow( const QRect &r )
 | 
|---|
| 594 | {
 | 
|---|
| 595 |     setWindow( r.x(), r.y(), r.width(), r.height() );
 | 
|---|
| 596 | }
 | 
|---|
| 597 | 
 | 
|---|
| 598 | inline void QPainter::setViewport( const QRect &r )
 | 
|---|
| 599 | {
 | 
|---|
| 600 |     setViewport( r.x(), r.y(), r.width(), r.height() );
 | 
|---|
| 601 | }
 | 
|---|
| 602 | #endif
 | 
|---|
| 603 | 
 | 
|---|
| 604 | inline void QPainter::setClipRect( int x, int y, int w, int h, CoordinateMode m )
 | 
|---|
| 605 | {
 | 
|---|
| 606 |     setClipRect( QRect(x,y,w,h), m );
 | 
|---|
| 607 | }
 | 
|---|
| 608 | 
 | 
|---|
| 609 | inline void QPainter::drawPoint( const QPoint &p )
 | 
|---|
| 610 | {
 | 
|---|
| 611 |     drawPoint( p.x(), p.y() );
 | 
|---|
| 612 | }
 | 
|---|
| 613 | 
 | 
|---|
| 614 | inline void QPainter::moveTo( const QPoint &p )
 | 
|---|
| 615 | {
 | 
|---|
| 616 |     moveTo( p.x(), p.y() );
 | 
|---|
| 617 | }
 | 
|---|
| 618 | 
 | 
|---|
| 619 | inline void QPainter::lineTo( const QPoint &p )
 | 
|---|
| 620 | {
 | 
|---|
| 621 |     lineTo( p.x(), p.y() );
 | 
|---|
| 622 | }
 | 
|---|
| 623 | 
 | 
|---|
| 624 | inline void QPainter::drawLine( const QPoint &p1, const QPoint &p2 )
 | 
|---|
| 625 | {
 | 
|---|
| 626 |     drawLine( p1.x(), p1.y(), p2.x(), p2.y() );
 | 
|---|
| 627 | }
 | 
|---|
| 628 | 
 | 
|---|
| 629 | inline void QPainter::drawRect( const QRect &r )
 | 
|---|
| 630 | {
 | 
|---|
| 631 |     drawRect( r.x(), r.y(), r.width(), r.height() );
 | 
|---|
| 632 | }
 | 
|---|
| 633 | 
 | 
|---|
| 634 | inline void QPainter::drawWinFocusRect( const QRect &r )
 | 
|---|
| 635 | {
 | 
|---|
| 636 |     drawWinFocusRect( r.x(), r.y(), r.width(), r.height() );
 | 
|---|
| 637 | }
 | 
|---|
| 638 | 
 | 
|---|
| 639 | inline void QPainter::drawWinFocusRect( const QRect &r,const QColor &penColor )
 | 
|---|
| 640 | {
 | 
|---|
| 641 |     drawWinFocusRect( r.x(), r.y(), r.width(), r.height(), penColor );
 | 
|---|
| 642 | }
 | 
|---|
| 643 | 
 | 
|---|
| 644 | inline void QPainter::drawRoundRect( const QRect &r, int xRnd, int yRnd )
 | 
|---|
| 645 | {
 | 
|---|
| 646 |     drawRoundRect( r.x(), r.y(), r.width(), r.height(), xRnd, yRnd );
 | 
|---|
| 647 | }
 | 
|---|
| 648 | 
 | 
|---|
| 649 | inline void QPainter::drawEllipse( const QRect &r )
 | 
|---|
| 650 | {
 | 
|---|
| 651 |     drawEllipse( r.x(), r.y(), r.width(), r.height() );
 | 
|---|
| 652 | }
 | 
|---|
| 653 | 
 | 
|---|
| 654 | inline void QPainter::drawArc( const QRect &r, int a, int alen )
 | 
|---|
| 655 | {
 | 
|---|
| 656 |     drawArc( r.x(), r.y(), r.width(), r.height(), a, alen );
 | 
|---|
| 657 | }
 | 
|---|
| 658 | 
 | 
|---|
| 659 | inline void QPainter::drawPie( const QRect &r, int a, int alen )
 | 
|---|
| 660 | {
 | 
|---|
| 661 |     drawPie( r.x(), r.y(), r.width(), r.height(), a, alen );
 | 
|---|
| 662 | }
 | 
|---|
| 663 | 
 | 
|---|
| 664 | inline void QPainter::drawChord( const QRect &r, int a, int alen )
 | 
|---|
| 665 | {
 | 
|---|
| 666 |     drawChord( r.x(), r.y(), r.width(), r.height(), a, alen );
 | 
|---|
| 667 | }
 | 
|---|
| 668 | 
 | 
|---|
| 669 | inline void QPainter::drawPixmap( const QPoint &p, const QPixmap &pm,
 | 
|---|
| 670 |                                   const QRect &sr )
 | 
|---|
| 671 | {
 | 
|---|
| 672 |     drawPixmap( p.x(), p.y(), pm, sr.x(), sr.y(), sr.width(), sr.height() );
 | 
|---|
| 673 | }
 | 
|---|
| 674 | 
 | 
|---|
| 675 | inline void QPainter::drawImage( const QPoint &p, const QImage &pm,
 | 
|---|
| 676 |                                  const QRect &sr, int conversionFlags )
 | 
|---|
| 677 | {
 | 
|---|
| 678 |     drawImage( p.x(), p.y(), pm,
 | 
|---|
| 679 |                sr.x(), sr.y(), sr.width(), sr.height(), conversionFlags );
 | 
|---|
| 680 | }
 | 
|---|
| 681 | 
 | 
|---|
| 682 | inline void QPainter::drawTiledPixmap( const QRect &r, const QPixmap &pm,
 | 
|---|
| 683 |                                        const QPoint &sp )
 | 
|---|
| 684 | {
 | 
|---|
| 685 |     drawTiledPixmap( r.x(), r.y(), r.width(), r.height(), pm, sp.x(), sp.y() );
 | 
|---|
| 686 | }
 | 
|---|
| 687 | 
 | 
|---|
| 688 | inline void QPainter::drawTiledPixmap( const QRect &r, const QPixmap &pm )
 | 
|---|
| 689 | {
 | 
|---|
| 690 |     drawTiledPixmap( r.x(), r.y(), r.width(), r.height(), pm, 0, 0 );
 | 
|---|
| 691 | }
 | 
|---|
| 692 | 
 | 
|---|
| 693 | inline void QPainter::fillRect( const QRect &r, const QBrush &brush )
 | 
|---|
| 694 | {
 | 
|---|
| 695 |     fillRect( r.x(), r.y(), r.width(), r.height(), brush );
 | 
|---|
| 696 | }
 | 
|---|
| 697 | 
 | 
|---|
| 698 | inline void QPainter::eraseRect( int x, int y, int w, int h )
 | 
|---|
| 699 | {
 | 
|---|
| 700 |     fillRect( x, y, w, h, backgroundColor() );
 | 
|---|
| 701 | }
 | 
|---|
| 702 | 
 | 
|---|
| 703 | inline void QPainter::eraseRect( const QRect &r )
 | 
|---|
| 704 | {
 | 
|---|
| 705 |     fillRect( r.x(), r.y(), r.width(), r.height(), backgroundColor() );
 | 
|---|
| 706 | }
 | 
|---|
| 707 | 
 | 
|---|
| 708 | inline void QPainter::drawText( const QPoint &p, const QString &s, int len, TextDirection dir )
 | 
|---|
| 709 | {
 | 
|---|
| 710 |     drawText( p.x(), p.y(), s, 0, len, dir );
 | 
|---|
| 711 | }
 | 
|---|
| 712 | 
 | 
|---|
| 713 | inline void QPainter::drawText( const QPoint &p, const QString &s, int pos, int len, TextDirection dir )
 | 
|---|
| 714 | {
 | 
|---|
| 715 |     drawText( p.x(), p.y(), s, pos, len, dir );
 | 
|---|
| 716 | }
 | 
|---|
| 717 | 
 | 
|---|
| 718 | inline void QPainter::drawText( int x, int y, int w, int h, int tf,
 | 
|---|
| 719 |                                 const QString& str, int len, QRect *br, QTextParag **i )
 | 
|---|
| 720 | {
 | 
|---|
| 721 |     QRect r(x, y, w, h);
 | 
|---|
| 722 |     drawText( r, tf, str, len, br, i );
 | 
|---|
| 723 | }
 | 
|---|
| 724 | 
 | 
|---|
| 725 | inline void QPainter::drawTextItem( const QPoint& p, const QTextItem &ti, int textflags )
 | 
|---|
| 726 | {
 | 
|---|
| 727 |     drawTextItem( p.x(), p.y(), ti, textflags );
 | 
|---|
| 728 | }
 | 
|---|
| 729 | 
 | 
|---|
| 730 | inline QRect QPainter::boundingRect( int x, int y, int w, int h, int tf,
 | 
|---|
| 731 |                                      const QString& str, int len, QTextParag **i )
 | 
|---|
| 732 | {
 | 
|---|
| 733 |     QRect r(x, y, w, h);
 | 
|---|
| 734 |     return boundingRect( r, tf, str, len, i );
 | 
|---|
| 735 | }
 | 
|---|
| 736 | 
 | 
|---|
| 737 | #if defined(Q_WS_QWS)
 | 
|---|
| 738 | inline QGfx * QPainter::internalGfx()
 | 
|---|
| 739 | {
 | 
|---|
| 740 |     return gfx;
 | 
|---|
| 741 | }
 | 
|---|
| 742 | #endif
 | 
|---|
| 743 | 
 | 
|---|
| 744 | #endif // QPAINTER_H
 | 
|---|