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

# qwt_dial.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 // vim: expandtab
    00011
    00012 #ifndef QWT_DIAL_H
    00013 #define QWT_DIAL_H 1
    00014
    00015 #include <qframe.h>
    00016 #include <qpalette.h>
    00017 #include "qwt_global.h"
    00018 #include "qwt_sldbase.h"
    00019 #include "qwt_scldraw.h"
    00020
    00021 class QwtDialNeedle;
    00022 class QwtDial;
    00023
    00030 class QWT_EXPORT QwtDialScaleDraw: public QwtScaleDraw
    00031 {
    00032 public:
    00033     QwtDialScaleDraw(QwtDial *);
    00034     virtual QString label(double value) const;
    00035
    00036     void showLabels(bool);
    00037     bool visibleLabels() const;
    00038
    00039     void setPenWidth(uint);
    00040     uint penWidth() const;
    00041
    00042 private:
    00043     QwtDial *d_parent;
    00044     int d_penWidth;
    00045     bool d_visibleLabels;
    00046 };
    00047
    00072 class QWT_EXPORT QwtDial: public QwtSliderBase
    00073 {
    00074     Q_OBJECT
    00075
    00076     Q_ENUMS(Shadow)
    00077     Q_ENUMS(Mode)
    00078
    00079     Q_PROPERTY(bool visibleBackground READ hasVisibleBackground WRITE showBackground)
    00080     Q_PROPERTY(int lineWidth READ lineWidth WRITE setLineWidth)
    00081     Q_PROPERTY(Shadow frameShadow READ frameShadow WRITE setFrameShadow)
    00082     Q_PROPERTY(Mode mode READ mode WRITE setMode)
    00083     Q_PROPERTY(double origin READ origin WRITE setOrigin)
    00084     Q_PROPERTY(bool wrapping READ wrapping WRITE setWrapping)
    00085
    00086     friend class QwtDialScaleDraw;
    00087 public:
    00088
    00097     enum Shadow
    00098     {
    00099         Plain = QFrame::Plain,
    00100         Raised = QFrame::Raised,
    00101         Sunken = QFrame::Sunken
    00102     };
    00103
    00105     enum ScaleOptions
    00106     {
    00107         ScaleBackbone = 1,
    00108         ScaleTicks = 2,
    00109         ScaleLabel = 4
    00110     };
    00111
    00117     enum Mode
    00118     {
    00119         RotateNeedle,
    00120         RotateScale
    00121     };
    00122
    00123     QwtDial( QWidget* parent=0, const char* name = 0);
    00124     virtual ~QwtDial();
    00125
    00126     void setFrameShadow(Shadow);
    00127     Shadow frameShadow() const;
    00128
    00129     bool hasVisibleBackground() const;
    00130     void showBackground(bool);
    00131
    00132     void setLineWidth(int);
    00133     int lineWidth() const;
    00134
    00135     void setMode(Mode);
    00136     Mode mode() const;
    00137
    00138     virtual void setWrapping(bool);
    00139     bool wrapping() const;
    00140
    00141     virtual void setScale(int maxMajIntv, int maxMinIntv, double step = 0.0);
    00142
    00143     void setScaleArc(double min, double max);
    00144     void setScaleOptions(int);
    00145     void setScaleTicks(int minLen, int medLen, int majLen, int penWidth = 1);
    00146
    00148     double minScaleArc() const { return d_minScaleArc; }
    00150     double maxScaleArc() const { return d_maxScaleArc; }
    00151
    00152     virtual void setOrigin(double);
    00153     double origin() const;
    00154
    00155     virtual void setNeedle(QwtDialNeedle *);
    00156     const QwtDialNeedle *needle() const;
    00157     QwtDialNeedle *needle();
    00158
    00159     QRect boundingRect() const;
    00160     QRect contentsRect() const;
    00161     virtual QRect scaleContentsRect() const;
    00162
    00163     virtual QSize sizeHint() const;
    00164     virtual QSize minimumSizeHint() const;
    00165
    00166     virtual void setScaleDraw(QwtDialScaleDraw *);
    00167
    00169     QwtDialScaleDraw *scaleDraw() { return d_scaleDraw; }
    00171     const QwtDialScaleDraw *scaleDraw() const { return d_scaleDraw; }
    00172
    00173 protected:
    00174     virtual void paintEvent(QPaintEvent *);
    00175     virtual void resizeEvent(QResizeEvent *);
    00176     virtual void keyPressEvent(QKeyEvent *);
    00177
    00178     virtual void drawFrame(QPainter *p);
    00179     virtual void drawContents(QPainter *) const;
    00180     virtual void drawFocusIndicator(QPainter *) const;
    00181
    00182     virtual void drawScale(QPainter *, const QPoint &center,
    00183         int radius, double origin, double arcMin, double arcMax) const;
    00184
    00194     virtual void drawScaleContents(QPainter *painter, const QPoint &center,
    00195         int radius) const;
    00196
    00197     virtual void drawNeedle(QPainter *, const QPoint &,
    00198         int radius, double direction, QPalette::ColorGroup) const;
    00199
    00200     virtual QString scaleLabel(double) const;
    00201     void updateScale();
    00202
    00203     virtual void rangeChange();
    00204     virtual void valueChange();
    00205
    00206     virtual double getValue(const QPoint &);
    00207     virtual void getScrollMode(const QPoint &,
    00208         int &scrollMode, int &direction);
    00209
    00210 private:
    00211     bool d_visibleBackground;
    00212     Shadow d_frameShadow;
    00213     int d_lineWidth;
    00214
    00215     Mode d_mode;
    00216
    00217     double d_origin;
    00218     double d_minScaleArc;
    00219     double d_maxScaleArc;
    00220
    00221     QwtDialScaleDraw *d_scaleDraw;
    00222     int d_maxMajIntv;
    00223     int d_maxMinIntv;
    00224     double d_scaleStep;
    00225
    00226     QwtDialNeedle *d_needle;
    00227
    00228     static double d_previousDir;
    00229 };
    00230
    00231 #endif