qwt_plot_textlabel.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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_PLOT_TEXT_LABEL_H
  10. #define QWT_PLOT_TEXT_LABEL_H 1
  11. #include "qwt_global.h"
  12. #include "qwt_plot_item.h"
  13. #include "qwt_text.h"
  14. /*!
  15. \brief A plot item, which displays a text label
  16. QwtPlotTextLabel displays a text label aligned to the plot canvas.
  17. In opposite to QwtPlotMarker the position of the label is unrelated to
  18. plot coordinates.
  19. As drawing a text is an expensive operation the label is cached
  20. in a pixmap to speed up replots.
  21. \par Example
  22. The following code shows how to add a title.
  23. \code
  24. QwtText title( "Plot Title" );
  25. title.setRenderFlags( Qt::AlignHCenter | Qt::AlignTop );
  26. QFont font;
  27. font.setBold( true );
  28. title.setFont( font );
  29. QwtPlotTextLabel *titleItem = new QwtPlotTextLabel();
  30. titleItem->setText( title );
  31. titleItem->attach( plot );
  32. \endcode
  33. \endpar
  34. \sa QwtPlotMarker
  35. */
  36. class QWT_EXPORT QwtPlotTextLabel: public QwtPlotItem
  37. {
  38. public:
  39. QwtPlotTextLabel();
  40. virtual ~QwtPlotTextLabel();
  41. virtual int rtti() const;
  42. void setText( const QwtText & );
  43. QwtText text() const;
  44. void setMargin( int margin );
  45. int margin() const;
  46. virtual QRectF textRect( const QRectF &, const QSizeF & ) const;
  47. protected:
  48. virtual void draw( QPainter *,
  49. const QwtScaleMap &, const QwtScaleMap &,
  50. const QRectF &) const;
  51. void invalidateCache();
  52. private:
  53. class PrivateData;
  54. PrivateData *d_data;
  55. };
  56. #endif