~ubuntu-branches/ubuntu/oneiric/qwt/oneiric-proposed

« back to all changes in this revision

Viewing changes to qwt-5.0.1/src/qwt_dial.h

  • Committer: Bazaar Package Importer
  • Author(s): Fathi Boudra
  • Date: 2007-10-05 15:20:41 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20071005152041-qmybqh4fj9jejyo2
Tags: 5.0.2-2
* Handle nostrip build option. (Closes: #437877)
* Build libqwt5-doc package in binary-indep target. (Closes: #443110)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
2
 
 * Qwt Widget Library
3
 
 * Copyright (C) 1997   Josef Wilgen
4
 
 * Copyright (C) 2002   Uwe Rathmann
5
 
 *
6
 
 * This library is free software; you can redistribute it and/or
7
 
 * modify it under the terms of the Qwt License, Version 1.0
8
 
 *****************************************************************************/
9
 
 
10
 
// vim: expandtab
11
 
 
12
 
#ifndef QWT_DIAL_H
13
 
#define QWT_DIAL_H 1
14
 
 
15
 
#include <qframe.h>
16
 
#include <qpalette.h>
17
 
#include "qwt_global.h"
18
 
#include "qwt_abstract_slider.h"
19
 
#include "qwt_round_scale_draw.h"
20
 
 
21
 
class QwtDialNeedle;
22
 
class QwtDial;
23
 
 
24
 
/*!
25
 
  \brief A special scale draw made for QwtDial
26
 
  
27
 
  \sa QwtDial, QwtCompass
28
 
*/
29
 
class QWT_EXPORT QwtDialScaleDraw: public QwtRoundScaleDraw
30
 
{
31
 
public:
32
 
    explicit QwtDialScaleDraw(QwtDial *);
33
 
    virtual QwtText label(double value) const;
34
 
 
35
 
    void setPenWidth(uint);
36
 
    uint penWidth() const;
37
 
 
38
 
private:
39
 
    QwtDial *d_parent;
40
 
    int d_penWidth;
41
 
};
42
 
 
43
 
/*!
44
 
  \brief QwtDial class provides a rounded range control. 
45
 
 
46
 
  QwtDial is intended as base class for dial widgets like
47
 
  speedometers, compass widgets, clocks ... 
48
 
 
49
 
  \image html dials2.png
50
 
 
51
 
  A dial contains a scale and a needle indicating the current value
52
 
  of the dial. Depending on Mode one of them is fixed and the 
53
 
  other is rotating. If not isReadOnly() the
54
 
  dial can be rotated by dragging the mouse or using keyboard inputs 
55
 
  (see keyPressEvent()). A dial might be wrapping, what means
56
 
  a rotation below/above one limit continues on the other limit (f.e compass).
57
 
  The scale might cover any arc of the dial, its values are related to
58
 
  the origin() of the dial.
59
 
  
60
 
  Qwt is missing a set of good looking needles (QwtDialNeedle).
61
 
  Contributions are very welcome.
62
 
  
63
 
  \sa QwtCompass, QwtAnalogClock, QwtDialNeedle
64
 
  \note The examples/dials example shows different types of dials.
65
 
*/
66
 
 
67
 
class QWT_EXPORT QwtDial: public QwtAbstractSlider
68
 
{
69
 
    Q_OBJECT
70
 
 
71
 
    Q_ENUMS(Shadow)
72
 
    Q_ENUMS(Mode)
73
 
 
74
 
    Q_PROPERTY(bool visibleBackground READ hasVisibleBackground WRITE showBackground)
75
 
    Q_PROPERTY(int lineWidth READ lineWidth WRITE setLineWidth)
76
 
    Q_PROPERTY(Shadow frameShadow READ frameShadow WRITE setFrameShadow)
77
 
    Q_PROPERTY(Mode mode READ mode WRITE setMode)
78
 
    Q_PROPERTY(double origin READ origin WRITE setOrigin)
79
 
    Q_PROPERTY(bool wrapping READ wrapping WRITE setWrapping)
80
 
 
81
 
    friend class QwtDialScaleDraw;
82
 
public:
83
 
 
84
 
    /*!
85
 
        \brief Frame shadow
86
 
 
87
 
         Unfortunately it is not possible to use QFrame::Shadow
88
 
         as a property of a widget that is not derived from QFrame.
89
 
         The following enum is made for the designer only. It is safe
90
 
         to use QFrame::Shadow instead.
91
 
     */
92
 
    enum Shadow
93
 
    {
94
 
        Plain = QFrame::Plain,
95
 
        Raised = QFrame::Raised,
96
 
        Sunken = QFrame::Sunken
97
 
    };
98
 
 
99
 
    //! see QwtDial::setScaleOptions
100
 
    enum ScaleOptions
101
 
    {
102
 
        ScaleBackbone = 1,
103
 
        ScaleTicks = 2,
104
 
        ScaleLabel = 4
105
 
    };
106
 
 
107
 
    /*!
108
 
        In case of RotateNeedle the needle is rotating, in case of
109
 
        RotateScale, the needle points to origin()
110
 
        and the scale is rotating.
111
 
    */
112
 
    enum Mode
113
 
    {
114
 
        RotateNeedle,
115
 
        RotateScale
116
 
    };
117
 
 
118
 
    explicit QwtDial( QWidget *parent = NULL);
119
 
#if QT_VERSION < 0x040000
120
 
    explicit QwtDial( QWidget *parent, const char *name);
121
 
#endif
122
 
 
123
 
    virtual ~QwtDial();
124
 
 
125
 
    void setFrameShadow(Shadow);
126
 
    Shadow frameShadow() const;
127
 
 
128
 
    bool hasVisibleBackground() const;
129
 
    void showBackground(bool);
130
 
 
131
 
    void setLineWidth(int);
132
 
    int lineWidth() const;
133
 
 
134
 
    void setMode(Mode);
135
 
    Mode mode() const;
136
 
 
137
 
    virtual void setWrapping(bool);
138
 
    bool wrapping() const;
139
 
 
140
 
    virtual void setScale(int maxMajIntv, int maxMinIntv, double step = 0.0);
141
 
 
142
 
    void setScaleArc(double min, double max);
143
 
    void setScaleOptions(int);
144
 
    void setScaleTicks(int minLen, int medLen, int majLen, int penWidth = 1);
145
 
 
146
 
    double minScaleArc() const;
147
 
    double maxScaleArc() const;
148
 
 
149
 
    virtual void setOrigin(double);
150
 
    double origin() const;
151
 
 
152
 
    virtual void setNeedle(QwtDialNeedle *);
153
 
    const QwtDialNeedle *needle() const;
154
 
    QwtDialNeedle *needle();
155
 
 
156
 
    QRect boundingRect() const;
157
 
    QRect contentsRect() const;
158
 
    virtual QRect scaleContentsRect() const;
159
 
 
160
 
    virtual QSize sizeHint() const;
161
 
    virtual QSize minimumSizeHint() const;
162
 
 
163
 
    virtual void setScaleDraw(QwtDialScaleDraw *);
164
 
 
165
 
    QwtDialScaleDraw *scaleDraw();
166
 
    const QwtDialScaleDraw *scaleDraw() const;
167
 
 
168
 
protected:
169
 
    virtual void paintEvent(QPaintEvent *);
170
 
    virtual void resizeEvent(QResizeEvent *);
171
 
    virtual void keyPressEvent(QKeyEvent *);
172
 
 
173
 
    virtual void updateMask();
174
 
 
175
 
    virtual void drawFrame(QPainter *p);
176
 
    virtual void drawContents(QPainter *) const;
177
 
    virtual void drawFocusIndicator(QPainter *) const;
178
 
 
179
 
    virtual void drawScale(QPainter *, const QPoint &center,
180
 
        int radius, double origin, double arcMin, double arcMax) const;
181
 
 
182
 
    /*!
183
 
      Draw the contents inside the scale
184
 
 
185
 
      Paints nothing.
186
 
 
187
 
      \param painter Painter
188
 
      \param center Center of the contents circle
189
 
      \param radius Radius of the contents circle
190
 
    */
191
 
    virtual void drawScaleContents(QPainter *painter, const QPoint &center, 
192
 
        int radius) const;
193
 
 
194
 
    virtual void drawNeedle(QPainter *, const QPoint &, 
195
 
        int radius, double direction, QPalette::ColorGroup) const;
196
 
 
197
 
    virtual QwtText scaleLabel(double) const;
198
 
    void updateScale();
199
 
 
200
 
    virtual void rangeChange();
201
 
    virtual void valueChange();
202
 
 
203
 
    virtual double getValue(const QPoint &);
204
 
    virtual void getScrollMode(const QPoint &, 
205
 
        int &scrollMode, int &direction);
206
 
 
207
 
private:
208
 
    void initDial();
209
 
 
210
 
    class PrivateData;
211
 
    PrivateData *d_data;
212
 
};
213
 
 
214
 
#endif