Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

# qwt_counter.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_COUNTER_H
    00013 #define QWT_COUNTER_H
    00014
    00015 #include <qwidget.h>
    00016 #include "qwt_global.h"
    00017 #include "qwt_drange.h"
    00018
    00019 class QwtArrowButton;
    00020 class QLineEdit;
    00021
    00063 class QWT_EXPORT QwtCounter : public QWidget, public QwtDblRange
    00064 {
    00065     Q_OBJECT
    00066
    00067     Q_PROPERTY( int numButtons READ numButtons WRITE setNumButtons )
    00068     Q_PROPERTY( double basicstep READ step WRITE setStep )
    00069     Q_PROPERTY( double minValue READ minVal WRITE setMinValue )
    00070     Q_PROPERTY( double maxValue READ maxVal WRITE setMaxValue )
    00071     Q_PROPERTY( int stepButton1 READ stepButton1 WRITE setStepButton1 )
    00072     Q_PROPERTY( int stepButton2 READ stepButton2 WRITE setStepButton2 )
    00073     Q_PROPERTY( int stepButton3 READ stepButton3 WRITE setStepButton3 )
    00074     Q_PROPERTY( double value READ value WRITE setValue )
    00075
    00076 public:
    00081     enum Button { Button1, Button2, Button3, ButtonCnt };
    00082
    00083     QwtCounter(QWidget *parent = 0, const char *name = 0);
    00084
    00086     double step() const {return QwtDblRange::step();}
    00088     void setStep(double s) {QwtDblRange::setStep(s);}
    00090     double minVal() const {return minValue();}
    00092     void setMinValue(double m) { setRange(m, maxValue(), step());}
    00094     double maxVal() const {return QwtDblRange::maxValue();}
    00096     void setMaxValue(double m) {setRange(minValue(), m, step());}
    00098     void setStepButton1(int nSteps) {setIncSteps(Button1, nSteps);}
    00100     int stepButton1() const {return incSteps(Button1);}
    00102     void setStepButton2(int nSteps) {setIncSteps(Button2, nSteps);}
    00104     int stepButton2() const {return incSteps(Button2);}
    00106     void setStepButton3(int nSteps) {setIncSteps(Button3, nSteps);}
    00108     int stepButton3() const {return incSteps(Button3);}
    00109     virtual double value() const { return QwtDblRange::value();}
    00110
    00111     void setNumButtons(int n);
    00112     int numButtons() const;
    00113
    00114     void setIncSteps(QwtCounter::Button btn, int nSteps);
    00115     int incSteps(QwtCounter::Button btn) const;
    00116
    00117     virtual void setValue(double);
    00118     virtual QSizePolicy sizePolicy() const;
    00119     virtual QSize sizeHint() const;
    00120
    00121     virtual bool eventFilter(QObject *, QEvent *);
    00122
    00123 signals:
    00128     void buttonReleased (double value);
    00129
    00134     void valueChanged (double value);
    00135
    00136 protected:
    00137     virtual void rangeChange();
    00138     virtual void fontChange(const QFont &f);
    00139
    00140 private slots:
    00141     void btnReleased();
    00142     void btnClicked();
    00143
    00144 private:
    00145     void updateButtons();
    00146     void showNum(double);
    00147     virtual void valueChange();
    00148
    00149     QwtArrowButton *d_buttonDown[ButtonCnt];
    00150     QwtArrowButton *d_buttonUp[ButtonCnt];
    00151     QLineEdit *d_valueEdit;
    00152
    00153     int d_increment[ButtonCnt];
    00154     int d_nButtons;
    00155
    00156     bool d_blockKeys;
    00157     bool d_keyPressed;
    00158 };
    00159
    00160 #endif