| 1 | /**************************************************************************** | 
|---|
| 2 | ** | 
|---|
| 3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). | 
|---|
| 4 | ** Contact: Qt Software Information (qt-info@nokia.com) | 
|---|
| 5 | ** | 
|---|
| 6 | ** This file is part of the QtGui module of the Qt Toolkit. | 
|---|
| 7 | ** | 
|---|
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | 
|---|
| 9 | ** Commercial Usage | 
|---|
| 10 | ** Licensees holding valid Qt Commercial licenses may use this file in | 
|---|
| 11 | ** accordance with the Qt Commercial License Agreement provided with the | 
|---|
| 12 | ** Software or, alternatively, in accordance with the terms contained in | 
|---|
| 13 | ** a written agreement between you and Nokia. | 
|---|
| 14 | ** | 
|---|
| 15 | ** GNU Lesser General Public License Usage | 
|---|
| 16 | ** Alternatively, this file may be used under the terms of the GNU Lesser | 
|---|
| 17 | ** General Public License version 2.1 as published by the Free Software | 
|---|
| 18 | ** Foundation and appearing in the file LICENSE.LGPL included in the | 
|---|
| 19 | ** packaging of this file.  Please review the following information to | 
|---|
| 20 | ** ensure the GNU Lesser General Public License version 2.1 requirements | 
|---|
| 21 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | 
|---|
| 22 | ** | 
|---|
| 23 | ** In addition, as a special exception, Nokia gives you certain | 
|---|
| 24 | ** additional rights. These rights are described in the Nokia Qt LGPL | 
|---|
| 25 | ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this | 
|---|
| 26 | ** package. | 
|---|
| 27 | ** | 
|---|
| 28 | ** GNU General Public License Usage | 
|---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU | 
|---|
| 30 | ** General Public License version 3.0 as published by the Free Software | 
|---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the | 
|---|
| 32 | ** packaging of this file.  Please review the following information to | 
|---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be | 
|---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html. | 
|---|
| 35 | ** | 
|---|
| 36 | ** If you are unsure which license is appropriate for your use, please | 
|---|
| 37 | ** contact the sales department at qt-sales@nokia.com. | 
|---|
| 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 | 
|---|