| 1 | /****************************************************************************
|
|---|
| 2 | **
|
|---|
| 3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
|---|
| 4 | ** All rights reserved.
|
|---|
| 5 | ** Contact: Nokia Corporation ([email protected])
|
|---|
| 6 | **
|
|---|
| 7 | ** This file is part of the QtGui module of the Qt Toolkit.
|
|---|
| 8 | **
|
|---|
| 9 | ** $QT_BEGIN_LICENSE:LGPL$
|
|---|
| 10 | ** Commercial Usage
|
|---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
|---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the
|
|---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in
|
|---|
| 14 | ** a written agreement between you and Nokia.
|
|---|
| 15 | **
|
|---|
| 16 | ** GNU Lesser General Public License Usage
|
|---|
| 17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
|---|
| 18 | ** General Public License version 2.1 as published by the Free Software
|
|---|
| 19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
|---|
| 20 | ** packaging of this file. Please review the following information to
|
|---|
| 21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
|---|
| 22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|---|
| 23 | **
|
|---|
| 24 | ** In addition, as a special exception, Nokia gives you certain additional
|
|---|
| 25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
|---|
| 26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|---|
| 27 | **
|
|---|
| 28 | ** GNU General Public License Usage
|
|---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
|---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
|---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
|---|
| 32 | ** packaging of this file. Please review the following information to
|
|---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
|---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
|---|
| 35 | **
|
|---|
| 36 | ** If you have questions regarding the use of this file, please contact
|
|---|
| 37 | ** Nokia at [email protected].
|
|---|
| 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 | ItemSendsScenePositionChanges = 0x10000,
|
|---|
| 110 | ItemStopsClickFocusPropagation = 0x20000
|
|---|
| 111 | // NB! Don't forget to increase the d_ptr->flags bit field by 1 when adding a new flag.
|
|---|
| 112 | };
|
|---|
| 113 | Q_DECLARE_FLAGS(GraphicsItemFlags, GraphicsItemFlag)
|
|---|
| 114 |
|
|---|
| 115 | enum GraphicsItemChange {
|
|---|
| 116 | ItemPositionChange,
|
|---|
| 117 | ItemMatrixChange,
|
|---|
| 118 | ItemVisibleChange,
|
|---|
| 119 | ItemEnabledChange,
|
|---|
| 120 | ItemSelectedChange,
|
|---|
| 121 | ItemParentChange,
|
|---|
| 122 | ItemChildAddedChange,
|
|---|
| 123 | ItemChildRemovedChange,
|
|---|
| 124 | ItemTransformChange,
|
|---|
| 125 | ItemPositionHasChanged,
|
|---|
| 126 | ItemTransformHasChanged,
|
|---|
| 127 | ItemSceneChange,
|
|---|
| 128 | ItemVisibleHasChanged,
|
|---|
| 129 | ItemEnabledHasChanged,
|
|---|
| 130 | ItemSelectedHasChanged,
|
|---|
| 131 | ItemParentHasChanged,
|
|---|
| 132 | ItemSceneHasChanged,
|
|---|
| 133 | ItemCursorChange,
|
|---|
| 134 | ItemCursorHasChanged,
|
|---|
| 135 | ItemToolTipChange,
|
|---|
| 136 | ItemToolTipHasChanged,
|
|---|
| 137 | ItemFlagsChange,
|
|---|
| 138 | ItemFlagsHaveChanged,
|
|---|
| 139 | ItemZValueChange,
|
|---|
| 140 | ItemZValueHasChanged,
|
|---|
| 141 | ItemOpacityChange,
|
|---|
| 142 | ItemOpacityHasChanged,
|
|---|
| 143 | ItemScenePositionHasChanged,
|
|---|
| 144 | ItemRotationChange,
|
|---|
| 145 | ItemRotationHasChanged,
|
|---|
| 146 | ItemScaleChange,
|
|---|
| 147 | ItemScaleHasChanged,
|
|---|
| 148 | ItemTransformOriginPointChange,
|
|---|
| 149 | ItemTransformOriginPointHasChanged
|
|---|
| 150 | };
|
|---|
| 151 |
|
|---|
| 152 | enum CacheMode {
|
|---|
| 153 | NoCache,
|
|---|
| 154 | ItemCoordinateCache,
|
|---|
| 155 | DeviceCoordinateCache
|
|---|
| 156 | };
|
|---|
| 157 |
|
|---|
| 158 | enum PanelModality
|
|---|
| 159 | {
|
|---|
| 160 | NonModal,
|
|---|
| 161 | PanelModal,
|
|---|
| 162 | SceneModal
|
|---|
| 163 | };
|
|---|
| 164 |
|
|---|
| 165 | QGraphicsItem(QGraphicsItem *parent = 0
|
|---|
| 166 | #ifndef Q_QDOC
|
|---|
| 167 | // ### obsolete argument
|
|---|
| 168 | , QGraphicsScene *scene = 0
|
|---|
| 169 | #endif
|
|---|
| 170 | );
|
|---|
| 171 | virtual ~QGraphicsItem();
|
|---|
| 172 |
|
|---|
| 173 | QGraphicsScene *scene() const;
|
|---|
| 174 |
|
|---|
| 175 | QGraphicsItem *parentItem() const;
|
|---|
| 176 | QGraphicsItem *topLevelItem() const;
|
|---|
| 177 | QGraphicsObject *parentObject() const;
|
|---|
| 178 | QGraphicsWidget *parentWidget() const;
|
|---|
| 179 | QGraphicsWidget *topLevelWidget() const;
|
|---|
| 180 | QGraphicsWidget *window() const;
|
|---|
| 181 | QGraphicsItem *panel() const;
|
|---|
| 182 | void setParentItem(QGraphicsItem *parent);
|
|---|
| 183 | QList<QGraphicsItem *> children() const; // ### obsolete
|
|---|
| 184 | QList<QGraphicsItem *> childItems() const;
|
|---|
| 185 | bool isWidget() const;
|
|---|
| 186 | bool isWindow() const;
|
|---|
| 187 | bool isPanel() const;
|
|---|
| 188 |
|
|---|
| 189 | QGraphicsObject *toGraphicsObject();
|
|---|
| 190 | const QGraphicsObject *toGraphicsObject() const;
|
|---|
| 191 |
|
|---|
| 192 | QGraphicsItemGroup *group() const;
|
|---|
| 193 | void setGroup(QGraphicsItemGroup *group);
|
|---|
| 194 |
|
|---|
| 195 | GraphicsItemFlags flags() const;
|
|---|
| 196 | void setFlag(GraphicsItemFlag flag, bool enabled = true);
|
|---|
| 197 | void setFlags(GraphicsItemFlags flags);
|
|---|
| 198 |
|
|---|
| 199 | CacheMode cacheMode() const;
|
|---|
| 200 | void setCacheMode(CacheMode mode, const QSize &cacheSize = QSize());
|
|---|
| 201 |
|
|---|
| 202 | PanelModality panelModality() const;
|
|---|
| 203 | void setPanelModality(PanelModality panelModality);
|
|---|
| 204 | bool isBlockedByModalPanel(QGraphicsItem **blockingPanel = 0) const;
|
|---|
| 205 |
|
|---|
| 206 | #ifndef QT_NO_TOOLTIP
|
|---|
| 207 | QString toolTip() const;
|
|---|
| 208 | void setToolTip(const QString &toolTip);
|
|---|
| 209 | #endif
|
|---|
| 210 |
|
|---|
| 211 | #ifndef QT_NO_CURSOR
|
|---|
| 212 | QCursor cursor() const;
|
|---|
| 213 | void setCursor(const QCursor &cursor);
|
|---|
| 214 | bool hasCursor() const;
|
|---|
| 215 | void unsetCursor();
|
|---|
| 216 | #endif
|
|---|
| 217 |
|
|---|
| 218 | bool isVisible() const;
|
|---|
| 219 | bool isVisibleTo(const QGraphicsItem *parent) const;
|
|---|
| 220 | void setVisible(bool visible);
|
|---|
| 221 | inline void hide() { setVisible(false); }
|
|---|
| 222 | inline void show() { setVisible(true); }
|
|---|
| 223 |
|
|---|
| 224 | bool isEnabled() const;
|
|---|
| 225 | void setEnabled(bool enabled);
|
|---|
| 226 |
|
|---|
| 227 | bool isSelected() const;
|
|---|
| 228 | void setSelected(bool selected);
|
|---|
| 229 |
|
|---|
| 230 | bool acceptDrops() const;
|
|---|
| 231 | void setAcceptDrops(bool on);
|
|---|
| 232 |
|
|---|
| 233 | qreal opacity() const;
|
|---|
| 234 | qreal effectiveOpacity() const;
|
|---|
| 235 | void setOpacity(qreal opacity);
|
|---|
| 236 |
|
|---|
| 237 | #ifndef QT_NO_GRAPHICSEFFECT
|
|---|
| 238 | // Effect
|
|---|
| 239 | QGraphicsEffect *graphicsEffect() const;
|
|---|
| 240 | void setGraphicsEffect(QGraphicsEffect *effect);
|
|---|
| 241 | #endif //QT_NO_GRAPHICSEFFECT
|
|---|
| 242 |
|
|---|
| 243 | Qt::MouseButtons acceptedMouseButtons() const;
|
|---|
| 244 | void setAcceptedMouseButtons(Qt::MouseButtons buttons);
|
|---|
| 245 |
|
|---|
| 246 | bool acceptsHoverEvents() const; // ### obsolete
|
|---|
| 247 | void setAcceptsHoverEvents(bool enabled); // ### obsolete
|
|---|
| 248 | bool acceptHoverEvents() const;
|
|---|
| 249 | void setAcceptHoverEvents(bool enabled);
|
|---|
| 250 | bool acceptTouchEvents() const;
|
|---|
| 251 | void setAcceptTouchEvents(bool enabled);
|
|---|
| 252 |
|
|---|
| 253 | bool filtersChildEvents() const;
|
|---|
| 254 | void setFiltersChildEvents(bool enabled);
|
|---|
| 255 |
|
|---|
| 256 | bool handlesChildEvents() const;
|
|---|
| 257 | void setHandlesChildEvents(bool enabled);
|
|---|
| 258 |
|
|---|
| 259 | bool isActive() const;
|
|---|
| 260 | void setActive(bool active);
|
|---|
| 261 |
|
|---|
| 262 | bool hasFocus() const;
|
|---|
| 263 | void setFocus(Qt::FocusReason focusReason = Qt::OtherFocusReason);
|
|---|
| 264 | void clearFocus();
|
|---|
| 265 |
|
|---|
| 266 | QGraphicsItem *focusProxy() const;
|
|---|
| 267 | void setFocusProxy(QGraphicsItem *item);
|
|---|
| 268 |
|
|---|
| 269 | QGraphicsItem *focusItem() const;
|
|---|
| 270 | QGraphicsItem *focusScopeItem() const;
|
|---|
| 271 |
|
|---|
| 272 | void grabMouse();
|
|---|
| 273 | void ungrabMouse();
|
|---|
| 274 | void grabKeyboard();
|
|---|
| 275 | void ungrabKeyboard();
|
|---|
| 276 |
|
|---|
| 277 | // Positioning in scene coordinates
|
|---|
| 278 | QPointF pos() const;
|
|---|
| 279 | inline qreal x() const { return pos().x(); }
|
|---|
| 280 | void setX(qreal x);
|
|---|
| 281 | inline qreal y() const { return pos().y(); }
|
|---|
| 282 | void setY(qreal y);
|
|---|
| 283 | QPointF scenePos() const;
|
|---|
| 284 | void setPos(const QPointF &pos);
|
|---|
| 285 | inline void setPos(qreal x, qreal y);
|
|---|
| 286 | inline void moveBy(qreal dx, qreal dy) { setPos(pos().x() + dx, pos().y() + dy); }
|
|---|
| 287 |
|
|---|
| 288 | void ensureVisible(const QRectF &rect = QRectF(), int xmargin = 50, int ymargin = 50);
|
|---|
| 289 | inline void ensureVisible(qreal x, qreal y, qreal w, qreal h, int xmargin = 50, int ymargin = 50);
|
|---|
| 290 |
|
|---|
| 291 | // Local transformation
|
|---|
| 292 | QMatrix matrix() const;
|
|---|
| 293 | QMatrix sceneMatrix() const;
|
|---|
| 294 | void setMatrix(const QMatrix &matrix, bool combine = false);
|
|---|
| 295 | void resetMatrix();
|
|---|
| 296 | QTransform transform() const;
|
|---|
| 297 | QTransform sceneTransform() const;
|
|---|
| 298 | QTransform deviceTransform(const QTransform &viewportTransform) const;
|
|---|
| 299 | QTransform itemTransform(const QGraphicsItem *other, bool *ok = 0) const;
|
|---|
| 300 | void setTransform(const QTransform &matrix, bool combine = false);
|
|---|
| 301 | void resetTransform();
|
|---|
| 302 |
|
|---|
| 303 | void rotate(qreal angle); // ### obsolete
|
|---|
| 304 | void scale(qreal sx, qreal sy); // ### obsolete
|
|---|
| 305 | void shear(qreal sh, qreal sv); // ### obsolete
|
|---|
| 306 | void translate(qreal dx, qreal dy); // ### obsolete
|
|---|
| 307 |
|
|---|
| 308 | void setRotation(qreal angle);
|
|---|
| 309 | qreal rotation() const;
|
|---|
| 310 |
|
|---|
| 311 | void setScale(qreal scale);
|
|---|
| 312 | qreal scale() const;
|
|---|
| 313 |
|
|---|
| 314 | QList<QGraphicsTransform *> transformations() const;
|
|---|
| 315 | void setTransformations(const QList<QGraphicsTransform *> &transformations);
|
|---|
| 316 |
|
|---|
| 317 | QPointF transformOriginPoint() const;
|
|---|
| 318 | void setTransformOriginPoint(const QPointF &origin);
|
|---|
| 319 | inline void setTransformOriginPoint(qreal ax, qreal ay)
|
|---|
| 320 | { setTransformOriginPoint(QPointF(ax,ay)); }
|
|---|
| 321 |
|
|---|
| 322 | virtual void advance(int phase);
|
|---|
| 323 |
|
|---|
| 324 | // Stacking order
|
|---|
| 325 | qreal zValue() const;
|
|---|
| 326 | void setZValue(qreal z);
|
|---|
| 327 | void stackBefore(const QGraphicsItem *sibling);
|
|---|
| 328 |
|
|---|
| 329 | // Hit test
|
|---|
| 330 | virtual QRectF boundingRect() const = 0;
|
|---|
| 331 | QRectF childrenBoundingRect() const;
|
|---|
| 332 | QRectF sceneBoundingRect() const;
|
|---|
| 333 | virtual QPainterPath shape() const;
|
|---|
| 334 | bool isClipped() const;
|
|---|
| 335 | QPainterPath clipPath() const;
|
|---|
| 336 | virtual bool contains(const QPointF &point) const;
|
|---|
| 337 | virtual bool collidesWithItem(const QGraphicsItem *other, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const;
|
|---|
| 338 | virtual bool collidesWithPath(const QPainterPath &path, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const;
|
|---|
| 339 | QList<QGraphicsItem *> collidingItems(Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const;
|
|---|
| 340 | bool isObscured() const;
|
|---|
| 341 | bool isObscured(const QRectF &rect) const; // ### Qt 5: merge with isObscured(), add QRectF arg to isObscuredBy()
|
|---|
| 342 | inline bool isObscured(qreal x, qreal y, qreal w, qreal h) const;
|
|---|
| 343 | virtual bool isObscuredBy(const QGraphicsItem *item) const;
|
|---|
| 344 | virtual QPainterPath opaqueArea() const;
|
|---|
| 345 |
|
|---|
| 346 | QRegion boundingRegion(const QTransform &itemToDeviceTransform) const;
|
|---|
| 347 | qreal boundingRegionGranularity() const;
|
|---|
| 348 | void setBoundingRegionGranularity(qreal granularity);
|
|---|
| 349 |
|
|---|
| 350 | // Drawing
|
|---|
| 351 | virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) = 0;
|
|---|
| 352 | void update(const QRectF &rect = QRectF());
|
|---|
| 353 | inline void update(qreal x, qreal y, qreal width, qreal height);
|
|---|
| 354 | void scroll(qreal dx, qreal dy, const QRectF &rect = QRectF());
|
|---|
| 355 |
|
|---|
| 356 | // Coordinate mapping
|
|---|
| 357 | QPointF mapToItem(const QGraphicsItem *item, const QPointF &point) const;
|
|---|
| 358 | QPointF mapToParent(const QPointF &point) const;
|
|---|
| 359 | QPointF mapToScene(const QPointF &point) const;
|
|---|
| 360 | QPolygonF mapToItem(const QGraphicsItem *item, const QRectF &rect) const;
|
|---|
| 361 | QPolygonF mapToParent(const QRectF &rect) const;
|
|---|
| 362 | QPolygonF mapToScene(const QRectF &rect) const;
|
|---|
| 363 | QRectF mapRectToItem(const QGraphicsItem *item, const QRectF &rect) const;
|
|---|
| 364 | QRectF mapRectToParent(const QRectF &rect) const;
|
|---|
| 365 | QRectF mapRectToScene(const QRectF &rect) const;
|
|---|
| 366 | QPolygonF mapToItem(const QGraphicsItem *item, const QPolygonF &polygon) const;
|
|---|
| 367 | QPolygonF mapToParent(const QPolygonF &polygon) const;
|
|---|
| 368 | QPolygonF mapToScene(const QPolygonF &polygon) const;
|
|---|
| 369 | QPainterPath mapToItem(const QGraphicsItem *item, const QPainterPath &path) const;
|
|---|
| 370 | QPainterPath mapToParent(const QPainterPath &path) const;
|
|---|
| 371 | QPainterPath mapToScene(const QPainterPath &path) const;
|
|---|
| 372 | QPointF mapFromItem(const QGraphicsItem *item, const QPointF &point) const;
|
|---|
| 373 | QPointF mapFromParent(const QPointF &point) const;
|
|---|
| 374 | QPointF mapFromScene(const QPointF &point) const;
|
|---|
| 375 | QPolygonF mapFromItem(const QGraphicsItem *item, const QRectF &rect) const;
|
|---|
| 376 | QPolygonF mapFromParent(const QRectF &rect) const;
|
|---|
| 377 | QPolygonF mapFromScene(const QRectF &rect) const;
|
|---|
| 378 | QRectF mapRectFromItem(const QGraphicsItem *item, const QRectF &rect) const;
|
|---|
| 379 | QRectF mapRectFromParent(const QRectF &rect) const;
|
|---|
| 380 | QRectF mapRectFromScene(const QRectF &rect) const;
|
|---|
| 381 | QPolygonF mapFromItem(const QGraphicsItem *item, const QPolygonF &polygon) const;
|
|---|
| 382 | QPolygonF mapFromParent(const QPolygonF &polygon) const;
|
|---|
| 383 | QPolygonF mapFromScene(const QPolygonF &polygon) const;
|
|---|
| 384 | QPainterPath mapFromItem(const QGraphicsItem *item, const QPainterPath &path) const;
|
|---|
| 385 | QPainterPath mapFromParent(const QPainterPath &path) const;
|
|---|
| 386 | QPainterPath mapFromScene(const QPainterPath &path) const;
|
|---|
| 387 |
|
|---|
| 388 | inline QPointF mapToItem(const QGraphicsItem *item, qreal x, qreal y) const;
|
|---|
| 389 | inline QPointF mapToParent(qreal x, qreal y) const;
|
|---|
| 390 | inline QPointF mapToScene(qreal x, qreal y) const;
|
|---|
| 391 | inline QPolygonF mapToItem(const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const;
|
|---|
| 392 | inline QPolygonF mapToParent(qreal x, qreal y, qreal w, qreal h) const;
|
|---|
| 393 | inline QPolygonF mapToScene(qreal x, qreal y, qreal w, qreal h) const;
|
|---|
| 394 | inline QRectF mapRectToItem(const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const;
|
|---|
| 395 | inline QRectF mapRectToParent(qreal x, qreal y, qreal w, qreal h) const;
|
|---|
| 396 | inline QRectF mapRectToScene(qreal x, qreal y, qreal w, qreal h) const;
|
|---|
| 397 | inline QPointF mapFromItem(const QGraphicsItem *item, qreal x, qreal y) const;
|
|---|
| 398 | inline QPointF mapFromParent(qreal x, qreal y) const;
|
|---|
| 399 | inline QPointF mapFromScene(qreal x, qreal y) const;
|
|---|
| 400 | inline QPolygonF mapFromItem(const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const;
|
|---|
| 401 | inline QPolygonF mapFromParent(qreal x, qreal y, qreal w, qreal h) const;
|
|---|
| 402 | inline QPolygonF mapFromScene(qreal x, qreal y, qreal w, qreal h) const;
|
|---|
| 403 | inline QRectF mapRectFromItem(const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const;
|
|---|
| 404 | inline QRectF mapRectFromParent(qreal x, qreal y, qreal w, qreal h) const;
|
|---|
| 405 | inline QRectF mapRectFromScene(qreal x, qreal y, qreal w, qreal h) const;
|
|---|
| 406 |
|
|---|
| 407 | bool isAncestorOf(const QGraphicsItem *child) const;
|
|---|
| 408 | QGraphicsItem *commonAncestorItem(const QGraphicsItem *other) const;
|
|---|
| 409 | bool isUnderMouse() const;
|
|---|
| 410 |
|
|---|
| 411 | // Custom data
|
|---|
| 412 | QVariant data(int key) const;
|
|---|
| 413 | void setData(int key, const QVariant &value);
|
|---|
| 414 |
|
|---|
| 415 | Qt::InputMethodHints inputMethodHints() const;
|
|---|
| 416 | void setInputMethodHints(Qt::InputMethodHints hints);
|
|---|
| 417 |
|
|---|
| 418 | enum {
|
|---|
| 419 | Type = 1,
|
|---|
| 420 | UserType = 65536
|
|---|
| 421 | };
|
|---|
| 422 | virtual int type() const;
|
|---|
| 423 |
|
|---|
| 424 | void installSceneEventFilter(QGraphicsItem *filterItem);
|
|---|
| 425 | void removeSceneEventFilter(QGraphicsItem *filterItem);
|
|---|
| 426 |
|
|---|
| 427 | protected:
|
|---|
| 428 | void updateMicroFocus();
|
|---|
| 429 | virtual bool sceneEventFilter(QGraphicsItem *watched, QEvent *event);
|
|---|
| 430 | virtual bool sceneEvent(QEvent *event);
|
|---|
| 431 | virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
|
|---|
| 432 | virtual void dragEnterEvent(QGraphicsSceneDragDropEvent *event);
|
|---|
| 433 | virtual void dragLeaveEvent(QGraphicsSceneDragDropEvent *event);
|
|---|
| 434 | virtual void dragMoveEvent(QGraphicsSceneDragDropEvent *event);
|
|---|
| 435 | virtual void dropEvent(QGraphicsSceneDragDropEvent *event);
|
|---|
| 436 | virtual void focusInEvent(QFocusEvent *event);
|
|---|
| 437 | virtual void focusOutEvent(QFocusEvent *event);
|
|---|
| 438 | virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
|---|
| 439 | virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
|
|---|
| 440 | virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
|
|---|
| 441 | virtual void keyPressEvent(QKeyEvent *event);
|
|---|
| 442 | virtual void keyReleaseEvent(QKeyEvent *event);
|
|---|
| 443 | virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
|---|
| 444 | virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
|---|
| 445 | virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
|---|
| 446 | virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
|
|---|
| 447 | virtual void wheelEvent(QGraphicsSceneWheelEvent *event);
|
|---|
| 448 | virtual void inputMethodEvent(QInputMethodEvent *event);
|
|---|
| 449 | virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
|
|---|
| 450 |
|
|---|
| 451 | virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value);
|
|---|
| 452 |
|
|---|
| 453 | enum Extension {
|
|---|
| 454 | UserExtension = 0x80000000
|
|---|
| 455 | };
|
|---|
| 456 | virtual bool supportsExtension(Extension extension) const;
|
|---|
| 457 | virtual void setExtension(Extension extension, const QVariant &variant);
|
|---|
| 458 | virtual QVariant extension(const QVariant &variant) const;
|
|---|
| 459 |
|
|---|
| 460 | protected:
|
|---|
| 461 | QGraphicsItem(QGraphicsItemPrivate &dd,
|
|---|
| 462 | QGraphicsItem *parent, QGraphicsScene *scene);
|
|---|
| 463 | QScopedPointer<QGraphicsItemPrivate> d_ptr;
|
|---|
| 464 |
|
|---|
| 465 | void addToIndex();
|
|---|
| 466 | void removeFromIndex();
|
|---|
| 467 | void prepareGeometryChange();
|
|---|
| 468 |
|
|---|
| 469 | private:
|
|---|
| 470 | Q_DISABLE_COPY(QGraphicsItem)
|
|---|
| 471 | Q_DECLARE_PRIVATE(QGraphicsItem)
|
|---|
| 472 | friend class QGraphicsItemGroup;
|
|---|
| 473 | friend class QGraphicsScene;
|
|---|
| 474 | friend class QGraphicsScenePrivate;
|
|---|
| 475 | friend class QGraphicsSceneFindItemBspTreeVisitor;
|
|---|
| 476 | friend class QGraphicsSceneBspTree;
|
|---|
| 477 | friend class QGraphicsView;
|
|---|
| 478 | friend class QGraphicsViewPrivate;
|
|---|
| 479 | friend class QGraphicsObject;
|
|---|
| 480 | friend class QGraphicsWidget;
|
|---|
| 481 | friend class QGraphicsWidgetPrivate;
|
|---|
| 482 | friend class QGraphicsProxyWidgetPrivate;
|
|---|
| 483 | friend class QGraphicsSceneIndex;
|
|---|
| 484 | friend class QGraphicsSceneIndexPrivate;
|
|---|
| 485 | friend class QGraphicsSceneBspTreeIndex;
|
|---|
| 486 | friend class QGraphicsSceneBspTreeIndexPrivate;
|
|---|
| 487 | friend class QGraphicsItemEffectSourcePrivate;
|
|---|
| 488 | friend class QGraphicsTransformPrivate;
|
|---|
| 489 | #ifndef QT_NO_GESTURES
|
|---|
| 490 | friend class QGestureManager;
|
|---|
| 491 | #endif
|
|---|
| 492 | friend class ::tst_QGraphicsItem;
|
|---|
| 493 | friend bool qt_closestLeaf(const QGraphicsItem *, const QGraphicsItem *);
|
|---|
| 494 | friend bool qt_closestItemFirst(const QGraphicsItem *, const QGraphicsItem *);
|
|---|
| 495 | };
|
|---|
| 496 |
|
|---|
| 497 | Q_DECLARE_OPERATORS_FOR_FLAGS(QGraphicsItem::GraphicsItemFlags)
|
|---|
| 498 | Q_DECLARE_INTERFACE(QGraphicsItem, "com.trolltech.Qt.QGraphicsItem")
|
|---|
| 499 |
|
|---|
| 500 | inline void QGraphicsItem::setPos(qreal ax, qreal ay)
|
|---|
| 501 | { setPos(QPointF(ax, ay)); }
|
|---|
| 502 | inline void QGraphicsItem::ensureVisible(qreal ax, qreal ay, qreal w, qreal h, int xmargin, int ymargin)
|
|---|
| 503 | { ensureVisible(QRectF(ax, ay, w, h), xmargin, ymargin); }
|
|---|
| 504 | inline void QGraphicsItem::update(qreal ax, qreal ay, qreal width, qreal height)
|
|---|
| 505 | { update(QRectF(ax, ay, width, height)); }
|
|---|
| 506 | inline bool QGraphicsItem::isObscured(qreal ax, qreal ay, qreal w, qreal h) const
|
|---|
| 507 | { return isObscured(QRectF(ax, ay, w, h)); }
|
|---|
| 508 | inline QPointF QGraphicsItem::mapToItem(const QGraphicsItem *item, qreal ax, qreal ay) const
|
|---|
| 509 | { return mapToItem(item, QPointF(ax, ay)); }
|
|---|
| 510 | inline QPointF QGraphicsItem::mapToParent(qreal ax, qreal ay) const
|
|---|
| 511 | { return mapToParent(QPointF(ax, ay)); }
|
|---|
| 512 | inline QPointF QGraphicsItem::mapToScene(qreal ax, qreal ay) const
|
|---|
| 513 | { return mapToScene(QPointF(ax, ay)); }
|
|---|
| 514 | inline QPointF QGraphicsItem::mapFromItem(const QGraphicsItem *item, qreal ax, qreal ay) const
|
|---|
| 515 | { return mapFromItem(item, QPointF(ax, ay)); }
|
|---|
| 516 | inline QPointF QGraphicsItem::mapFromParent(qreal ax, qreal ay) const
|
|---|
| 517 | { return mapFromParent(QPointF(ax, ay)); }
|
|---|
| 518 | inline QPointF QGraphicsItem::mapFromScene(qreal ax, qreal ay) const
|
|---|
| 519 | { return mapFromScene(QPointF(ax, ay)); }
|
|---|
| 520 | inline QPolygonF QGraphicsItem::mapToItem(const QGraphicsItem *item, qreal ax, qreal ay, qreal w, qreal h) const
|
|---|
| 521 | { return mapToItem(item, QRectF(ax, ay, w, h)); }
|
|---|
| 522 | inline QPolygonF QGraphicsItem::mapToParent(qreal ax, qreal ay, qreal w, qreal h) const
|
|---|
| 523 | { return mapToParent(QRectF(ax, ay, w, h)); }
|
|---|
| 524 | inline QPolygonF QGraphicsItem::mapToScene(qreal ax, qreal ay, qreal w, qreal h) const
|
|---|
| 525 | { return mapToScene(QRectF(ax, ay, w, h)); }
|
|---|
| 526 | inline QRectF QGraphicsItem::mapRectToItem(const QGraphicsItem *item, qreal ax, qreal ay, qreal w, qreal h) const
|
|---|
| 527 | { return mapRectToItem(item, QRectF(ax, ay, w, h)); }
|
|---|
| 528 | inline QRectF QGraphicsItem::mapRectToParent(qreal ax, qreal ay, qreal w, qreal h) const
|
|---|
| 529 | { return mapRectToParent(QRectF(ax, ay, w, h)); }
|
|---|
| 530 | inline QRectF QGraphicsItem::mapRectToScene(qreal ax, qreal ay, qreal w, qreal h) const
|
|---|
| 531 | { return mapRectToScene(QRectF(ax, ay, w, h)); }
|
|---|
| 532 | inline QPolygonF QGraphicsItem::mapFromItem(const QGraphicsItem *item, qreal ax, qreal ay, qreal w, qreal h) const
|
|---|
| 533 | { return mapFromItem(item, QRectF(ax, ay, w, h)); }
|
|---|
| 534 | inline QPolygonF QGraphicsItem::mapFromParent(qreal ax, qreal ay, qreal w, qreal h) const
|
|---|
| 535 | { return mapFromParent(QRectF(ax, ay, w, h)); }
|
|---|
| 536 | inline QPolygonF QGraphicsItem::mapFromScene(qreal ax, qreal ay, qreal w, qreal h) const
|
|---|
| 537 | { return mapFromScene(QRectF(ax, ay, w, h)); }
|
|---|
| 538 | inline QRectF QGraphicsItem::mapRectFromItem(const QGraphicsItem *item, qreal ax, qreal ay, qreal w, qreal h) const
|
|---|
| 539 | { return mapRectFromItem(item, QRectF(ax, ay, w, h)); }
|
|---|
| 540 | inline QRectF QGraphicsItem::mapRectFromParent(qreal ax, qreal ay, qreal w, qreal h) const
|
|---|
| 541 | { return mapRectFromParent(QRectF(ax, ay, w, h)); }
|
|---|
| 542 | inline QRectF QGraphicsItem::mapRectFromScene(qreal ax, qreal ay, qreal w, qreal h) const
|
|---|
| 543 | { return mapRectFromScene(QRectF(ax, ay, w, h)); }
|
|---|
| 544 |
|
|---|
| 545 |
|
|---|
| 546 | class Q_GUI_EXPORT QGraphicsObject : public QObject, public QGraphicsItem
|
|---|
| 547 | {
|
|---|
| 548 | Q_OBJECT
|
|---|
| 549 | Q_PROPERTY(QGraphicsObject * parent READ parentObject WRITE setParentItem NOTIFY parentChanged DESIGNABLE false)
|
|---|
| 550 | Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity NOTIFY opacityChanged FINAL)
|
|---|
| 551 | Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged)
|
|---|
| 552 | Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged FINAL)
|
|---|
| 553 | Q_PROPERTY(QPointF pos READ pos WRITE setPos FINAL)
|
|---|
| 554 | Q_PROPERTY(qreal x READ x WRITE setX NOTIFY xChanged FINAL)
|
|---|
| 555 | Q_PROPERTY(qreal y READ y WRITE setY NOTIFY yChanged FINAL)
|
|---|
| 556 | Q_PROPERTY(qreal z READ zValue WRITE setZValue NOTIFY zChanged FINAL)
|
|---|
| 557 | Q_PROPERTY(qreal rotation READ rotation WRITE setRotation NOTIFY rotationChanged)
|
|---|
| 558 | Q_PROPERTY(qreal scale READ scale WRITE setScale NOTIFY scaleChanged)
|
|---|
| 559 | Q_PROPERTY(QPointF transformOriginPoint READ transformOriginPoint WRITE setTransformOriginPoint)
|
|---|
|
|---|