Skip to content
Snippets Groups Projects
qwt_text_label.h 1.8 KiB
Newer Older
  • Learn to ignore specific revisions
  • pixhawk's avatar
    pixhawk committed
    /* -*- 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
    #include <qframe.h>
    
    pixhawk's avatar
    pixhawk committed
    
    class QString;
    class QPaintEvent;
    class QPainter;
    
    /*!
       \brief A Widget which displays a QwtText
    */
    
    class QWT_EXPORT QwtTextLabel : public QFrame
    {
    
    pixhawk's avatar
    pixhawk committed
    
        Q_PROPERTY( int indent READ indent WRITE setIndent )
        Q_PROPERTY( int margin READ margin WRITE setMargin )
    
    Bryant's avatar
    Bryant committed
        Q_PROPERTY( QString plainText READ plainText WRITE setPlainText )
    
    pixhawk's avatar
    pixhawk committed
    
    public:
    
    Bryant's avatar
    Bryant committed
        explicit QwtTextLabel( QWidget *parent = NULL );
        explicit QwtTextLabel( const QwtText &, QWidget *parent = NULL );
    
    pixhawk's avatar
    pixhawk committed
        virtual ~QwtTextLabel();
    
    
    Bryant's avatar
    Bryant committed
        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
    
        void clear();
    
    public:
        const QwtText &text() const;
    
        int indent() const;
    
    Bryant's avatar
    Bryant committed
        void setIndent( int );
    
    pixhawk's avatar
    pixhawk committed
    
        int margin() const;
    
    Bryant's avatar
    Bryant committed
        void setMargin( int );
    
    pixhawk's avatar
    pixhawk committed
    
        virtual QSize sizeHint() const;
        virtual QSize minimumSizeHint() const;
    
    Bryant's avatar
    Bryant committed
        virtual int heightForWidth( int ) const;
    
    pixhawk's avatar
    pixhawk committed
    
        QRect textRect() const;
    
    
    Bryant's avatar
    Bryant committed
        virtual void drawText( QPainter *, const QRectF & );
    
    
    pixhawk's avatar
    pixhawk committed
    protected:
    
    Bryant's avatar
    Bryant committed
        virtual void paintEvent( QPaintEvent *e );
        virtual void drawContents( QPainter * );
    
    pixhawk's avatar
    pixhawk committed
    
    private:
        void init();
        int defaultIndent() const;
    
        class PrivateData;
        PrivateData *d_data;
    };
    
    #endif