# 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_abstract_slider.h"
    00019 #include "qwt_round_scale_draw.h"
    00020
    00021 class QwtDialNeedle;
    00022 class QwtDial;
    00023
    00029 class QWT_EXPORT QwtDialScaleDraw: public QwtRoundScaleDraw
    00030 {
    00031 public:
    00032     explicit QwtDialScaleDraw(QwtDial *);
    00033     virtual QwtText label(double value) const;
    00034
    00035     void setPenWidth(uint);
    00036     uint penWidth() const;
    00037
    00038 private:
    00039     QwtDial *d_parent;
    00040     int d_penWidth;
    00041 };
    00042
    00067 class QWT_EXPORT QwtDial: public QwtAbstractSlider
    00068 {
    00069     Q_OBJECT
    00070
    00071     Q_ENUMS(Shadow)
    00072     Q_ENUMS(Mode)
    00073     Q_ENUMS(Direction)
    00074
    00075     Q_PROPERTY(bool visibleBackground READ hasVisibleBackground WRITE showBackground)
    00076     Q_PROPERTY(int lineWidth READ lineWidth WRITE setLineWidth)
    00077     Q_PROPERTY(Shadow frameShadow READ frameShadow WRITE setFrameShadow)
    00078     Q_PROPERTY(Mode mode READ mode WRITE setMode)
    00079     Q_PROPERTY(double origin READ origin WRITE setOrigin)
    00080     Q_PROPERTY(bool wrapping READ wrapping WRITE setWrapping)
    00081     Q_PROPERTY(Direction direction READ direction WRITE setDirection)
    00082
    00083     friend class QwtDialScaleDraw;
    00084 public:
    00085
    00094     enum Shadow
    00095     {
    00096         Plain = QFrame::Plain,
    00097         Raised = QFrame::Raised,
    00098         Sunken = QFrame::Sunken
    00099     };
    00100
    00102     enum ScaleOptions
    00103     {
    00104         ScaleBackbone = 1,
    00105         ScaleTicks = 2,
    00106         ScaleLabel = 4
    00107     };
    00108
    00114     enum Mode
    00115     {
    00116         RotateNeedle,
    00117         RotateScale
    00118     };
    00119
    00123     enum Direction
    00124     {
    00125         Clockwise,
    00126         CounterClockwise
    00127     };
    00128
    00129     explicit QwtDial( QWidget *parent = NULL);
    00130 #if QT_VERSION < 0x040000
    00131     explicit QwtDial( QWidget *parent, const char *name);
    00132 #endif
    00133
    00134     virtual ~QwtDial();
    00135
    00136     void setFrameShadow(Shadow);
    00137     Shadow frameShadow() const;
    00138
    00139     bool hasVisibleBackground() const;
    00140     void showBackground(bool);
    00141
    00142     void setLineWidth(int);
    00143     int lineWidth() const;
    00144
    00145     void setMode(Mode);
    00146     Mode mode() const;
    00147
    00148     virtual void setWrapping(bool);
    00149     bool wrapping() const;
    00150
    00151     virtual void setScale(int maxMajIntv, int maxMinIntv, double step = 0.0);
    00152
    00153     void setScaleArc(double min, double max);
    00154     void setScaleOptions(int);
    00155     void setScaleTicks(int minLen, int medLen, int majLen, int penWidth = 1);
    00156
    00157     double minScaleArc() const;
    00158     double maxScaleArc() const;
    00159
    00160     virtual void setOrigin(double);
    00161     double origin() const;
    00162
    00163     void setDirection(Direction);
    00164     Direction direction() const;
    00165
    00166     virtual void setNeedle(QwtDialNeedle *);
    00167     const QwtDialNeedle *needle() const;
    00168     QwtDialNeedle *needle();
    00169
    00170     QRect boundingRect() const;
    00171     QRect contentsRect() const;
    00172     virtual QRect scaleContentsRect() const;
    00173
    00174     virtual QSize sizeHint() const;
    00175     virtual QSize minimumSizeHint() const;
    00176
    00177     virtual void setScaleDraw(QwtDialScaleDraw *);
    00178
    00179     QwtDialScaleDraw *scaleDraw();
    00180     const QwtDialScaleDraw *scaleDraw() const;
    00181
    00182 protected:
    00183     virtual void paintEvent(QPaintEvent *);
    00184     virtual void resizeEvent(QResizeEvent *);
    00185     virtual void keyPressEvent(QKeyEvent *);
    00186
    00187     virtual void updateMask();
    00188
    00189     virtual void drawFrame(QPainter *p);
    00190     virtual void drawContents(QPainter *) const;
    00191     virtual void drawFocusIndicator(QPainter *) const;
    00192
    00193     virtual void drawScale(QPainter *, const QPoint &center,
    00194         int radius, double origin, double arcMin, double arcMax) const;
    00195
    00205     virtual void drawScaleContents(QPainter *painter, const QPoint &center,
    00206         int radius) const;
    00207
    00208     virtual void drawNeedle(QPainter *, const QPoint &,
    00209         int radius, double direction, QPalette::ColorGroup) const;
    00210
    00211     virtual QwtText scaleLabel(double) const;
    00212     void updateScale();
    00213
    00214     virtual void rangeChange();
    00215     virtual void valueChange();
    00216
    00217     virtual double getValue(const QPoint &);
    00218     virtual void getScrollMode(const QPoint &,
    00219         int &scrollMode, int &direction);
    00220
    00221 private:
    00222     void initDial();
    00223
    00224     class PrivateData;
    00225     PrivateData *d_data;
    00226 };
    00227
    00228 #endif