| 1 | /****************************************************************************
|
|---|
| 2 | ** $Id: qpainter.h 61 2006-02-06 21:43:39Z 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 def_crgn;
|
|---|
| 413 | QRegion cur_crgn;
|
|---|
| 414 | #elif defined(Q_WS_X11)
|
|---|
| 415 | friend class QFontEngineXLFD;
|
|---|
| 416 | friend class QFontEngineXft;
|
|---|
| 417 | friend class QFontEngineBox;
|
|---|
| 418 | Display *dpy; // current display
|
|---|
| 419 | int scrn; // current screen
|
|---|
| 420 | Qt::HANDLE hd; // handle to drawable
|
|---|
| 421 | Qt::HANDLE rendhd; // handle to Xft draw
|
|---|
| 422 | GC gc; // graphics context (standard)
|
|---|
| 423 | GC gc_brush; // graphics contect for brush
|
|---|
| 424 | QPoint curPt; // current point
|
|---|
| 425 | uint clip_serial; // clipping serial number
|
|---|
| 426 | #elif defined(Q_WS_MAC)
|
|---|
| 427 | Qt::HANDLE hd; // handle to drawable
|
|---|
| 428 | void initPaintDevice(bool force=FALSE, QPoint *off=NULL, QRegion *rgn=NULL);
|
|---|
| 429 | friend const QRegion &qt_mac_update_painter(QPainter *, bool);
|
|---|
| 430 | friend class QFontEngineMac;
|
|---|
| 431 | friend class QMacPainter;
|
|---|
| 432 | #elif defined(Q_WS_QWS)
|
|---|
| 433 | friend class QFontEngine;
|
|---|
| 434 | QGfx * gfx;
|
|---|
| 435 | friend void qwsUpdateActivePainters();
|
|---|
| 436 | #endif
|
|---|
| 437 | friend class QFontMetrics;
|
|---|
| 438 | friend class QFontInfo;
|
|---|
| 439 | friend class QTextLayout;
|
|---|
| 440 | friend void qt_format_text( const QFont &, const QRect &r,
|
|---|
| 441 | int tf, const QString& str, int len, QRect *brect,
|
|---|
| 442 | int tabstops, int* tabarray, int tabarraylen,
|
|---|
| 443 | QTextParag **internal, QPainter* painter );
|
|---|
| 444 | friend void qt_draw_background( QPainter *p, int x, int y, int w, int h );
|
|---|
| 445 | friend void qt_draw_transformed_rect( QPainter *p, int x, int y, int w, int h, bool fill );
|
|---|
| 446 | friend class QPrinter;
|
|---|
| 447 |
|
|---|
| 448 | private: // Disabled copy constructor and operator=
|
|---|
| 449 | #if defined(Q_DISABLE_COPY)
|
|---|
| 450 | QPainter( const QPainter & );
|
|---|
| 451 | QPainter &operator=( const QPainter & );
|
|---|
| 452 | #endif
|
|---|
| 453 |
|
|---|
| 454 | enum TransformationCodes {
|
|---|
| 455 | TxNone = 0, // transformation codes
|
|---|
| 456 | TxTranslate = 1, // copy in qpainter_*.cpp
|
|---|
| 457 | TxScale = 2,
|
|---|
| 458 | TxRotShear = 3
|
|---|
| 459 | };
|
|---|
| 460 | };
|
|---|
| 461 |
|
|---|
| 462 |
|
|---|
| 463 | /*****************************************************************************
|
|---|
| 464 | QPainter member functions
|
|---|
| 465 | *****************************************************************************/
|
|---|
| 466 |
|
|---|
| 467 | inline QPaintDevice *QPainter::device() const
|
|---|
| 468 | {
|
|---|
| 469 | return pdev;
|
|---|
| 470 | }
|
|---|
| 471 |
|
|---|
| 472 | inline bool QPainter::isActive() const
|
|---|
| 473 | {
|
|---|
| 474 | return testf(IsActive);
|
|---|
| 475 | }
|
|---|
| 476 |
|
|---|
| 477 | inline const QFont &QPainter::font() const
|
|---|
| 478 | {
|
|---|
| 479 | return cfont;
|
|---|
| 480 | }
|
|---|
| 481 |
|
|---|
| 482 | inline const QPen &QPainter::pen() const
|
|---|
| 483 | {
|
|---|
| 484 | return cpen;
|
|---|
| 485 | }
|
|---|
| 486 |
|
|---|
| 487 | inline const QBrush &QPainter::brush() const
|
|---|
| 488 | {
|
|---|
| 489 | return cbrush;
|
|---|
| 490 | }
|
|---|
| 491 |
|
|---|
| 492 | /*
|
|---|
| 493 | inline PaintUnit QPainter::unit() const
|
|---|
| 494 | {
|
|---|
| 495 | return (PaintUnit)pu;
|
|---|
| 496 | }
|
|---|
| 497 | */
|
|---|
| 498 |
|
|---|
| 499 | inline const QColor &QPainter::backgroundColor() const
|
|---|
| 500 | {
|
|---|
| 501 | return bg_col;
|
|---|
| 502 | }
|
|---|
| 503 |
|
|---|
| 504 | inline Qt::BGMode QPainter::backgroundMode() const
|
|---|
| 505 | {
|
|---|
| 506 | return (BGMode)bg_mode;
|
|---|
| 507 | }
|
|---|
| 508 |
|
|---|
| 509 | inline Qt::RasterOp QPainter::rasterOp() const
|
|---|
| 510 | {
|
|---|
| 511 | return (RasterOp)rop;
|
|---|
| 512 | }
|
|---|
| 513 |
|
|---|
| 514 | inline const QPoint &QPainter::brushOrigin() const
|
|---|
| 515 | {
|
|---|
| 516 | return bro;
|
|---|
| 517 | }
|
|---|
| 518 |
|
|---|
| 519 | inline bool QPainter::hasViewXForm() const
|
|---|
| 520 | {
|
|---|
| 521 | #ifndef QT_NO_TRANSFORMATIONS
|
|---|
| 522 | return testf(VxF);
|
|---|
| 523 | #else
|
|---|
| 524 | return xlatex || xlatey;
|
|---|
| 525 | #endif
|
|---|
| 526 | }
|
|---|
| 527 |
|
|---|
| 528 | inline bool QPainter::hasWorldXForm() const
|
|---|
| 529 | {
|
|---|
| 530 | #ifndef QT_NO_TRANSFORMATIONS
|
|---|
| 531 | return testf(WxF);
|
|---|
| 532 | #else
|
|---|
| 533 | return xlatex || xlatey;
|
|---|
| 534 | #endif
|
|---|
| 535 | }
|
|---|
| 536 |
|
|---|
| 537 | inline double QPainter::translationX() const
|
|---|
| 538 | {
|
|---|
| 539 | #ifndef QT_NO_TRANSFORMATIONS
|
|---|
| 540 | return worldMatrix().dx();
|
|---|
| 541 | #else
|
|---|
| 542 | return xlatex;
|
|---|
| 543 | #endif
|
|---|
| 544 | }
|
|---|
| 545 |
|
|---|
| 546 | inline double QPainter::translationY() const
|
|---|
| 547 | {
|
|---|
| 548 | #ifndef QT_NO_TRANSFORMATIONS
|
|---|
| 549 | return worldMatrix().dy();
|
|---|
| 550 | #else
|
|---|
| 551 | return xlatey;
|
|---|
| 552 | #endif
|
|---|
| 553 | }
|
|---|
| 554 |
|
|---|
| 555 |
|
|---|
| 556 | inline bool QPainter::hasClipping() const
|
|---|
| 557 | {
|
|---|
| 558 | return testf(ClipOn);
|
|---|
| 559 | }
|
|---|
| 560 |
|
|---|
| 561 | inline int QPainter::tabStops() const
|
|---|
| 562 | {
|
|---|
| 563 | return tabstops;
|
|---|
| 564 | }
|
|---|
| 565 |
|
|---|
| 566 | inline int *QPainter::tabArray() const
|
|---|
| 567 | {
|
|---|
| 568 | return tabarray;
|
|---|
| 569 | }
|
|---|
| 570 |
|
|---|
| 571 | #if defined(Q_WS_WIN)
|
|---|
| 572 | inline HDC QPainter::handle() const
|
|---|
| 573 | {
|
|---|
| 574 | return hdc;
|
|---|
| 575 | }
|
|---|
| 576 | #elif defined(Q_WS_PM)
|
|---|
| 577 | inline HPS QPainter::handle() const
|
|---|
| 578 | {
|
|---|
| 579 | return hps;
|
|---|
| 580 | }
|
|---|
| 581 | #elif defined(Q_WS_X11) || defined(Q_WS_MAC)
|
|---|
| 582 | inline Qt::HANDLE QPainter::handle() const
|
|---|
| 583 | {
|
|---|
| 584 | return hd;
|
|---|
| 585 | }
|
|---|
| 586 | #endif
|
|---|
| 587 |
|
|---|
| 588 | inline void QPainter::setBrushOrigin( const QPoint &p )
|
|---|
| 589 | {
|
|---|
| 590 | setBrushOrigin( p.x(), p.y() );
|
|---|
| 591 | }
|
|---|
| 592 |
|
|---|
| 593 | #ifndef QT_NO_TRANSFORMATIONS
|
|---|
| 594 | inline void QPainter::setWindow( const QRect &r )
|
|---|
| 595 | {
|
|---|
| 596 | setWindow( r.x(), r.y(), r.width(), r.height() );
|
|---|
| 597 | }
|
|---|
| 598 |
|
|---|
| 599 | inline void QPainter::setViewport( const QRect &r )
|
|---|
| 600 | {
|
|---|
| 601 | setViewport( r.x(), r.y(), r.width(), r.height() );
|
|---|
| 602 | }
|
|---|
| 603 | #endif
|
|---|
| 604 |
|
|---|
| 605 | inline void QPainter::setClipRect( int x, int y, int w, int h, CoordinateMode m )
|
|---|
| 606 | {
|
|---|
| 607 | setClipRect( QRect(x,y,w,h), m );
|
|---|
| 608 | }
|
|---|
| 609 |
|
|---|
| 610 | inline void QPainter::drawPoint( const QPoint &p )
|
|---|
| 611 | {
|
|---|
| 612 | drawPoint( p.x(), p.y() );
|
|---|
| 613 | }
|
|---|
| 614 |
|
|---|
| 615 | inline void QPainter::moveTo( const QPoint &p )
|
|---|
| 616 | {
|
|---|
| 617 | moveTo( p.x(), p.y() );
|
|---|
| 618 | }
|
|---|
| 619 |
|
|---|
| 620 | inline void QPainter::lineTo( const QPoint &p )
|
|---|
| 621 | {
|
|---|
| 622 | lineTo( p.x(), p.y() );
|
|---|
| 623 | }
|
|---|
| 624 |
|
|---|
| 625 | inline void QPainter::drawLine( const QPoint &p1, const QPoint &p2 )
|
|---|
| 626 | {
|
|---|
| 627 | drawLine( p1.x(), p1.y(), p2.x(), p2.y() );
|
|---|
| 628 | }
|
|---|
| 629 |
|
|---|
| 630 | inline void QPainter::drawRect( const QRect &r )
|
|---|
| 631 | {
|
|---|
| 632 | drawRect( r.x(), r.y(), r.width(), r.height() );
|
|---|
| 633 | }
|
|---|
| 634 |
|
|---|
| 635 | inline void QPainter::drawWinFocusRect( const QRect &r )
|
|---|
| 636 | {
|
|---|
| 637 | drawWinFocusRect( r.x(), r.y(), r.width(), r.height() );
|
|---|
| 638 | }
|
|---|
| 639 |
|
|---|
| 640 | inline void QPainter::drawWinFocusRect( const QRect &r,const QColor &penColor )
|
|---|
| 641 | {
|
|---|
| 642 | drawWinFocusRect( r.x(), r.y(), r.width(), r.height(), penColor );
|
|---|
| 643 | }
|
|---|
| 644 |
|
|---|
| 645 | inline void QPainter::drawRoundRect( const QRect &r, int xRnd, int yRnd )
|
|---|
| 646 | {
|
|---|
| 647 | drawRoundRect( r.x(), r.y(), r.width(), r.height(), xRnd, yRnd );
|
|---|
| 648 | }
|
|---|
| 649 |
|
|---|
| 650 | inline void QPainter::drawEllipse( const QRect &r )
|
|---|
| 651 | {
|
|---|
| 652 | drawEllipse( r.x(), r.y(), r.width(), r.height() );
|
|---|
| 653 | }
|
|---|
| 654 |
|
|---|
| 655 | inline void QPainter::drawArc( const QRect &r, int a, int alen )
|
|---|
| 656 | {
|
|---|
| 657 | drawArc( r.x(), r.y(), r.width(), r.height(), a, alen );
|
|---|
| 658 | }
|
|---|
| 659 |
|
|---|
| 660 | inline void QPainter::drawPie( const QRect &r, int a, int alen )
|
|---|
| 661 | {
|
|---|
| 662 | drawPie( r.x(), r.y(), r.width(), r.height(), a, alen );
|
|---|
| 663 | }
|
|---|
| 664 |
|
|---|
| 665 | inline void QPainter::drawChord( const QRect &r, int a, int alen )
|
|---|
| 666 | {
|
|---|
| 667 | drawChord( r.x(), r.y(), r.width(), r.height(), a, alen );
|
|---|
| 668 | }
|
|---|
| 669 |
|
|---|
| 670 | inline void QPainter::drawPixmap( const QPoint &p, const QPixmap &pm,
|
|---|
| 671 | const QRect &sr )
|
|---|
| 672 | {
|
|---|
| 673 | drawPixmap( p.x(), p.y(), pm, sr.x(), sr.y(), sr.width(), sr.height() );
|
|---|
| 674 | }
|
|---|
| 675 |
|
|---|
| 676 | inline void QPainter::drawImage( const QPoint &p, const QImage &pm,
|
|---|
| 677 | const QRect &sr, int conversionFlags )
|
|---|
| 678 | {
|
|---|
| 679 | drawImage( p.x(), p.y(), pm,
|
|---|
| 680 | sr.x(), sr.y(), sr.width(), sr.height(), conversionFlags );
|
|---|
| 681 | }
|
|---|
| 682 |
|
|---|
| 683 | inline void QPainter::drawTiledPixmap( const QRect &r, const QPixmap &pm,
|
|---|
| 684 | const QPoint &sp )
|
|---|
| 685 | {
|
|---|
| 686 | drawTiledPixmap( r.x(), r.y(), r.width(), r.height(), pm, sp.x(), sp.y() );
|
|---|
| 687 | }
|
|---|
| 688 |
|
|---|
| 689 | inline void QPainter::drawTiledPixmap( const QRect &r, const QPixmap &pm )
|
|---|
| 690 | {
|
|---|
| 691 | drawTiledPixmap( r.x(), r.y(), r.width(), r.height(), pm, 0, 0 );
|
|---|
| 692 | }
|
|---|
| 693 |
|
|---|
| 694 | inline void QPainter::fillRect( const QRect &r, const QBrush &brush )
|
|---|
| 695 | {
|
|---|
| 696 | fillRect( r.x(), r.y(), r.width(), r.height(), brush );
|
|---|
| 697 | }
|
|---|
| 698 |
|
|---|
| 699 | inline void QPainter::eraseRect( int x, int y, int w, int h )
|
|---|
| 700 | {
|
|---|
| 701 | fillRect( x, y, w, h, backgroundColor() );
|
|---|
| 702 | }
|
|---|
| 703 |
|
|---|
| 704 | inline void QPainter::eraseRect( const QRect &r )
|
|---|
| 705 | {
|
|---|
| 706 | fillRect( r.x(), r.y(), r.width(), r.height(), backgroundColor() );
|
|---|
| 707 | }
|
|---|
| 708 |
|
|---|
| 709 | inline void QPainter::drawText( const QPoint &p, const QString &s, int len, TextDirection dir )
|
|---|
| 710 | {
|
|---|
| 711 | drawText( p.x(), p.y(), s, 0, len, dir );
|
|---|
| 712 | }
|
|---|
| 713 |
|
|---|
| 714 | inline void QPainter::drawText( const QPoint &p, const QString &s, int pos, int len, TextDirection dir )
|
|---|
| 715 | {
|
|---|
| 716 | drawText( p.x(), p.y(), s, pos, len, dir );
|
|---|
| 717 | }
|
|---|
| 718 |
|
|---|
| 719 | inline void QPainter::drawText( int x, int y, int w, int h, int tf,
|
|---|
| 720 | const QString& str, int len, QRect *br, QTextParag **i )
|
|---|
| 721 | {
|
|---|
| 722 | QRect r(x, y, w, h);
|
|---|
| 723 | drawText( r, tf, str, len, br, i );
|
|---|
| 724 | }
|
|---|
| 725 |
|
|---|
| 726 | inline void QPainter::drawTextItem( const QPoint& p, const QTextItem &ti, int textflags )
|
|---|
| 727 | {
|
|---|
| 728 | drawTextItem( p.x(), p.y(), ti, textflags );
|
|---|
| 729 | }
|
|---|
| 730 |
|
|---|
| 731 | inline QRect QPainter::boundingRect( int x, int y, int w, int h, int tf,
|
|---|
| 732 | const QString& str, int len, QTextParag **i )
|
|---|
| 733 | {
|
|---|
| 734 | QRect r(x, y, w, h);
|
|---|
| 735 | return boundingRect( r, tf, str, len, i );
|
|---|
| 736 | }
|
|---|
| 737 |
|
|---|
| 738 | #if defined(Q_WS_QWS)
|
|---|
| 739 | inline QGfx * QPainter::internalGfx()
|
|---|
| 740 | {
|
|---|
| 741 | return gfx;
|
|---|
| 742 | }
|
|---|
| 743 | #endif
|
|---|
| 744 |
|
|---|
| 745 | #endif // QPAINTER_H
|
|---|