~loic.molinari/+junk/qtdeclarative-shadereffectsource-changes

« back to all changes in this revision

Viewing changes to src/quick/items/qquicktextedit_p.h

  • Committer: Loïc Molinari
  • Date: 2012-04-21 17:59:51 UTC
  • Revision ID: loic.molinari@canonical.com-20120421175951-bqx68caaf5zrp76l
Initial import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
 
4
** Contact: http://www.qt-project.org/
 
5
**
 
6
** This file is part of the QtQml module of the Qt Toolkit.
 
7
**
 
8
** $QT_BEGIN_LICENSE:LGPL$
 
9
** GNU Lesser General Public License Usage
 
10
** This file may be used under the terms of the GNU Lesser General Public
 
11
** License version 2.1 as published by the Free Software Foundation and
 
12
** appearing in the file LICENSE.LGPL included in the packaging of this
 
13
** file. Please review the following information to ensure the GNU Lesser
 
14
** General Public License version 2.1 requirements will be met:
 
15
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
 
16
**
 
17
** In addition, as a special exception, Nokia gives you certain additional
 
18
** rights. These rights are described in the Nokia Qt LGPL Exception
 
19
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
 
20
**
 
21
** GNU General Public License Usage
 
22
** Alternatively, this file may be used under the terms of the GNU General
 
23
** Public License version 3.0 as published by the Free Software Foundation
 
24
** and appearing in the file LICENSE.GPL included in the packaging of this
 
25
** file. Please review the following information to ensure the GNU General
 
26
** Public License version 3.0 requirements will be met:
 
27
** http://www.gnu.org/copyleft/gpl.html.
 
28
**
 
29
** Other Usage
 
30
** Alternatively, this file may be used in accordance with the terms and
 
31
** conditions contained in a signed written agreement between you and Nokia.
 
32
**
 
33
**
 
34
**
 
35
**
 
36
**
 
37
**
 
38
** $QT_END_LICENSE$
 
39
**
 
40
****************************************************************************/
 
41
 
 
42
#ifndef QQUICKTEXTEDIT_P_H
 
43
#define QQUICKTEXTEDIT_P_H
 
44
 
 
45
#include "qquickimplicitsizeitem_p.h"
 
46
 
 
47
#include <QtGui/qtextoption.h>
 
48
 
 
49
QT_BEGIN_HEADER
 
50
 
 
51
QT_BEGIN_NAMESPACE
 
52
 
 
53
class QQuickTextEditPrivate;
 
54
class Q_AUTOTEST_EXPORT QQuickTextEdit : public QQuickImplicitSizeItem
 
55
{
 
56
    Q_OBJECT
 
57
    Q_ENUMS(VAlignment)
 
58
    Q_ENUMS(HAlignment)
 
59
    Q_ENUMS(TextFormat)
 
60
    Q_ENUMS(WrapMode)
 
61
    Q_ENUMS(SelectionMode)
 
62
 
 
63
    Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
 
64
    Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
 
65
    Q_PROPERTY(QColor selectionColor READ selectionColor WRITE setSelectionColor NOTIFY selectionColorChanged)
 
66
    Q_PROPERTY(QColor selectedTextColor READ selectedTextColor WRITE setSelectedTextColor NOTIFY selectedTextColorChanged)
 
67
    Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY fontChanged)
 
68
    Q_PROPERTY(HAlignment horizontalAlignment READ hAlign WRITE setHAlign RESET resetHAlign NOTIFY horizontalAlignmentChanged)
 
69
    Q_PROPERTY(HAlignment effectiveHorizontalAlignment READ effectiveHAlign NOTIFY effectiveHorizontalAlignmentChanged)
 
70
    Q_PROPERTY(VAlignment verticalAlignment READ vAlign WRITE setVAlign NOTIFY verticalAlignmentChanged)
 
71
    Q_PROPERTY(WrapMode wrapMode READ wrapMode WRITE setWrapMode NOTIFY wrapModeChanged)
 
72
    Q_PROPERTY(int lineCount READ lineCount NOTIFY lineCountChanged)
 
73
    Q_PROPERTY(int length READ length NOTIFY textChanged)
 
74
    Q_PROPERTY(qreal contentWidth READ contentWidth NOTIFY contentSizeChanged)
 
75
    Q_PROPERTY(qreal contentHeight READ contentHeight NOTIFY contentSizeChanged)
 
76
    Q_PROPERTY(qreal paintedWidth READ contentWidth NOTIFY contentSizeChanged)  // Compatibility
 
77
    Q_PROPERTY(qreal paintedHeight READ contentHeight NOTIFY contentSizeChanged)
 
78
    Q_PROPERTY(TextFormat textFormat READ textFormat WRITE setTextFormat NOTIFY textFormatChanged)
 
79
    Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly NOTIFY readOnlyChanged)
 
80
    Q_PROPERTY(bool cursorVisible READ isCursorVisible WRITE setCursorVisible NOTIFY cursorVisibleChanged)
 
81
    Q_PROPERTY(int cursorPosition READ cursorPosition WRITE setCursorPosition NOTIFY cursorPositionChanged)
 
82
    Q_PROPERTY(QRectF cursorRectangle READ cursorRectangle NOTIFY cursorRectangleChanged)
 
83
    Q_PROPERTY(QQmlComponent* cursorDelegate READ cursorDelegate WRITE setCursorDelegate NOTIFY cursorDelegateChanged)
 
84
    Q_PROPERTY(int selectionStart READ selectionStart NOTIFY selectionStartChanged)
 
85
    Q_PROPERTY(int selectionEnd READ selectionEnd NOTIFY selectionEndChanged)
 
86
    Q_PROPERTY(QString selectedText READ selectedText NOTIFY selectionChanged)
 
87
    Q_PROPERTY(bool activeFocusOnPress READ focusOnPress WRITE setFocusOnPress NOTIFY activeFocusOnPressChanged)
 
88
    Q_PROPERTY(bool persistentSelection READ persistentSelection WRITE setPersistentSelection NOTIFY persistentSelectionChanged)
 
89
    Q_PROPERTY(qreal textMargin READ textMargin WRITE setTextMargin NOTIFY textMarginChanged)
 
90
    Q_PROPERTY(Qt::InputMethodHints inputMethodHints READ inputMethodHints WRITE setInputMethodHints NOTIFY inputMethodHintsChanged)
 
91
    Q_PROPERTY(bool selectByMouse READ selectByMouse WRITE setSelectByMouse NOTIFY selectByMouseChanged)
 
92
    Q_PROPERTY(SelectionMode mouseSelectionMode READ mouseSelectionMode WRITE setMouseSelectionMode NOTIFY mouseSelectionModeChanged)
 
93
    Q_PROPERTY(bool canPaste READ canPaste NOTIFY canPasteChanged)
 
94
    Q_PROPERTY(bool canUndo READ canUndo NOTIFY canUndoChanged)
 
95
    Q_PROPERTY(bool canRedo READ canRedo NOTIFY canRedoChanged)
 
96
    Q_PROPERTY(bool inputMethodComposing READ isInputMethodComposing NOTIFY inputMethodComposingChanged)
 
97
    Q_PROPERTY(QUrl baseUrl READ baseUrl WRITE setBaseUrl RESET resetBaseUrl NOTIFY baseUrlChanged)
 
98
 
 
99
public:
 
100
    QQuickTextEdit(QQuickItem *parent=0);
 
101
 
 
102
    enum HAlignment {
 
103
        AlignLeft = Qt::AlignLeft,
 
104
        AlignRight = Qt::AlignRight,
 
105
        AlignHCenter = Qt::AlignHCenter,
 
106
        AlignJustify = Qt::AlignJustify
 
107
    };
 
108
 
 
109
    enum VAlignment {
 
110
        AlignTop = Qt::AlignTop,
 
111
        AlignBottom = Qt::AlignBottom,
 
112
        AlignVCenter = Qt::AlignVCenter
 
113
    };
 
114
 
 
115
    enum TextFormat {
 
116
        PlainText = Qt::PlainText,
 
117
        RichText = Qt::RichText,
 
118
        AutoText = Qt::AutoText
 
119
    };
 
120
 
 
121
    enum WrapMode { NoWrap = QTextOption::NoWrap,
 
122
                    WordWrap = QTextOption::WordWrap,
 
123
                    WrapAnywhere = QTextOption::WrapAnywhere,
 
124
                    WrapAtWordBoundaryOrAnywhere = QTextOption::WrapAtWordBoundaryOrAnywhere, // COMPAT
 
125
                    Wrap = QTextOption::WrapAtWordBoundaryOrAnywhere
 
126
                  };
 
127
 
 
128
    enum SelectionMode {
 
129
        SelectCharacters,
 
130
        SelectWords
 
131
    };
 
132
 
 
133
    Q_INVOKABLE void openSoftwareInputPanel();
 
134
    Q_INVOKABLE void closeSoftwareInputPanel();
 
135
 
 
136
    QString text() const;
 
137
    void setText(const QString &);
 
138
 
 
139
    TextFormat textFormat() const;
 
140
    void setTextFormat(TextFormat format);
 
141
 
 
142
    QFont font() const;
 
143
    void setFont(const QFont &font);
 
144
 
 
145
    QColor color() const;
 
146
    void setColor(const QColor &c);
 
147
 
 
148
    QColor selectionColor() const;
 
149
    void setSelectionColor(const QColor &c);
 
150
 
 
151
    QColor selectedTextColor() const;
 
152
    void setSelectedTextColor(const QColor &c);
 
153
 
 
154
    HAlignment hAlign() const;
 
155
    void setHAlign(HAlignment align);
 
156
    void resetHAlign();
 
157
    HAlignment effectiveHAlign() const;
 
158
 
 
159
    VAlignment vAlign() const;
 
160
    void setVAlign(VAlignment align);
 
161
 
 
162
    WrapMode wrapMode() const;
 
163
    void setWrapMode(WrapMode w);
 
164
 
 
165
    int lineCount() const;
 
166
 
 
167
    int length() const;
 
168
 
 
169
    bool isCursorVisible() const;
 
170
    void setCursorVisible(bool on);
 
171
 
 
172
    int cursorPosition() const;
 
173
    void setCursorPosition(int pos);
 
174
 
 
175
    QQmlComponent* cursorDelegate() const;
 
176
    void setCursorDelegate(QQmlComponent*);
 
177
 
 
178
    int selectionStart() const;
 
179
    int selectionEnd() const;
 
180
 
 
181
    QString selectedText() const;
 
182
 
 
183
    bool focusOnPress() const;
 
184
    void setFocusOnPress(bool on);
 
185
 
 
186
    bool persistentSelection() const;
 
187
    void setPersistentSelection(bool on);
 
188
 
 
189
    qreal textMargin() const;
 
190
    void setTextMargin(qreal margin);
 
191
 
 
192
    Qt::InputMethodHints inputMethodHints() const;
 
193
    void setInputMethodHints(Qt::InputMethodHints hints);
 
194
 
 
195
    bool selectByMouse() const;
 
196
    void setSelectByMouse(bool);
 
197
 
 
198
    SelectionMode mouseSelectionMode() const;
 
199
    void setMouseSelectionMode(SelectionMode mode);
 
200
 
 
201
    bool canPaste() const;
 
202
 
 
203
    bool canUndo() const;
 
204
    bool canRedo() const;
 
205
 
 
206
    virtual void componentComplete();
 
207
 
 
208
    /* FROM EDIT */
 
209
    void setReadOnly(bool);
 
210
    bool isReadOnly() const;
 
211
 
 
212
    void setTextInteractionFlags(Qt::TextInteractionFlags flags);
 
213
    Qt::TextInteractionFlags textInteractionFlags() const;
 
214
 
 
215
    QRectF cursorRectangle() const;
 
216
 
 
217
    QVariant inputMethodQuery(Qt::InputMethodQuery property) const;
 
218
 
 
219
    qreal contentWidth() const;
 
220
    qreal contentHeight() const;
 
221
 
 
222
    QUrl baseUrl() const;
 
223
    void setBaseUrl(const QUrl &url);
 
224
    void resetBaseUrl();
 
225
 
 
226
    Q_INVOKABLE QRectF positionToRectangle(int) const;
 
227
    Q_INVOKABLE int positionAt(qreal x, qreal y) const;
 
228
    Q_INVOKABLE void moveCursorSelection(int pos);
 
229
    Q_INVOKABLE void moveCursorSelection(int pos, SelectionMode mode);
 
230
 
 
231
    QRectF boundingRect() const;
 
232
 
 
233
    bool isInputMethodComposing() const;
 
234
 
 
235
    Q_INVOKABLE QString getText(int start, int end) const;
 
236
    Q_INVOKABLE QString getFormattedText(int start, int end) const;
 
237
 
 
238
Q_SIGNALS:
 
239
    void textChanged();
 
240
    void contentSizeChanged();
 
241
    void cursorPositionChanged();
 
242
    void cursorRectangleChanged();
 
243
    void selectionStartChanged();
 
244
    void selectionEndChanged();
 
245
    void selectionChanged();
 
246
    void colorChanged(const QColor &color);
 
247
    void selectionColorChanged(const QColor &color);
 
248
    void selectedTextColorChanged(const QColor &color);
 
249
    void fontChanged(const QFont &font);
 
250
    void horizontalAlignmentChanged(HAlignment alignment);
 
251
    void verticalAlignmentChanged(VAlignment alignment);
 
252
    void wrapModeChanged();
 
253
    void lineCountChanged();
 
254
    void textFormatChanged(TextFormat textFormat);
 
255
    void readOnlyChanged(bool isReadOnly);
 
256
    void cursorVisibleChanged(bool isCursorVisible);
 
257
    void cursorDelegateChanged();
 
258
    void activeFocusOnPressChanged(bool activeFocusOnPressed);
 
259
    void persistentSelectionChanged(bool isPersistentSelection);
 
260
    void textMarginChanged(qreal textMargin);
 
261
    void selectByMouseChanged(bool selectByMouse);
 
262
    void mouseSelectionModeChanged(SelectionMode mode);
 
263
    void linkActivated(const QString &link);
 
264
    void canPasteChanged();
 
265
    void canUndoChanged();
 
266
    void canRedoChanged();
 
267
    void inputMethodComposingChanged();
 
268
    void effectiveHorizontalAlignmentChanged();
 
269
    void baseUrlChanged();
 
270
    void inputMethodHintsChanged();
 
271
 
 
272
public Q_SLOTS:
 
273
    void selectAll();
 
274
    void selectWord();
 
275
    void select(int start, int end);
 
276
    void deselect();
 
277
    bool isRightToLeft(int start, int end);
 
278
#ifndef QT_NO_CLIPBOARD
 
279
    void cut();
 
280
    void copy();
 
281
    void paste();
 
282
#endif
 
283
    void undo();
 
284
    void redo();
 
285
    void insert(int position, const QString &text);
 
286
    void remove(int start, int end);
 
287
 
 
288
private Q_SLOTS:
 
289
    void q_textChanged();
 
290
    void updateSelectionMarkers();
 
291
    void moveCursorDelegate();
 
292
    void loadCursorDelegate();
 
293
    void q_canPasteChanged();
 
294
    void updateDocument();
 
295
    void updateCursor();
 
296
    void q_updateAlignment();
 
297
    void updateSize();
 
298
    void triggerPreprocess();
 
299
 
 
300
private:
 
301
    void updateTotalLines();
 
302
 
 
303
protected:
 
304
    virtual void geometryChanged(const QRectF &newGeometry,
 
305
                                 const QRectF &oldGeometry);
 
306
 
 
307
    bool event(QEvent *);
 
308
    void keyPressEvent(QKeyEvent *);
 
309
    void keyReleaseEvent(QKeyEvent *);
 
310
    void focusInEvent(QFocusEvent *event);
 
311
 
 
312
    // mouse filter?
 
313
    void mousePressEvent(QMouseEvent *event);
 
314
    void mouseReleaseEvent(QMouseEvent *event);
 
315
    void mouseDoubleClickEvent(QMouseEvent *event);
 
316
    void mouseMoveEvent(QMouseEvent *event);
 
317
    void inputMethodEvent(QInputMethodEvent *e);
 
318
    virtual void itemChange(ItemChange, const ItemChangeData &);
 
319
 
 
320
    QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *updatePaintNodeData);
 
321
 
 
322
private:
 
323
    Q_DISABLE_COPY(QQuickTextEdit)
 
324
    Q_DECLARE_PRIVATE(QQuickTextEdit)
 
325
};
 
326
 
 
327
QT_END_NAMESPACE
 
328
 
 
329
QML_DECLARE_TYPE(QQuickTextEdit)
 
330
 
 
331
QT_END_HEADER
 
332
 
 
333
#endif // QQUICKTEXTEDIT_P_H