|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 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 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
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 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #ifndef QGRAPHICSITEM_H |
|
43 #define QGRAPHICSITEM_H |
|
44 |
|
45 #include <QtCore/qglobal.h> |
|
46 #include <QtCore/qobject.h> |
|
47 #include <QtCore/qvariant.h> |
|
48 #include <QtCore/qrect.h> |
|
49 #include <QtCore/qscopedpointer.h> |
|
50 #include <QtGui/qpainterpath.h> |
|
51 #include <QtGui/qpixmap.h> |
|
52 |
|
53 class tst_QGraphicsItem; |
|
54 |
|
55 QT_BEGIN_HEADER |
|
56 |
|
57 QT_BEGIN_NAMESPACE |
|
58 |
|
59 QT_MODULE(Gui) |
|
60 |
|
61 #if !defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW |
|
62 |
|
63 class QBrush; |
|
64 class QCursor; |
|
65 class QFocusEvent; |
|
66 class QGraphicsEffect; |
|
67 class QGraphicsItemGroup; |
|
68 class QGraphicsObject; |
|
69 class QGraphicsSceneContextMenuEvent; |
|
70 class QGraphicsSceneDragDropEvent; |
|
71 class QGraphicsSceneEvent; |
|
72 class QGraphicsSceneHoverEvent; |
|
73 class QGraphicsSceneMouseEvent; |
|
74 class QGraphicsSceneWheelEvent; |
|
75 class QGraphicsScene; |
|
76 class QGraphicsTransform; |
|
77 class QGraphicsWidget; |
|
78 class QInputMethodEvent; |
|
79 class QKeyEvent; |
|
80 class QMatrix; |
|
81 class QMenu; |
|
82 class QPainter; |
|
83 class QPen; |
|
84 class QPointF; |
|
85 class QRectF; |
|
86 class QStyleOptionGraphicsItem; |
|
87 |
|
88 class QGraphicsItemPrivate; |
|
89 class Q_GUI_EXPORT QGraphicsItem |
|
90 { |
|
91 public: |
|
92 enum GraphicsItemFlag { |
|
93 ItemIsMovable = 0x1, |
|
94 ItemIsSelectable = 0x2, |
|
95 ItemIsFocusable = 0x4, |
|
96 ItemClipsToShape = 0x8, |
|
97 ItemClipsChildrenToShape = 0x10, |
|
98 ItemIgnoresTransformations = 0x20, |
|
99 ItemIgnoresParentOpacity = 0x40, |
|
100 ItemDoesntPropagateOpacityToChildren = 0x80, |
|
101 ItemStacksBehindParent = 0x100, |
|
102 ItemUsesExtendedStyleOption = 0x200, |
|
103 ItemHasNoContents = 0x400, |
|
104 ItemSendsGeometryChanges = 0x800, |
|
105 ItemAcceptsInputMethod = 0x1000, |
|
106 ItemNegativeZStacksBehindParent = 0x2000, |
|
107 ItemIsPanel = 0x4000, |
|
108 ItemIsFocusScope = 0x8000 // internal |
|
109 // NB! Don't forget to increase the d_ptr->flags bit field by 1 when adding a new flag. |
|
110 }; |
|
111 Q_DECLARE_FLAGS(GraphicsItemFlags, GraphicsItemFlag) |
|
112 |
|
113 enum GraphicsItemChange { |
|
114 ItemPositionChange, |
|
115 ItemMatrixChange, |
|
116 ItemVisibleChange, |
|
117 ItemEnabledChange, |
|
118 ItemSelectedChange, |
|
119 ItemParentChange, |
|
120 ItemChildAddedChange, |
|
121 ItemChildRemovedChange, |
|
122 ItemTransformChange, |
|
123 ItemPositionHasChanged, |
|
124 ItemTransformHasChanged, |
|
125 ItemSceneChange, |
|
126 ItemVisibleHasChanged, |
|
127 ItemEnabledHasChanged, |
|
128 ItemSelectedHasChanged, |
|
129 ItemParentHasChanged, |
|
130 ItemSceneHasChanged, |
|
131 ItemCursorChange, |
|
132 ItemCursorHasChanged, |
|
133 ItemToolTipChange, |
|
134 ItemToolTipHasChanged, |
|
135 ItemFlagsChange, |
|
136 ItemFlagsHaveChanged, |
|
137 ItemZValueChange, |
|
138 ItemZValueHasChanged, |
|
139 ItemOpacityChange, |
|
140 ItemOpacityHasChanged |
|
141 }; |
|
142 |
|
143 enum CacheMode { |
|
144 NoCache, |
|
145 ItemCoordinateCache, |
|
146 DeviceCoordinateCache |
|
147 }; |
|
148 |
|
149 enum PanelModality |
|
150 { |
|
151 NonModal, |
|
152 PanelModal, |
|
153 SceneModal |
|
154 }; |
|
155 |
|
156 QGraphicsItem(QGraphicsItem *parent = 0 |
|
157 #ifndef Q_QDOC |
|
158 // ### obsolete argument |
|
159 , QGraphicsScene *scene = 0 |
|
160 #endif |
|
161 ); |
|
162 virtual ~QGraphicsItem(); |
|
163 |
|
164 QGraphicsScene *scene() const; |
|
165 |
|
166 QGraphicsItem *parentItem() const; |
|
167 QGraphicsItem *topLevelItem() const; |
|
168 QGraphicsObject *parentObject() const; |
|
169 QGraphicsWidget *parentWidget() const; |
|
170 QGraphicsWidget *topLevelWidget() const; |
|
171 QGraphicsWidget *window() const; |
|
172 QGraphicsItem *panel() const; |
|
173 void setParentItem(QGraphicsItem *parent); |
|
174 QList<QGraphicsItem *> children() const; // ### obsolete |
|
175 QList<QGraphicsItem *> childItems() const; |
|
176 bool isWidget() const; |
|
177 bool isWindow() const; |
|
178 bool isPanel() const; |
|
179 |
|
180 QGraphicsObject *toGraphicsObject(); |
|
181 const QGraphicsObject *toGraphicsObject() const; |
|
182 |
|
183 QGraphicsItemGroup *group() const; |
|
184 void setGroup(QGraphicsItemGroup *group); |
|
185 |
|
186 GraphicsItemFlags flags() const; |
|
187 void setFlag(GraphicsItemFlag flag, bool enabled = true); |
|
188 void setFlags(GraphicsItemFlags flags); |
|
189 |
|
190 CacheMode cacheMode() const; |
|
191 void setCacheMode(CacheMode mode, const QSize &cacheSize = QSize()); |
|
192 |
|
193 PanelModality panelModality() const; |
|
194 void setPanelModality(PanelModality panelModality); |
|
195 bool isBlockedByModalPanel(QGraphicsItem **blockingPanel = 0) const; |
|
196 |
|
197 #ifndef QT_NO_TOOLTIP |
|
198 QString toolTip() const; |
|
199 void setToolTip(const QString &toolTip); |
|
200 #endif |
|
201 |
|
202 #ifndef QT_NO_CURSOR |
|
203 QCursor cursor() const; |
|
204 void setCursor(const QCursor &cursor); |
|
205 bool hasCursor() const; |
|
206 void unsetCursor(); |
|
207 #endif |
|
208 |
|
209 bool isVisible() const; |
|
210 bool isVisibleTo(const QGraphicsItem *parent) const; |
|
211 void setVisible(bool visible); |
|
212 inline void hide() { setVisible(false); } |
|
213 inline void show() { setVisible(true); } |
|
214 |
|
215 bool isEnabled() const; |
|
216 void setEnabled(bool enabled); |
|
217 |
|
218 bool isSelected() const; |
|
219 void setSelected(bool selected); |
|
220 |
|
221 bool acceptDrops() const; |
|
222 void setAcceptDrops(bool on); |
|
223 |
|
224 qreal opacity() const; |
|
225 qreal effectiveOpacity() const; |
|
226 void setOpacity(qreal opacity); |
|
227 |
|
228 // Effect |
|
229 QGraphicsEffect *graphicsEffect() const; |
|
230 void setGraphicsEffect(QGraphicsEffect *effect); |
|
231 |
|
232 Qt::MouseButtons acceptedMouseButtons() const; |
|
233 void setAcceptedMouseButtons(Qt::MouseButtons buttons); |
|
234 |
|
235 bool acceptsHoverEvents() const; // ### obsolete |
|
236 void setAcceptsHoverEvents(bool enabled); // ### obsolete |
|
237 bool acceptHoverEvents() const; |
|
238 void setAcceptHoverEvents(bool enabled); |
|
239 bool acceptTouchEvents() const; |
|
240 void setAcceptTouchEvents(bool enabled); |
|
241 |
|
242 bool filtersChildEvents() const; |
|
243 void setFiltersChildEvents(bool enabled); |
|
244 |
|
245 bool handlesChildEvents() const; |
|
246 void setHandlesChildEvents(bool enabled); |
|
247 |
|
248 bool isActive() const; |
|
249 void setActive(bool active); |
|
250 |
|
251 bool hasFocus() const; |
|
252 void setFocus(Qt::FocusReason focusReason = Qt::OtherFocusReason); |
|
253 void clearFocus(); |
|
254 |
|
255 QGraphicsItem *focusProxy() const; |
|
256 void setFocusProxy(QGraphicsItem *item); |
|
257 |
|
258 QGraphicsItem *focusItem() const; |
|
259 QGraphicsItem *focusScopeItem() const; |
|
260 |
|
261 void grabMouse(); |
|
262 void ungrabMouse(); |
|
263 void grabKeyboard(); |
|
264 void ungrabKeyboard(); |
|
265 |
|
266 // Positioning in scene coordinates |
|
267 QPointF pos() const; |
|
268 inline qreal x() const { return pos().x(); } |
|
269 void setX(qreal x); |
|
270 inline qreal y() const { return pos().y(); } |
|
271 void setY(qreal y); |
|
272 QPointF scenePos() const; |
|
273 void setPos(const QPointF &pos); |
|
274 inline void setPos(qreal x, qreal y); |
|
275 inline void moveBy(qreal dx, qreal dy) { setPos(pos().x() + dx, pos().y() + dy); } |
|
276 |
|
277 void ensureVisible(const QRectF &rect = QRectF(), int xmargin = 50, int ymargin = 50); |
|
278 inline void ensureVisible(qreal x, qreal y, qreal w, qreal h, int xmargin = 50, int ymargin = 50); |
|
279 |
|
280 // Local transformation |
|
281 QMatrix matrix() const; |
|
282 QMatrix sceneMatrix() const; |
|
283 void setMatrix(const QMatrix &matrix, bool combine = false); |
|
284 void resetMatrix(); |
|
285 QTransform transform() const; |
|
286 QTransform sceneTransform() const; |
|
287 QTransform deviceTransform(const QTransform &viewportTransform) const; |
|
288 QTransform itemTransform(const QGraphicsItem *other, bool *ok = 0) const; |
|
289 void setTransform(const QTransform &matrix, bool combine = false); |
|
290 void resetTransform(); |
|
291 |
|
292 void rotate(qreal angle); // ### obsolete |
|
293 void scale(qreal sx, qreal sy); // ### obsolete |
|
294 void shear(qreal sh, qreal sv); // ### obsolete |
|
295 void translate(qreal dx, qreal dy); // ### obsolete |
|
296 |
|
297 void setRotation(qreal angle); |
|
298 qreal rotation() const; |
|
299 |
|
300 void setScale(qreal scale); |
|
301 qreal scale() const; |
|
302 |
|
303 QList<QGraphicsTransform *> transformations() const; |
|
304 void setTransformations(const QList<QGraphicsTransform *> &transformations); |
|
305 |
|
306 QPointF transformOriginPoint() const; |
|
307 void setTransformOriginPoint(const QPointF &origin); |
|
308 inline void setTransformOriginPoint(qreal ax, qreal ay) |
|
309 { setTransformOriginPoint(QPointF(ax,ay)); } |
|
310 |
|
311 virtual void advance(int phase); |
|
312 |
|
313 // Stacking order |
|
314 qreal zValue() const; |
|
315 void setZValue(qreal z); |
|
316 void stackBefore(const QGraphicsItem *sibling); |
|
317 |
|
318 // Hit test |
|
319 virtual QRectF boundingRect() const = 0; |
|
320 QRectF childrenBoundingRect() const; |
|
321 QRectF sceneBoundingRect() const; |
|
322 virtual QPainterPath shape() const; |
|
323 bool isClipped() const; |
|
324 QPainterPath clipPath() const; |
|
325 virtual bool contains(const QPointF &point) const; |
|
326 virtual bool collidesWithItem(const QGraphicsItem *other, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const; |
|
327 virtual bool collidesWithPath(const QPainterPath &path, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const; |
|
328 QList<QGraphicsItem *> collidingItems(Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const; |
|
329 bool isObscured() const; |
|
330 bool isObscured(const QRectF &rect) const; // ### Qt 5: merge with isObscured(), add QRectF arg to isObscuredBy() |
|
331 inline bool isObscured(qreal x, qreal y, qreal w, qreal h) const; |
|
332 virtual bool isObscuredBy(const QGraphicsItem *item) const; |
|
333 virtual QPainterPath opaqueArea() const; |
|
334 |
|
335 QRegion boundingRegion(const QTransform &itemToDeviceTransform) const; |
|
336 qreal boundingRegionGranularity() const; |
|
337 void setBoundingRegionGranularity(qreal granularity); |
|
338 |
|
339 // Drawing |
|
340 virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) = 0; |
|
341 void update(const QRectF &rect = QRectF()); |
|
342 inline void update(qreal x, qreal y, qreal width, qreal height); |
|
343 void scroll(qreal dx, qreal dy, const QRectF &rect = QRectF()); |
|
344 |
|
345 // Coordinate mapping |
|
346 QPointF mapToItem(const QGraphicsItem *item, const QPointF &point) const; |
|
347 QPointF mapToParent(const QPointF &point) const; |
|
348 QPointF mapToScene(const QPointF &point) const; |
|
349 QPolygonF mapToItem(const QGraphicsItem *item, const QRectF &rect) const; |
|
350 QPolygonF mapToParent(const QRectF &rect) const; |
|
351 QPolygonF mapToScene(const QRectF &rect) const; |
|
352 QRectF mapRectToItem(const QGraphicsItem *item, const QRectF &rect) const; |
|
353 QRectF mapRectToParent(const QRectF &rect) const; |
|
354 QRectF mapRectToScene(const QRectF &rect) const; |
|
355 QPolygonF mapToItem(const QGraphicsItem *item, const QPolygonF &polygon) const; |
|
356 QPolygonF mapToParent(const QPolygonF &polygon) const; |
|
357 QPolygonF mapToScene(const QPolygonF &polygon) const; |
|
358 QPainterPath mapToItem(const QGraphicsItem *item, const QPainterPath &path) const; |
|
359 QPainterPath mapToParent(const QPainterPath &path) const; |
|
360 QPainterPath mapToScene(const QPainterPath &path) const; |
|
361 QPointF mapFromItem(const QGraphicsItem *item, const QPointF &point) const; |
|
362 QPointF mapFromParent(const QPointF &point) const; |
|
363 QPointF mapFromScene(const QPointF &point) const; |
|
364 QPolygonF mapFromItem(const QGraphicsItem *item, const QRectF &rect) const; |
|
365 QPolygonF mapFromParent(const QRectF &rect) const; |
|
366 QPolygonF mapFromScene(const QRectF &rect) const; |
|
367 QRectF mapRectFromItem(const QGraphicsItem *item, const QRectF &rect) const; |
|
368 QRectF mapRectFromParent(const QRectF &rect) const; |
|
369 QRectF mapRectFromScene(const QRectF &rect) const; |
|
370 QPolygonF mapFromItem(const QGraphicsItem *item, const QPolygonF &polygon) const; |
|
371 QPolygonF mapFromParent(const QPolygonF &polygon) const; |
|
372 QPolygonF mapFromScene(const QPolygonF &polygon) const; |
|
373 QPainterPath mapFromItem(const QGraphicsItem *item, const QPainterPath &path) const; |
|
374 QPainterPath mapFromParent(const QPainterPath &path) const; |
|
375 QPainterPath mapFromScene(const QPainterPath &path) const; |
|
376 |
|
377 inline QPointF mapToItem(const QGraphicsItem *item, qreal x, qreal y) const; |
|
378 inline QPointF mapToParent(qreal x, qreal y) const; |
|
379 inline QPointF mapToScene(qreal x, qreal y) const; |
|
380 inline QPolygonF mapToItem(const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const; |
|
381 inline QPolygonF mapToParent(qreal x, qreal y, qreal w, qreal h) const; |
|
382 inline QPolygonF mapToScene(qreal x, qreal y, qreal w, qreal h) const; |
|
383 inline QRectF mapRectToItem(const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const; |
|
384 inline QRectF mapRectToParent(qreal x, qreal y, qreal w, qreal h) const; |
|
385 inline QRectF mapRectToScene(qreal x, qreal y, qreal w, qreal h) const; |
|
386 inline QPointF mapFromItem(const QGraphicsItem *item, qreal x, qreal y) const; |
|
387 inline QPointF mapFromParent(qreal x, qreal y) const; |
|
388 inline QPointF mapFromScene(qreal x, qreal y) const; |
|
389 inline QPolygonF mapFromItem(const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const; |
|
390 inline QPolygonF mapFromParent(qreal x, qreal y, qreal w, qreal h) const; |
|
391 inline QPolygonF mapFromScene(qreal x, qreal y, qreal w, qreal h) const; |
|
392 inline QRectF mapRectFromItem(const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const; |
|
393 inline QRectF mapRectFromParent(qreal x, qreal y, qreal w, qreal h) const; |
|
394 inline QRectF mapRectFromScene(qreal x, qreal y, qreal w, qreal h) const; |
|
395 |
|
396 bool isAncestorOf(const QGraphicsItem *child) const; |
|
397 QGraphicsItem *commonAncestorItem(const QGraphicsItem *other) const; |
|
398 bool isUnderMouse() const; |
|
399 |
|
400 // Custom data |
|
401 QVariant data(int key) const; |
|
402 void setData(int key, const QVariant &value); |
|
403 |
|
404 Qt::InputMethodHints inputMethodHints() const; |
|
405 void setInputMethodHints(Qt::InputMethodHints hints); |
|
406 |
|
407 enum { |
|
408 Type = 1, |
|
409 UserType = 65536 |
|
410 }; |
|
411 virtual int type() const; |
|
412 |
|
413 void installSceneEventFilter(QGraphicsItem *filterItem); |
|
414 void removeSceneEventFilter(QGraphicsItem *filterItem); |
|
415 |
|
416 protected: |
|
417 virtual bool sceneEventFilter(QGraphicsItem *watched, QEvent *event); |
|
418 virtual bool sceneEvent(QEvent *event); |
|
419 virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent *event); |
|
420 virtual void dragEnterEvent(QGraphicsSceneDragDropEvent *event); |
|
421 virtual void dragLeaveEvent(QGraphicsSceneDragDropEvent *event); |
|
422 virtual void dragMoveEvent(QGraphicsSceneDragDropEvent *event); |
|
423 virtual void dropEvent(QGraphicsSceneDragDropEvent *event); |
|
424 virtual void focusInEvent(QFocusEvent *event); |
|
425 virtual void focusOutEvent(QFocusEvent *event); |
|
426 virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event); |
|
427 virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *event); |
|
428 virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); |
|
429 virtual void keyPressEvent(QKeyEvent *event); |
|
430 virtual void keyReleaseEvent(QKeyEvent *event); |
|
431 virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); |
|
432 virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event); |
|
433 virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); |
|
434 virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event); |
|
435 virtual void wheelEvent(QGraphicsSceneWheelEvent *event); |
|
436 virtual void inputMethodEvent(QInputMethodEvent *event); |
|
437 virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const; |
|
438 |
|
439 virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value); |
|
440 |
|
441 enum Extension { |
|
442 UserExtension = 0x80000000 |
|
443 }; |
|
444 virtual bool supportsExtension(Extension extension) const; |
|
445 virtual void setExtension(Extension extension, const QVariant &variant); |
|
446 virtual QVariant extension(const QVariant &variant) const; |
|
447 |
|
448 protected: |
|
449 QGraphicsItem(QGraphicsItemPrivate &dd, |
|
450 QGraphicsItem *parent, QGraphicsScene *scene); |
|
451 QScopedPointer<QGraphicsItemPrivate> d_ptr; |
|
452 |
|
453 void addToIndex(); |
|
454 void removeFromIndex(); |
|
455 void prepareGeometryChange(); |
|
456 |
|
457 private: |
|
458 Q_DISABLE_COPY(QGraphicsItem) |
|
459 Q_DECLARE_PRIVATE(QGraphicsItem) |
|
460 friend class QGraphicsItemGroup; |
|
461 friend class QGraphicsScene; |
|
462 friend class QGraphicsScenePrivate; |
|
463 friend class QGraphicsSceneFindItemBspTreeVisitor; |
|
464 friend class QGraphicsSceneBspTree; |
|
465 friend class QGraphicsView; |
|
466 friend class QGraphicsViewPrivate; |
|
467 friend class QGraphicsObject; |
|
468 friend class QGraphicsWidget; |
|
469 friend class QGraphicsWidgetPrivate; |
|
470 friend class QGraphicsProxyWidgetPrivate; |
|
471 friend class QGraphicsSceneIndex; |
|
472 friend class QGraphicsSceneIndexPrivate; |
|
473 friend class QGraphicsSceneBspTreeIndex; |
|
474 friend class QGraphicsSceneBspTreeIndexPrivate; |
|
475 friend class QGraphicsItemEffectSourcePrivate; |
|
476 friend class QGraphicsTransformPrivate; |
|
477 friend class QGestureManager; |
|
478 friend class ::tst_QGraphicsItem; |
|
479 friend bool qt_closestLeaf(const QGraphicsItem *, const QGraphicsItem *); |
|
480 friend bool qt_closestItemFirst(const QGraphicsItem *, const QGraphicsItem *); |
|
481 }; |
|
482 |
|
483 Q_DECLARE_OPERATORS_FOR_FLAGS(QGraphicsItem::GraphicsItemFlags) |
|
484 Q_DECLARE_INTERFACE(QGraphicsItem, "com.trolltech.Qt.QGraphicsItem") |
|
485 |
|
486 inline void QGraphicsItem::setPos(qreal ax, qreal ay) |
|
487 { setPos(QPointF(ax, ay)); } |
|
488 inline void QGraphicsItem::ensureVisible(qreal ax, qreal ay, qreal w, qreal h, int xmargin, int ymargin) |
|
489 { ensureVisible(QRectF(ax, ay, w, h), xmargin, ymargin); } |
|
490 inline void QGraphicsItem::update(qreal ax, qreal ay, qreal width, qreal height) |
|
491 { update(QRectF(ax, ay, width, height)); } |
|
492 inline bool QGraphicsItem::isObscured(qreal ax, qreal ay, qreal w, qreal h) const |
|
493 { return isObscured(QRectF(ax, ay, w, h)); } |
|
494 inline QPointF QGraphicsItem::mapToItem(const QGraphicsItem *item, qreal ax, qreal ay) const |
|
495 { return mapToItem(item, QPointF(ax, ay)); } |
|
496 inline QPointF QGraphicsItem::mapToParent(qreal ax, qreal ay) const |
|
497 { return mapToParent(QPointF(ax, ay)); } |
|
498 inline QPointF QGraphicsItem::mapToScene(qreal ax, qreal ay) const |
|
499 { return mapToScene(QPointF(ax, ay)); } |
|
500 inline QPointF QGraphicsItem::mapFromItem(const QGraphicsItem *item, qreal ax, qreal ay) const |
|
501 { return mapFromItem(item, QPointF(ax, ay)); } |
|
502 inline QPointF QGraphicsItem::mapFromParent(qreal ax, qreal ay) const |
|
503 { return mapFromParent(QPointF(ax, ay)); } |
|
504 inline QPointF QGraphicsItem::mapFromScene(qreal ax, qreal ay) const |
|
505 { return mapFromScene(QPointF(ax, ay)); } |
|
506 inline QPolygonF QGraphicsItem::mapToItem(const QGraphicsItem *item, qreal ax, qreal ay, qreal w, qreal h) const |
|
507 { return mapToItem(item, QRectF(ax, ay, w, h)); } |
|
508 inline QPolygonF QGraphicsItem::mapToParent(qreal ax, qreal ay, qreal w, qreal h) const |
|
509 { return mapToParent(QRectF(ax, ay, w, h)); } |
|
510 inline QPolygonF QGraphicsItem::mapToScene(qreal ax, qreal ay, qreal w, qreal h) const |
|
511 { return mapToScene(QRectF(ax, ay, w, h)); } |
|
512 inline QRectF QGraphicsItem::mapRectToItem(const QGraphicsItem *item, qreal ax, qreal ay, qreal w, qreal h) const |
|
513 { return mapRectToItem(item, QRectF(ax, ay, w, h)); } |
|
514 inline QRectF QGraphicsItem::mapRectToParent(qreal ax, qreal ay, qreal w, qreal h) const |
|
515 { return mapRectToParent(QRectF(ax, ay, w, h)); } |
|
516 inline QRectF QGraphicsItem::mapRectToScene(qreal ax, qreal ay, qreal w, qreal h) const |
|
517 { return mapRectToScene(QRectF(ax, ay, w, h)); } |
|
518 inline QPolygonF QGraphicsItem::mapFromItem(const QGraphicsItem *item, qreal ax, qreal ay, qreal w, qreal h) const |
|
519 { return mapFromItem(item, QRectF(ax, ay, w, h)); } |
|
520 inline QPolygonF QGraphicsItem::mapFromParent(qreal ax, qreal ay, qreal w, qreal h) const |
|
521 { return mapFromParent(QRectF(ax, ay, w, h)); } |
|
522 inline QPolygonF QGraphicsItem::mapFromScene(qreal ax, qreal ay, qreal w, qreal h) const |
|
523 { return mapFromScene(QRectF(ax, ay, w, h)); } |
|
524 inline QRectF QGraphicsItem::mapRectFromItem(const QGraphicsItem *item, qreal ax, qreal ay, qreal w, qreal h) const |
|
525 { return mapRectFromItem(item, QRectF(ax, ay, w, h)); } |
|
526 inline QRectF QGraphicsItem::mapRectFromParent(qreal ax, qreal ay, qreal w, qreal h) const |
|
527 { return mapRectFromParent(QRectF(ax, ay, w, h)); } |
|
528 inline QRectF QGraphicsItem::mapRectFromScene(qreal ax, qreal ay, qreal w, qreal h) const |
|
529 { return mapRectFromScene(QRectF(ax, ay, w, h)); } |
|
530 |
|
531 |
|
532 class Q_GUI_EXPORT QGraphicsObject : public QObject, public QGraphicsItem |
|
533 { |
|
534 Q_OBJECT |
|
535 Q_PROPERTY(QGraphicsObject * parent READ parentObject WRITE setParentItem NOTIFY parentChanged DESIGNABLE false) |
|
536 Q_PROPERTY(QString id READ objectName WRITE setObjectName) |
|
537 Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity NOTIFY opacityChanged FINAL) |
|
538 Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged) |
|
539 Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged FINAL) |
|
540 Q_PROPERTY(QPointF pos READ pos WRITE setPos) |
|
541 Q_PROPERTY(qreal x READ x WRITE setX NOTIFY xChanged) |
|
542 Q_PROPERTY(qreal y READ y WRITE setY NOTIFY yChanged) |
|
543 Q_PROPERTY(qreal z READ zValue WRITE setZValue NOTIFY zChanged) |
|
544 Q_PROPERTY(qreal rotation READ rotation WRITE setRotation NOTIFY rotationChanged) |
|
545 Q_PROPERTY(qreal scale READ scale WRITE setScale NOTIFY scaleChanged) |
|
546 Q_PROPERTY(QPointF transformOriginPoint READ transformOriginPoint WRITE setTransformOriginPoint) |
|
547 Q_INTERFACES(QGraphicsItem) |
|
548 public: |
|
549 QGraphicsObject(QGraphicsItem *parent = 0); |
|
550 |
|
551 // ### Qt 5: Disambiguate |
|
552 #ifdef Q_NO_USING_KEYWORD |
|
553 const QObjectList &children() const { return QObject::children(); } |
|
554 #else |
|
555 using QObject::children; |
|
556 #endif |
|
557 |
|
558 void grabGesture(Qt::GestureType type, Qt::GestureContext context = Qt::ItemWithChildrenGesture); |
|
559 |
|
560 Q_SIGNALS: |
|
561 void parentChanged(); |
|
562 void opacityChanged(); |
|
563 void visibleChanged(); |
|
564 void enabledChanged(); |
|
565 void xChanged(); |
|
566 void yChanged(); |
|
567 void zChanged(); |
|
568 void rotationChanged(); |
|
569 void scaleChanged(); |
|
570 |
|
571 protected: |
|
572 QGraphicsObject(QGraphicsItemPrivate &dd, QGraphicsItem *parent, QGraphicsScene *scene); |
|
573 private: |
|
574 friend class QGraphicsItem; |
|
575 friend class QGraphicsItemPrivate; |
|
576 }; |
|
577 |
|
578 |
|
579 class QAbstractGraphicsShapeItemPrivate; |
|
580 class Q_GUI_EXPORT QAbstractGraphicsShapeItem : public QGraphicsItem |
|
581 { |
|
582 public: |
|
583 QAbstractGraphicsShapeItem(QGraphicsItem *parent = 0 |
|
584 #ifndef Q_QDOC |
|
585 // ### obsolete argument |
|
586 , QGraphicsScene *scene = 0 |
|
587 #endif |
|
588 ); |
|
589 ~QAbstractGraphicsShapeItem(); |
|
590 |
|
591 QPen pen() const; |
|
592 void setPen(const QPen &pen); |
|
593 |
|
594 QBrush brush() const; |
|
595 void setBrush(const QBrush &brush); |
|
596 |
|
597 bool isObscuredBy(const QGraphicsItem *item) const; |
|
598 QPainterPath opaqueArea() const; |
|
599 |
|
600 protected: |
|
601 QAbstractGraphicsShapeItem(QAbstractGraphicsShapeItemPrivate &dd, |
|
602 QGraphicsItem *parent, QGraphicsScene *scene); |
|
603 |
|
604 private: |
|
605 Q_DISABLE_COPY(QAbstractGraphicsShapeItem) |
|
606 Q_DECLARE_PRIVATE(QAbstractGraphicsShapeItem) |
|
607 }; |
|
608 |
|
609 class QGraphicsPathItemPrivate; |
|
610 class Q_GUI_EXPORT QGraphicsPathItem : public QAbstractGraphicsShapeItem |
|
611 { |
|
612 public: |
|
613 QGraphicsPathItem(QGraphicsItem *parent = 0 |
|
614 #ifndef Q_QDOC |
|
615 // ### obsolete argument |
|
616 , QGraphicsScene *scene = 0 |
|
617 #endif |
|
618 ); |
|
619 QGraphicsPathItem(const QPainterPath &path, QGraphicsItem *parent = 0 |
|
620 #ifndef Q_QDOC |
|
621 // ### obsolete argument |
|
622 , QGraphicsScene *scene = 0 |
|
623 #endif |
|
624 ); |
|
625 ~QGraphicsPathItem(); |
|
626 |
|
627 QPainterPath path() const; |
|
628 void setPath(const QPainterPath &path); |
|
629 |
|
630 QRectF boundingRect() const; |
|
631 QPainterPath shape() const; |
|
632 bool contains(const QPointF &point) const; |
|
633 |
|
634 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); |
|
635 |
|
636 bool isObscuredBy(const QGraphicsItem *item) const; |
|
637 QPainterPath opaqueArea() const; |
|
638 |
|
639 enum { Type = 2 }; |
|
640 int type() const; |
|
641 |
|
642 protected: |
|
643 bool supportsExtension(Extension extension) const; |
|
644 void setExtension(Extension extension, const QVariant &variant); |
|
645 QVariant extension(const QVariant &variant) const; |
|
646 |
|
647 private: |
|
648 Q_DISABLE_COPY(QGraphicsPathItem) |
|
649 Q_DECLARE_PRIVATE(QGraphicsPathItem) |
|
650 }; |
|
651 |
|
652 class QGraphicsRectItemPrivate; |
|
653 class Q_GUI_EXPORT QGraphicsRectItem : public QAbstractGraphicsShapeItem |
|
654 { |
|
655 public: |
|
656 QGraphicsRectItem(QGraphicsItem *parent = 0 |
|
657 #ifndef Q_QDOC |
|
658 // ### obsolete argument |
|
659 , QGraphicsScene *scene = 0 |
|
660 #endif |
|
661 ); |
|
662 QGraphicsRectItem(const QRectF &rect, QGraphicsItem *parent = 0 |
|
663 #ifndef Q_QDOC |
|
664 // ### obsolete argument |
|
665 , QGraphicsScene *scene = 0 |
|
666 #endif |
|
667 ); |
|
668 QGraphicsRectItem(qreal x, qreal y, qreal w, qreal h, QGraphicsItem *parent = 0 |
|
669 #ifndef Q_QDOC |
|
670 // ### obsolete argument |
|
671 , QGraphicsScene *scene = 0 |
|
672 #endif |
|
673 ); |
|
674 ~QGraphicsRectItem(); |
|
675 |
|
676 QRectF rect() const; |
|
677 void setRect(const QRectF &rect); |
|
678 inline void setRect(qreal x, qreal y, qreal w, qreal h); |
|
679 |
|
680 QRectF boundingRect() const; |
|
681 QPainterPath shape() const; |
|
682 bool contains(const QPointF &point) const; |
|
683 |
|
684 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); |
|
685 |
|
686 bool isObscuredBy(const QGraphicsItem *item) const; |
|
687 QPainterPath opaqueArea() const; |
|
688 |
|
689 enum { Type = 3 }; |
|
690 int type() const; |
|
691 |
|
692 protected: |
|
693 bool supportsExtension(Extension extension) const; |
|
694 void setExtension(Extension extension, const QVariant &variant); |
|
695 QVariant extension(const QVariant &variant) const; |
|
696 |
|
697 private: |
|
698 Q_DISABLE_COPY(QGraphicsRectItem) |
|
699 Q_DECLARE_PRIVATE(QGraphicsRectItem) |
|
700 }; |
|
701 |
|
702 inline void QGraphicsRectItem::setRect(qreal ax, qreal ay, qreal w, qreal h) |
|
703 { setRect(QRectF(ax, ay, w, h)); } |
|
704 |
|
705 class QGraphicsEllipseItemPrivate; |
|
706 class Q_GUI_EXPORT QGraphicsEllipseItem : public QAbstractGraphicsShapeItem |
|
707 { |
|
708 public: |
|
709 QGraphicsEllipseItem(QGraphicsItem *parent = 0 |
|
710 #ifndef Q_QDOC |
|
711 // ### obsolete argument |
|
712 , QGraphicsScene *scene = 0 |
|
713 #endif |
|
714 ); |
|
715 QGraphicsEllipseItem(const QRectF &rect, QGraphicsItem *parent = 0 |
|
716 #ifndef Q_QDOC |
|
717 // ### obsolete argument |
|
718 , QGraphicsScene *scene = 0 |
|
719 #endif |
|
720 ); |
|
721 QGraphicsEllipseItem(qreal x, qreal y, qreal w, qreal h, QGraphicsItem *parent = 0 |
|
722 #ifndef Q_QDOC |
|
723 // ### obsolete argument |
|
724 , QGraphicsScene *scene = 0 |
|
725 #endif |
|
726 ); |
|
727 ~QGraphicsEllipseItem(); |
|
728 |
|
729 QRectF rect() const; |
|
730 void setRect(const QRectF &rect); |
|
731 inline void setRect(qreal x, qreal y, qreal w, qreal h); |
|
732 |
|
733 int startAngle() const; |
|
734 void setStartAngle(int angle); |
|
735 |
|
736 int spanAngle() const; |
|
737 void setSpanAngle(int angle); |
|
738 |
|
739 QRectF boundingRect() const; |
|
740 QPainterPath shape() const; |
|
741 bool contains(const QPointF &point) const; |
|
742 |
|
743 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); |
|
744 |
|
745 bool isObscuredBy(const QGraphicsItem *item) const; |
|
746 QPainterPath opaqueArea() const; |
|
747 |
|
748 enum { Type = 4 }; |
|
749 int type() const; |
|
750 |
|
751 protected: |
|
752 bool supportsExtension(Extension extension) const; |
|
753 void setExtension(Extension extension, const QVariant &variant); |
|
754 QVariant extension(const QVariant &variant) const; |
|
755 |
|
756 private: |
|
757 Q_DISABLE_COPY(QGraphicsEllipseItem) |
|
758 Q_DECLARE_PRIVATE(QGraphicsEllipseItem) |
|
759 }; |
|
760 |
|
761 inline void QGraphicsEllipseItem::setRect(qreal ax, qreal ay, qreal w, qreal h) |
|
762 { setRect(QRectF(ax, ay, w, h)); } |
|
763 |
|
764 class QGraphicsPolygonItemPrivate; |
|
765 class Q_GUI_EXPORT QGraphicsPolygonItem : public QAbstractGraphicsShapeItem |
|
766 { |
|
767 public: |
|
768 QGraphicsPolygonItem(QGraphicsItem *parent = 0 |
|
769 #ifndef Q_QDOC |
|
770 // ### obsolete argument |
|
771 , QGraphicsScene *scene = 0 |
|
772 #endif |
|
773 ); |
|
774 QGraphicsPolygonItem(const QPolygonF &polygon, |
|
775 QGraphicsItem *parent = 0 |
|
776 #ifndef Q_QDOC |
|
777 // ### obsolete argument |
|
778 , QGraphicsScene *scene = 0 |
|
779 #endif |
|
780 ); |
|
781 ~QGraphicsPolygonItem(); |
|
782 |
|
783 QPolygonF polygon() const; |
|
784 void setPolygon(const QPolygonF &polygon); |
|
785 |
|
786 Qt::FillRule fillRule() const; |
|
787 void setFillRule(Qt::FillRule rule); |
|
788 |
|
789 QRectF boundingRect() const; |
|
790 QPainterPath shape() const; |
|
791 bool contains(const QPointF &point) const; |
|
792 |
|
793 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); |
|
794 |
|
795 bool isObscuredBy(const QGraphicsItem *item) const; |
|
796 QPainterPath opaqueArea() const; |
|
797 |
|
798 enum { Type = 5 }; |
|
799 int type() const; |
|
800 |
|
801 protected: |
|
802 bool supportsExtension(Extension extension) const; |
|
803 void setExtension(Extension extension, const QVariant &variant); |
|
804 QVariant extension(const QVariant &variant) const; |
|
805 |
|
806 private: |
|
807 Q_DISABLE_COPY(QGraphicsPolygonItem) |
|
808 Q_DECLARE_PRIVATE(QGraphicsPolygonItem) |
|
809 }; |
|
810 |
|
811 class QGraphicsLineItemPrivate; |
|
812 class Q_GUI_EXPORT QGraphicsLineItem : public QGraphicsItem |
|
813 { |
|
814 public: |
|
815 QGraphicsLineItem(QGraphicsItem *parent = 0 |
|
816 #ifndef Q_QDOC |
|
817 // ### obsolete argument |
|
818 , QGraphicsScene *scene = 0 |
|
819 #endif |
|
820 ); |
|
821 QGraphicsLineItem(const QLineF &line, QGraphicsItem *parent = 0 |
|
822 #ifndef Q_QDOC |
|
823 // ### obsolete argument |
|
824 , QGraphicsScene *scene = 0 |
|
825 #endif |
|
826 ); |
|
827 QGraphicsLineItem(qreal x1, qreal y1, qreal x2, qreal y2, QGraphicsItem *parent = 0 |
|
828 #ifndef Q_QDOC |
|
829 // ### obsolete argument |
|
830 , QGraphicsScene *scene = 0 |
|
831 #endif |
|
832 ); |
|
833 ~QGraphicsLineItem(); |
|
834 |
|
835 QPen pen() const; |
|
836 void setPen(const QPen &pen); |
|
837 |
|
838 QLineF line() const; |
|
839 void setLine(const QLineF &line); |
|
840 inline void setLine(qreal x1, qreal y1, qreal x2, qreal y2) |
|
841 { setLine(QLineF(x1, y1, x2, y2)); } |
|
842 |
|
843 QRectF boundingRect() const; |
|
844 QPainterPath shape() const; |
|
845 bool contains(const QPointF &point) const; |
|
846 |
|
847 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); |
|
848 |
|
849 bool isObscuredBy(const QGraphicsItem *item) const; |
|
850 QPainterPath opaqueArea() const; |
|
851 |
|
852 enum { Type = 6 }; |
|
853 int type() const; |
|
854 |
|
855 protected: |
|
856 bool supportsExtension(Extension extension) const; |
|
857 void setExtension(Extension extension, const QVariant &variant); |
|
858 QVariant extension(const QVariant &variant) const; |
|
859 |
|
860 private: |
|
861 Q_DISABLE_COPY(QGraphicsLineItem) |
|
862 Q_DECLARE_PRIVATE(QGraphicsLineItem) |
|
863 }; |
|
864 |
|
865 class QGraphicsPixmapItemPrivate; |
|
866 class Q_GUI_EXPORT QGraphicsPixmapItem : public QGraphicsItem |
|
867 { |
|
868 public: |
|
869 enum ShapeMode { |
|
870 MaskShape, |
|
871 BoundingRectShape, |
|
872 HeuristicMaskShape |
|
873 }; |
|
874 |
|
875 QGraphicsPixmapItem(QGraphicsItem *parent = 0 |
|
876 #ifndef Q_QDOC |
|
877 // ### obsolete argument |
|
878 , QGraphicsScene *scene = 0 |
|
879 #endif |
|
880 ); |
|
881 QGraphicsPixmapItem(const QPixmap &pixmap, QGraphicsItem *parent = 0 |
|
882 #ifndef Q_QDOC |
|
883 // ### obsolete argument |
|
884 , QGraphicsScene *scene = 0 |
|
885 #endif |
|
886 ); |
|
887 ~QGraphicsPixmapItem(); |
|
888 |
|
889 QPixmap pixmap() const; |
|
890 void setPixmap(const QPixmap &pixmap); |
|
891 |
|
892 Qt::TransformationMode transformationMode() const; |
|
893 void setTransformationMode(Qt::TransformationMode mode); |
|
894 |
|
895 QPointF offset() const; |
|
896 void setOffset(const QPointF &offset); |
|
897 inline void setOffset(qreal x, qreal y); |
|
898 |
|
899 QRectF boundingRect() const; |
|
900 QPainterPath shape() const; |
|
901 bool contains(const QPointF &point) const; |
|
902 |
|
903 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); |
|
904 |
|
905 bool isObscuredBy(const QGraphicsItem *item) const; |
|
906 QPainterPath opaqueArea() const; |
|
907 |
|
908 enum { Type = 7 }; |
|
909 int type() const; |
|
910 |
|
911 ShapeMode shapeMode() const; |
|
912 void setShapeMode(ShapeMode mode); |
|
913 |
|
914 protected: |
|
915 bool supportsExtension(Extension extension) const; |
|
916 void setExtension(Extension extension, const QVariant &variant); |
|
917 QVariant extension(const QVariant &variant) const; |
|
918 |
|
919 private: |
|
920 Q_DISABLE_COPY(QGraphicsPixmapItem) |
|
921 Q_DECLARE_PRIVATE(QGraphicsPixmapItem) |
|
922 }; |
|
923 |
|
924 inline void QGraphicsPixmapItem::setOffset(qreal ax, qreal ay) |
|
925 { setOffset(QPointF(ax, ay)); } |
|
926 |
|
927 class QGraphicsTextItemPrivate; |
|
928 class QTextDocument; |
|
929 class QTextCursor; |
|
930 class Q_GUI_EXPORT QGraphicsTextItem : public QGraphicsObject |
|
931 { |
|
932 Q_OBJECT |
|
933 QDOC_PROPERTY(bool openExternalLinks READ openExternalLinks WRITE setOpenExternalLinks) |
|
934 QDOC_PROPERTY(QTextCursor textCursor READ textCursor WRITE setTextCursor) |
|
935 |
|
936 public: |
|
937 QGraphicsTextItem(QGraphicsItem *parent = 0 |
|
938 #ifndef Q_QDOC |
|
939 // ### obsolete argument |
|
940 , QGraphicsScene *scene = 0 |
|
941 #endif |
|
942 ); |
|
943 QGraphicsTextItem(const QString &text, QGraphicsItem *parent = 0 |
|
944 #ifndef Q_QDOC |
|
945 // ### obsolete argument |
|
946 , QGraphicsScene *scene = 0 |
|
947 #endif |
|
948 ); |
|
949 ~QGraphicsTextItem(); |
|
950 |
|
951 QString toHtml() const; |
|
952 void setHtml(const QString &html); |
|
953 |
|
954 QString toPlainText() const; |
|
955 void setPlainText(const QString &text); |
|
956 |
|
957 QFont font() const; |
|
958 void setFont(const QFont &font); |
|
959 |
|
960 void setDefaultTextColor(const QColor &c); |
|
961 QColor defaultTextColor() const; |
|
962 |
|
963 QRectF boundingRect() const; |
|
964 QPainterPath shape() const; |
|
965 bool contains(const QPointF &point) const; |
|
966 |
|
967 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); |
|
968 |
|
969 bool isObscuredBy(const QGraphicsItem *item) const; |
|
970 QPainterPath opaqueArea() const; |
|
971 |
|
972 enum { Type = 8 }; |
|
973 int type() const; |
|
974 |
|
975 void setTextWidth(qreal width); |
|
976 qreal textWidth() const; |
|
977 |
|
978 void adjustSize(); |
|
979 |
|
980 void setDocument(QTextDocument *document); |
|
981 QTextDocument *document() const; |
|
982 |
|
983 void setTextInteractionFlags(Qt::TextInteractionFlags flags); |
|
984 Qt::TextInteractionFlags textInteractionFlags() const; |
|
985 |
|
986 void setTabChangesFocus(bool b); |
|
987 bool tabChangesFocus() const; |
|
988 |
|
989 void setOpenExternalLinks(bool open); |
|
990 bool openExternalLinks() const; |
|
991 |
|
992 void setTextCursor(const QTextCursor &cursor); |
|
993 QTextCursor textCursor() const; |
|
994 |
|
995 Q_SIGNALS: |
|
996 void linkActivated(const QString &); |
|
997 void linkHovered(const QString &); |
|
998 |
|
999 protected: |
|
1000 bool sceneEvent(QEvent *event); |
|
1001 void mousePressEvent(QGraphicsSceneMouseEvent *event); |
|
1002 void mouseMoveEvent(QGraphicsSceneMouseEvent *event); |
|
1003 void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); |
|
1004 void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event); |
|
1005 void contextMenuEvent(QGraphicsSceneContextMenuEvent *event); |
|
1006 void keyPressEvent(QKeyEvent *event); |
|
1007 void keyReleaseEvent(QKeyEvent *event); |
|
1008 void focusInEvent(QFocusEvent *event); |
|
1009 void focusOutEvent(QFocusEvent *event); |
|
1010 void dragEnterEvent(QGraphicsSceneDragDropEvent *event); |
|
1011 void dragLeaveEvent(QGraphicsSceneDragDropEvent *event); |
|
1012 void dragMoveEvent(QGraphicsSceneDragDropEvent *event); |
|
1013 void dropEvent(QGraphicsSceneDragDropEvent *event); |
|
1014 void inputMethodEvent(QInputMethodEvent *event); |
|
1015 void hoverEnterEvent(QGraphicsSceneHoverEvent *event); |
|
1016 void hoverMoveEvent(QGraphicsSceneHoverEvent *event); |
|
1017 void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); |
|
1018 |
|
1019 QVariant inputMethodQuery(Qt::InputMethodQuery query) const; |
|
1020 |
|
1021 bool supportsExtension(Extension extension) const; |
|
1022 void setExtension(Extension extension, const QVariant &variant); |
|
1023 QVariant extension(const QVariant &variant) const; |
|
1024 |
|
1025 private: |
|
1026 Q_DISABLE_COPY(QGraphicsTextItem) |
|
1027 Q_PRIVATE_SLOT(dd, void _q_updateBoundingRect(const QSizeF &)) |
|
1028 Q_PRIVATE_SLOT(dd, void _q_update(QRectF)) |
|
1029 Q_PRIVATE_SLOT(dd, void _q_ensureVisible(QRectF)) |
|
1030 QGraphicsTextItemPrivate *dd; |
|
1031 friend class QGraphicsTextItemPrivate; |
|
1032 }; |
|
1033 |
|
1034 class QGraphicsSimpleTextItemPrivate; |
|
1035 class Q_GUI_EXPORT QGraphicsSimpleTextItem : public QAbstractGraphicsShapeItem |
|
1036 { |
|
1037 public: |
|
1038 QGraphicsSimpleTextItem(QGraphicsItem *parent = 0 |
|
1039 #ifndef Q_QDOC |
|
1040 // ### obsolete argument |
|
1041 , QGraphicsScene *scene = 0 |
|
1042 #endif |
|
1043 ); |
|
1044 QGraphicsSimpleTextItem(const QString &text, QGraphicsItem *parent = 0 |
|
1045 #ifndef Q_QDOC |
|
1046 // ### obsolete argument |
|
1047 , QGraphicsScene *scene = 0 |
|
1048 #endif |
|
1049 ); |
|
1050 ~QGraphicsSimpleTextItem(); |
|
1051 |
|
1052 void setText(const QString &text); |
|
1053 QString text() const; |
|
1054 |
|
1055 void setFont(const QFont &font); |
|
1056 QFont font() const; |
|
1057 |
|
1058 QRectF boundingRect() const; |
|
1059 QPainterPath shape() const; |
|
1060 bool contains(const QPointF &point) const; |
|
1061 |
|
1062 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); |
|
1063 |
|
1064 bool isObscuredBy(const QGraphicsItem *item) const; |
|
1065 QPainterPath opaqueArea() const; |
|
1066 |
|
1067 enum { Type = 9 }; |
|
1068 int type() const; |
|
1069 |
|
1070 protected: |
|
1071 bool supportsExtension(Extension extension) const; |
|
1072 void setExtension(Extension extension, const QVariant &variant); |
|
1073 QVariant extension(const QVariant &variant) const; |
|
1074 |
|
1075 private: |
|
1076 Q_DISABLE_COPY(QGraphicsSimpleTextItem) |
|
1077 Q_DECLARE_PRIVATE(QGraphicsSimpleTextItem) |
|
1078 }; |
|
1079 |
|
1080 class QGraphicsItemGroupPrivate; |
|
1081 class Q_GUI_EXPORT QGraphicsItemGroup : public QGraphicsItem |
|
1082 { |
|
1083 public: |
|
1084 QGraphicsItemGroup(QGraphicsItem *parent = 0 |
|
1085 #ifndef Q_QDOC |
|
1086 // ### obsolete argument |
|
1087 , QGraphicsScene *scene = 0 |
|
1088 #endif |
|
1089 ); |
|
1090 ~QGraphicsItemGroup(); |
|
1091 |
|
1092 void addToGroup(QGraphicsItem *item); |
|
1093 void removeFromGroup(QGraphicsItem *item); |
|
1094 |
|
1095 QRectF boundingRect() const; |
|
1096 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); |
|
1097 |
|
1098 bool isObscuredBy(const QGraphicsItem *item) const; |
|
1099 QPainterPath opaqueArea() const; |
|
1100 |
|
1101 enum { Type = 10 }; |
|
1102 int type() const; |
|
1103 |
|
1104 private: |
|
1105 Q_DISABLE_COPY(QGraphicsItemGroup) |
|
1106 Q_DECLARE_PRIVATE(QGraphicsItemGroup) |
|
1107 }; |
|
1108 |
|
1109 template <class T> inline T qgraphicsitem_cast(QGraphicsItem *item) |
|
1110 { |
|
1111 return int(static_cast<T>(0)->Type) == int(QGraphicsItem::Type) |
|
1112 || (item && int(static_cast<T>(0)->Type) == item->type()) ? static_cast<T>(item) : 0; |
|
1113 } |
|
1114 |
|
1115 template <class T> inline T qgraphicsitem_cast(const QGraphicsItem *item) |
|
1116 { |
|
1117 return int(static_cast<T>(0)->Type) == int(QGraphicsItem::Type) |
|
1118 || (item && int(static_cast<T>(0)->Type) == item->type()) ? static_cast<T>(item) : 0; |
|
1119 } |
|
1120 |
|
1121 #ifndef QT_NO_DEBUG_STREAM |
|
1122 Q_GUI_EXPORT QDebug operator<<(QDebug debug, QGraphicsItem *item); |
|
1123 Q_GUI_EXPORT QDebug operator<<(QDebug debug, QGraphicsObject *item); |
|
1124 Q_GUI_EXPORT QDebug operator<<(QDebug debug, QGraphicsItem::GraphicsItemChange change); |
|
1125 Q_GUI_EXPORT QDebug operator<<(QDebug debug, QGraphicsItem::GraphicsItemFlag flag); |
|
1126 Q_GUI_EXPORT QDebug operator<<(QDebug debug, QGraphicsItem::GraphicsItemFlags flags); |
|
1127 #endif |
|
1128 |
|
1129 QT_END_NAMESPACE |
|
1130 |
|
1131 Q_DECLARE_METATYPE(QGraphicsItem *) |
|
1132 Q_DECLARE_METATYPE(QGraphicsScene *) |
|
1133 |
|
1134 QT_BEGIN_NAMESPACE |
|
1135 |
|
1136 #endif // QT_NO_GRAPHICSVIEW |
|
1137 |
|
1138 QT_END_NAMESPACE |
|
1139 |
|
1140 QT_END_HEADER |
|
1141 |
|
1142 #endif // QGRAPHICSITEM_H |