Qwt User's Guide 5.2.3

- Main Page
- Related Pages
- Classes

qwt_painter.h
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 <qpoint.h>
14 #include <qrect.h>
15 #include <qpen.h>
16 #include "qwt_global.h"
17 #include "qwt_layout_metrics.h"
18 #include "qwt_polygon.h"
19
20 class QPainter;
21 class QBrush;
22 class QColor;
23 class QWidget;
24 class QwtScaleMap;
25 class QwtColorMap;
26 class QwtDoubleInterval;
27
28 #if QT_VERSION < 0x040000
29 class QColorGroup;
30 class QSimpleRichText;
31 #else
32 class QPalette;
33 class QTextDocument;
34 #endif
35
36 #if defined(Q_WS_X11)
37 // Warning: QCOORD_MIN, QCOORD_MAX are wrong on X11.
38 #define QWT_COORD_MAX 16384
39 #define QWT_COORD_MIN (-QWT_COORD_MAX - 1)
40 #else
41 #define QWT_COORD_MAX 2147483647
42 #define QWT_COORD_MIN -QWT_COORD_MAX - 1
43 #endif
44
63 class QWT_EXPORT QwtPainter
64 {
65 public:
66 static void setMetricsMap(const QPaintDevice *layout,
67 const QPaintDevice *device);
68 static void setMetricsMap(const QwtMetricsMap &);
69 static void resetMetricsMap();
70 static const QwtMetricsMap &metricsMap();
71
72 static void setDeviceClipping(bool);
73 static bool deviceClipping();
74 static const QRect &deviceClipRect();
75
76 static void setClipRect(QPainter *, const QRect &);
77
78 static void drawText(QPainter *, int x, int y,
79 const QString &);
80 static void drawText(QPainter *, const QPoint &,
81 const QString &);
82 static void drawText(QPainter *, int x, int y, int w, int h,
83 int flags, const QString &);
84 static void drawText(QPainter *, const QRect &,
85 int flags, const QString &);
86
87 #ifndef QT_NO_RICHTEXT
88 #if QT_VERSION < 0x040000
89 static void drawSimpleRichText(QPainter *, const QRect &,
90 int flags, QSimpleRichText &);
91 #else
92 static void drawSimpleRichText(QPainter *, const QRect &,
93 int flags, QTextDocument &);
94 #endif
95 #endif
96
97 static void drawRect(QPainter *, int x, int y, int w, int h);
98 static void drawRect(QPainter *, const QRect &rect);
99 static void fillRect(QPainter *, const QRect &, const QBrush &);
100
101 static void drawEllipse(QPainter *, const QRect &);
102 static void drawPie(QPainter *, const QRect & r, int a, int alen);
103
104 static void drawLine(QPainter *, int x1, int y1, int x2, int y2);
105 static void drawLine(QPainter *, const QPoint &p1, const QPoint &p2);
106 static void drawPolygon(QPainter *, const QwtPolygon &pa);
107 static void drawPolyline(QPainter *, const QwtPolygon &pa);
108 static void drawPoint(QPainter *, int x, int y);
109
110 #if QT_VERSION < 0x040000
111 static void drawRoundFrame(QPainter *, const QRect &,
112 int width, const QColorGroup &cg, bool sunken);
113 #else
114 static void drawRoundFrame(QPainter *, const QRect &,
115 int width, const QPalette &, bool sunken);
116 #endif
117 static void drawFocusRect(QPainter *, QWidget *);
118 static void drawFocusRect(QPainter *, QWidget *, const QRect &);
119
120 static void drawColorBar(QPainter *painter,
121 const QwtColorMap &, const QwtDoubleInterval &,
122 const QwtScaleMap &, Qt::Orientation, const QRect &);
123
124 #if QT_VERSION < 0x040000
125 static void setSVGMode(bool on);
126 static bool isSVGMode();
127 #endif
128
129 static QPen scaledPen(const QPen &);
130
131 private:
132 static void drawColoredArc(QPainter *, const QRect &,
133 int peak, int arc, int intervall, const QColor &c1, const QColor &c2);
134
135 static bool d_deviceClipping;
136 static QwtMetricsMap d_metricsMap;
137 #if QT_VERSION < 0x040000
138 static bool d_SVGMode;
139 #endif
140 };
141
143 inline void QwtPainter::drawLine(QPainter *painter,
144 const QPoint &p1, const QPoint &p2)
145 {
146 drawLine(painter, p1.x(), p1.y(), p2.x(), p2.y());
147 }
148
154 inline bool QwtPainter::deviceClipping()
155 {
156 return d_deviceClipping;
157 }
158
159 #endif