Qwt User's Guide 6.3.0
Loading...
Searching...
No Matches
qwt_painter.h
1/******************************************************************************
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 <qpalette.h>
16#include <qpolygon.h>
17#include <qpen.h>
18
19class QwtScaleMap;
20class QwtColorMap;
21class QwtInterval;
22
23class QPainter;
24class QBrush;
25class QWidget;
26class QImage;
27class QPixmap;
28class QFontMetrics;
29class QFontMetricsF;
30class QTextDocument;
31class QPainterPath;
32
36class QWT_EXPORT QwtPainter
37{
38 public:
39 static void setPolylineSplitting( bool );
40 static bool polylineSplitting();
41
42 static void setRoundingAlignment( bool );
43 static bool roundingAlignment();
44 static bool roundingAlignment( const QPainter* );
45
46 static void drawText( QPainter*, qreal x, qreal y, const QString& );
47 static void drawText( QPainter*, const QPointF&, const QString& );
48 static void drawText( QPainter*, qreal x, qreal y, qreal w, qreal h,
49 int flags, const QString& );
50 static void drawText( QPainter*, const QRectF&,
51 int flags, const QString& );
52
53#ifndef QT_NO_RICHTEXT
54 static void drawSimpleRichText( QPainter*, const QRectF&,
55 int flags, const QTextDocument& );
56#endif
57
58 static void drawRect( QPainter*, qreal x, qreal y, qreal w, qreal h );
59 static void drawRect( QPainter*, const QRectF& rect );
60 static void fillRect( QPainter*, const QRectF&, const QBrush& );
61
62 static void drawEllipse( QPainter*, const QRectF& );
63 static void drawPie( QPainter*, const QRectF& r, int a, int alen );
64
65 static void drawLine( QPainter*, qreal x1, qreal y1, qreal x2, qreal y2 );
66 static void drawLine( QPainter*, const QPointF& p1, const QPointF& p2 );
67 static void drawLine( QPainter*, const QLineF& );
68
69 static void drawPolygon( QPainter*, const QPolygonF& );
70 static void drawPolyline( QPainter*, const QPolygonF& );
71 static void drawPolyline( QPainter*, const QPointF*, int pointCount );
72
73 static void drawPolygon( QPainter*, const QPolygon& );
74 static void drawPolyline( QPainter*, const QPolygon& );
75 static void drawPolyline( QPainter*, const QPoint*, int pointCount );
76
77 static void drawPoint( QPainter*, const QPoint& );
78 static void drawPoints( QPainter*, const QPolygon& );
79 static void drawPoints( QPainter*, const QPoint*, int pointCount );
80
81 static void drawPoint( QPainter*, qreal x, qreal y );
82 static void drawPoint( QPainter*, const QPointF& );
83 static void drawPoints( QPainter*, const QPolygonF& );
84 static void drawPoints( QPainter*, const QPointF*, int pointCount );
85
86 static void drawPath( QPainter*, const QPainterPath& );
87 static void drawImage( QPainter*, const QRectF&, const QImage& );
88 static void drawPixmap( QPainter*, const QRectF&, const QPixmap& );
89
90 static void drawRoundFrame( QPainter*,
91 const QRectF&, const QPalette&, int lineWidth, int frameStyle );
92
93 static void drawRoundedFrame( QPainter*,
94 const QRectF&, qreal xRadius, qreal yRadius,
95 const QPalette&, int lineWidth, int frameStyle );
96
97 static void drawFrame( QPainter*, const QRectF& rect,
98 const QPalette& palette, QPalette::ColorRole foregroundRole,
99 int lineWidth, int midLineWidth, int frameStyle );
100
101 static void drawFocusRect( QPainter*, const QWidget* );
102 static void drawFocusRect( QPainter*, const QWidget*, const QRect& );
103
104 static void drawColorBar( QPainter*,
105 const QwtColorMap&, const QwtInterval&,
106 const QwtScaleMap&, Qt::Orientation, const QRectF& );
107
108 static bool isAligning( const QPainter*);
109 static bool isX11GraphicsSystem();
110
111 static void fillPixmap( const QWidget*,
112 QPixmap&, const QPoint& offset = QPoint() );
113
114 static void drawBackgound( QPainter*,
115 const QRectF&, const QWidget* );
116
117 static QPixmap backingStore( QWidget*, const QSize& );
118 static qreal devicePixelRatio( const QPaintDevice* );
119
120 static qreal effectivePenWidth( const QPen& );
121
122 static int horizontalAdvance( const QFontMetrics&, const QString& );
123 static qreal horizontalAdvance( const QFontMetricsF&, const QString& );
124
125 static int horizontalAdvance( const QFontMetrics&, QChar );
126 static qreal horizontalAdvance( const QFontMetricsF&, QChar );
127
128 static QFont scaledFont( const QFont&, const QPaintDevice* = NULL );
129
130 private:
131 static bool m_polylineSplitting;
132 static bool m_roundingAlignment;
133};
134
136inline void QwtPainter::drawPoint( QPainter* painter, qreal x, qreal y )
137{
138 QwtPainter::drawPoint( painter, QPointF( x, y ) );
139}
140
142inline void QwtPainter::drawPoints( QPainter* painter, const QPolygon& polygon )
143{
144 drawPoints( painter, polygon.data(), polygon.size() );
145}
146
148inline void QwtPainter::drawPoints( QPainter* painter, const QPolygonF& polygon )
149{
150 drawPoints( painter, polygon.data(), polygon.size() );
151}
152
154inline void QwtPainter::drawLine( QPainter* painter,
155 qreal x1, qreal y1, qreal x2, qreal y2 )
156{
157 QwtPainter::drawLine( painter, QPointF( x1, y1 ), QPointF( x2, y2 ) );
158}
159
161inline void QwtPainter::drawLine( QPainter* painter, const QLineF& line )
162{
163 QwtPainter::drawLine( painter, line.p1(), line.p2() );
164}
165
171{
172 return m_polylineSplitting;
173}
174
184{
185 return m_roundingAlignment;
186}
187
192inline bool QwtPainter::roundingAlignment( const QPainter* painter )
193{
194 return m_roundingAlignment && isAligning(painter);
195}
196
201inline qreal QwtPainter::effectivePenWidth( const QPen& pen )
202{
203 const qreal width = pen.widthF();
204 return ( width < 1.0 ) ? 1.0 : width;
205}
206
207#endif
QwtColorMap is used to map values into colors.
A class representing an interval.
A collection of QPainter workarounds.
Definition qwt_painter.h:37
static void drawPoints(QPainter *, const QPolygon &)
Wrapper for QPainter::drawPoints()
static bool polylineSplitting()
static bool isAligning(const QPainter *)
static qreal effectivePenWidth(const QPen &)
static void drawPoint(QPainter *, const QPoint &)
Wrapper for QPainter::drawPoint()
static bool roundingAlignment()
static void drawLine(QPainter *, qreal x1, qreal y1, qreal x2, qreal y2)
Wrapper for QPainter::drawLine()
A scale map.