| 1 | /**************************************************************************** |
| 2 | ** |
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. |
| 4 | ** Contact: https://www.qt.io/licensing/ |
| 5 | ** |
| 6 | ** This file is part of the QtWidgets module of the Qt Toolkit. |
| 7 | ** |
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ |
| 9 | ** Commercial License Usage |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in |
| 11 | ** accordance with the commercial license agreement provided with the |
| 12 | ** Software or, alternatively, in accordance with the terms contained in |
| 13 | ** a written agreement between you and The Qt Company. For licensing terms |
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
| 15 | ** information use the contact form at https://www.qt.io/contact-us. |
| 16 | ** |
| 17 | ** GNU Lesser General Public License Usage |
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
| 19 | ** General Public License version 3 as published by the Free Software |
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the |
| 21 | ** packaging of this file. Please review the following information to |
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements |
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
| 24 | ** |
| 25 | ** GNU General Public License Usage |
| 26 | ** Alternatively, this file may be used under the terms of the GNU |
| 27 | ** General Public License version 2.0 or (at your option) the GNU General |
| 28 | ** Public license version 3 or any later version approved by the KDE Free |
| 29 | ** Qt Foundation. The licenses are as published by the Free Software |
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
| 31 | ** included in the packaging of this file. Please review the following |
| 32 | ** information to ensure the GNU General Public License requirements will |
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
| 35 | ** |
| 36 | ** $QT_END_LICENSE$ |
| 37 | ** |
| 38 | ****************************************************************************/ |
| 39 | |
| 40 | #ifndef QLABEL_P_H |
| 41 | #define QLABEL_P_H |
| 42 | |
| 43 | // |
| 44 | // W A R N I N G |
| 45 | // ------------- |
| 46 | // |
| 47 | // This file is not part of the Qt API. It exists purely as an |
| 48 | // implementation detail. This header file may change from version to |
| 49 | // version without notice, or even be removed. |
| 50 | // |
| 51 | // We mean it. |
| 52 | // |
| 53 | |
| 54 | #include <QtWidgets/private/qtwidgetsglobal_p.h> |
| 55 | #include "qlabel.h" |
| 56 | |
| 57 | #include "private/qtextdocumentlayout_p.h" |
| 58 | #include "private/qwidgettextcontrol_p.h" |
| 59 | #include "qtextdocumentfragment.h" |
| 60 | #include "qframe_p.h" |
| 61 | #include "qtextdocument.h" |
| 62 | #if QT_CONFIG(movie) |
| 63 | #include "qmovie.h" |
| 64 | #endif |
| 65 | #include "qimage.h" |
| 66 | #include "qbitmap.h" |
| 67 | #include "qpicture.h" |
| 68 | #if QT_CONFIG(menu) |
| 69 | #include "qmenu.h" |
| 70 | #endif |
| 71 | |
| 72 | QT_BEGIN_NAMESPACE |
| 73 | |
| 74 | class Q_AUTOTEST_EXPORT QLabelPrivate : public QFramePrivate |
| 75 | { |
| 76 | Q_DECLARE_PUBLIC(QLabel) |
| 77 | public: |
| 78 | QLabelPrivate(); |
| 79 | ~QLabelPrivate(); |
| 80 | |
| 81 | void init(); |
| 82 | void clearContents(); |
| 83 | void updateLabel(); |
| 84 | QSize sizeForWidth(int w) const; |
| 85 | |
| 86 | #if QT_CONFIG(movie) |
| 87 | void _q_movieUpdated(const QRect&); |
| 88 | void _q_movieResized(const QSize&); |
| 89 | #endif |
| 90 | #ifndef QT_NO_SHORTCUT |
| 91 | void updateShortcut(); |
| 92 | void _q_buddyDeleted(); |
| 93 | #endif |
| 94 | inline bool needTextControl() const { |
| 95 | Q_Q(const QLabel); |
| 96 | return isTextLabel |
| 97 | && (effectiveTextFormat != Qt::PlainText |
| 98 | || (textInteractionFlags & (Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard)) |
| 99 | || q->focusPolicy() != Qt::NoFocus); |
| 100 | } |
| 101 | |
| 102 | void ensureTextPopulated() const; |
| 103 | void ensureTextLayouted() const; |
| 104 | void ensureTextControl() const; |
| 105 | void sendControlEvent(QEvent *e); |
| 106 | |
| 107 | void _q_linkHovered(const QString &link); |
| 108 | |
| 109 | QRectF layoutRect() const; |
| 110 | QRect documentRect() const; |
| 111 | QPoint layoutPoint(const QPoint& p) const; |
| 112 | Qt::LayoutDirection textDirection() const; |
| 113 | #ifndef QT_NO_CONTEXTMENU |
| 114 | QMenu *createStandardContextMenu(const QPoint &pos); |
| 115 | #endif |
| 116 | |
| 117 | mutable QSize sh; |
| 118 | mutable QSize msh; |
| 119 | QString text; |
| 120 | QPixmap *pixmap; |
| 121 | QPixmap *scaledpixmap; |
| 122 | QImage *cachedimage; |
| 123 | #ifndef QT_NO_PICTURE |
| 124 | QPicture *picture; |
| 125 | #endif |
| 126 | #if QT_CONFIG(movie) |
| 127 | QPointer<QMovie> movie; |
| 128 | #endif |
| 129 | mutable QWidgetTextControl *control; |
| 130 | mutable QTextCursor shortcutCursor; |
| 131 | #ifndef QT_NO_CURSOR |
| 132 | QCursor cursor; |
| 133 | #endif |
| 134 | #ifndef QT_NO_SHORTCUT |
| 135 | QPointer<QWidget> buddy; |
| 136 | int shortcutId; |
| 137 | #endif |
| 138 | Qt::TextFormat textformat; |
| 139 | Qt::TextFormat effectiveTextFormat; |
| 140 | Qt::TextInteractionFlags textInteractionFlags; |
| 141 | mutable QSizePolicy sizePolicy; |
| 142 | int margin; |
| 143 | ushort align; |
| 144 | short indent; |
| 145 | mutable uint valid_hints : 1; |
| 146 | uint scaledcontents : 1; |
| 147 | mutable uint textLayoutDirty : 1; |
| 148 | mutable uint textDirty : 1; |
| 149 | mutable uint isTextLabel : 1; |
| 150 | mutable uint hasShortcut : 1; |
| 151 | #ifndef QT_NO_CURSOR |
| 152 | uint validCursor : 1; |
| 153 | uint onAnchor : 1; |
| 154 | #endif |
| 155 | uint openExternalLinks : 1; |
| 156 | // <-- space for more bit field values here |
| 157 | |
| 158 | friend class QMessageBoxPrivate; |
| 159 | }; |
| 160 | |
| 161 | QT_END_NAMESPACE |
| 162 | |
| 163 | #endif // QLABEL_P_H |
| 164 | |