00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef QWT_PAINTER_H
00011 #define QWT_PAINTER_H
00012
00013 #include "qwt_global.h"
00014
00015 #include <qpoint.h>
00016 #include <qrect.h>
00017 #include <qpen.h>
00018 #include <qline.h>
00019 #include <qpalette.h>
00020
00021 class QPainter;
00022 class QBrush;
00023 class QColor;
00024 class QWidget;
00025 class QPolygonF;
00026 class QRectF;
00027 class QImage;
00028 class QPixmap;
00029 class QwtScaleMap;
00030 class QwtColorMap;
00031 class QwtInterval;
00032
00033 class QTextDocument;
00034 class QPainterPath;
00035
00039 class QWT_EXPORT QwtPainter
00040 {
00041 public:
00042 static void setPolylineSplitting( bool );
00043 static bool polylineSplitting();
00044
00045 static void setRoundingAlignment( bool );
00046 static bool roundingAlignment();
00047 static bool roundingAlignment(QPainter *);
00048
00049 static void drawText( QPainter *, double x, double y, const QString & );
00050 static void drawText( QPainter *, const QPointF &, const QString & );
00051 static void drawText( QPainter *, double x, double y, double w, double h,
00052 int flags, const QString & );
00053 static void drawText( QPainter *, const QRectF &,
00054 int flags, const QString & );
00055
00056 #ifndef QT_NO_RICHTEXT
00057 static void drawSimpleRichText( QPainter *, const QRectF &,
00058 int flags, const QTextDocument & );
00059 #endif
00060
00061 static void drawRect( QPainter *, double x, double y, double w, double h );
00062 static void drawRect( QPainter *, const QRectF &rect );
00063 static void fillRect( QPainter *, const QRectF &, const QBrush & );
00064
00065 static void drawEllipse( QPainter *, const QRectF & );
00066 static void drawPie( QPainter *, const QRectF & r, int a, int alen );
00067
00068 static void drawLine( QPainter *, double x1, double y1, double x2, double y2 );
00069 static void drawLine( QPainter *, const QPointF &p1, const QPointF &p2 );
00070 static void drawLine( QPainter *, const QLineF & );
00071
00072 static void drawPolygon( QPainter *, const QPolygonF & );
00073 static void drawPolyline( QPainter *, const QPolygonF & );
00074 static void drawPolyline( QPainter *, const QPointF *, int pointCount );
00075
00076 static void drawPolygon( QPainter *, const QPolygon & );
00077 static void drawPolyline( QPainter *, const QPolygon & );
00078 static void drawPolyline( QPainter *, const QPoint *, int pointCount );
00079
00080 static void drawPoint( QPainter *, const QPoint & );
00081 static void drawPoints( QPainter *, const QPolygon & );
00082 static void drawPoints( QPainter *, const QPoint *, int pointCount );
00083
00084 static void drawPoint( QPainter *, double x, double y );
00085 static void drawPoint( QPainter *, const QPointF & );
00086 static void drawPoints( QPainter *, const QPolygonF & );
00087 static void drawPoints( QPainter *, const QPointF *, int pointCount );
00088
00089 static void drawPath( QPainter *, const QPainterPath & );
00090 static void drawImage( QPainter *, const QRectF &, const QImage & );
00091 static void drawPixmap( QPainter *, const QRectF &, const QPixmap & );
00092
00093 static void drawRoundFrame( QPainter *,
00094 const QRectF &, const QPalette &, int lineWidth, int frameStyle );
00095
00096 static void drawRoundedFrame( QPainter *,
00097 const QRectF &, double xRadius, double yRadius,
00098 const QPalette &, int lineWidth, int frameStyle );
00099
00100 static void drawFrame( QPainter *, const QRectF &rect,
00101 const QPalette &palette, QPalette::ColorRole foregroundRole,
00102 int lineWidth, int midLineWidth, int frameStyle );
00103
00104 static void drawFocusRect( QPainter *, const QWidget * );
00105 static void drawFocusRect( QPainter *, const QWidget *, const QRect & );
00106
00107 static void drawColorBar( QPainter *painter,
00108 const QwtColorMap &, const QwtInterval &,
00109 const QwtScaleMap &, Qt::Orientation, const QRectF & );
00110
00111 static bool isAligning( QPainter *painter );
00112 static bool isX11GraphicsSystem();
00113
00114 static void fillPixmap( const QWidget *,
00115 QPixmap &, const QPoint &offset = QPoint() );
00116
00117 static void drawBackgound( QPainter *painter,
00118 const QRectF &rect, const QWidget *widget );
00119
00120 static QPixmap backingStore( QWidget *, const QSize & );
00121 static qreal devicePixelRatio( const QPaintDevice * );
00122
00123 private:
00124 static bool d_polylineSplitting;
00125 static bool d_roundingAlignment;
00126 };
00127
00129 inline void QwtPainter::drawPoint( QPainter *painter, double x, double y )
00130 {
00131 QwtPainter::drawPoint( painter, QPointF( x, y ) );
00132 }
00133
00135 inline void QwtPainter::drawPoints( QPainter *painter, const QPolygon &polygon )
00136 {
00137 drawPoints( painter, polygon.data(), polygon.size() );
00138 }
00139
00141 inline void QwtPainter::drawPoints( QPainter *painter, const QPolygonF &polygon )
00142 {
00143 drawPoints( painter, polygon.data(), polygon.size() );
00144 }
00145
00147 inline void QwtPainter::drawLine( QPainter *painter,
00148 double x1, double y1, double x2, double y2 )
00149 {
00150 QwtPainter::drawLine( painter, QPointF( x1, y1 ), QPointF( x2, y2 ) );
00151 }
00152
00154 inline void QwtPainter::drawLine( QPainter *painter, const QLineF &line )
00155 {
00156 QwtPainter::drawLine( painter, line.p1(), line.p2() );
00157 }
00158
00163 inline bool QwtPainter::polylineSplitting()
00164 {
00165 return d_polylineSplitting;
00166 }
00167
00176 inline bool QwtPainter::roundingAlignment()
00177 {
00178 return d_roundingAlignment;
00179 }
00180
00185 inline bool QwtPainter::roundingAlignment(QPainter *painter)
00186 {
00187 return d_roundingAlignment && isAligning(painter);
00188 }
00189 #endif