1 | /****************************************************************************
|
---|
2 | ** $Id: qpainter.h 2 2005-11-16 15:49:26Z 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_X11) || defined(Q_WS_MAC)
|
---|
282 | HANDLE handle() const;
|
---|
283 | #endif
|
---|
284 |
|
---|
285 |
|
---|
286 | static void initialize();
|
---|
287 | static void cleanup();
|
---|
288 |
|
---|
289 | private:
|
---|
290 | void init();
|
---|
291 | void destroy();
|
---|
292 | void updateFont();
|
---|
293 | void updatePen();
|
---|
294 | void updateBrush();
|
---|
295 | #ifndef QT_NO_TRANSFORMATIONS
|
---|
296 | void updateXForm();
|
---|
297 | void updateInvXForm();
|
---|
298 | #endif
|
---|
299 | void map( int, int, int *rx, int *ry ) const;
|
---|
300 | void map( int, int, int, int, int *, int *, int *, int * ) const;
|
---|
301 | void mapInv( int, int, int *, int * ) const;
|
---|
302 | void mapInv( int, int, int, int, int *, int *, int *, int * ) const;
|
---|
303 | void drawPolyInternal( const QPointArray &, bool close=TRUE );
|
---|
304 | void drawWinFocusRect( int x, int y, int w, int h, bool xorPaint,
|
---|
305 | const QColor &penColor );
|
---|
306 |
|
---|
307 | enum { IsActive=0x01, ExtDev=0x02, IsStartingUp=0x04, NoCache=0x08,
|
---|
308 | VxF=0x10, WxF=0x20, ClipOn=0x40, SafePolygon=0x80, MonoDev=0x100,
|
---|
309 | DirtyFont=0x200, DirtyPen=0x400, DirtyBrush=0x800,
|
---|
310 | RGBColor=0x1000, FontMet=0x2000, FontInf=0x4000, CtorBegin=0x8000,
|
---|
311 | UsePrivateCx = 0x10000, VolatileDC = 0x20000, Qt2Compat = 0x40000 };
|
---|
312 | uint flags;
|
---|
313 | bool testf( uint b ) const { return (flags&b)!=0; }
|
---|
314 | void setf( uint b ) { flags |= b; }
|
---|
315 | void setf( uint b, bool v );
|
---|
316 | void clearf( uint b ) { flags &= (uint)(~b); }
|
---|
317 | void fix_neg_rect( int *x, int *y, int *w, int *h );
|
---|
318 |
|
---|
319 | QPainterPrivate *d;
|
---|
320 | QPaintDevice *pdev;
|
---|
321 | QColor bg_col;
|
---|
322 | uchar bg_mode;
|
---|
323 | uchar rop;
|
---|
324 | uchar pu;
|
---|
325 | QPoint bro;
|
---|
326 | QFont cfont;
|
---|
327 | QFont *pfont; // font used for metrics (might be different for printers)
|
---|
328 | QPen cpen;
|
---|
329 | QBrush cbrush;
|
---|
330 | QRegion crgn;
|
---|
331 | int tabstops;
|
---|
332 | int *tabarray;
|
---|
333 | int tabarraylen;
|
---|
334 | bool block_ext; // for temporary blocking of external devices
|
---|
335 |
|
---|
336 | // Transformations
|
---|
337 | #ifndef QT_NO_TRANSFORMATIONS
|
---|
338 | QCOORD wx, wy, ww, wh;
|
---|
339 | QCOORD vx, vy, vw, vh;
|
---|
340 | QWMatrix wxmat;
|
---|
341 |
|
---|
342 | // Cached composition (and inverse) of transformations
|
---|
343 | QWMatrix xmat;
|
---|
344 | QWMatrix ixmat;
|
---|
345 |
|
---|
346 |
|
---|
347 |
|
---|
348 | double m11() const { return xmat.m11(); }
|
---|
349 | double m12() const { return xmat.m12(); }
|
---|
350 | double m21() const { return xmat.m21(); }
|
---|
351 | double m22() const { return xmat.m22(); }
|
---|
352 | double dx() const { return xmat.dx(); }
|
---|
353 | double dy() const { return xmat.dy(); }
|
---|
354 | double im11() const { return ixmat.m11(); }
|
---|
355 | double im12() const { return ixmat.m12(); }
|
---|
356 | double im21() const { return ixmat.m21(); }
|
---|
357 | double im22() const { return ixmat.m22(); }
|
---|
358 | double idx() const { return ixmat.dx(); }
|
---|
359 | double idy() const { return ixmat.dy(); }
|
---|
360 |
|
---|
361 | int txop;
|
---|
362 | bool txinv;
|
---|
363 |
|
---|
364 | #else
|
---|
365 | // even without transformations we still have translations
|
---|
366 | int xlatex;
|
---|
367 | int xlatey;
|
---|
368 | #endif
|
---|
369 |
|
---|
370 | void *penRef; // pen cache ref
|
---|
371 | void *brushRef; // brush cache ref
|
---|
372 | void *ps_stack;
|
---|
373 | void *wm_stack;
|
---|
374 | void killPStack();
|
---|
375 |
|
---|
376 | protected:
|
---|
377 | #ifdef Q_OS_TEMP
|
---|
378 | QPoint internalCurrentPos;
|
---|
379 | uint old_pix; // ### All win platforms in 4.0
|
---|
380 | #endif
|
---|
381 | #if defined(Q_WS_WIN)
|
---|
382 | friend class QFontEngineWin;
|
---|
383 | friend class QFontEngineBox;
|
---|
384 | QT_WIN_PAINTER_MEMBERS
|
---|
385 | #elif defined(Q_WS_X11)
|
---|
386 | friend class QFontEngineXLFD;
|
---|
387 | friend class QFontEngineXft;
|
---|
388 | friend class QFontEngineBox;
|
---|
389 | Display *dpy; // current display
|
---|
390 | int scrn; // current screen
|
---|
391 | Qt::HANDLE hd; // handle to drawable
|
---|
392 | Qt::HANDLE rendhd; // handle to Xft draw
|
---|
393 | GC gc; // graphics context (standard)
|
---|
394 | GC gc_brush; // graphics contect for brush
|
---|
395 | QPoint curPt; // current point
|
---|
396 | uint clip_serial; // clipping serial number
|
---|
397 | #elif defined(Q_WS_MAC)
|
---|
398 | Qt::HANDLE hd; // handle to drawable
|
---|
399 | void initPaintDevice(bool force=FALSE, QPoint *off=NULL, QRegion *rgn=NULL);
|
---|
400 | friend const QRegion &qt_mac_update_painter(QPainter *, bool);
|
---|
401 | friend class QFontEngineMac;
|
---|
402 | friend class QMacPainter;
|
---|
403 | #elif defined(Q_WS_QWS)
|
---|
404 | friend class QFontEngine;
|
---|
405 | QGfx * gfx;
|
---|
406 | friend void qwsUpdateActivePainters();
|
---|
407 | #endif
|
---|
408 | friend class QFontMetrics;
|
---|
409 | friend class QFontInfo;
|
---|
410 | friend class QTextLayout;
|
---|
411 | friend void qt_format_text( const QFont &, const QRect &r,
|
---|
412 | int tf, const QString& str, int len, QRect *brect,
|
---|
413 | int tabstops, int* tabarray, int tabarraylen,
|
---|
414 | QTextParag **internal, QPainter* painter );
|
---|
415 | friend void qt_draw_background( QPainter *p, int x, int y, int w, int h );
|
---|
416 | friend void qt_draw_transformed_rect( QPainter *p, int x, int y, int w, int h, bool fill );
|
---|
417 | friend class QPrinter;
|
---|
418 |
|
---|
419 | private: // Disabled copy constructor and operator=
|
---|
420 | #if defined(Q_DISABLE_COPY)
|
---|
421 | QPainter( const QPainter & );
|
---|
422 | QPainter &operator=( const QPainter & );
|
---|
423 | #endif
|
---|
424 |
|
---|
425 | enum TransformationCodes {
|
---|
426 | TxNone = 0, // transformation codes
|
---|
427 | TxTranslate = 1, // copy in qpainter_*.cpp
|
---|
428 | TxScale = 2,
|
---|
429 | TxRotShear = 3
|
---|
430 | };
|
---|
431 | };
|
---|
432 |
|
---|
433 |
|
---|
434 | /*****************************************************************************
|
---|
435 | QPainter member functions
|
---|
436 | *****************************************************************************/
|
---|
437 |
|
---|
438 | inline QPaintDevice *QPainter::device() const
|
---|
439 | {
|
---|
440 | return pdev;
|
---|
441 | }
|
---|
442 |
|
---|
443 | inline bool QPainter::isActive() const
|
---|
444 | {
|
---|
445 | return testf(IsActive);
|
---|
446 | }
|
---|
447 |
|
---|
448 | inline const QFont &QPainter::font() const
|
---|
449 | {
|
---|
450 | return cfont;
|
---|
451 | }
|
---|
452 |
|
---|
453 | inline const QPen &QPainter::pen() const
|
---|
454 | {
|
---|
455 | return cpen;
|
---|
456 | }
|
---|
457 |
|
---|
458 | inline const QBrush &QPainter::brush() const
|
---|
459 | {
|
---|
460 | return cbrush;
|
---|
461 | }
|
---|
462 |
|
---|
463 | /*
|
---|
464 | inline PaintUnit QPainter::unit() const
|
---|
465 | {
|
---|
466 | return (PaintUnit)pu;
|
---|
467 | }
|
---|
468 | */
|
---|
469 |
|
---|
470 | inline const QColor &QPainter::backgroundColor() const
|
---|
471 | {
|
---|
472 | return bg_col;
|
---|
473 | }
|
---|
474 |
|
---|
475 | inline Qt::BGMode QPainter::backgroundMode() const
|
---|
476 | {
|
---|
477 | return (BGMode)bg_mode;
|
---|
478 | }
|
---|
479 |
|
---|
480 | inline Qt::RasterOp QPainter::rasterOp() const
|
---|
481 | {
|
---|
482 | return (RasterOp)rop;
|
---|
483 | }
|
---|
484 |
|
---|
485 | inline const QPoint &QPainter::brushOrigin() const
|
---|
486 | {
|
---|
487 | return bro;
|
---|
488 | }
|
---|
489 |
|
---|
490 | inline bool QPainter::hasViewXForm() const
|
---|
491 | {
|
---|
492 | #ifndef QT_NO_TRANSFORMATIONS
|
---|
493 | return testf(VxF);
|
---|
494 | #else
|
---|
495 | return xlatex || xlatey;
|
---|
496 | #endif
|
---|
497 | }
|
---|
498 |
|
---|
499 | inline bool QPainter::hasWorldXForm() const
|
---|
500 | {
|
---|
501 | #ifndef QT_NO_TRANSFORMATIONS
|
---|
502 | return testf(WxF);
|
---|
503 | #else
|
---|
504 | return xlatex || xlatey;
|
---|
505 | #endif
|
---|
506 | }
|
---|
507 |
|
---|
508 | inline double QPainter::translationX() const
|
---|
509 | {
|
---|
510 | #ifndef QT_NO_TRANSFORMATIONS
|
---|
511 | return worldMatrix().dx();
|
---|
512 | #else
|
---|
513 | return xlatex;
|
---|
514 | #endif
|
---|
515 | }
|
---|
516 |
|
---|
517 | inline double QPainter::translationY() const
|
---|
518 | {
|
---|
519 | #ifndef QT_NO_TRANSFORMATIONS
|
---|
520 | return worldMatrix().dy();
|
---|
521 | #else
|
---|
522 | return xlatey;
|
---|
523 | #endif
|
---|
524 | }
|
---|
525 |
|
---|
526 |
|
---|
527 | inline bool QPainter::hasClipping() const
|
---|
528 | {
|
---|
529 | return testf(ClipOn);
|
---|
530 | }
|
---|
531 |
|
---|
532 | inline int QPainter::tabStops() const
|
---|
533 | {
|
---|
534 | return tabstops;
|
---|
535 | }
|
---|
536 |
|
---|
537 | inline int *QPainter::tabArray() const
|
---|
538 | {
|
---|
539 | return tabarray;
|
---|
540 | }
|
---|
541 |
|
---|
542 | #if defined(Q_WS_WIN)
|
---|
543 | inline HDC QPainter::handle() const
|
---|
544 | {
|
---|
545 | return hdc;
|
---|
546 | }
|
---|
547 | #elif defined(Q_WS_X11) || defined(Q_WS_MAC)
|
---|
548 | inline Qt::HANDLE QPainter::handle() const
|
---|
549 | {
|
---|
550 | return hd;
|
---|
551 | }
|
---|
552 | #endif
|
---|
553 |
|
---|
554 | inline void QPainter::setBrushOrigin( const QPoint &p )
|
---|
555 | {
|
---|
556 | setBrushOrigin( p.x(), p.y() );
|
---|
557 | }
|
---|
558 |
|
---|
559 | #ifndef QT_NO_TRANSFORMATIONS
|
---|
560 | inline void QPainter::setWindow( const QRect &r )
|
---|
561 | {
|
---|
562 | setWindow( r.x(), r.y(), r.width(), r.height() );
|
---|
563 | }
|
---|
564 |
|
---|
565 | inline void QPainter::setViewport( const QRect &r )
|
---|
566 | {
|
---|
567 | setViewport( r.x(), r.y(), r.width(), r.height() );
|
---|
568 | }
|
---|
569 | #endif
|
---|
570 |
|
---|
571 | inline void QPainter::setClipRect( int x, int y, int w, int h, CoordinateMode m )
|
---|
572 | {
|
---|
573 | setClipRect( QRect(x,y,w,h), m );
|
---|
574 | }
|
---|
575 |
|
---|
576 | inline void QPainter::drawPoint( const QPoint &p )
|
---|
577 | {
|
---|
578 | drawPoint( p.x(), p.y() );
|
---|
579 | }
|
---|
580 |
|
---|
581 | inline void QPainter::moveTo( const QPoint &p )
|
---|
582 | {
|
---|
583 | moveTo( p.x(), p.y() );
|
---|
584 | }
|
---|
585 |
|
---|
586 | inline void QPainter::lineTo( const QPoint &p )
|
---|
587 | {
|
---|
588 | lineTo( p.x(), p.y() );
|
---|
589 | }
|
---|
590 |
|
---|
591 | inline void QPainter::drawLine( const QPoint &p1, const QPoint &p2 )
|
---|
592 | {
|
---|
593 | drawLine( p1.x(), p1.y(), p2.x(), p2.y() );
|
---|
594 | }
|
---|
595 |
|
---|
596 | inline void QPainter::drawRect( const QRect &r )
|
---|
597 | {
|
---|
598 | drawRect( r.x(), r.y(), r.width(), r.height() );
|
---|
599 | }
|
---|
600 |
|
---|
601 | inline void QPainter::drawWinFocusRect( const QRect &r )
|
---|
602 | {
|
---|
603 | drawWinFocusRect( r.x(), r.y(), r.width(), r.height() );
|
---|
604 | }
|
---|
605 |
|
---|
606 | inline void QPainter::drawWinFocusRect( const QRect &r,const QColor &penColor )
|
---|
607 | {
|
---|
608 | drawWinFocusRect( r.x(), r.y(), r.width(), r.height(), penColor );
|
---|
609 | }
|
---|
610 |
|
---|
611 | inline void QPainter::drawRoundRect( const QRect &r, int xRnd, int yRnd )
|
---|
612 | {
|
---|
613 | drawRoundRect( r.x(), r.y(), r.width(), r.height(), xRnd, yRnd );
|
---|
614 | }
|
---|
615 |
|
---|
616 | inline void QPainter::drawEllipse( const QRect &r )
|
---|
617 | {
|
---|
618 | drawEllipse( r.x(), r.y(), r.width(), r.height() );
|
---|
619 | }
|
---|
620 |
|
---|
621 | inline void QPainter::drawArc( const QRect &r, int a, int alen )
|
---|
622 | {
|
---|
623 | drawArc( r.x(), r.y(), r.width(), r.height(), a, alen );
|
---|
624 | }
|
---|
625 |
|
---|
626 | inline void QPainter::drawPie( const QRect &r, int a, int alen )
|
---|
627 | {
|
---|
628 | drawPie( r.x(), r.y(), r.width(), r.height(), a, alen );
|
---|
629 | }
|
---|
630 |
|
---|
631 | inline void QPainter::drawChord( const QRect &r, int a, int alen )
|
---|
632 | {
|
---|
633 | drawChord( r.x(), r.y(), r.width(), r.height(), a, alen );
|
---|
634 | }
|
---|
635 |
|
---|
636 | inline void QPainter::drawPixmap( const QPoint &p, const QPixmap &pm,
|
---|
637 | const QRect &sr )
|
---|
638 | {
|
---|
639 | drawPixmap( p.x(), p.y(), pm, sr.x(), sr.y(), sr.width(), sr.height() );
|
---|
640 | }
|
---|
641 |
|
---|
642 | inline void QPainter::drawImage( const QPoint &p, const QImage &pm,
|
---|
643 | const QRect &sr, int conversionFlags )
|
---|
644 | {
|
---|
645 | drawImage( p.x(), p.y(), pm,
|
---|
646 | sr.x(), sr.y(), sr.width(), sr.height(), conversionFlags );
|
---|
647 | }
|
---|
648 |
|
---|
649 | inline void QPainter::drawTiledPixmap( const QRect &r, const QPixmap &pm,
|
---|
650 | const QPoint &sp )
|
---|
651 | {
|
---|
652 | drawTiledPixmap( r.x(), r.y(), r.width(), r.height(), pm, sp.x(), sp.y() );
|
---|
653 | }
|
---|
654 |
|
---|
655 | inline void QPainter::drawTiledPixmap( const QRect &r, const QPixmap &pm )
|
---|
656 | {
|
---|
657 | drawTiledPixmap( r.x(), r.y(), r.width(), r.height(), pm, 0, 0 );
|
---|
658 | }
|
---|
659 |
|
---|
660 | inline void QPainter::fillRect( const QRect &r, const QBrush &brush )
|
---|
661 | {
|
---|
662 | fillRect( r.x(), r.y(), r.width(), r.height(), brush );
|
---|
663 | }
|
---|
664 |
|
---|
665 | inline void QPainter::eraseRect( int x, int y, int w, int h )
|
---|
666 | {
|
---|
667 | fillRect( x, y, w, h, backgroundColor() );
|
---|
668 | }
|
---|
669 |
|
---|
670 | inline void QPainter::eraseRect( const QRect &r )
|
---|
671 | {
|
---|
672 | fillRect( r.x(), r.y(), r.width(), r.height(), backgroundColor() );
|
---|
673 | }
|
---|
674 |
|
---|
675 | inline void QPainter::drawText( const QPoint &p, const QString &s, int len, TextDirection dir )
|
---|
676 | {
|
---|
677 | drawText( p.x(), p.y(), s, 0, len, dir );
|
---|
678 | }
|
---|
679 |
|
---|
680 | inline void QPainter::drawText( const QPoint &p, const QString &s, int pos, int len, TextDirection dir )
|
---|
681 | {
|
---|
682 | drawText( p.x(), p.y(), s, pos, len, dir );
|
---|
683 | }
|
---|
684 |
|
---|
685 | inline void QPainter::drawText( int x, int y, int w, int h, int tf,
|
---|
686 | const QString& str, int len, QRect *br, QTextParag **i )
|
---|
687 | {
|
---|
688 | QRect r(x, y, w, h);
|
---|
689 | drawText( r, tf, str, len, br, i );
|
---|
690 | }
|
---|
691 |
|
---|
692 | inline void QPainter::drawTextItem( const QPoint& p, const QTextItem &ti, int textflags )
|
---|
693 | {
|
---|
694 | drawTextItem( p.x(), p.y(), ti, textflags );
|
---|
695 | }
|
---|
696 |
|
---|
697 | inline QRect QPainter::boundingRect( int x, int y, int w, int h, int tf,
|
---|
698 | const QString& str, int len, QTextParag **i )
|
---|
699 | {
|
---|
700 | QRect r(x, y, w, h);
|
---|
701 | return boundingRect( r, tf, str, len, i );
|
---|
702 | }
|
---|
703 |
|
---|
704 | #if defined(Q_WS_QWS)
|
---|
705 | inline QGfx * QPainter::internalGfx()
|
---|
706 | {
|
---|
707 | return gfx;
|
---|
708 | }
|
---|
709 | #endif
|
---|
710 |
|
---|
711 | #endif // QPAINTER_H
|
---|