src/gui/widgets/qlabel.h
changeset 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
-1:000000000000 0:1918ee327afb
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the QtGui module of the Qt Toolkit.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 #ifndef QLABEL_H
       
    43 #define QLABEL_H
       
    44 
       
    45 #include <QtGui/qframe.h>
       
    46 
       
    47 QT_BEGIN_HEADER
       
    48 
       
    49 QT_BEGIN_NAMESPACE
       
    50 
       
    51 QT_MODULE(Gui)
       
    52 
       
    53 class QLabelPrivate;
       
    54 
       
    55 class Q_GUI_EXPORT QLabel : public QFrame
       
    56 {
       
    57     Q_OBJECT
       
    58     Q_PROPERTY(QString text READ text WRITE setText)
       
    59     Q_PROPERTY(Qt::TextFormat textFormat READ textFormat WRITE setTextFormat)
       
    60     Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap)
       
    61     Q_PROPERTY(bool scaledContents READ hasScaledContents WRITE setScaledContents)
       
    62     Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment)
       
    63     Q_PROPERTY(bool wordWrap READ wordWrap WRITE setWordWrap)
       
    64     Q_PROPERTY(int margin READ margin WRITE setMargin)
       
    65     Q_PROPERTY(int indent READ indent WRITE setIndent)
       
    66     Q_PROPERTY(bool openExternalLinks READ openExternalLinks WRITE setOpenExternalLinks)
       
    67     Q_PROPERTY(Qt::TextInteractionFlags textInteractionFlags READ textInteractionFlags WRITE setTextInteractionFlags)
       
    68 
       
    69 public:
       
    70     explicit QLabel(QWidget *parent=0, Qt::WindowFlags f=0);
       
    71     explicit QLabel(const QString &text, QWidget *parent=0, Qt::WindowFlags f=0);
       
    72     ~QLabel();
       
    73 
       
    74     QString text() const;
       
    75     const QPixmap *pixmap() const;
       
    76 #ifndef QT_NO_PICTURE
       
    77     const QPicture *picture() const;
       
    78 #endif
       
    79 #ifndef QT_NO_MOVIE
       
    80     QMovie *movie() const;
       
    81 #endif
       
    82 
       
    83     Qt::TextFormat textFormat() const;
       
    84     void setTextFormat(Qt::TextFormat);
       
    85 
       
    86     Qt::Alignment alignment() const;
       
    87     void setAlignment(Qt::Alignment);
       
    88 
       
    89     void setWordWrap(bool on);
       
    90     bool wordWrap() const;
       
    91 
       
    92     int indent() const;
       
    93     void setIndent(int);
       
    94 
       
    95     int margin() const;
       
    96     void setMargin(int);
       
    97 
       
    98     bool hasScaledContents() const;
       
    99     void setScaledContents(bool);
       
   100     QSize sizeHint() const;
       
   101     QSize minimumSizeHint() const;
       
   102 #ifndef QT_NO_SHORTCUT
       
   103     void setBuddy(QWidget *);
       
   104     QWidget *buddy() const;
       
   105 #endif
       
   106     int heightForWidth(int) const;
       
   107 
       
   108     bool openExternalLinks() const;
       
   109     void setOpenExternalLinks(bool open);
       
   110 
       
   111     void setTextInteractionFlags(Qt::TextInteractionFlags flags);
       
   112     Qt::TextInteractionFlags textInteractionFlags() const;
       
   113 
       
   114 public Q_SLOTS:
       
   115     void setText(const QString &);
       
   116     void setPixmap(const QPixmap &);
       
   117 #ifndef QT_NO_PICTURE
       
   118     void setPicture(const QPicture &);
       
   119 #endif
       
   120 #ifndef QT_NO_MOVIE
       
   121     void setMovie(QMovie *movie);
       
   122 #endif
       
   123     void setNum(int);
       
   124     void setNum(double);
       
   125     void clear();
       
   126 
       
   127 Q_SIGNALS:
       
   128     void linkActivated(const QString& link);
       
   129     void linkHovered(const QString& link);
       
   130 
       
   131 protected:
       
   132     bool event(QEvent *e);
       
   133     void keyPressEvent(QKeyEvent *ev);
       
   134     void paintEvent(QPaintEvent *);
       
   135     void changeEvent(QEvent *);
       
   136     void mousePressEvent(QMouseEvent *ev);
       
   137     void mouseMoveEvent(QMouseEvent *ev);
       
   138     void mouseReleaseEvent(QMouseEvent *ev);
       
   139     void contextMenuEvent(QContextMenuEvent *ev);
       
   140     void focusInEvent(QFocusEvent *ev);
       
   141     void focusOutEvent(QFocusEvent *ev);
       
   142     bool focusNextPrevChild(bool next);
       
   143 
       
   144 #ifdef QT3_SUPPORT
       
   145 public:
       
   146     QT3_SUPPORT_CONSTRUCTOR QLabel(QWidget *parent, const char* name, Qt::WindowFlags f=0);
       
   147     QT3_SUPPORT_CONSTRUCTOR QLabel(const QString &text, QWidget *parent, const char* name,
       
   148            Qt::WindowFlags f=0);
       
   149     QT3_SUPPORT_CONSTRUCTOR QLabel(QWidget *buddy, const QString &,
       
   150            QWidget *parent=0, const char* name=0, Qt::WindowFlags f=0);
       
   151     QT3_SUPPORT void setAlignment(int alignment);
       
   152 
       
   153     // don't mark the next function with QT3_SUPPORT
       
   154     inline void setAlignment(Qt::AlignmentFlag flag) { setAlignment((Qt::Alignment)flag); }
       
   155 #endif
       
   156 
       
   157 private:
       
   158     Q_DISABLE_COPY(QLabel)
       
   159     Q_DECLARE_PRIVATE(QLabel)
       
   160 #ifndef QT_NO_MOVIE
       
   161     Q_PRIVATE_SLOT(d_func(), void _q_movieUpdated(const QRect&))
       
   162     Q_PRIVATE_SLOT(d_func(), void _q_movieResized(const QSize&))
       
   163 #endif
       
   164     Q_PRIVATE_SLOT(d_func(), void _q_linkHovered(const QString &))
       
   165 
       
   166     friend class QTipLabel;
       
   167     friend class QMessageBoxPrivate;
       
   168     friend class QBalloonTip;
       
   169 };
       
   170 
       
   171 QT_END_NAMESPACE
       
   172 
       
   173 QT_END_HEADER
       
   174 
       
   175 #endif // QLABEL_H