qwt_legend.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. #ifndef QWT_LEGEND_H
  10. #define QWT_LEGEND_H
  11. #include "qwt_global.h"
  12. #include "qwt_abstract_legend.h"
  13. #include <qvariant.h>
  14. class QScrollBar;
  15. /*!
  16. \brief The legend widget
  17. The QwtLegend widget is a tabular arrangement of legend items. Legend
  18. items might be any type of widget, but in general they will be
  19. a QwtLegendLabel.
  20. \sa QwtLegendLabel, QwtPlotItem, QwtPlot
  21. */
  22. class QWT_EXPORT QwtLegend : public QwtAbstractLegend
  23. {
  24. Q_OBJECT
  25. public:
  26. explicit QwtLegend( QWidget *parent = NULL );
  27. virtual ~QwtLegend();
  28. void setMaxColumns( uint numColums );
  29. uint maxColumns() const;
  30. void setDefaultItemMode( QwtLegendData::Mode );
  31. QwtLegendData::Mode defaultItemMode() const;
  32. QWidget *contentsWidget();
  33. const QWidget *contentsWidget() const;
  34. QWidget *legendWidget( const QVariant & ) const;
  35. QList<QWidget *> legendWidgets( const QVariant & ) const;
  36. QVariant itemInfo( const QWidget * ) const;
  37. virtual bool eventFilter( QObject *, QEvent * );
  38. virtual QSize sizeHint() const;
  39. virtual int heightForWidth( int width ) const;
  40. QScrollBar *horizontalScrollBar() const;
  41. QScrollBar *verticalScrollBar() const;
  42. virtual void renderLegend( QPainter *,
  43. const QRectF &, bool fillBackground ) const;
  44. virtual void renderItem( QPainter *,
  45. const QWidget *, const QRectF &, bool fillBackground ) const;
  46. virtual bool isEmpty() const;
  47. virtual int scrollExtent( Qt::Orientation ) const;
  48. Q_SIGNALS:
  49. /*!
  50. A signal which is emitted when the user has clicked on
  51. a legend label, which is in QwtLegendData::Clickable mode.
  52. \param itemInfo Info for the item item of the
  53. selected legend item
  54. \param index Index of the legend label in the list of widgets
  55. that are associated with the plot item
  56. \note clicks are disabled as default
  57. \sa setDefaultItemMode(), defaultItemMode(), QwtPlot::itemToInfo()
  58. */
  59. void clicked( const QVariant &itemInfo, int index );
  60. /*!
  61. A signal which is emitted when the user has clicked on
  62. a legend label, which is in QwtLegendData::Checkable mode
  63. \param itemInfo Info for the item of the
  64. selected legend label
  65. \param index Index of the legend label in the list of widgets
  66. that are associated with the plot item
  67. \param on True when the legend label is checked
  68. \note clicks are disabled as default
  69. \sa setDefaultItemMode(), defaultItemMode(), QwtPlot::itemToInfo()
  70. */
  71. void checked( const QVariant &itemInfo, bool on, int index );
  72. public Q_SLOTS:
  73. virtual void updateLegend( const QVariant &,
  74. const QList<QwtLegendData> & );
  75. protected Q_SLOTS:
  76. void itemClicked();
  77. void itemChecked( bool );
  78. protected:
  79. virtual QWidget *createWidget( const QwtLegendData & ) const;
  80. virtual void updateWidget( QWidget *widget, const QwtLegendData & );
  81. private:
  82. void updateTabOrder();
  83. class PrivateData;
  84. PrivateData *d_data;
  85. };
  86. #endif