qwt_text_label.h 1.8 KB
Newer Older
pixhawk's avatar
pixhawk committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
 * Qwt Widget Library
 * Copyright (C) 1997   Josef Wilgen
 * Copyright (C) 2002   Uwe Rathmann
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the Qwt License, Version 1.0
 *****************************************************************************/

#ifndef QWT_TEXT_LABEL_H
#define QWT_TEXT_LABEL_H

#include "qwt_global.h"
#include "qwt_text.h"
Bryant's avatar
Bryant committed
15
#include <qframe.h>
pixhawk's avatar
pixhawk committed
16 17 18 19 20 21 22 23 24 25 26

class QString;
class QPaintEvent;
class QPainter;

/*!
   \brief A Widget which displays a QwtText
*/

class QWT_EXPORT QwtTextLabel : public QFrame
{
27
    Q_OBJECT
pixhawk's avatar
pixhawk committed
28 29 30

    Q_PROPERTY( int indent READ indent WRITE setIndent )
    Q_PROPERTY( int margin READ margin WRITE setMargin )
Bryant's avatar
Bryant committed
31
    Q_PROPERTY( QString plainText READ plainText WRITE setPlainText )
pixhawk's avatar
pixhawk committed
32 33

public:
Bryant's avatar
Bryant committed
34 35
    explicit QwtTextLabel( QWidget *parent = NULL );
    explicit QwtTextLabel( const QwtText &, QWidget *parent = NULL );
pixhawk's avatar
pixhawk committed
36 37
    virtual ~QwtTextLabel();

Bryant's avatar
Bryant committed
38 39 40 41 42 43 44
    void setPlainText( const QString & );
    QString plainText() const;

public Q_SLOTS:
    void setText( const QString &,
        QwtText::TextFormat textFormat = QwtText::AutoText );
    virtual void setText( const QwtText & );
pixhawk's avatar
pixhawk committed
45 46 47 48 49 50 51

    void clear();

public:
    const QwtText &text() const;

    int indent() const;
Bryant's avatar
Bryant committed
52
    void setIndent( int );
pixhawk's avatar
pixhawk committed
53 54

    int margin() const;
Bryant's avatar
Bryant committed
55
    void setMargin( int );
pixhawk's avatar
pixhawk committed
56 57 58

    virtual QSize sizeHint() const;
    virtual QSize minimumSizeHint() const;
Bryant's avatar
Bryant committed
59
    virtual int heightForWidth( int ) const;
pixhawk's avatar
pixhawk committed
60 61 62

    QRect textRect() const;

Bryant's avatar
Bryant committed
63 64
    virtual void drawText( QPainter *, const QRectF & );

pixhawk's avatar
pixhawk committed
65
protected:
Bryant's avatar
Bryant committed
66 67
    virtual void paintEvent( QPaintEvent *e );
    virtual void drawContents( QPainter * );
pixhawk's avatar
pixhawk committed
68 69 70 71 72 73 74 75 76 77

private:
    void init();
    int defaultIndent() const;

    class PrivateData;
    PrivateData *d_data;
};

#endif