Qwt User's Guide  5.2.3
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 <qframe.h>
14 #include "qwt_global.h"
15 #include "qwt_text.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 
32 public:
33  explicit QwtTextLabel(QWidget *parent = NULL);
34 #if QT_VERSION < 0x040000
35  explicit QwtTextLabel(QWidget *parent, const char *name);
36 #endif
37  explicit QwtTextLabel(const QwtText &, QWidget *parent = NULL);
38  virtual ~QwtTextLabel();
39 
40 public slots:
41  void setText(const QString &,
42  QwtText::TextFormat textFormat = QwtText::AutoText);
43  virtual void setText(const QwtText &);
44 
45  void clear();
46 
47 public:
48  const QwtText &text() const;
49 
50  int indent() const;
51  void setIndent(int);
52 
53  int margin() const;
54  void setMargin(int);
55 
56  virtual QSize sizeHint() const;
57  virtual QSize minimumSizeHint() const;
58  virtual int heightForWidth(int) const;
59 
60  QRect textRect() const;
61 
62 protected:
63  virtual void paintEvent(QPaintEvent *e);
64  virtual void drawContents(QPainter *);
65  virtual void drawText(QPainter *, const QRect &);
66 
67 private:
68  void init();
69  int defaultIndent() const;
70 
71  class PrivateData;
72  PrivateData *d_data;
73 };
74 
75 #endif