[4271] | 1 | /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
---|
| 2 | * Qwt Widget Library
|
---|
| 3 | * Copyright (C) 1997 Josef Wilgen
|
---|
| 4 | * Copyright (C) 2002 Uwe Rathmann
|
---|
| 5 | *
|
---|
| 6 | * This library is free software; you can redistribute it and/or
|
---|
| 7 | * modify it under the terms of the Qwt License, Version 1.0
|
---|
| 8 | *****************************************************************************/
|
---|
| 9 |
|
---|
| 10 | #ifndef QWT_LEGEND_H
|
---|
| 11 | #define QWT_LEGEND_H
|
---|
| 12 |
|
---|
| 13 | #include "qwt_global.h"
|
---|
[8127] | 14 | #include "qwt_abstract_legend.h"
|
---|
| 15 | #include <qvariant.h>
|
---|
[4271] | 16 |
|
---|
| 17 | class QScrollBar;
|
---|
| 18 |
|
---|
| 19 | /*!
|
---|
| 20 | \brief The legend widget
|
---|
| 21 |
|
---|
| 22 | The QwtLegend widget is a tabular arrangement of legend items. Legend
|
---|
| 23 | items might be any type of widget, but in general they will be
|
---|
[8127] | 24 | a QwtLegendLabel.
|
---|
[4271] | 25 |
|
---|
[8127] | 26 | \sa QwtLegendLabel, QwtPlotItem, QwtPlot
|
---|
[4271] | 27 | */
|
---|
| 28 |
|
---|
[8127] | 29 | class QWT_EXPORT QwtLegend : public QwtAbstractLegend
|
---|
[4271] | 30 | {
|
---|
| 31 | Q_OBJECT
|
---|
| 32 |
|
---|
| 33 | public:
|
---|
| 34 | explicit QwtLegend( QWidget *parent = NULL );
|
---|
| 35 | virtual ~QwtLegend();
|
---|
| 36 |
|
---|
[8127] | 37 | void setMaxColumns( uint numColums );
|
---|
| 38 | uint maxColumns() const;
|
---|
[4271] | 39 |
|
---|
[8127] | 40 | void setDefaultItemMode( QwtLegendData::Mode );
|
---|
| 41 | QwtLegendData::Mode defaultItemMode() const;
|
---|
| 42 |
|
---|
[4271] | 43 | QWidget *contentsWidget();
|
---|
| 44 | const QWidget *contentsWidget() const;
|
---|
| 45 |
|
---|
[8127] | 46 | QWidget *legendWidget( const QVariant & ) const;
|
---|
| 47 | QList<QWidget *> legendWidgets( const QVariant & ) const;
|
---|
[4271] | 48 |
|
---|
[8127] | 49 | QVariant itemInfo( const QWidget * ) const;
|
---|
[4271] | 50 |
|
---|
| 51 | virtual bool eventFilter( QObject *, QEvent * );
|
---|
| 52 |
|
---|
| 53 | virtual QSize sizeHint() const;
|
---|
[9383] | 54 | virtual int heightForWidth( int width ) const;
|
---|
[4271] | 55 |
|
---|
| 56 | QScrollBar *horizontalScrollBar() const;
|
---|
| 57 | QScrollBar *verticalScrollBar() const;
|
---|
| 58 |
|
---|
[9383] | 59 | virtual void renderLegend( QPainter *,
|
---|
[8127] | 60 | const QRectF &, bool fillBackground ) const;
|
---|
| 61 |
|
---|
[9383] | 62 | virtual void renderItem( QPainter *,
|
---|
[8127] | 63 | const QWidget *, const QRectF &, bool fillBackground ) const;
|
---|
| 64 |
|
---|
| 65 | virtual bool isEmpty() const;
|
---|
| 66 | virtual int scrollExtent( Qt::Orientation ) const;
|
---|
| 67 |
|
---|
| 68 | Q_SIGNALS:
|
---|
| 69 | /*!
|
---|
| 70 | A signal which is emitted when the user has clicked on
|
---|
| 71 | a legend label, which is in QwtLegendData::Clickable mode.
|
---|
| 72 |
|
---|
| 73 | \param itemInfo Info for the item item of the
|
---|
| 74 | selected legend item
|
---|
| 75 | \param index Index of the legend label in the list of widgets
|
---|
| 76 | that are associated with the plot item
|
---|
| 77 |
|
---|
| 78 | \note clicks are disabled as default
|
---|
| 79 | \sa setDefaultItemMode(), defaultItemMode(), QwtPlot::itemToInfo()
|
---|
| 80 | */
|
---|
| 81 | void clicked( const QVariant &itemInfo, int index );
|
---|
| 82 |
|
---|
| 83 | /*!
|
---|
| 84 | A signal which is emitted when the user has clicked on
|
---|
| 85 | a legend label, which is in QwtLegendData::Checkable mode
|
---|
| 86 |
|
---|
| 87 | \param itemInfo Info for the item of the
|
---|
| 88 | selected legend label
|
---|
| 89 | \param index Index of the legend label in the list of widgets
|
---|
| 90 | that are associated with the plot item
|
---|
| 91 | \param on True when the legend label is checked
|
---|
| 92 |
|
---|
| 93 | \note clicks are disabled as default
|
---|
| 94 | \sa setDefaultItemMode(), defaultItemMode(), QwtPlot::itemToInfo()
|
---|
| 95 | */
|
---|
| 96 | void checked( const QVariant &itemInfo, bool on, int index );
|
---|
| 97 |
|
---|
| 98 | public Q_SLOTS:
|
---|
| 99 | virtual void updateLegend( const QVariant &,
|
---|
| 100 | const QList<QwtLegendData> & );
|
---|
| 101 |
|
---|
| 102 | protected Q_SLOTS:
|
---|
| 103 | void itemClicked();
|
---|
| 104 | void itemChecked( bool );
|
---|
| 105 |
|
---|
[4271] | 106 | protected:
|
---|
[8127] | 107 | virtual QWidget *createWidget( const QwtLegendData & ) const;
|
---|
[9383] | 108 | virtual void updateWidget( QWidget *widget, const QwtLegendData & );
|
---|
[4271] | 109 |
|
---|
| 110 | private:
|
---|
[8127] | 111 | void updateTabOrder();
|
---|
| 112 |
|
---|
[4271] | 113 | class PrivateData;
|
---|
| 114 | PrivateData *d_data;
|
---|
| 115 | };
|
---|
| 116 |
|
---|
[9383] | 117 | #endif
|
---|