qwt_abstract_legend.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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_ABSTRACT_LEGEND_H
  10. #define QWT_ABSTRACT_LEGEND_H
  11. #include "qwt_global.h"
  12. #include "qwt_legend_data.h"
  13. #include <qframe.h>
  14. #include <qlist.h>
  15. class QVariant;
  16. /*!
  17. \brief Abstract base class for legend widgets
  18. Legends, that need to be under control of the QwtPlot layout system
  19. need to be derived from QwtAbstractLegend.
  20. \note Other type of legends can be implemented by connecting to
  21. the QwtPlot::legendDataChanged() signal. But as these legends
  22. are unknown to the plot layout system the layout code
  23. ( on screen and for QwtPlotRenderer ) need to be organized
  24. in application code.
  25. \sa QwtLegend
  26. */
  27. class QWT_EXPORT QwtAbstractLegend : public QFrame
  28. {
  29. Q_OBJECT
  30. public:
  31. explicit QwtAbstractLegend( QWidget *parent = NULL );
  32. virtual ~QwtAbstractLegend();
  33. /*!
  34. Render the legend into a given rectangle.
  35. \param painter Painter
  36. \param rect Bounding rectangle
  37. \param fillBackground When true, fill rect with the widget background
  38. \sa renderLegend() is used by QwtPlotRenderer
  39. */
  40. virtual void renderLegend( QPainter *painter,
  41. const QRectF &rect, bool fillBackground ) const = 0;
  42. //! \return True, when no plot item is inserted
  43. virtual bool isEmpty() const = 0;
  44. virtual int scrollExtent( Qt::Orientation ) const;
  45. public Q_SLOTS:
  46. /*!
  47. \brief Update the entries for a plot item
  48. \param itemInfo Info about an item
  49. \param data List of legend entry attributes for the item
  50. */
  51. virtual void updateLegend( const QVariant &itemInfo,
  52. const QList<QwtLegendData> &data ) = 0;
  53. };
  54. #endif