00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef QY2BarGraph_h
00025 #define QY2BarGraph_h
00026
00027 #include <qframe.h>
00028 #include <qarray.h>
00029 #include <vector>
00030
00031 using std::vector;
00032
00033
00034 class QY2BarGraph : public QFrame
00035 {
00036 Q_OBJECT
00037
00038 public:
00039
00040 QY2BarGraph( QWidget * parent=0, const char * name=0 );
00041
00045 void addSegment( const QString &label=QString(), int value=0 );
00046
00051 void setSegments( int segmentCount );
00052
00057 void setValue( int segmentNo, int newValue );
00058
00064 void setLabel( int segmentNo, const QString &newLabel );
00065
00069 int segments() const { return _values.size(); }
00070
00074 int value( int segmentNo ) const;
00075
00081 const QString label( int segmentNo ) const;
00082
00086 int sumValues() const;
00087
00088
00094 const QColor segmentBackgroundColor( int segmentNo );
00095
00101 const QColor segmentForegroundColor( int segmentNo );
00102
00106 virtual QSize sizeHint() const;
00107
00108 protected:
00109
00114 virtual void drawContents( QPainter * );
00115
00116
00121 bool index_invalid( int i, const char * function_name ) const;
00122
00123 private:
00124
00125 vector<int> _values;
00126 vector<QString> _labels;
00127 };
00128
00129 #endif // QY2BarGraph_h