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

« back to all changes in this revision

Viewing changes to qwt-5.0.1/src/qwt_counter.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_COUNTER_H
13
 
#define QWT_COUNTER_H
14
 
 
15
 
#include <qwidget.h>
16
 
#include "qwt_global.h"
17
 
#include "qwt_double_range.h"
18
 
 
19
 
/*!
20
 
  \brief The Counter Widget
21
 
 
22
 
  A Counter consists of a label displaying a number and
23
 
  one ore more (up to three) push buttons on each side
24
 
  of the label which can be used to increment or decrement
25
 
  the counter's value.
26
 
 
27
 
  A Counter has a range from a minimum value to a maximum value
28
 
  and a step size. The range can be specified using
29
 
  QwtDblRange::setRange().
30
 
  The counter's value is an integer multiple of the step size.
31
 
  The number of steps by which a button increments or decrements
32
 
  the value can be specified using QwtCounter::setIncSteps().
33
 
  The number of buttons can be changed with
34
 
  QwtCounter::setNumButtons().
35
 
 
36
 
  Holding the space bar down with focus on a button is the
37
 
  fastest method to step through the counter values.
38
 
  When the counter underflows/overflows, the focus is set
39
 
  to the smallest up/down button and counting is disabled.
40
 
  Counting is re-enabled on a button release event (mouse or
41
 
  space bar).
42
 
 
43
 
  Example:
44
 
\code
45
 
#include "../include/qwt_counter.h>
46
 
 
47
 
QwtCounter *cnt;
48
 
 
49
 
cnt = new QwtCounter(parent, name);
50
 
 
51
 
cnt->setRange(0.0, 100.0, 1.0);             // From 0.0 to 100, step 1.0
52
 
cnt->setNumButtons(2);                      // Two buttons each side
53
 
cnt->setIncSteps(QwtCounter::Button1, 1);   // Button 1 increments 1 step
54
 
cnt->setIncSteps(QwtCounter::Button2, 20);  // Button 2 increments 20 steps
55
 
 
56
 
connect(cnt, SIGNAL(valueChanged(double)), my_class, SLOT(newValue(double)));
57
 
\endcode
58
 
 */
59
 
 
60
 
class QWT_EXPORT QwtCounter : public QWidget, public QwtDoubleRange
61
 
{
62
 
    Q_OBJECT
63
 
 
64
 
    Q_PROPERTY( int numButtons READ numButtons WRITE setNumButtons )
65
 
    Q_PROPERTY( double basicstep READ step WRITE setStep )
66
 
    Q_PROPERTY( double minValue READ minVal WRITE setMinValue )
67
 
    Q_PROPERTY( double maxValue READ maxVal WRITE setMaxValue )
68
 
    Q_PROPERTY( int stepButton1 READ stepButton1 WRITE setStepButton1 )
69
 
    Q_PROPERTY( int stepButton2 READ stepButton2 WRITE setStepButton2 )
70
 
    Q_PROPERTY( int stepButton3 READ stepButton3 WRITE setStepButton3 )
71
 
    Q_PROPERTY( double value READ value WRITE setValue )
72
 
    Q_PROPERTY( bool editable READ editable WRITE setEditable )
73
 
 
74
 
public:
75
 
    /*!
76
 
        Button index
77
 
    */
78
 
 
79
 
    enum Button 
80
 
    {   
81
 
        Button1,    
82
 
        Button2,    
83
 
        Button3,    
84
 
        ButtonCnt   
85
 
    };
86
 
 
87
 
    explicit QwtCounter(QWidget *parent = NULL);
88
 
#if QT_VERSION < 0x040000
89
 
    explicit QwtCounter(QWidget *parent, const char *name);
90
 
#endif
91
 
    virtual ~QwtCounter();
92
 
 
93
 
    bool editable() const;
94
 
    void setEditable(bool);
95
 
 
96
 
    void setNumButtons(int n);
97
 
    int numButtons() const;
98
 
    
99
 
    void setIncSteps(QwtCounter::Button btn, int nSteps);
100
 
    int incSteps(QwtCounter::Button btn) const;
101
 
 
102
 
    virtual void setValue(double);
103
 
    virtual QSize sizeHint() const;
104
 
 
105
 
    virtual void polish();
106
 
 
107
 
    // a set of dummies to help the designer
108
 
 
109
 
    double step() const;
110
 
    void setStep(double s);
111
 
    double minVal() const;
112
 
    void setMinValue(double m);
113
 
    double maxVal() const;
114
 
    void setMaxValue(double m);
115
 
    void setStepButton1(int nSteps);
116
 
    int stepButton1() const;
117
 
    void setStepButton2(int nSteps);
118
 
    int stepButton2() const;
119
 
    void setStepButton3(int nSteps);
120
 
    int stepButton3() const;
121
 
    virtual double value() const;
122
 
 
123
 
signals:
124
 
    /*!
125
 
        This signal is emitted when a button has been released
126
 
        \param value The new value
127
 
    */
128
 
    void buttonReleased (double value);  
129
 
 
130
 
    /*!
131
 
        This signal is emitted when the counter's value has changed
132
 
        \param value The new value
133
 
    */
134
 
    void valueChanged (double value);
135
 
 
136
 
protected:
137
 
    virtual bool event(QEvent *);
138
 
    virtual void wheelEvent(QWheelEvent *);
139
 
    virtual void keyPressEvent(QKeyEvent *);
140
 
    virtual void rangeChange();
141
 
 
142
 
private slots:
143
 
    void btnReleased();
144
 
    void btnClicked();
145
 
    void textChanged();
146
 
 
147
 
private:
148
 
    void initCounter();
149
 
    void updateButtons();
150
 
    void showNum(double);
151
 
    virtual void valueChange();
152
 
    
153
 
    class PrivateData;
154
 
    PrivateData *d_data;
155
 
};
156
 
 
157
 
#endif