Qt 4.8
qdeclarativetextedit_p.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtDeclarative 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 Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/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 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QDECLARATIVETEXTEDIT_H
43 #define QDECLARATIVETEXTEDIT_H
44 
45 #include "private/qdeclarativetext_p.h"
46 #include "private/qdeclarativeimplicitsizeitem_p.h"
47 
48 #include <QtGui/qtextdocument.h>
49 #include <QtGui/qtextoption.h>
50 #include <QtGui/qtextcursor.h>
51 #include <QtGui/qtextformat.h>
52 
54 
56 
57 QT_MODULE(Declarative)
58 
59 
62 {
63  Q_OBJECT
69 
71  QColor color;
72  QColor selectionColor;
73  QColor selectedTextColor;
74  QFont font;
75  HAlignment horizontalAlignment;
76  VAlignment verticalAlignment;
77  WrapMode wrapMode;
78  int lineCount;
79  qreal paintedWidth;
80  qreal paintedHeight;
81  TextFormat textFormat;
82  bool readOnly;
83  bool cursorVisible;
84  int cursorPosition;
85  QRect cursorRectangle;
86  QDeclarativeComponent* cursorDelegate;
87  int selectionStart;
88  int selectionEnd;
89  QString selectedText;
90  bool activeFocusOnPress;
91  bool persistentSelection;
92  qreal textMargin;
93  Qt::InputMethodHints inputMethodHints;
94  bool selectByMouse;
95  SelectionMode mouseSelectionMode;
96  bool canPaste;
97  bool inputMethodComposing;
98 
99 public:
101 
102  enum HAlignment {
106  AlignJustify = Qt::AlignJustify // ### VERSIONING: Only in QtQuick 1.1
107  };
108 
109  enum VAlignment {
113  };
114 
115  enum TextFormat {
119  };
120 
121  enum WrapMode { NoWrap = QTextOption::NoWrap,
124  WrapAtWordBoundaryOrAnywhere = QTextOption::WrapAtWordBoundaryOrAnywhere, // COMPAT
126  };
127 
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  bool isCursorVisible() const;
168  void setCursorVisible(bool on);
169 
170  int cursorPosition() const;
171  void setCursorPosition(int pos);
172 
173  QDeclarativeComponent* cursorDelegate() const;
174  void setCursorDelegate(QDeclarativeComponent*);
175 
176  int selectionStart() const;
177  int selectionEnd() const;
178 
179  QString selectedText() const;
180 
181  bool focusOnPress() const;
182  void setFocusOnPress(bool on);
183 
184  bool persistentSelection() const;
185  void setPersistentSelection(bool on);
186 
187  qreal textMargin() const;
188  void setTextMargin(qreal margin);
189 
190  bool selectByMouse() const;
191  void setSelectByMouse(bool);
192 
193  SelectionMode mouseSelectionMode() const;
194  void setMouseSelectionMode(SelectionMode mode);
195 
196  bool canPaste() const;
197 
198  virtual void componentComplete();
199 
200  /* FROM EDIT */
201  void setReadOnly(bool);
202  bool isReadOnly() const;
203 
204  void setTextInteractionFlags(Qt::TextInteractionFlags flags);
205  Qt::TextInteractionFlags textInteractionFlags() const;
206 
207  QRect cursorRectangle() const;
208 
210 
211  qreal paintedWidth() const;
212  qreal paintedHeight() const;
213 
214  Q_INVOKABLE QRectF positionToRectangle(int) const;
215  Q_INVOKABLE int positionAt(int x, int y) const;
216  Q_INVOKABLE void moveCursorSelection(int pos);
217  Q_INVOKABLE Q_REVISION(1) void moveCursorSelection(int pos, SelectionMode mode);
218 
219  QRectF boundingRect() const;
220 
221  bool isInputMethodComposing() const;
222 
223 Q_SIGNALS:
224  void textChanged(const QString &);
225  void paintedSizeChanged();
226  void cursorPositionChanged();
227  void cursorRectangleChanged();
228  void selectionStartChanged();
229  void selectionEndChanged();
230  void selectionChanged();
231  void colorChanged(const QColor &color);
232  void selectionColorChanged(const QColor &color);
233  void selectedTextColorChanged(const QColor &color);
234  void fontChanged(const QFont &font);
235  void horizontalAlignmentChanged(HAlignment alignment);
236  void verticalAlignmentChanged(VAlignment alignment);
237  void wrapModeChanged();
238  void lineCountChanged();
239  void textFormatChanged(TextFormat textFormat);
240  void readOnlyChanged(bool isReadOnly);
241  void cursorVisibleChanged(bool isCursorVisible);
242  void cursorDelegateChanged();
243  void activeFocusOnPressChanged(bool activeFocusOnPressed);
244  void persistentSelectionChanged(bool isPersistentSelection);
245  void textMarginChanged(qreal textMargin);
246  void selectByMouseChanged(bool selectByMouse);
247  Q_REVISION(1) void mouseSelectionModeChanged(SelectionMode mode);
248  Q_REVISION(1) void linkActivated(const QString &link);
249  Q_REVISION(1) void canPasteChanged();
250  Q_REVISION(1) void inputMethodComposingChanged();
251 
252 public Q_SLOTS:
253  void selectAll();
254  void selectWord();
255  void select(int start, int end);
256  Q_REVISION(1) void deselect();
257  Q_REVISION(1) bool isRightToLeft(int start, int end);
258 #ifndef QT_NO_CLIPBOARD
259  void cut();
260  void copy();
261  void paste();
262 #endif
263 
264 private Q_SLOTS:
265  void updateImgCache(const QRectF &rect);
266  void q_textChanged();
267  void updateSelectionMarkers();
268  void moveCursorDelegate();
269  void loadCursorDelegate();
270  void q_canPasteChanged();
271 
272 private:
273  void updateSize();
274  void updateTotalLines();
275 
276 protected:
277  virtual void geometryChanged(const QRectF &newGeometry,
278  const QRectF &oldGeometry);
279 
280  bool event(QEvent *);
281  void keyPressEvent(QKeyEvent *);
282  void keyReleaseEvent(QKeyEvent *);
284 
285  // mouse filter?
290 
292 
293  void drawContents(QPainter *, const QRect &);
294 private:
297 };
298 
300 
302 
304 
305 #endif
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
The QKeyEvent class describes a key event.
Definition: qevent.h:224
double qreal
Definition: qglobal.h:1193
unsigned char c[8]
Definition: qnumeric_p.h:62
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
EventRef event
#define QT_MODULE(x)
Definition: qglobal.h:2783
QScopedPointer< QGraphicsItemPrivate > d_ptr
#define QML_DECLARE_TYPE(TYPE)
Definition: qdeclarative.h:56
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
virtual bool event(QEvent *)
The QGraphicsSceneMouseEvent class provides mouse events in the graphics view framework.
#define Q_INVOKABLE
Definition: qobjectdefs.h:90
int select(int, fd_set *, fd_set *, fd_set *, struct timeval *)
virtual void keyPressEvent(QKeyEvent *event)
#define Q_DISABLE_COPY(Class)
Disables the use of copy constructors and assignment operators for the given Class.
Definition: qglobal.h:2523
virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
This event handler, for event event, can be reimplemented to receive mouse doubleclick events for thi...
#define Q_SLOTS
Definition: qobjectdefs.h:71
The QString class provides a Unicode character string.
Definition: qstring.h:83
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event)
This event handler, for event event, can be reimplemented to receive mouse press events for this item...
#define Q_SIGNALS
Definition: qobjectdefs.h:72
virtual void focusInEvent(QFocusEvent *event)
This event handler, for event event, can be reimplemented to receive focus in events for this item...
#define Q_ENUMS(x)
Definition: qobjectdefs.h:84
static const QRectF boundingRect(const QPointF *points, int pointCount)
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
The QDeclarativeComponent class encapsulates a QML component definition.
The QDeclarativeItem class provides the most basic of all visual items in QML.
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event)
This event handler, for event event, can be reimplemented to receive mouse move events for this item...
QVariant data(int key) const
Returns this item&#39;s custom data for the key key as a QVariant.
#define Q_OBJECT
Definition: qobjectdefs.h:157
#define Q_DECLARE_PRIVATE_D(Dptr, Class)
Definition: qglobal.h:2472
virtual void keyReleaseEvent(QKeyEvent *event)
InputMethodQuery
Definition: qnamespace.h:1541
The QInputMethodEvent class provides parameters for input method events.
Definition: qevent.h:431
virtual void drawContents(QPainter *, const QRect &)
This function is called when the cache needs to be refreshed.
virtual void inputMethodEvent(QInputMethodEvent *)
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
virtual void componentComplete()
const char * property
Definition: qwizard.cpp:138
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
Definition: qnamespace.h:54
#define Q_AUTOTEST_EXPORT
Definition: qglobal.h:1510
virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const
static const KeyPair *const end
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
#define QT_END_HEADER
Definition: qglobal.h:137
virtual void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
This function is called to handle this item&#39;s changes in geometry from oldGeometry to newGeometry...
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
This event handler, for event event, can be reimplemented to receive mouse release events for this it...
The QFocusEvent class contains event parameters for widget focus events.
Definition: qevent.h:275
#define text
Definition: qobjectdefs.h:80