1
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
3
* Copyright (C) 1997 Josef Wilgen
4
* Copyright (C) 2002 Uwe Rathmann
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
*****************************************************************************/
16
#include "qwt_global.h"
17
#include "qwt_double_range.h"
20
\brief The Counter Widget
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
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().
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
45
#include "../include/qwt_counter.h>
49
cnt = new QwtCounter(parent, name);
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
56
connect(cnt, SIGNAL(valueChanged(double)), my_class, SLOT(newValue(double)));
60
class QWT_EXPORT QwtCounter : public QWidget, public QwtDoubleRange
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 )
87
explicit QwtCounter(QWidget *parent = NULL);
88
#if QT_VERSION < 0x040000
89
explicit QwtCounter(QWidget *parent, const char *name);
91
virtual ~QwtCounter();
93
bool editable() const;
94
void setEditable(bool);
96
void setNumButtons(int n);
97
int numButtons() const;
99
void setIncSteps(QwtCounter::Button btn, int nSteps);
100
int incSteps(QwtCounter::Button btn) const;
102
virtual void setValue(double);
103
virtual QSize sizeHint() const;
105
virtual void polish();
107
// a set of dummies to help the designer
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;
125
This signal is emitted when a button has been released
126
\param value The new value
128
void buttonReleased (double value);
131
This signal is emitted when the counter's value has changed
132
\param value The new value
134
void valueChanged (double value);
137
virtual bool event(QEvent *);
138
virtual void wheelEvent(QWheelEvent *);
139
virtual void keyPressEvent(QKeyEvent *);
140
virtual void rangeChange();
149
void updateButtons();
150
void showNum(double);
151
virtual void valueChange();