qwt_text_label.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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_TEXT_LABEL_H
  10. #define QWT_TEXT_LABEL_H
  11. #include "qwt_global.h"
  12. #include "qwt_text.h"
  13. #include <qframe.h>
  14. class QString;
  15. class QPaintEvent;
  16. class QPainter;
  17. /*!
  18. \brief A Widget which displays a QwtText
  19. */
  20. class QWT_EXPORT QwtTextLabel : public QFrame
  21. {
  22. Q_OBJECT
  23. Q_PROPERTY( int indent READ indent WRITE setIndent )
  24. Q_PROPERTY( int margin READ margin WRITE setMargin )
  25. public:
  26. explicit QwtTextLabel( QWidget *parent = NULL );
  27. explicit QwtTextLabel( const QwtText &, QWidget *parent = NULL );
  28. virtual ~QwtTextLabel();
  29. public Q_SLOTS:
  30. void setText( const QString &,
  31. QwtText::TextFormat textFormat = QwtText::AutoText );
  32. virtual void setText( const QwtText & );
  33. void clear();
  34. public:
  35. const QwtText &text() const;
  36. int indent() const;
  37. void setIndent( int );
  38. int margin() const;
  39. void setMargin( int );
  40. virtual QSize sizeHint() const;
  41. virtual QSize minimumSizeHint() const;
  42. virtual int heightForWidth( int ) const;
  43. QRect textRect() const;
  44. protected:
  45. virtual void paintEvent( QPaintEvent *e );
  46. virtual void drawContents( QPainter * );
  47. virtual void drawText( QPainter *, const QRect & );
  48. private:
  49. void init();
  50. int defaultIndent() const;
  51. class PrivateData;
  52. PrivateData *d_data;
  53. };
  54. #endif