| 1 | /**************************************************************************** | 
|---|
| 2 | ** | 
|---|
| 3 | ** Copyright (C) 2011 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 | ** Commercial Usage | 
|---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in | 
|---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the | 
|---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in | 
|---|
| 14 | ** a written agreement between you and Nokia. | 
|---|
| 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 | ** 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 have questions regarding the use of this file, please contact | 
|---|
| 37 | ** Nokia at qt-info@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 | Q_PROPERTY(bool hasSelectedText READ hasSelectedText) | 
|---|
| 69 | Q_PROPERTY(QString selectedText READ selectedText) | 
|---|
| 70 |  | 
|---|
| 71 | public: | 
|---|
| 72 | explicit QLabel(QWidget *parent=0, Qt::WindowFlags f=0); | 
|---|
| 73 | explicit QLabel(const QString &text, QWidget *parent=0, Qt::WindowFlags f=0); | 
|---|
| 74 | ~QLabel(); | 
|---|
| 75 |  | 
|---|
| 76 | QString text() const; | 
|---|
| 77 | const QPixmap *pixmap() const; | 
|---|
| 78 | #ifndef QT_NO_PICTURE | 
|---|
| 79 | const QPicture *picture() const; | 
|---|
| 80 | #endif | 
|---|
| 81 | #ifndef QT_NO_MOVIE | 
|---|
| 82 | QMovie *movie() const; | 
|---|
| 83 | #endif | 
|---|
| 84 |  | 
|---|
| 85 | Qt::TextFormat textFormat() const; | 
|---|
| 86 | void setTextFormat(Qt::TextFormat); | 
|---|
| 87 |  | 
|---|
| 88 | Qt::Alignment alignment() const; | 
|---|
| 89 | void setAlignment(Qt::Alignment); | 
|---|
| 90 |  | 
|---|
| 91 | void setWordWrap(bool on); | 
|---|
| 92 | bool wordWrap() const; | 
|---|
| 93 |  | 
|---|
| 94 | int indent() const; | 
|---|
| 95 | void setIndent(int); | 
|---|
| 96 |  | 
|---|
| 97 | int margin() const; | 
|---|
| 98 | void setMargin(int); | 
|---|
| 99 |  | 
|---|
| 100 | bool hasScaledContents() const; | 
|---|
| 101 | void setScaledContents(bool); | 
|---|
| 102 | QSize sizeHint() const; | 
|---|
| 103 | QSize minimumSizeHint() const; | 
|---|
| 104 | #ifndef QT_NO_SHORTCUT | 
|---|
| 105 | void setBuddy(QWidget *); | 
|---|
| 106 | QWidget *buddy() const; | 
|---|
| 107 | #endif | 
|---|
| 108 | int heightForWidth(int) const; | 
|---|
| 109 |  | 
|---|
| 110 | bool openExternalLinks() const; | 
|---|
| 111 | void setOpenExternalLinks(bool open); | 
|---|
| 112 |  | 
|---|
| 113 | void setTextInteractionFlags(Qt::TextInteractionFlags flags); | 
|---|
| 114 | Qt::TextInteractionFlags textInteractionFlags() const; | 
|---|
| 115 |  | 
|---|
| 116 | void setSelection(int, int); | 
|---|
| 117 | bool hasSelectedText() const; | 
|---|
| 118 | QString selectedText() const; | 
|---|
| 119 | int selectionStart() const; | 
|---|
| 120 |  | 
|---|
| 121 | public Q_SLOTS: | 
|---|
| 122 | void setText(const QString &); | 
|---|
| 123 | void setPixmap(const QPixmap &); | 
|---|
| 124 | #ifndef QT_NO_PICTURE | 
|---|
| 125 | void setPicture(const QPicture &); | 
|---|
| 126 | #endif | 
|---|
| 127 | #ifndef QT_NO_MOVIE | 
|---|
| 128 | void setMovie(QMovie *movie); | 
|---|
| 129 | #endif | 
|---|
| 130 | void setNum(int); | 
|---|
| 131 | void setNum(double); | 
|---|
| 132 | void clear(); | 
|---|
| 133 |  | 
|---|
| 134 | Q_SIGNALS: | 
|---|
| 135 | void linkActivated(const QString& link); | 
|---|
| 136 | void linkHovered(const QString& link); | 
|---|
| 137 |  | 
|---|
| 138 | protected: | 
|---|
| 139 | bool event(QEvent *e); | 
|---|
| 140 | void keyPressEvent(QKeyEvent *ev); | 
|---|
| 141 | void paintEvent(QPaintEvent *); | 
|---|
| 142 | void changeEvent(QEvent *); | 
|---|
| 143 | void mousePressEvent(QMouseEvent *ev); | 
|---|
| 144 | void mouseMoveEvent(QMouseEvent *ev); | 
|---|
| 145 | void mouseReleaseEvent(QMouseEvent *ev); | 
|---|
| 146 | void contextMenuEvent(QContextMenuEvent *ev); | 
|---|
| 147 | void focusInEvent(QFocusEvent *ev); | 
|---|
| 148 | void focusOutEvent(QFocusEvent *ev); | 
|---|
| 149 | bool focusNextPrevChild(bool next); | 
|---|
| 150 |  | 
|---|
| 151 | #ifdef QT3_SUPPORT | 
|---|
| 152 | public: | 
|---|
| 153 | QT3_SUPPORT_CONSTRUCTOR QLabel(QWidget *parent, const char* name, Qt::WindowFlags f=0); | 
|---|
| 154 | QT3_SUPPORT_CONSTRUCTOR QLabel(const QString &text, QWidget *parent, const char* name, | 
|---|
| 155 | Qt::WindowFlags f=0); | 
|---|
| 156 | QT3_SUPPORT_CONSTRUCTOR QLabel(QWidget *buddy, const QString &, | 
|---|
| 157 | QWidget *parent=0, const char* name=0, Qt::WindowFlags f=0); | 
|---|
| 158 | QT3_SUPPORT void setAlignment(int alignment); | 
|---|
| 159 |  | 
|---|
| 160 | // don't mark the next function with QT3_SUPPORT | 
|---|
| 161 | inline void setAlignment(Qt::AlignmentFlag flag) { setAlignment((Qt::Alignment)flag); } | 
|---|
| 162 | #endif | 
|---|
| 163 |  | 
|---|
| 164 | private: | 
|---|
| 165 | Q_DISABLE_COPY(QLabel) | 
|---|
| 166 | Q_DECLARE_PRIVATE(QLabel) | 
|---|
| 167 | #ifndef QT_NO_MOVIE | 
|---|
| 168 | Q_PRIVATE_SLOT(d_func(), void _q_movieUpdated(const QRect&)) | 
|---|
| 169 | Q_PRIVATE_SLOT(d_func(), void _q_movieResized(const QSize&)) | 
|---|
| 170 | #endif | 
|---|
| 171 | Q_PRIVATE_SLOT(d_func(), void _q_linkHovered(const QString &)) | 
|---|
| 172 |  | 
|---|
| 173 | friend class QTipLabel; | 
|---|
| 174 | friend class QMessageBoxPrivate; | 
|---|
| 175 | friend class QBalloonTip; | 
|---|
| 176 | }; | 
|---|
| 177 |  | 
|---|
| 178 | QT_END_NAMESPACE | 
|---|
| 179 |  | 
|---|
| 180 | QT_END_HEADER | 
|---|
| 181 |  | 
|---|
| 182 | #endif // QLABEL_H | 
|---|