Qwt User's Guide  6.1.0
 All Classes Functions Variables Typedefs Enumerations Enumerator Pages
qwt_text_label.h
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 
10 #ifndef QWT_TEXT_LABEL_H
11 #define QWT_TEXT_LABEL_H
12 
13 #include "qwt_global.h"
14 #include "qwt_text.h"
15 #include <qframe.h>
16 
17 class QString;
18 class QPaintEvent;
19 class QPainter;
20 
25 class QWT_EXPORT QwtTextLabel : public QFrame
26 {
27  Q_OBJECT
28 
29  Q_PROPERTY( int indent READ indent WRITE setIndent )
30  Q_PROPERTY( int margin READ margin WRITE setMargin )
31  Q_PROPERTY( QString plainText READ plainText WRITE setPlainText )
32 
33 public:
34  explicit QwtTextLabel( QWidget *parent = NULL );
35  explicit QwtTextLabel( const QwtText &, QWidget *parent = NULL );
36  virtual ~QwtTextLabel();
37 
38  void setPlainText( const QString & );
39  QString plainText() const;
40 
41 public Q_SLOTS:
42  void setText( const QString &,
44  virtual void setText( const QwtText & );
45 
46  void clear();
47 
48 public:
49  const QwtText &text() const;
50 
51  int indent() const;
52  void setIndent( int );
53 
54  int margin() const;
55  void setMargin( int );
56 
57  virtual QSize sizeHint() const;
58  virtual QSize minimumSizeHint() const;
59  virtual int heightForWidth( int ) const;
60 
61  QRect textRect() const;
62 
63  virtual void drawText( QPainter *, const QRectF & );
64 
65 protected:
66  virtual void paintEvent( QPaintEvent *e );
67  virtual void drawContents( QPainter * );
68 
69 private:
70  void init();
71  int defaultIndent() const;
72 
73  class PrivateData;
74  PrivateData *d_data;
75 };
76 
77 #endif