source: pacpusframework/branches/2.0-beta1/include/extlib/qwt-5.2.1/qwt_painter.h@ 89

Last change on this file since 89 was 89, checked in by morasjul, 11 years ago

PACPUS 2.0 Beta deployed in new branch

Major changes:
-Add communication interface between components
-Add examples for communications interface (TestComponents)
-Move to Qt5 support

  • Property svn:executable set to *
File size: 4.8 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 <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
20class QPainter;
21class QBrush;
22class QColor;
23class QWidget;
24class QwtScaleMap;
25class QwtColorMap;
26class QwtDoubleInterval;
27
28#if QT_VERSION < 0x040000
29class QColorGroup;
30class QSimpleRichText;
31#else
32class QPalette;
33class 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
45/*!
46 \brief A collection of QPainter workarounds
47
48 1) Clipping to coordinate system limits (Qt3 only)
49
50 On X11 pixel coordinates are stored in shorts. Qt
51 produces overruns when mapping QCOORDS to shorts.
52
53 2) Scaling to device metrics
54
55 QPainter scales fonts, line and fill patterns to the metrics
56 of the paint device. Other values like the geometries of rects, points
57 remain device independend. To enable a device independent widget
58 implementation, QwtPainter adds scaling of these geometries.
59 (Unfortunately QPainter::scale scales both types of paintings,
60 so the objects of the first type would be scaled twice).
61*/
62
63class QWT_EXPORT QwtPainter
64{
65public:
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
131private:
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
142//! Wrapper for QPainter::drawLine()
143inline 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
149/*!
150 Returns whether device clipping is enabled. On X11 the default
151 is enabled, otherwise it is disabled.
152 \sa QwtPainter::setDeviceClipping()
153*/
154inline bool QwtPainter::deviceClipping()
155{
156 return d_deviceClipping;
157}
158
159#endif
Note: See TracBrowser for help on using the repository browser.