00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef QWT_LEGEND_ITEM_H
00013 #define QWT_LEGEND_ITEM_H
00014
00015 #include "qwt_global.h"
00016 #include "qwt_legend.h"
00017 #include "qwt_text.h"
00018 #include "qwt_text_label.h"
00019
00020 class QPainter;
00021 class QPen;
00022 class QwtSymbol;
00023
00024 class QWT_EXPORT QwtLegendItem: public QwtTextLabel
00025 {
00026 Q_OBJECT
00027 public:
00035 enum IdentifierMode
00036 {
00037 NoIdentifier = 0,
00038 ShowLine = 1,
00039 ShowSymbol = 2,
00040 ShowText = 4
00041 };
00042
00043 explicit QwtLegendItem(QWidget *parent = 0);
00044 virtual ~QwtLegendItem();
00045
00046 void setItemMode(QwtLegend::LegendItemMode);
00047 QwtLegend::LegendItemMode itemMode() const;
00048
00049 virtual void setText(const QwtText &);
00050
00051 void setSpacing(int spacing);
00052 int spacing() const;
00053
00054 void setIdentifierMode(int);
00055 int identifierMode() const;
00056
00057 void setIdentifierWidth(int width);
00058 int identifierWidth() const;
00059
00060 virtual QSize sizeHint() const;
00061
00062 bool isChecked() const;
00063
00064 virtual void drawIdentifier(QPainter *, const QRect &) const = 0;
00065 virtual void drawItem(QPainter *p, const QRect &) const;
00066
00067 public slots:
00068 void setChecked(bool on);
00069
00070 signals:
00072 void clicked();
00073
00075 void pressed();
00076
00078 void released();
00079
00081 void checked(bool);
00082
00083 protected:
00084 void setDown(bool);
00085 bool isDown() const;
00086
00087 virtual void paintEvent(QPaintEvent *);
00088 virtual void mousePressEvent(QMouseEvent *);
00089 virtual void mouseReleaseEvent(QMouseEvent *);
00090 virtual void keyPressEvent(QKeyEvent *);
00091 virtual void keyReleaseEvent(QKeyEvent *);
00092
00093 private:
00094 class PrivateData;
00095 PrivateData *d_data;
00096 };
00097
00109 class QWT_EXPORT QwtLegendCurveItem: public QwtLegendItem
00110 {
00111 Q_OBJECT
00112 public:
00113
00114 explicit QwtLegendCurveItem(QWidget *parent = 0);
00115 explicit QwtLegendCurveItem(const QwtSymbol &, const QPen &,
00116 const QwtText &, QWidget *parent = 0);
00117 virtual ~QwtLegendCurveItem();
00118
00119 void setSymbol(const QwtSymbol &);
00120 const QwtSymbol& symbol() const;
00121
00122 void setCurvePen(const QPen &);
00123 const QPen& curvePen() const;
00124
00125 virtual void drawIdentifier(QPainter *, const QRect &) const;
00126
00127 private:
00128 class PrivateData;
00129 PrivateData *d_data;
00130 };
00131
00132 #endif // QWT_LEGEND_ITEM_H