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 
00074     Q_PROPERTY(bool visibleBackground READ hasVisibleBackground WRITE showBackground)
00075     Q_PROPERTY(int lineWidth READ lineWidth WRITE setLineWidth)
00076     Q_PROPERTY(Shadow frameShadow READ frameShadow WRITE setFrameShadow)
00077     Q_PROPERTY(Mode mode READ mode WRITE setMode)
00078     Q_PROPERTY(double origin READ origin WRITE setOrigin)
00079     Q_PROPERTY(bool wrapping READ wrapping WRITE setWrapping)
00080 
00081     friend class QwtDialScaleDraw;
00082 public:
00083 
00092     enum Shadow
00093     {
00094         Plain = QFrame::Plain,
00095         Raised = QFrame::Raised,
00096         Sunken = QFrame::Sunken
00097     };
00098 
00100     enum ScaleOptions
00101     {
00102         ScaleBackbone = 1,
00103         ScaleTicks = 2,
00104         ScaleLabel = 4
00105     };
00106 
00112     enum Mode
00113     {
00114         RotateNeedle,
00115         RotateScale
00116     };
00117 
00118     explicit QwtDial( QWidget *parent = NULL);
00119 #if QT_VERSION < 0x040000
00120     explicit QwtDial( QWidget *parent, const char *name);
00121 #endif
00122 
00123     virtual ~QwtDial();
00124 
00125     void setFrameShadow(Shadow);
00126     Shadow frameShadow() const;
00127 
00128     bool hasVisibleBackground() const;
00129     void showBackground(bool);
00130 
00131     void setLineWidth(int);
00132     int lineWidth() const;
00133 
00134     void setMode(Mode);
00135     Mode mode() const;
00136 
00137     virtual void setWrapping(bool);
00138     bool wrapping() const;
00139 
00140     virtual void setScale(int maxMajIntv, int maxMinIntv, double step = 0.0);
00141 
00142     void setScaleArc(double min, double max);
00143     void setScaleOptions(int);
00144     void setScaleTicks(int minLen, int medLen, int majLen, int penWidth = 1);
00145 
00146     double minScaleArc() const;
00147     double maxScaleArc() const;
00148 
00149     virtual void setOrigin(double);
00150     double origin() const;
00151 
00152     virtual void setNeedle(QwtDialNeedle *);
00153     const QwtDialNeedle *needle() const;
00154     QwtDialNeedle *needle();
00155 
00156     QRect boundingRect() const;
00157     QRect contentsRect() const;
00158     virtual QRect scaleContentsRect() const;
00159 
00160     virtual QSize sizeHint() const;
00161     virtual QSize minimumSizeHint() const;
00162 
00163     virtual void setScaleDraw(QwtDialScaleDraw *);
00164 
00165     QwtDialScaleDraw *scaleDraw();
00166     const QwtDialScaleDraw *scaleDraw() const;
00167 
00168 protected:
00169     virtual void paintEvent(QPaintEvent *);
00170     virtual void resizeEvent(QResizeEvent *);
00171     virtual void keyPressEvent(QKeyEvent *);
00172 
00173     virtual void updateMask();
00174 
00175     virtual void drawFrame(QPainter *p);
00176     virtual void drawContents(QPainter *) const;
00177     virtual void drawFocusIndicator(QPainter *) const;
00178 
00179     virtual void drawScale(QPainter *, const QPoint &center,
00180         int radius, double origin, double arcMin, double arcMax) const;
00181 
00191     virtual void drawScaleContents(QPainter *painter, const QPoint &center, 
00192         int radius) const;
00193 
00194     virtual void drawNeedle(QPainter *, const QPoint &, 
00195         int radius, double direction, QPalette::ColorGroup) const;
00196 
00197     virtual QwtText scaleLabel(double) const;
00198     void updateScale();
00199 
00200     virtual void rangeChange();
00201     virtual void valueChange();
00202 
00203     virtual double getValue(const QPoint &);
00204     virtual void getScrollMode(const QPoint &, 
00205         int &scrollMode, int &direction);
00206 
00207 private:
00208     void initDial();
00209 
00210     class PrivateData;
00211     PrivateData *d_data;
00212 };
00213 
00214 #endif

Generated on Mon Feb 26 21:22:36 2007 for Qwt User's Guide by  doxygen 1.4.6