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

qwt_legend.h

Go to the documentation of this file.
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_LEGEND_H
00013 #define QWT_LEGEND_H
00014 
00015 #include <qpen.h>
00016 #include <qscrollview.h>
00017 #include <qpushbutton.h>
00018 #include <qintdict.h>
00019 #include "qwt_global.h"
00020 #include "qwt_symbol.h"
00021 
00022 class QPainter;
00023 
00024 #if defined(QWT_TEMPLATEDLL)
00025 // MOC_SKIP_BEGIN
00026 template class QWT_EXPORT QIntDict<QWidget>;
00027 // MOC_SKIP_END
00028 #endif
00029 
00040 class QWT_EXPORT QwtLegendButton: public QPushButton
00041 {
00042     Q_OBJECT
00043 
00044 public:
00045 
00046     enum IdentifierMode
00047     {
00048         NoIdentifier = 0,
00049         ShowLine = 1,
00050         ShowSymbol = 2,
00051         ShowText = 4
00052     };
00053 
00054     QwtLegendButton(QWidget *parent = 0, const char *name = 0);
00055     QwtLegendButton(const QwtSymbol &, const QPen &,
00056         const QString &, QWidget *parent = 0, const char *name = 0);
00057 
00063     int identifierMode() const { return d_identifierMode; }
00064 
00069     const QwtSymbol& symbol() const { return d_symbol; }
00070 
00075     const QPen& curvePen() const { return d_curvePen; }
00076 
00077     void setIdentifierMode(int);
00078     void setSymbol(const QwtSymbol &);
00079     void setCurvePen(const QPen &);
00080     
00081     virtual void drawContents(QPainter *p, const QRect &) const; 
00082 
00083     virtual QSize sizeHint() const;
00084     virtual QSize minimumSizeHint() const;
00085 
00086 protected:
00087     virtual void updateIconset();
00088     virtual void drawButtonLabel(QPainter *);
00089     virtual void drawIdentifier(QPainter *, const QRect &) const;
00090 
00091 private:
00092     int d_identifierMode;
00093     QwtSymbol d_symbol;
00094     QPen d_curvePen;
00095 };
00096 
00107 class QWT_EXPORT QwtLegend : public QScrollView
00108 {
00109     Q_OBJECT
00110 
00111 public:
00112 
00113     enum LegendDisplayPolicy
00114     {
00115         None = 0,
00116         Fixed = 1,
00117         Auto = 2
00118     };
00119 
00120     QwtLegend(QWidget *parent = 0, const char *name = 0);
00121     
00138     void setDisplayPolicy(int policy, int mode = -1);
00139 
00143     int displayPolicy() const { return d_displayPolicy; }
00144 
00149     int identifierMode() const { return d_identifierMode; }
00150 
00154     QWidget *contentsWidget() { return d_contentsWidget; }
00155 
00159     const QWidget *contentsWidget() const { return d_contentsWidget; }
00160 
00161     void insertItem(QWidget *, long key);
00162 
00164     QWidget *findItem(long key) { return d_items.find(key); }
00165 
00167     const QWidget *findItem(long key) const { return d_items.find(key); }
00168 
00170     QWidget *takeItem(long key) { return d_items.take(key); }
00171 
00172     virtual QIntDictIterator<QWidget> itemIterator() const;
00173 
00174     long key(const QWidget *) const;
00175 
00176     void clear();
00177     
00179     bool isEmpty() const { return d_items.count() == 0; }
00180 
00182     uint itemCount() const { return d_items.count(); }
00183 
00184     virtual bool eventFilter(QObject *, QEvent *);
00185 
00186     virtual QSize sizeHint() const;
00187     virtual int heightForWidth(int w) const;
00188 
00189 protected:
00190     virtual void viewportResizeEvent(QResizeEvent *);
00191     virtual void layoutContents();
00192 
00193 private:
00194     int d_displayPolicy;
00195     int d_identifierMode;
00196     QIntDict<QWidget> d_items;
00197     QWidget *d_contentsWidget;
00198 };
00199 
00200 #endif // QWT_LEGEND_H

Generated on Fri Nov 7 14:11:45 2003 for Qwt Developer's Guide by doxygen 1.3.2