source: trunk/src/declarative/graphicsitems/qdeclarativetext_p.h

Last change on this file was 846, checked in by Dmitry A. Kuminov, 14 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

File size: 6.6 KB
Line 
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 QtDeclarative 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 QDECLARATIVETEXT_H
43#define QDECLARATIVETEXT_H
44
45#include <QtGui/qtextoption.h>
46#include "qdeclarativeitem.h"
47
48#include <private/qdeclarativeglobal_p.h>
49
50QT_BEGIN_HEADER
51
52QT_BEGIN_NAMESPACE
53
54QT_MODULE(Declarative)
55class QDeclarativeTextPrivate;
56class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeText : public QDeclarativeItem
57{
58 Q_OBJECT
59 Q_ENUMS(HAlignment)
60 Q_ENUMS(VAlignment)
61 Q_ENUMS(TextStyle)
62 Q_ENUMS(TextFormat)
63 Q_ENUMS(TextElideMode)
64 Q_ENUMS(WrapMode)
65
66 Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
67 Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged)
68 Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
69 Q_PROPERTY(TextStyle style READ style WRITE setStyle NOTIFY styleChanged)
70 Q_PROPERTY(QColor styleColor READ styleColor WRITE setStyleColor NOTIFY styleColorChanged)
71 Q_PROPERTY(HAlignment horizontalAlignment READ hAlign WRITE setHAlign NOTIFY horizontalAlignmentChanged)
72 Q_PROPERTY(VAlignment verticalAlignment READ vAlign WRITE setVAlign NOTIFY verticalAlignmentChanged)
73 Q_PROPERTY(WrapMode wrapMode READ wrapMode WRITE setWrapMode NOTIFY wrapModeChanged)
74 Q_PROPERTY(TextFormat textFormat READ textFormat WRITE setTextFormat NOTIFY textFormatChanged)
75 Q_PROPERTY(TextElideMode elide READ elideMode WRITE setElideMode NOTIFY elideModeChanged) //### elideMode?
76 Q_PROPERTY(qreal paintedWidth READ paintedWidth NOTIFY paintedSizeChanged)
77 Q_PROPERTY(qreal paintedHeight READ paintedHeight NOTIFY paintedSizeChanged)
78
79public:
80 QDeclarativeText(QDeclarativeItem *parent=0);
81 ~QDeclarativeText();
82
83 enum HAlignment { AlignLeft = Qt::AlignLeft,
84 AlignRight = Qt::AlignRight,
85 AlignHCenter = Qt::AlignHCenter };
86 enum VAlignment { AlignTop = Qt::AlignTop,
87 AlignBottom = Qt::AlignBottom,
88 AlignVCenter = Qt::AlignVCenter };
89 enum TextStyle { Normal,
90 Outline,
91 Raised,
92 Sunken };
93 enum TextFormat { PlainText = Qt::PlainText,
94 RichText = Qt::RichText,
95 AutoText = Qt::AutoText,
96 StyledText = 4 };
97 enum TextElideMode { ElideLeft = Qt::ElideLeft,
98 ElideRight = Qt::ElideRight,
99 ElideMiddle = Qt::ElideMiddle,
100 ElideNone = Qt::ElideNone };
101
102 enum WrapMode { NoWrap = QTextOption::NoWrap,
103 WordWrap = QTextOption::WordWrap,
104 WrapAnywhere = QTextOption::WrapAnywhere,
105 WrapAtWordBoundaryOrAnywhere = QTextOption::WrapAtWordBoundaryOrAnywhere, // COMPAT
106 Wrap = QTextOption::WrapAtWordBoundaryOrAnywhere
107 };
108
109 QString text() const;
110 void setText(const QString &);
111
112 QFont font() const;
113 void setFont(const QFont &font);
114
115 QColor color() const;
116 void setColor(const QColor &c);
117
118 TextStyle style() const;
119 void setStyle(TextStyle style);
120
121 QColor styleColor() const;
122 void setStyleColor(const QColor &c);
123
124 HAlignment hAlign() const;
125 void setHAlign(HAlignment align);
126
127 VAlignment vAlign() const;
128 void setVAlign(VAlignment align);
129
130 WrapMode wrapMode() const;
131 void setWrapMode(WrapMode w);
132
133 TextFormat textFormat() const;
134 void setTextFormat(TextFormat format);
135
136 TextElideMode elideMode() const;
137 void setElideMode(TextElideMode);
138
139 void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
140
141 virtual void componentComplete();
142
143 int resourcesLoading() const; // mainly for testing
144
145 qreal paintedWidth() const;
146 qreal paintedHeight() const;
147
148 QRectF boundingRect() const;
149
150Q_SIGNALS:
151 void textChanged(const QString &text);
152 void linkActivated(const QString &link);
153 void fontChanged(const QFont &font);
154 void colorChanged(const QColor &color);
155 void styleChanged(TextStyle style);
156 void styleColorChanged(const QColor &color);
157 void horizontalAlignmentChanged(HAlignment alignment);
158 void verticalAlignmentChanged(VAlignment alignment);
159 void wrapModeChanged();
160 void textFormatChanged(TextFormat textFormat);
161 void elideModeChanged(TextElideMode mode);
162 void paintedSizeChanged();
163
164protected:
165 void mousePressEvent(QGraphicsSceneMouseEvent *event);
166 void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
167 virtual void geometryChanged(const QRectF &newGeometry,
168 const QRectF &oldGeometry);
169
170private:
171 Q_DISABLE_COPY(QDeclarativeText)
172 Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeText)
173};
174
175QT_END_NAMESPACE
176
177QML_DECLARE_TYPE(QDeclarativeText)
178
179QT_END_HEADER
180
181#endif
Note: See TracBrowser for help on using the repository browser.