source: ntrip/trunk/GnssCenter/qwt/qwt_painter.h@ 5290

Last change on this file since 5290 was 4839, checked in by mervart, 12 years ago
File size: 4.5 KB
Line 
1/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
2 * Qwt Widget Library
3 * Copyright (C) 1997 Josef Wilgen
4 * Copyright (C) 2002 Uwe Rathmann
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the Qwt License, Version 1.0
8 *****************************************************************************/
9
10#ifndef QWT_PAINTER_H
11#define QWT_PAINTER_H
12
13#include "qwt_global.h"
14
15#include <qpoint.h>
16#include <qrect.h>
17#include <qpen.h>
18#include <qline.h>
19
20class QPainter;
21class QBrush;
22class QColor;
23class QWidget;
24class QPolygonF;
25class QRectF;
26class QImage;
27class QPixmap;
28class QwtScaleMap;
29class QwtColorMap;
30class QwtInterval;
31
32class QPalette;
33class QTextDocument;
34class QPainterPath;
35
36/*!
37 \brief A collection of QPainter workarounds
38*/
39class QWT_EXPORT QwtPainter
40{
41public:
42 static void setPolylineSplitting( bool );
43 static bool polylineSplitting();
44
45 static void setRoundingAlignment( bool );
46 static bool roundingAlignment();
47 static bool roundingAlignment(QPainter *);
48
49 static void drawText( QPainter *, double x, double y, const QString & );
50 static void drawText( QPainter *, const QPointF &, const QString & );
51 static void drawText( QPainter *, double x, double y, double w, double h,
52 int flags, const QString & );
53 static void drawText( QPainter *, const QRectF &,
54 int flags, const QString & );
55
56#ifndef QT_NO_RICHTEXT
57 static void drawSimpleRichText( QPainter *, const QRectF &,
58 int flags, const QTextDocument & );
59#endif
60
61 static void drawRect( QPainter *, double x, double y, double w, double h );
62 static void drawRect( QPainter *, const QRectF &rect );
63 static void fillRect( QPainter *, const QRectF &, const QBrush & );
64
65 static void drawEllipse( QPainter *, const QRectF & );
66 static void drawPie( QPainter *, const QRectF & r, int a, int alen );
67
68 static void drawLine( QPainter *, double x1, double y1, double x2, double y2 );
69 static void drawLine( QPainter *, const QPointF &p1, const QPointF &p2 );
70 static void drawLine( QPainter *, const QLineF & );
71
72 static void drawPolygon( QPainter *, const QPolygonF &pa );
73 static void drawPolyline( QPainter *, const QPolygonF &pa );
74 static void drawPolyline( QPainter *, const QPointF *, int pointCount );
75
76 static void drawPoint( QPainter *, double x, double y );
77 static void drawPoint( QPainter *, const QPointF & );
78
79 static void drawPath( QPainter *, const QPainterPath & );
80 static void drawImage( QPainter *, const QRectF &, const QImage & );
81 static void drawPixmap( QPainter *, const QRectF &, const QPixmap & );
82
83 static void drawRoundedFrame( QPainter *,
84 const QRectF &, double xRadius, double yRadius,
85 const QPalette &, int lineWidth, int frameStyle );
86
87 static void drawFocusRect( QPainter *, QWidget * );
88 static void drawFocusRect( QPainter *, QWidget *, const QRect & );
89
90 static void drawColorBar( QPainter *painter,
91 const QwtColorMap &, const QwtInterval &,
92 const QwtScaleMap &, Qt::Orientation, const QRectF & );
93
94 static bool isAligning( QPainter *painter );
95
96private:
97 static bool d_polylineSplitting;
98 static bool d_roundingAlignment;
99};
100
101//! Wrapper for QPainter::drawPoint()
102inline void QwtPainter::drawPoint( QPainter *painter, double x, double y )
103{
104 QwtPainter::drawPoint( painter, QPointF( x, y ) );
105}
106
107//! Wrapper for QPainter::drawLine()
108inline void QwtPainter::drawLine( QPainter *painter,
109 double x1, double y1, double x2, double y2 )
110{
111 QwtPainter::drawLine( painter, QPointF( x1, y1 ), QPointF( x2, y2 ) );
112}
113
114//! Wrapper for QPainter::drawLine()
115inline void QwtPainter::drawLine( QPainter *painter, const QLineF &line )
116{
117 QwtPainter::drawLine( painter, line.p1(), line.p2() );
118}
119
120/*!
121 Returns whether line splitting for the raster paint engine is enabled.
122 \sa setPolylineSplitting()
123*/
124inline bool QwtPainter::polylineSplitting()
125{
126 return d_polylineSplitting;
127}
128
129/*!
130 Returns whether coordinates should be rounded, before they are painted
131 to a paint engine that floors to integer values. For other paint engines
132 this ( Pdf, SVG ), this flag has no effect.
133
134 \sa setRoundingAlignment(), isAligning()
135*/
136inline bool QwtPainter::roundingAlignment()
137{
138 return d_roundingAlignment;
139}
140
141/*!
142 \return roundingAlignment() && isAligning(painter);
143 \param painter Painter
144*/
145inline bool QwtPainter::roundingAlignment(QPainter *painter)
146{
147 return d_roundingAlignment && isAligning(painter);
148}
149#endif
Note: See TracBrowser for help on using the repository browser.