qwt_legend.h 3.36 KB
Newer Older
pixhawk's avatar
pixhawk committed
1 2 3 4 5 6 7 8 9 10 11 12 13
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
 * Qwt Widget Library
 * Copyright (C) 1997   Josef Wilgen
 * Copyright (C) 2002   Uwe Rathmann
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the Qwt License, Version 1.0
 *****************************************************************************/

#ifndef QWT_LEGEND_H
#define QWT_LEGEND_H

#include "qwt_global.h"
Bryant's avatar
Bryant committed
14 15
#include "qwt_abstract_legend.h"
#include <qvariant.h>
pixhawk's avatar
pixhawk committed
16 17 18 19 20 21 22 23

class QScrollBar;

/*!
  \brief The legend widget

  The QwtLegend widget is a tabular arrangement of legend items. Legend
  items might be any type of widget, but in general they will be
Bryant's avatar
Bryant committed
24
  a QwtLegendLabel.
pixhawk's avatar
pixhawk committed
25

Bryant's avatar
Bryant committed
26
  \sa QwtLegendLabel, QwtPlotItem, QwtPlot
pixhawk's avatar
pixhawk committed
27 28
*/

Bryant's avatar
Bryant committed
29
class QWT_EXPORT QwtLegend : public QwtAbstractLegend
pixhawk's avatar
pixhawk committed
30 31 32 33
{
    Q_OBJECT

public:
Bryant's avatar
Bryant committed
34 35
    explicit QwtLegend( QWidget *parent = NULL );
    virtual ~QwtLegend();
pixhawk's avatar
pixhawk committed
36

Bryant's avatar
Bryant committed
37 38
    void setMaxColumns( uint numColums );
    uint maxColumns() const;
pixhawk's avatar
pixhawk committed
39

Bryant's avatar
Bryant committed
40 41
    void setDefaultItemMode( QwtLegendData::Mode );
    QwtLegendData::Mode defaultItemMode() const;
pixhawk's avatar
pixhawk committed
42

Bryant's avatar
Bryant committed
43 44
    QWidget *contentsWidget();
    const QWidget *contentsWidget() const;
pixhawk's avatar
pixhawk committed
45

Bryant's avatar
Bryant committed
46 47
    QWidget *legendWidget( const QVariant &  ) const;
    QList<QWidget *> legendWidgets( const QVariant & ) const;
pixhawk's avatar
pixhawk committed
48

Bryant's avatar
Bryant committed
49
    QVariant itemInfo( const QWidget * ) const;
pixhawk's avatar
pixhawk committed
50

Bryant's avatar
Bryant committed
51
    virtual bool eventFilter( QObject *, QEvent * );
pixhawk's avatar
pixhawk committed
52

Bryant's avatar
Bryant committed
53 54
    virtual QSize sizeHint() const;
    virtual int heightForWidth( int w ) const;
55

Bryant's avatar
Bryant committed
56 57
    QScrollBar *horizontalScrollBar() const;
    QScrollBar *verticalScrollBar() const;
pixhawk's avatar
pixhawk committed
58

Bryant's avatar
Bryant committed
59 60
    virtual void renderLegend( QPainter *, 
        const QRectF &, bool fillBackground ) const;
pixhawk's avatar
pixhawk committed
61

Bryant's avatar
Bryant committed
62 63
    virtual void renderItem( QPainter *, 
        const QWidget *, const QRectF &, bool fillBackground ) const;
pixhawk's avatar
pixhawk committed
64

Bryant's avatar
Bryant committed
65 66
    virtual bool isEmpty() const;
    virtual int scrollExtent( Qt::Orientation ) const;
pixhawk's avatar
pixhawk committed
67

Bryant's avatar
Bryant committed
68 69 70 71
Q_SIGNALS:
    /*!
      A signal which is emitted when the user has clicked on
      a legend label, which is in QwtLegendData::Clickable mode.
pixhawk's avatar
pixhawk committed
72

Bryant's avatar
Bryant committed
73 74 75 76
      \param itemInfo Info for the item item of the
                      selected legend item
      \param index Index of the legend label in the list of widgets
                   that are associated with the plot item
pixhawk's avatar
pixhawk committed
77

Bryant's avatar
Bryant committed
78 79 80 81
      \note clicks are disabled as default
      \sa setDefaultItemMode(), defaultItemMode(), QwtPlot::itemToInfo()
     */
    void clicked( const QVariant &itemInfo, int index );
pixhawk's avatar
pixhawk committed
82

Bryant's avatar
Bryant committed
83 84 85
    /*!
      A signal which is emitted when the user has clicked on
      a legend label, which is in QwtLegendData::Checkable mode
86

Bryant's avatar
Bryant committed
87 88 89 90 91
      \param itemInfo Info for the item of the
                      selected legend label
      \param index Index of the legend label in the list of widgets
                   that are associated with the plot item
      \param on True when the legend label is checked
pixhawk's avatar
pixhawk committed
92

Bryant's avatar
Bryant committed
93 94 95 96
      \note clicks are disabled as default
      \sa setDefaultItemMode(), defaultItemMode(), QwtPlot::itemToInfo()
     */
    void checked( const QVariant &itemInfo, bool on, int index );
pixhawk's avatar
pixhawk committed
97

Bryant's avatar
Bryant committed
98 99 100
public Q_SLOTS:
    virtual void updateLegend( const QVariant &,
        const QList<QwtLegendData> & );
pixhawk's avatar
pixhawk committed
101

Bryant's avatar
Bryant committed
102 103 104
protected Q_SLOTS:
    void itemClicked();
    void itemChecked( bool );
pixhawk's avatar
pixhawk committed
105 106

protected:
Bryant's avatar
Bryant committed
107 108
    virtual QWidget *createWidget( const QwtLegendData & ) const;
    virtual void updateWidget( QWidget *widget, const QwtLegendData &data );
pixhawk's avatar
pixhawk committed
109 110

private:
Bryant's avatar
Bryant committed
111 112
    void updateTabOrder();

pixhawk's avatar
pixhawk committed
113 114 115 116
    class PrivateData;
    PrivateData *d_data;
};

Bryant's avatar
Bryant committed
117
#endif