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_double_range.h"
00018 
00060 class QWT_EXPORT QwtCounter : public QWidget, public QwtDoubleRange
00061 {
00062     Q_OBJECT
00063 
00064     Q_PROPERTY( int numButtons READ numButtons WRITE setNumButtons )
00065     Q_PROPERTY( double basicstep READ step WRITE setStep )
00066     Q_PROPERTY( double minValue READ minVal WRITE setMinValue )
00067     Q_PROPERTY( double maxValue READ maxVal WRITE setMaxValue )
00068     Q_PROPERTY( int stepButton1 READ stepButton1 WRITE setStepButton1 )
00069     Q_PROPERTY( int stepButton2 READ stepButton2 WRITE setStepButton2 )
00070     Q_PROPERTY( int stepButton3 READ stepButton3 WRITE setStepButton3 )
00071     Q_PROPERTY( double value READ value WRITE setValue )
00072     Q_PROPERTY( bool editable READ editable WRITE setEditable )
00073 
00074 public:
00079     enum Button 
00080     {   
00081         Button1,    
00082         Button2,    
00083         Button3,    
00084         ButtonCnt   
00085     };
00086 
00087     explicit QwtCounter(QWidget *parent = NULL);
00088 #if QT_VERSION < 0x040000
00089     explicit QwtCounter(QWidget *parent, const char *name);
00090 #endif
00091     virtual ~QwtCounter();
00092 
00093     bool editable() const;
00094     void setEditable(bool);
00095  
00096     void setNumButtons(int n);
00097     int numButtons() const;
00098     
00099     void setIncSteps(QwtCounter::Button btn, int nSteps);
00100     int incSteps(QwtCounter::Button btn) const;
00101 
00102     virtual void setValue(double);
00103     virtual QSize sizeHint() const;
00104 
00105     virtual void polish();
00106 
00107     // a set of dummies to help the designer
00108 
00109     double step() const;
00110     void setStep(double s);
00111     double minVal() const;
00112     void setMinValue(double m);
00113     double maxVal() const;
00114     void setMaxValue(double m);
00115     void setStepButton1(int nSteps);
00116     int stepButton1() const;
00117     void setStepButton2(int nSteps);
00118     int stepButton2() const;
00119     void setStepButton3(int nSteps);
00120     int stepButton3() const;
00121     virtual double value() const;
00122 
00123 signals:
00128     void buttonReleased (double value);  
00129 
00134     void valueChanged (double value);
00135 
00136 protected:
00137     virtual bool event(QEvent *);
00138     virtual void wheelEvent(QWheelEvent *);
00139     virtual void keyPressEvent(QKeyEvent *);
00140     virtual void rangeChange();
00141 
00142 private slots:
00143     void btnReleased();
00144     void btnClicked();
00145     void textChanged();
00146 
00147 private:
00148     void initCounter();
00149     void updateButtons();
00150     void showNum(double);
00151     virtual void valueChange();
00152     
00153     class PrivateData;
00154     PrivateData *d_data;
00155 };
00156 
00157 #endif

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