- Main Page
- Related Pages
- Classes
- Files

- File List

# qwt_dial_needle.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_DIAL_NEEDLE_H
    00011 #define QWT_DIAL_NEEDLE_H 1
    00012
    00013 #include <qpalette.h>
    00014 #include "qwt_global.h"
    00015
    00016 class QPainter;
    00017 class QPoint;
    00018
    00031 class QWT_EXPORT QwtDialNeedle
    00032 {
    00033 public:
    00034     QwtDialNeedle();
    00035     virtual ~QwtDialNeedle();
    00036
    00046     virtual void draw(QPainter *painter, const QPoint &center,
    00047         int length, double direction,
    00048         QPalette::ColorGroup cg = QPalette::Active) const = 0;
    00049
    00050     virtual void setPalette(const QPalette &);
    00051     const QPalette &palette() const;
    00052
    00053 protected:
    00054     static void drawKnob(QPainter *, const QPoint &pos,
    00055         int width, const QBrush &, bool sunken);
    00056
    00057 private:
    00058     QPalette d_palette;
    00059 };
    00060
    00073 class QWT_EXPORT QwtDialSimpleNeedle: public QwtDialNeedle
    00074 {
    00075 public:
    00077     enum Style
    00078     {
    00079         Arrow,
    00080         Ray
    00081     };
    00082
    00083     QwtDialSimpleNeedle(Style, bool hasKnob = true,
    00084         const QColor &mid = Qt::gray, const QColor &base = Qt::darkGray);
    00085
    00086     virtual void draw(QPainter *, const QPoint &, int length,
    00087         double direction, QPalette::ColorGroup = QPalette::Active) const;
    00088
    00089     static void drawArrowNeedle(QPainter *,
    00090         const QPalette&, QPalette::ColorGroup,
    00091         const QPoint &, int length, int width, double direction,
    00092         bool hasKnob);
    00093
    00094     static void drawRayNeedle(QPainter *,
    00095         const QPalette&, QPalette::ColorGroup,
    00096         const QPoint &, int length, int width, double direction,
    00097         bool hasKnob);
    00098
    00099     void setWidth(int width);
    00100     int width() const;
    00101
    00102 private:
    00103     Style d_style;
    00104     bool d_hasKnob;
    00105     int d_width;
    00106 };
    00107
    00125 class QWT_EXPORT QwtCompassMagnetNeedle: public QwtDialNeedle
    00126 {
    00127 public:
    00129     enum Style
    00130     {
    00131         TriangleStyle,
    00132         ThinStyle
    00133     };
    00134     QwtCompassMagnetNeedle(Style = TriangleStyle,
    00135         const QColor &light = Qt::white, const QColor &dark = Qt::red);
    00136
    00137     virtual void draw(QPainter *, const QPoint &, int length,
    00138         double direction, QPalette::ColorGroup = QPalette::Active) const;
    00139
    00140     static void drawTriangleNeedle(QPainter *,
    00141         const QPalette &, QPalette::ColorGroup,
    00142         const QPoint &, int length, double direction);
    00143
    00144     static void drawThinNeedle(QPainter *,
    00145         const QPalette &, QPalette::ColorGroup,
    00146         const QPoint &, int length, double direction);
    00147
    00148 protected:
    00149     static void drawPointer(QPainter *painter, const QBrush &brush,
    00150         int colorOffset, const QPoint &center,
    00151         int length, int width, double direction);
    00152
    00153 private:
    00154     Style d_style;
    00155 };
    00156
    00170 class QWT_EXPORT QwtCompassWindArrow: public QwtDialNeedle
    00171 {
    00172 public:
    00174     enum Style
    00175     {
    00176         Style1,
    00177         Style2
    00178     };
    00179
    00180     QwtCompassWindArrow(Style, const QColor &light = Qt::white,
    00181         const QColor &dark = Qt::gray);
    00182
    00183     virtual void draw(QPainter *, const QPoint &, int length,
    00184         double direction, QPalette::ColorGroup = QPalette::Active) const;
    00185
    00186     static void drawStyle1Needle(QPainter *,
    00187         const QPalette &, QPalette::ColorGroup,
    00188         const QPoint &, int length, double direction);
    00189
    00190     static void drawStyle2Needle(QPainter *,
    00191         const QPalette &, QPalette::ColorGroup,
    00192         const QPoint &, int length, double direction);
    00193
    00194 private:
    00195     Style d_style;
    00196 };
    00197
    00198 #endif // QWT_DIAL_NEEDLE_H