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