- Main Page
- Classes
- Files
- Related Pages

# qwt_painter.h

    00001 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
    00002  * Qwt Widget Library
    00003  * Copyright (C) 1997   Josef Wilgen
    00004  * Copyright (C) 2002   Uwe Rathmann
    00005  *
    00006  * This library is free software; you can redistribute it and/or
    00007  * modify it under the terms of the Qwt License, Version 1.0
    00008  *****************************************************************************/
    00009
    00010 #ifndef QWT_PAINTER_H
    00011 #define QWT_PAINTER_H
    00012
    00013 #include <qpoint.h>
    00014 #include <qrect.h>
    00015 #include "qwt_global.h"
    00016 #include "qwt_layout_metrics.h"
    00017 #include "qwt_polygon.h"
    00018
    00019 class QPainter;
    00020 class QBrush;
    00021 class QColor;
    00022 class QWidget;
    00023 class QwtScaleMap;
    00024 class QwtColorMap;
    00025 class QwtDoubleInterval;
    00026
    00027 #if QT_VERSION < 0x040000
    00028 class QColorGroup;
    00029 class QSimpleRichText;
    00030 #else
    00031 class QPalette;
    00032 class QTextDocument;
    00033 #endif
    00034
    00035 #if defined(Q_WS_X11)
    00036 // Warning: QCOORD_MIN, QCOORD_MAX are wrong on X11.
    00037 #define QWT_COORD_MAX 16384
    00038 #define QWT_COORD_MIN (-QWT_COORD_MAX - 1)
    00039 #else
    00040 #define QWT_COORD_MAX 2147483647
    00041 #define QWT_COORD_MIN -QWT_COORD_MAX - 1
    00042 #endif
    00043
    00062 class QWT_EXPORT QwtPainter
    00063 {
    00064 public:
    00065     static void setMetricsMap(const QPaintDevice *layout,
    00066         const QPaintDevice *device);
    00067     static void setMetricsMap(const QwtMetricsMap &);
    00068     static void resetMetricsMap();
    00069     static const QwtMetricsMap &metricsMap();
    00070
    00071     static void setDeviceClipping(bool);
    00072     static bool deviceClipping();
    00073
    00074     static void setClipRect(QPainter *, const QRect &);
    00075
    00076     static void drawText(QPainter *, int x, int y,
    00077         const QString &);
    00078     static void drawText(QPainter *, const QPoint &,
    00079         const QString &);
    00080     static void drawText(QPainter *, int x, int y, int w, int h,
    00081         int flags, const QString &);
    00082     static void drawText(QPainter *, const QRect &,
    00083         int flags, const QString &);
    00084
    00085 #ifndef QT_NO_RICHTEXT
    00086 #if QT_VERSION < 0x040000
    00087     static void drawSimpleRichText(QPainter *, const QRect &,
    00088         int flags, QSimpleRichText &);
    00089 #else
    00090     static void drawSimpleRichText(QPainter *, const QRect &,
    00091         int flags, QTextDocument &);
    00092 #endif
    00093 #endif
    00094
    00095     static void drawRect(QPainter *, int x, int y, int w, int h);
    00096     static void drawRect(QPainter *, const QRect &rect);
    00097     static void fillRect(QPainter *, const QRect &, const QBrush &);
    00098
    00099     static void drawEllipse(QPainter *, const QRect &);
    00100     static void drawPie(QPainter *, const QRect & r, int a, int alen);
    00101
    00102     static void drawLine(QPainter *, int x1, int y1, int x2, int y2);
    00103     static void drawLine(QPainter *, const QPoint &p1, const QPoint &p2);
    00104     static void drawPolygon(QPainter *, const QwtPolygon &pa);
    00105     static void drawPolyline(QPainter *, const QwtPolygon &pa);
    00106     static void drawPoint(QPainter *, int x, int y);
    00107
    00108 #if QT_VERSION < 0x040000
    00109     static void drawRoundFrame(QPainter *, const QRect &,
    00110         int width, const QColorGroup &cg, bool sunken);
    00111 #else
    00112     static void drawRoundFrame(QPainter *, const QRect &,
    00113         int width, const QPalette &, bool sunken);
    00114 #endif
    00115     static void drawFocusRect(QPainter *, QWidget *);
    00116     static void drawFocusRect(QPainter *, QWidget *, const QRect &);
    00117
    00118     static QwtPolygon clip(const QwtPolygon &);
    00119
    00120     static void drawColorBar(QPainter *painter,
    00121         const QwtColorMap &, const QwtDoubleInterval &,
    00122         const QwtScaleMap &, Qt::Orientation, const QRect &);
    00123
    00124 #if QT_VERSION < 0x040000
    00125     static void setSVGMode(bool on);
    00126     static bool isSVGMode();
    00127 #endif
    00128
    00129 private:
    00130     static void drawColoredArc(QPainter *, const QRect &,
    00131         int peak, int arc, int intervall, const QColor &c1, const QColor &c2);
    00132
    00133     static const QRect &deviceClipRect();
    00134
    00135     static bool d_deviceClipping;
    00136     static QwtMetricsMap d_metricsMap;
    00137 #if QT_VERSION < 0x040000
    00138     static bool d_SVGMode;
    00139 #endif
    00140 };
    00141
    00143 inline void QwtPainter::drawLine(QPainter *painter,
    00144     const QPoint &p1, const QPoint &p2)
    00145 {
    00146     drawLine(painter, p1.x(), p1.y(), p2.x(), p2.y());
    00147 }
    00148
    00149 #endif