qwt_text_label.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. Q_PROPERTY( QString plainText READ plainText WRITE setPlainText )
  26. public:
  27. explicit QwtTextLabel( QWidget *parent = NULL );
  28. explicit QwtTextLabel( const QwtText &, QWidget *parent = NULL );
  29. virtual ~QwtTextLabel();
  30. void setPlainText( const QString & );
  31. QString plainText() const;
  32. public Q_SLOTS:
  33. void setText( const QString &,
  34. QwtText::TextFormat textFormat = QwtText::AutoText );
  35. virtual void setText( const QwtText & );
  36. void clear();
  37. public:
  38. const QwtText &text() const;
  39. int indent() const;
  40. void setIndent( int );
  41. int margin() const;
  42. void setMargin( int );
  43. virtual QSize sizeHint() const;
  44. virtual QSize minimumSizeHint() const;
  45. virtual int heightForWidth( int ) const;
  46. QRect textRect() const;
  47. virtual void drawText( QPainter *, const QRectF & );
  48. protected:
  49. virtual void paintEvent( QPaintEvent * );
  50. virtual void drawContents( QPainter * );
  51. private:
  52. void init();
  53. int defaultIndent() const;
  54. class PrivateData;
  55. PrivateData *d_data;
  56. };
  57. #endif