Qwt User's Guide
svn
|
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 #ifndef QWT_COUNTER_H 00011 #define QWT_COUNTER_H 00012 00013 #include "qwt_global.h" 00014 #include "qwt_double_range.h" 00015 #include <qwidget.h> 00016 00058 class QWT_EXPORT QwtCounter : public QWidget, public QwtDoubleRange 00059 { 00060 Q_OBJECT 00061 00062 Q_PROPERTY( int numButtons READ numButtons WRITE setNumButtons ) 00063 Q_PROPERTY( double basicstep READ step WRITE setStep ) 00064 Q_PROPERTY( double minValue READ minValue WRITE setMinValue ) 00065 Q_PROPERTY( double maxValue READ maxValue WRITE setMaxValue ) 00066 Q_PROPERTY( int stepButton1 READ stepButton1 WRITE setStepButton1 ) 00067 Q_PROPERTY( int stepButton2 READ stepButton2 WRITE setStepButton2 ) 00068 Q_PROPERTY( int stepButton3 READ stepButton3 WRITE setStepButton3 ) 00069 Q_PROPERTY( double value READ value WRITE setValue ) 00070 Q_PROPERTY( bool editable READ editable WRITE setEditable ) 00071 00072 public: 00074 enum Button 00075 { 00077 Button1, 00078 00080 Button2, 00081 00083 Button3, 00084 00086 ButtonCnt 00087 }; 00088 00089 explicit QwtCounter( QWidget *parent = NULL ); 00090 virtual ~QwtCounter(); 00091 00092 bool editable() const; 00093 void setEditable( bool ); 00094 00095 void setNumButtons( int n ); 00096 int numButtons() const; 00097 00098 void setIncSteps( QwtCounter::Button btn, int nSteps ); 00099 int incSteps( QwtCounter::Button btn ) const; 00100 00101 virtual void setValue( double ); 00102 virtual QSize sizeHint() const; 00103 00104 // a set of dummies to help the designer 00105 00106 double step() const; 00107 void setStep( double s ); 00108 00109 double minValue() const; 00110 void setMinValue( double m ); 00111 00112 double maxValue() const; 00113 void setMaxValue( double m ); 00114 00115 void setStepButton1( int nSteps ); 00116 int stepButton1() const; 00117 00118 void setStepButton2( int nSteps ); 00119 int stepButton2() const; 00120 00121 void setStepButton3( int nSteps ); 00122 int stepButton3() const; 00123 00124 virtual double value() const; 00125 00126 Q_SIGNALS: 00131 void buttonReleased ( double value ); 00132 00137 void valueChanged ( double value ); 00138 00139 protected: 00140 virtual bool event( QEvent * ); 00141 virtual void wheelEvent( QWheelEvent * ); 00142 virtual void keyPressEvent( QKeyEvent * ); 00143 virtual void rangeChange(); 00144 00145 private Q_SLOTS: 00146 void btnReleased(); 00147 void btnClicked(); 00148 void textChanged(); 00149 00150 private: 00151 void initCounter(); 00152 void updateButtons(); 00153 void showNum( double ); 00154 virtual void valueChange(); 00155 00156 class PrivateData; 00157 PrivateData *d_data; 00158 }; 00159 00160 #endif