Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

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:
00076     enum Style
00077     {
00078         Arrow,
00079         Ray
00080     };
00081 
00082     QwtDialSimpleNeedle(Style, bool hasKnob = true, 
00083         const QColor &mid = Qt::gray, const QColor &base = Qt::darkGray);
00084 
00085     virtual void draw(QPainter *, const QPoint &, int length, 
00086         double direction, QPalette::ColorGroup = QPalette::Active) const;
00087 
00088     static void drawArrowNeedle(QPainter *, 
00089         const QPalette&, QPalette::ColorGroup,
00090         const QPoint &, int length, int width, double direction, 
00091         bool hasKnob);
00092 
00093     static void drawRayNeedle(QPainter *, 
00094         const QPalette&, QPalette::ColorGroup,
00095         const QPoint &, int length, int width, double direction, 
00096         bool hasKnob);
00097 
00098     void setWidth(int width);
00099     int width() const;
00100 
00101 private:
00102     Style d_style;
00103     bool d_hasKnob;
00104     int d_width;
00105 };
00106 
00124 class QWT_EXPORT QwtCompassMagnetNeedle: public QwtDialNeedle
00125 {
00126 public:
00127     enum Style
00128     {
00129         TriangleStyle,
00130         ThinStyle
00131     };
00132     QwtCompassMagnetNeedle(Style = TriangleStyle,
00133         const QColor &light = Qt::white, const QColor &dark = Qt::red);
00134 
00135     virtual void draw(QPainter *, const QPoint &, int length, 
00136         double direction, QPalette::ColorGroup = QPalette::Active) const;
00137 
00138     static void drawTriangleNeedle(QPainter *, 
00139         const QPalette &, QPalette::ColorGroup,
00140         const QPoint &, int length, double direction); 
00141 
00142     static void drawThinNeedle(QPainter *,
00143         const QPalette &, QPalette::ColorGroup,
00144         const QPoint &, int length, double direction);
00145 
00146 protected:
00147     static void drawPointer(QPainter *painter, const QBrush &brush,
00148         int colorOffset, const QPoint &center, 
00149         int length, int width, double direction);
00150 
00151 private:
00152     Style d_style;
00153 };
00154 
00168 class QWT_EXPORT QwtCompassWindArrow: public QwtDialNeedle
00169 {
00170 public:
00171     enum Style
00172     {
00173         Style1,
00174         Style2
00175     };
00176 
00177     QwtCompassWindArrow(Style, const QColor &light = Qt::white,
00178         const QColor &dark = Qt::gray);
00179 
00180     virtual void draw(QPainter *, const QPoint &, int length,
00181         double direction, QPalette::ColorGroup = QPalette::Active) const;
00182 
00183     static void drawStyle1Needle(QPainter *, 
00184         const QPalette &, QPalette::ColorGroup,
00185         const QPoint &, int length, double direction);
00186 
00187     static void drawStyle2Needle(QPainter *, 
00188         const QPalette &, QPalette::ColorGroup,
00189         const QPoint &, int length, double direction);
00190 
00191 private:
00192     Style d_style;
00193 };
00194 
00195 #endif // QWT_DIAL_NEEDLE_H

Generated on Mon Jan 30 22:16:25 2006 for Qwt User's Guide by  doxygen 1.4.4