| 1 | /**************************************************************************** | 
|---|
| 2 | ** | 
|---|
| 3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). | 
|---|
| 4 | ** Contact: Qt Software Information (qt-info@nokia.com) | 
|---|
| 5 | ** | 
|---|
| 6 | ** This file is part of the QtGui module of the Qt Toolkit. | 
|---|
| 7 | ** | 
|---|
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | 
|---|
| 9 | ** Commercial Usage | 
|---|
| 10 | ** Licensees holding valid Qt Commercial licenses may use this file in | 
|---|
| 11 | ** accordance with the Qt Commercial License Agreement provided with the | 
|---|
| 12 | ** Software or, alternatively, in accordance with the terms contained in | 
|---|
| 13 | ** a written agreement between you and Nokia. | 
|---|
| 14 | ** | 
|---|
| 15 | ** GNU Lesser General Public License Usage | 
|---|
| 16 | ** Alternatively, this file may be used under the terms of the GNU Lesser | 
|---|
| 17 | ** General Public License version 2.1 as published by the Free Software | 
|---|
| 18 | ** Foundation and appearing in the file LICENSE.LGPL included in the | 
|---|
| 19 | ** packaging of this file.  Please review the following information to | 
|---|
| 20 | ** ensure the GNU Lesser General Public License version 2.1 requirements | 
|---|
| 21 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | 
|---|
| 22 | ** | 
|---|
| 23 | ** In addition, as a special exception, Nokia gives you certain | 
|---|
| 24 | ** additional rights. These rights are described in the Nokia Qt LGPL | 
|---|
| 25 | ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this | 
|---|
| 26 | ** 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 are unsure which license is appropriate for your use, please | 
|---|
| 37 | ** contact the sales department at qt-sales@nokia.com. | 
|---|
| 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 <QtGui/qpainterpath.h> | 
|---|
| 50 | #include <QtGui/qpixmap.h> | 
|---|
| 51 |  | 
|---|
| 52 | class tst_QGraphicsItem; | 
|---|
| 53 |  | 
|---|
| 54 | QT_BEGIN_HEADER | 
|---|
| 55 |  | 
|---|
| 56 | QT_BEGIN_NAMESPACE | 
|---|
| 57 |  | 
|---|
| 58 | QT_MODULE(Gui) | 
|---|
| 59 |  | 
|---|
| 60 | #if !defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW | 
|---|
| 61 |  | 
|---|
| 62 | class QBrush; | 
|---|
| 63 | class QCursor; | 
|---|
| 64 | class QFocusEvent; | 
|---|
| 65 | class QGraphicsItemGroup; | 
|---|
| 66 | class QGraphicsSceneContextMenuEvent; | 
|---|
| 67 | class QGraphicsSceneDragDropEvent; | 
|---|
| 68 | class QGraphicsSceneEvent; | 
|---|
| 69 | class QGraphicsSceneHoverEvent; | 
|---|
| 70 | class QGraphicsSceneMouseEvent; | 
|---|
| 71 | class QGraphicsSceneWheelEvent; | 
|---|
| 72 | class QGraphicsScene; | 
|---|
| 73 | class QGraphicsWidget; | 
|---|
| 74 | class QInputMethodEvent; | 
|---|
| 75 | class QKeyEvent; | 
|---|
| 76 | class QMatrix; | 
|---|
| 77 | class QMenu; | 
|---|
| 78 | class QPainter; | 
|---|
| 79 | class QPen; | 
|---|
| 80 | class QPointF; | 
|---|
| 81 | class QRectF; | 
|---|
| 82 | class QStyleOptionGraphicsItem; | 
|---|
| 83 |  | 
|---|
| 84 | class QGraphicsItemPrivate; | 
|---|
| 85 | class Q_GUI_EXPORT QGraphicsItem | 
|---|
| 86 | { | 
|---|
| 87 | public: | 
|---|
| 88 | enum GraphicsItemFlag { | 
|---|
| 89 | ItemIsMovable = 0x1, | 
|---|
| 90 | ItemIsSelectable = 0x2, | 
|---|
| 91 | ItemIsFocusable = 0x4, | 
|---|
| 92 | ItemClipsToShape = 0x8, | 
|---|
| 93 | ItemClipsChildrenToShape = 0x10, | 
|---|
| 94 | ItemIgnoresTransformations = 0x20, | 
|---|
| 95 | ItemIgnoresParentOpacity = 0x40, | 
|---|
| 96 | ItemDoesntPropagateOpacityToChildren = 0x80, | 
|---|
| 97 | ItemStacksBehindParent = 0x100 | 
|---|
| 98 | }; | 
|---|
| 99 | Q_DECLARE_FLAGS(GraphicsItemFlags, GraphicsItemFlag) | 
|---|
| 100 |  | 
|---|
| 101 | enum GraphicsItemChange { | 
|---|
| 102 | ItemPositionChange, | 
|---|
| 103 | ItemMatrixChange, | 
|---|
| 104 | ItemVisibleChange, | 
|---|
| 105 | ItemEnabledChange, | 
|---|
| 106 | ItemSelectedChange, | 
|---|
| 107 | ItemParentChange, | 
|---|
| 108 | ItemChildAddedChange, | 
|---|
| 109 | ItemChildRemovedChange, | 
|---|
| 110 | ItemTransformChange, | 
|---|
| 111 | ItemPositionHasChanged, | 
|---|
| 112 | ItemTransformHasChanged, | 
|---|
| 113 | ItemSceneChange, | 
|---|
| 114 | ItemVisibleHasChanged, | 
|---|
| 115 | ItemEnabledHasChanged, | 
|---|
| 116 | ItemSelectedHasChanged, | 
|---|
| 117 | ItemParentHasChanged, | 
|---|
| 118 | ItemSceneHasChanged, | 
|---|
| 119 | ItemCursorChange, | 
|---|
| 120 | ItemCursorHasChanged, | 
|---|
| 121 | ItemToolTipChange, | 
|---|
| 122 | ItemToolTipHasChanged, | 
|---|
| 123 | ItemFlagsChange, | 
|---|
| 124 | ItemFlagsHaveChanged, | 
|---|
| 125 | ItemZValueChange, | 
|---|
| 126 | ItemZValueHasChanged, | 
|---|
| 127 | ItemOpacityChange, | 
|---|
| 128 | ItemOpacityHasChanged | 
|---|
| 129 | }; | 
|---|
| 130 |  | 
|---|
| 131 | enum CacheMode { | 
|---|
| 132 | NoCache, | 
|---|
| 133 | ItemCoordinateCache, | 
|---|
| 134 | DeviceCoordinateCache | 
|---|
| 135 | }; | 
|---|
| 136 |  | 
|---|
| 137 | QGraphicsItem(QGraphicsItem *parent = 0 | 
|---|
| 138 | #ifndef Q_QDOC | 
|---|
| 139 | // obsolete argument | 
|---|
| 140 | , QGraphicsScene *scene = 0 | 
|---|
| 141 | #endif | 
|---|
| 142 | ); | 
|---|
| 143 | virtual ~QGraphicsItem(); | 
|---|
| 144 |  | 
|---|
| 145 | QGraphicsScene *scene() const; | 
|---|
| 146 |  | 
|---|
| 147 | QGraphicsItem *parentItem() const; | 
|---|
| 148 | QGraphicsItem *topLevelItem() const; | 
|---|
| 149 | QGraphicsWidget *parentWidget() const; | 
|---|
| 150 | QGraphicsWidget *topLevelWidget() const; | 
|---|
| 151 | QGraphicsWidget *window() const; | 
|---|
| 152 | void setParentItem(QGraphicsItem *parent); | 
|---|
| 153 | QList<QGraphicsItem *> children() const; // ### obsolete | 
|---|
| 154 | QList<QGraphicsItem *> childItems() const; | 
|---|
| 155 | bool isWidget() const; | 
|---|
| 156 | bool isWindow() const; | 
|---|
| 157 |  | 
|---|
| 158 | QGraphicsItemGroup *group() const; | 
|---|
| 159 | void setGroup(QGraphicsItemGroup *group); | 
|---|
| 160 |  | 
|---|
| 161 | GraphicsItemFlags flags() const; | 
|---|
| 162 | void setFlag(GraphicsItemFlag flag, bool enabled = true); | 
|---|
| 163 | void setFlags(GraphicsItemFlags flags); | 
|---|
| 164 |  | 
|---|
| 165 | CacheMode cacheMode() const; | 
|---|
| 166 | void setCacheMode(CacheMode mode, const QSize &cacheSize = QSize()); | 
|---|
| 167 |  | 
|---|
| 168 | #ifndef QT_NO_TOOLTIP | 
|---|
| 169 | QString toolTip() const; | 
|---|
| 170 | void setToolTip(const QString &toolTip); | 
|---|
| 171 | #endif | 
|---|
| 172 |  | 
|---|
| 173 | #ifndef QT_NO_CURSOR | 
|---|
| 174 | QCursor cursor() const; | 
|---|
| 175 | void setCursor(const QCursor &cursor); | 
|---|
| 176 | bool hasCursor() const; | 
|---|
| 177 | void unsetCursor(); | 
|---|
| 178 | #endif | 
|---|
| 179 |  | 
|---|
| 180 | bool isVisible() const; | 
|---|
| 181 | bool isVisibleTo(const QGraphicsItem *parent) const; | 
|---|
| 182 | void setVisible(bool visible); | 
|---|
| 183 | inline void hide() { setVisible(false); } | 
|---|
| 184 | inline void show() { setVisible(true); } | 
|---|
| 185 |  | 
|---|
| 186 | bool isEnabled() const; | 
|---|
| 187 | void setEnabled(bool enabled); | 
|---|
| 188 |  | 
|---|
| 189 | bool isSelected() const; | 
|---|
| 190 | void setSelected(bool selected); | 
|---|
| 191 |  | 
|---|
| 192 | bool acceptDrops() const; | 
|---|
| 193 | void setAcceptDrops(bool on); | 
|---|
| 194 |  | 
|---|
| 195 | qreal opacity() const; | 
|---|
| 196 | qreal effectiveOpacity() const; | 
|---|
| 197 | void setOpacity(qreal opacity); | 
|---|
| 198 |  | 
|---|
| 199 | Qt::MouseButtons acceptedMouseButtons() const; | 
|---|
| 200 | void setAcceptedMouseButtons(Qt::MouseButtons buttons); | 
|---|
| 201 |  | 
|---|
| 202 | bool acceptsHoverEvents() const; // obsolete | 
|---|
| 203 | void setAcceptsHoverEvents(bool enabled); // obsolete | 
|---|
| 204 | bool acceptHoverEvents() const; | 
|---|
| 205 | void setAcceptHoverEvents(bool enabled); | 
|---|
| 206 |  | 
|---|
| 207 | bool handlesChildEvents() const; | 
|---|
| 208 | void setHandlesChildEvents(bool enabled); | 
|---|
| 209 |  | 
|---|
| 210 | bool hasFocus() const; | 
|---|
| 211 | void setFocus(Qt::FocusReason focusReason = Qt::OtherFocusReason); | 
|---|
| 212 | void clearFocus(); | 
|---|
| 213 |  | 
|---|
| 214 | void grabMouse(); | 
|---|
| 215 | void ungrabMouse(); | 
|---|
| 216 | void grabKeyboard(); | 
|---|
| 217 | void ungrabKeyboard(); | 
|---|
| 218 |  | 
|---|
| 219 | // Positioning in scene coordinates | 
|---|
| 220 | QPointF pos() const; | 
|---|
| 221 | inline qreal x() const { return pos().x(); } | 
|---|
| 222 | inline qreal y() const { return pos().y(); } | 
|---|
| 223 | QPointF scenePos() const; | 
|---|
| 224 | void setPos(const QPointF &pos); | 
|---|
| 225 | inline void setPos(qreal x, qreal y); | 
|---|
| 226 | inline void moveBy(qreal dx, qreal dy) { setPos(pos().x() + dx, pos().y() + dy); } | 
|---|
| 227 |  | 
|---|
| 228 | void ensureVisible(const QRectF &rect = QRectF(), int xmargin = 50, int ymargin = 50); | 
|---|
| 229 | inline void ensureVisible(qreal x, qreal y, qreal w, qreal h, int xmargin = 50, int ymargin = 50); | 
|---|
| 230 |  | 
|---|
| 231 | // Local transformation | 
|---|
| 232 | QMatrix matrix() const; | 
|---|
| 233 | QMatrix sceneMatrix() const; | 
|---|
| 234 | void setMatrix(const QMatrix &matrix, bool combine = false); | 
|---|
| 235 | void resetMatrix(); | 
|---|
| 236 | QTransform transform() const; | 
|---|
| 237 | QTransform sceneTransform() const; | 
|---|
| 238 | QTransform deviceTransform(const QTransform &viewportTransform) const; | 
|---|
| 239 | QTransform itemTransform(const QGraphicsItem *other, bool *ok = 0) const; | 
|---|
| 240 | void setTransform(const QTransform &matrix, bool combine = false); | 
|---|
| 241 | void resetTransform(); | 
|---|
| 242 |  | 
|---|
| 243 | void rotate(qreal angle); | 
|---|
| 244 | void scale(qreal sx, qreal sy); | 
|---|
| 245 | void shear(qreal sh, qreal sv); | 
|---|
| 246 | void translate(qreal dx, qreal dy); | 
|---|
| 247 | virtual void advance(int phase); | 
|---|
| 248 |  | 
|---|
| 249 | // Stacking order | 
|---|
| 250 | qreal zValue() const; | 
|---|
| 251 | void setZValue(qreal z); | 
|---|
| 252 |  | 
|---|
| 253 | // Hit test | 
|---|
| 254 | virtual QRectF boundingRect() const = 0; | 
|---|
| 255 | QRectF childrenBoundingRect() const; | 
|---|
| 256 | QRectF sceneBoundingRect() const; | 
|---|
| 257 | virtual QPainterPath shape() const; | 
|---|
| 258 | bool isClipped() const; | 
|---|
| 259 | QPainterPath clipPath() const; | 
|---|
| 260 | virtual bool contains(const QPointF &point) const; | 
|---|
| 261 | virtual bool collidesWithItem(const QGraphicsItem *other, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const; | 
|---|
| 262 | virtual bool collidesWithPath(const QPainterPath &path, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const; | 
|---|
| 263 | QList<QGraphicsItem *> collidingItems(Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const; | 
|---|
| 264 | bool isObscured() const; | 
|---|
| 265 | bool isObscured(const QRectF &rect) const; // ### Qt 5: merge with isObscured(), add QRectF arg to isObscuredBy() | 
|---|
| 266 | inline bool isObscured(qreal x, qreal y, qreal w, qreal h) const; | 
|---|
| 267 | virtual bool isObscuredBy(const QGraphicsItem *item) const; | 
|---|
| 268 | virtual QPainterPath opaqueArea() const; | 
|---|
| 269 |  | 
|---|
| 270 | QRegion boundingRegion(const QTransform &itemToDeviceTransform) const; | 
|---|
| 271 | qreal boundingRegionGranularity() const; | 
|---|
| 272 | void setBoundingRegionGranularity(qreal granularity); | 
|---|
| 273 |  | 
|---|
| 274 | // Drawing | 
|---|
| 275 | virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) = 0; | 
|---|
| 276 | void update(const QRectF &rect = QRectF()); | 
|---|
| 277 | inline void update(qreal x, qreal y, qreal width, qreal height); | 
|---|
| 278 | void scroll(qreal dx, qreal dy, const QRectF &rect = QRectF()); | 
|---|
| 279 |  | 
|---|
| 280 | // Coordinate mapping | 
|---|
| 281 | QPointF mapToItem(const QGraphicsItem *item, const QPointF &point) const; | 
|---|
| 282 | QPointF mapToParent(const QPointF &point) const; | 
|---|
| 283 | QPointF mapToScene(const QPointF &point) const; | 
|---|
| 284 | QPolygonF mapToItem(const QGraphicsItem *item, const QRectF &rect) const; | 
|---|
| 285 | QPolygonF mapToParent(const QRectF &rect) const; | 
|---|
| 286 | QPolygonF mapToScene(const QRectF &rect) const; | 
|---|
| 287 | QRectF mapRectToItem(const QGraphicsItem *item, const QRectF &rect) const; | 
|---|
| 288 | QRectF mapRectToParent(const QRectF &rect) const; | 
|---|
| 289 | QRectF mapRectToScene(const QRectF &rect) const; | 
|---|
| 290 | QPolygonF mapToItem(const QGraphicsItem *item, const QPolygonF &polygon) const; | 
|---|
| 291 | QPolygonF mapToParent(const QPolygonF &polygon) const; | 
|---|
| 292 | QPolygonF mapToScene(const QPolygonF &polygon) const; | 
|---|
| 293 | QPainterPath mapToItem(const QGraphicsItem *item, const QPainterPath &path) const; | 
|---|
| 294 | QPainterPath mapToParent(const QPainterPath &path) const; | 
|---|
| 295 | QPainterPath mapToScene(const QPainterPath &path) const; | 
|---|
| 296 | QPointF mapFromItem(const QGraphicsItem *item, const QPointF &point) const; | 
|---|
| 297 | QPointF mapFromParent(const QPointF &point) const; | 
|---|
| 298 | QPointF mapFromScene(const QPointF &point) const; | 
|---|
| 299 | QPolygonF mapFromItem(const QGraphicsItem *item, const QRectF &rect) const; | 
|---|
| 300 | QPolygonF mapFromParent(const QRectF &rect) const; | 
|---|
| 301 | QPolygonF mapFromScene(const QRectF &rect) const; | 
|---|
| 302 | QRectF mapRectFromItem(const QGraphicsItem *item, const QRectF &rect) const; | 
|---|
| 303 | QRectF mapRectFromParent(const QRectF &rect) const; | 
|---|
| 304 | QRectF mapRectFromScene(const QRectF &rect) const; | 
|---|
| 305 | QPolygonF mapFromItem(const QGraphicsItem *item, const QPolygonF &polygon) const; | 
|---|
| 306 | QPolygonF mapFromParent(const QPolygonF &polygon) const; | 
|---|
| 307 | QPolygonF mapFromScene(const QPolygonF &polygon) const; | 
|---|
| 308 | QPainterPath mapFromItem(const QGraphicsItem *item, const QPainterPath &path) const; | 
|---|
| 309 | QPainterPath mapFromParent(const QPainterPath &path) const; | 
|---|
| 310 | QPainterPath mapFromScene(const QPainterPath &path) const; | 
|---|
| 311 |  | 
|---|
| 312 | inline QPointF mapToItem(const QGraphicsItem *item, qreal x, qreal y) const; | 
|---|
| 313 | inline QPointF mapToParent(qreal x, qreal y) const; | 
|---|
| 314 | inline QPointF mapToScene(qreal x, qreal y) const; | 
|---|
| 315 | inline QPolygonF mapToItem(const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const; | 
|---|
| 316 | inline QPolygonF mapToParent(qreal x, qreal y, qreal w, qreal h) const; | 
|---|
| 317 | inline QPolygonF mapToScene(qreal x, qreal y, qreal w, qreal h) const; | 
|---|
| 318 | inline QRectF mapRectToItem(const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const; | 
|---|
| 319 | inline QRectF mapRectToParent(qreal x, qreal y, qreal w, qreal h) const; | 
|---|
| 320 | inline QRectF mapRectToScene(qreal x, qreal y, qreal w, qreal h) const; | 
|---|
| 321 | inline QPointF mapFromItem(const QGraphicsItem *item, qreal x, qreal y) const; | 
|---|
| 322 | inline QPointF mapFromParent(qreal x, qreal y) const; | 
|---|
| 323 | inline QPointF mapFromScene(qreal x, qreal y) const; | 
|---|
| 324 | inline QPolygonF mapFromItem(const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const; | 
|---|
| 325 | inline QPolygonF mapFromParent(qreal x, qreal y, qreal w, qreal h) const; | 
|---|
| 326 | inline QPolygonF mapFromScene(qreal x, qreal y, qreal w, qreal h) const; | 
|---|
| 327 | inline QRectF mapRectFromItem(const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const; | 
|---|
| 328 | inline QRectF mapRectFromParent(qreal x, qreal y, qreal w, qreal h) const; | 
|---|
| 329 | inline QRectF mapRectFromScene(qreal x, qreal y, qreal w, qreal h) const; | 
|---|
| 330 |  | 
|---|
| 331 | bool isAncestorOf(const QGraphicsItem *child) const; | 
|---|
| 332 | QGraphicsItem *commonAncestorItem(const QGraphicsItem *other) const; | 
|---|
| 333 | bool isUnderMouse() const; | 
|---|
| 334 |  | 
|---|
| 335 | // Custom data | 
|---|
| 336 | QVariant data(int key) const; | 
|---|
| 337 | void setData(int key, const QVariant &value); | 
|---|
| 338 |  | 
|---|
| 339 | enum { | 
|---|
| 340 | Type = 1, | 
|---|
| 341 | UserType = 65536 | 
|---|
| 342 | }; | 
|---|
| 343 | virtual int type() const; | 
|---|
| 344 |  | 
|---|
| 345 | void installSceneEventFilter(QGraphicsItem *filterItem); | 
|---|
| 346 | void removeSceneEventFilter(QGraphicsItem *filterItem); | 
|---|
| 347 |  | 
|---|
| 348 | protected: | 
|---|
| 349 | virtual bool sceneEventFilter(QGraphicsItem *watched, QEvent *event); | 
|---|
| 350 | virtual bool sceneEvent(QEvent *event); | 
|---|
| 351 | virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent *event); | 
|---|
| 352 | virtual void dragEnterEvent(QGraphicsSceneDragDropEvent *event); | 
|---|
| 353 | virtual void dragLeaveEvent(QGraphicsSceneDragDropEvent *event); | 
|---|
| 354 | virtual void dragMoveEvent(QGraphicsSceneDragDropEvent *event); | 
|---|
| 355 | virtual void dropEvent(QGraphicsSceneDragDropEvent *event); | 
|---|
| 356 | virtual void focusInEvent(QFocusEvent *event); | 
|---|
| 357 | virtual void focusOutEvent(QFocusEvent *event); | 
|---|
| 358 | virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event); | 
|---|
| 359 | virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *event); | 
|---|
| 360 | virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); | 
|---|
| 361 | virtual void keyPressEvent(QKeyEvent *event); | 
|---|
| 362 | virtual void keyReleaseEvent(QKeyEvent *event); | 
|---|
| 363 | virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); | 
|---|
| 364 | virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event); | 
|---|
| 365 | virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); | 
|---|
| 366 | virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event); | 
|---|
| 367 | virtual void wheelEvent(QGraphicsSceneWheelEvent *event); | 
|---|
| 368 | virtual void inputMethodEvent(QInputMethodEvent *event); | 
|---|
| 369 | virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const; | 
|---|
| 370 |  | 
|---|
| 371 | virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value); | 
|---|
| 372 |  | 
|---|
| 373 | enum Extension { | 
|---|
| 374 | UserExtension = 0x80000000 | 
|---|
| 375 | }; | 
|---|
| 376 | virtual bool supportsExtension(Extension extension) const; | 
|---|
| 377 | virtual void setExtension(Extension extension, const QVariant &variant); | 
|---|
| 378 | virtual QVariant extension(const QVariant &variant) const; | 
|---|
| 379 |  | 
|---|
| 380 | protected: | 
|---|
| 381 | QGraphicsItem(QGraphicsItemPrivate &dd, | 
|---|
| 382 | QGraphicsItem *parent, QGraphicsScene *scene); | 
|---|
| 383 | QGraphicsItemPrivate *d_ptr; | 
|---|
| 384 |  | 
|---|
| 385 | void addToIndex(); | 
|---|
| 386 | void removeFromIndex(); | 
|---|
| 387 | void prepareGeometryChange(); | 
|---|
| 388 |  | 
|---|
| 389 | private: | 
|---|
| 390 | Q_DISABLE_COPY(QGraphicsItem) | 
|---|
| 391 | Q_DECLARE_PRIVATE(QGraphicsItem) | 
|---|
| 392 | friend class QGraphicsItemGroup; | 
|---|
| 393 | friend class QGraphicsScene; | 
|---|
| 394 | friend class QGraphicsScenePrivate; | 
|---|
| 395 | friend class QGraphicsSceneFindItemBspTreeVisitor; | 
|---|
| 396 | friend class QGraphicsView; | 
|---|
| 397 | friend class QGraphicsViewPrivate; | 
|---|
| 398 | friend class QGraphicsWidget; | 
|---|
| 399 | friend class QGraphicsWidgetPrivate; | 
|---|
| 400 | friend class QGraphicsProxyWidgetPrivate; | 
|---|
| 401 | friend class ::tst_QGraphicsItem; | 
|---|
| 402 | friend bool qt_closestLeaf(const QGraphicsItem *, const QGraphicsItem *); | 
|---|
| 403 | friend bool qt_closestItemFirst(const QGraphicsItem *, const QGraphicsItem *); | 
|---|
| 404 | }; | 
|---|
| 405 |  | 
|---|
| 406 | Q_DECLARE_OPERATORS_FOR_FLAGS(QGraphicsItem::GraphicsItemFlags) | 
|---|
| 407 |  | 
|---|
| 408 | inline void QGraphicsItem::setPos(qreal ax, qreal ay) | 
|---|
| 409 | { setPos(QPointF(ax, ay)); } | 
|---|
| 410 | inline void QGraphicsItem::ensureVisible(qreal ax, qreal ay, qreal w, qreal h, int xmargin, int ymargin) | 
|---|
| 411 | { ensureVisible(QRectF(ax, ay, w, h), xmargin, ymargin); } | 
|---|
| 412 | inline void QGraphicsItem::update(qreal ax, qreal ay, qreal width, qreal height) | 
|---|
| 413 | { update(QRectF(ax, ay, width, height)); } | 
|---|
| 414 | inline bool QGraphicsItem::isObscured(qreal ax, qreal ay, qreal w, qreal h) const | 
|---|
| 415 | { return isObscured(QRectF(ax, ay, w, h)); } | 
|---|
| 416 | inline QPointF QGraphicsItem::mapToItem(const QGraphicsItem *item, qreal ax, qreal ay) const | 
|---|
| 417 | { return mapToItem(item, QPointF(ax, ay)); } | 
|---|
| 418 | inline QPointF QGraphicsItem::mapToParent(qreal ax, qreal ay) const | 
|---|
| 419 | { return mapToParent(QPointF(ax, ay)); } | 
|---|
| 420 | inline QPointF QGraphicsItem::mapToScene(qreal ax, qreal ay) const | 
|---|
| 421 | { return mapToScene(QPointF(ax, ay));  } | 
|---|
| 422 | inline QPointF QGraphicsItem::mapFromItem(const QGraphicsItem *item, qreal ax, qreal ay) const | 
|---|
| 423 | { return mapFromItem(item, QPointF(ax, ay)); } | 
|---|
| 424 | inline QPointF QGraphicsItem::mapFromParent(qreal ax, qreal ay) const | 
|---|
| 425 | { return mapFromParent(QPointF(ax, ay));  } | 
|---|
| 426 | inline QPointF QGraphicsItem::mapFromScene(qreal ax, qreal ay) const | 
|---|
| 427 | { return mapFromScene(QPointF(ax, ay));  } | 
|---|
| 428 | inline QPolygonF QGraphicsItem::mapToItem(const QGraphicsItem *item, qreal ax, qreal ay, qreal w, qreal h) const | 
|---|
| 429 | { return mapToItem(item, QRectF(ax, ay, w, h)); } | 
|---|
| 430 | inline QPolygonF QGraphicsItem::mapToParent(qreal ax, qreal ay, qreal w, qreal h) const | 
|---|
| 431 | { return mapToParent(QRectF(ax, ay, w, h)); } | 
|---|
| 432 | inline QPolygonF QGraphicsItem::mapToScene(qreal ax, qreal ay, qreal w, qreal h) const | 
|---|
| 433 | { return mapToScene(QRectF(ax, ay, w, h)); } | 
|---|
| 434 | inline QRectF QGraphicsItem::mapRectToItem(const QGraphicsItem *item, qreal ax, qreal ay, qreal w, qreal h) const | 
|---|
| 435 | { return mapRectToItem(item, QRectF(ax, ay, w, h)); } | 
|---|
| 436 | inline QRectF QGraphicsItem::mapRectToParent(qreal ax, qreal ay, qreal w, qreal h) const | 
|---|
| 437 | { return mapRectToParent(QRectF(ax, ay, w, h)); } | 
|---|
| 438 | inline QRectF QGraphicsItem::mapRectToScene(qreal ax, qreal ay, qreal w, qreal h) const | 
|---|
| 439 | { return mapRectToScene(QRectF(ax, ay, w, h)); } | 
|---|
| 440 | inline QPolygonF QGraphicsItem::mapFromItem(const QGraphicsItem *item, qreal ax, qreal ay, qreal w, qreal h) const | 
|---|
| 441 | { return mapFromItem(item, QRectF(ax, ay, w, h)); } | 
|---|
| 442 | inline QPolygonF QGraphicsItem::mapFromParent(qreal ax, qreal ay, qreal w, qreal h) const | 
|---|
| 443 | { return mapFromParent(QRectF(ax, ay, w, h)); } | 
|---|
| 444 | inline QPolygonF QGraphicsItem::mapFromScene(qreal ax, qreal ay, qreal w, qreal h) const | 
|---|
| 445 | { return mapFromScene(QRectF(ax, ay, w, h)); } | 
|---|
| 446 | inline QRectF QGraphicsItem::mapRectFromItem(const QGraphicsItem *item, qreal ax, qreal ay, qreal w, qreal h) const | 
|---|
| 447 | { return mapRectFromItem(item, QRectF(ax, ay, w, h)); } | 
|---|
| 448 | inline QRectF QGraphicsItem::mapRectFromParent(qreal ax, qreal ay, qreal w, qreal h) const | 
|---|
| 449 | { return mapRectFromParent(QRectF(ax, ay, w, h)); } | 
|---|
| 450 | inline QRectF QGraphicsItem::mapRectFromScene(qreal ax, qreal ay, qreal w, qreal h) const | 
|---|
| 451 | { return mapRectFromScene(QRectF(ax, ay, w, h)); } | 
|---|
| 452 |  | 
|---|
| 453 | class QAbstractGraphicsShapeItemPrivate; | 
|---|
| 454 | class Q_GUI_EXPORT QAbstractGraphicsShapeItem : public QGraphicsItem | 
|---|
| 455 | { | 
|---|
| 456 | public: | 
|---|
| 457 | QAbstractGraphicsShapeItem(QGraphicsItem *parent = 0 | 
|---|
| 458 | #ifndef Q_QDOC | 
|---|
| 459 | // obsolete argument | 
|---|
| 460 | , QGraphicsScene *scene = 0 | 
|---|
| 461 | #endif | 
|---|
| 462 | ); | 
|---|
| 463 | ~QAbstractGraphicsShapeItem(); | 
|---|
| 464 |  | 
|---|
| 465 | QPen pen() const; | 
|---|
| 466 | void setPen(const QPen &pen); | 
|---|
| 467 |  | 
|---|
| 468 | QBrush brush() const; | 
|---|
| 469 | void setBrush(const QBrush &brush); | 
|---|
| 470 |  | 
|---|
| 471 | bool isObscuredBy(const QGraphicsItem *item) const; | 
|---|
| 472 | QPainterPath opaqueArea() const; | 
|---|
| 473 |  | 
|---|
| 474 | protected: | 
|---|
| 475 | QAbstractGraphicsShapeItem(QAbstractGraphicsShapeItemPrivate &dd, | 
|---|
| 476 | QGraphicsItem *parent, QGraphicsScene *scene); | 
|---|
| 477 |  | 
|---|
| 478 | private: | 
|---|
| 479 | Q_DISABLE_COPY(QAbstractGraphicsShapeItem) | 
|---|
| 480 | Q_DECLARE_PRIVATE(QAbstractGraphicsShapeItem) | 
|---|
| 481 | }; | 
|---|
| 482 |  | 
|---|
| 483 | class QGraphicsPathItemPrivate; | 
|---|
| 484 | class Q_GUI_EXPORT QGraphicsPathItem : public QAbstractGraphicsShapeItem | 
|---|
| 485 | { | 
|---|
| 486 | public: | 
|---|
| 487 | QGraphicsPathItem(QGraphicsItem *parent = 0 | 
|---|
| 488 | #ifndef Q_QDOC | 
|---|
| 489 | // obsolete argument | 
|---|
| 490 | , QGraphicsScene *scene = 0 | 
|---|
| 491 | #endif | 
|---|
| 492 | ); | 
|---|
| 493 | QGraphicsPathItem(const QPainterPath &path, QGraphicsItem *parent = 0 | 
|---|
| 494 | #ifndef Q_QDOC | 
|---|
| 495 | // obsolete argument | 
|---|
| 496 | , QGraphicsScene *scene = 0 | 
|---|
| 497 | #endif | 
|---|
| 498 | ); | 
|---|
| 499 | ~QGraphicsPathItem(); | 
|---|
| 500 |  | 
|---|
| 501 | QPainterPath path() const; | 
|---|
| 502 | void setPath(const QPainterPath &path); | 
|---|
| 503 |  | 
|---|
| 504 | QRectF boundingRect() const; | 
|---|
| 505 | QPainterPath shape() const; | 
|---|
| 506 | bool contains(const QPointF &point) const; | 
|---|
| 507 |  | 
|---|
| 508 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); | 
|---|
| 509 |  | 
|---|
| 510 | bool isObscuredBy(const QGraphicsItem *item) const; | 
|---|
| 511 | QPainterPath opaqueArea() const; | 
|---|
| 512 |  | 
|---|
| 513 | enum { Type = 2 }; | 
|---|
| 514 | int type() const; | 
|---|
| 515 |  | 
|---|
| 516 | protected: | 
|---|
| 517 | bool supportsExtension(Extension extension) const; | 
|---|
| 518 | void setExtension(Extension extension, const QVariant &variant); | 
|---|
| 519 | QVariant extension(const QVariant &variant) const; | 
|---|
| 520 |  | 
|---|
| 521 | private: | 
|---|
| 522 | Q_DISABLE_COPY(QGraphicsPathItem) | 
|---|
| 523 | Q_DECLARE_PRIVATE(QGraphicsPathItem) | 
|---|
| 524 | }; | 
|---|
| 525 |  | 
|---|
| 526 | class QGraphicsRectItemPrivate; | 
|---|
| 527 | class Q_GUI_EXPORT QGraphicsRectItem : public QAbstractGraphicsShapeItem | 
|---|
| 528 | { | 
|---|
| 529 | public: | 
|---|
| 530 | QGraphicsRectItem(QGraphicsItem *parent = 0 | 
|---|
| 531 | #ifndef Q_QDOC | 
|---|
| 532 | // obsolete argument | 
|---|
| 533 | , QGraphicsScene *scene = 0 | 
|---|
| 534 | #endif | 
|---|
| 535 | ); | 
|---|
| 536 | QGraphicsRectItem(const QRectF &rect, QGraphicsItem *parent = 0 | 
|---|
| 537 | #ifndef Q_QDOC | 
|---|
| 538 | // obsolete argument | 
|---|
| 539 | , QGraphicsScene *scene = 0 | 
|---|
| 540 | #endif | 
|---|
| 541 | ); | 
|---|
| 542 | QGraphicsRectItem(qreal x, qreal y, qreal w, qreal h, QGraphicsItem *parent = 0 | 
|---|
| 543 | #ifndef Q_QDOC | 
|---|
| 544 | // obsolete argument | 
|---|
| 545 | , QGraphicsScene *scene = 0 | 
|---|
| 546 | #endif | 
|---|
| 547 | ); | 
|---|
| 548 | ~QGraphicsRectItem(); | 
|---|
| 549 |  | 
|---|
| 550 | QRectF rect() const; | 
|---|
| 551 | void setRect(const QRectF &rect); | 
|---|
| 552 | inline void setRect(qreal x, qreal y, qreal w, qreal h); | 
|---|
| 553 |  | 
|---|
| 554 | QRectF boundingRect() const; | 
|---|
| 555 | QPainterPath shape() const; | 
|---|
| 556 | bool contains(const QPointF &point) const; | 
|---|
| 557 |  | 
|---|
| 558 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); | 
|---|
| 559 |  | 
|---|
| 560 | bool isObscuredBy(const QGraphicsItem *item) const; | 
|---|
| 561 | QPainterPath opaqueArea() const; | 
|---|
| 562 |  | 
|---|
| 563 | enum { Type = 3 }; | 
|---|
| 564 | int type() const; | 
|---|
| 565 |  | 
|---|
| 566 | protected: | 
|---|
| 567 | bool supportsExtension(Extension extension) const; | 
|---|
| 568 | void setExtension(Extension extension, const QVariant &variant); | 
|---|
| 569 | QVariant extension(const QVariant &variant) const; | 
|---|
| 570 |  | 
|---|
| 571 | private: | 
|---|
| 572 | Q_DISABLE_COPY(QGraphicsRectItem) | 
|---|
| 573 | Q_DECLARE_PRIVATE(QGraphicsRectItem) | 
|---|
| 574 | }; | 
|---|
| 575 |  | 
|---|
| 576 | inline void QGraphicsRectItem::setRect(qreal ax, qreal ay, qreal w, qreal h) | 
|---|
| 577 | { setRect(QRectF(ax, ay, w, h)); } | 
|---|
| 578 |  | 
|---|
| 579 | class QGraphicsEllipseItemPrivate; | 
|---|
| 580 | class Q_GUI_EXPORT QGraphicsEllipseItem : public QAbstractGraphicsShapeItem | 
|---|
| 581 | { | 
|---|
| 582 | public: | 
|---|
| 583 | QGraphicsEllipseItem(QGraphicsItem *parent = 0 | 
|---|
| 584 | #ifndef Q_QDOC | 
|---|
| 585 | // obsolete argument | 
|---|
| 586 | , QGraphicsScene *scene = 0 | 
|---|
| 587 | #endif | 
|---|
| 588 | ); | 
|---|
| 589 | QGraphicsEllipseItem(const QRectF &rect, QGraphicsItem *parent = 0 | 
|---|
| 590 | #ifndef Q_QDOC | 
|---|
| 591 | // obsolete argument | 
|---|
| 592 | , QGraphicsScene *scene = 0 | 
|---|
| 593 | #endif | 
|---|
| 594 | ); | 
|---|
| 595 | QGraphicsEllipseItem(qreal x, qreal y, qreal w, qreal h, QGraphicsItem *parent = 0 | 
|---|
| 596 | #ifndef Q_QDOC | 
|---|
| 597 | // obsolete argument | 
|---|
| 598 | , QGraphicsScene *scene = 0 | 
|---|
| 599 | #endif | 
|---|
| 600 | ); | 
|---|
| 601 | ~QGraphicsEllipseItem(); | 
|---|
| 602 |  | 
|---|
| 603 | QRectF rect() const; | 
|---|
| 604 | void setRect(const QRectF &rect); | 
|---|
| 605 | inline void setRect(qreal x, qreal y, qreal w, qreal h); | 
|---|
| 606 |  | 
|---|
| 607 | int startAngle() const; | 
|---|
| 608 | void setStartAngle(int angle); | 
|---|
| 609 |  | 
|---|
| 610 | int spanAngle() const; | 
|---|
| 611 | void setSpanAngle(int angle); | 
|---|
| 612 |  | 
|---|
| 613 | QRectF boundingRect() const; | 
|---|
| 614 | QPainterPath shape() const; | 
|---|
| 615 | bool contains(const QPointF &point) const; | 
|---|
| 616 |  | 
|---|
| 617 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); | 
|---|
| 618 |  | 
|---|
| 619 | bool isObscuredBy(const QGraphicsItem *item) const; | 
|---|
| 620 | QPainterPath opaqueArea() const; | 
|---|
| 621 |  | 
|---|
| 622 | enum { Type = 4 }; | 
|---|
| 623 | int type() const; | 
|---|
| 624 |  | 
|---|
| 625 | protected: | 
|---|
| 626 | bool supportsExtension(Extension extension) const; | 
|---|
| 627 | void setExtension(Extension extension, const QVariant &variant); | 
|---|
| 628 | QVariant extension(const QVariant &variant) const; | 
|---|
| 629 |  | 
|---|
| 630 | private: | 
|---|
| 631 | Q_DISABLE_COPY(QGraphicsEllipseItem) | 
|---|
| 632 | Q_DECLARE_PRIVATE(QGraphicsEllipseItem) | 
|---|
| 633 | }; | 
|---|
| 634 |  | 
|---|
| 635 | inline void QGraphicsEllipseItem::setRect(qreal ax, qreal ay, qreal w, qreal h) | 
|---|
| 636 | { setRect(QRectF(ax, ay, w, h)); } | 
|---|
| 637 |  | 
|---|
| 638 | class QGraphicsPolygonItemPrivate; | 
|---|
| 639 | class Q_GUI_EXPORT QGraphicsPolygonItem : public QAbstractGraphicsShapeItem | 
|---|
| 640 | { | 
|---|
| 641 | public: | 
|---|
| 642 | QGraphicsPolygonItem(QGraphicsItem *parent = 0 | 
|---|
| 643 | #ifndef Q_QDOC | 
|---|
| 644 | // obsolete argument | 
|---|
| 645 | , QGraphicsScene *scene = 0 | 
|---|
| 646 | #endif | 
|---|
| 647 | ); | 
|---|
| 648 | QGraphicsPolygonItem(const QPolygonF &polygon, | 
|---|
| 649 | QGraphicsItem *parent = 0 | 
|---|
| 650 | #ifndef Q_QDOC | 
|---|
| 651 | // obsolete argument | 
|---|
| 652 | , QGraphicsScene *scene = 0 | 
|---|
| 653 | #endif | 
|---|
| 654 | ); | 
|---|
| 655 | ~QGraphicsPolygonItem(); | 
|---|
| 656 |  | 
|---|
| 657 | QPolygonF polygon() const; | 
|---|
| 658 | void setPolygon(const QPolygonF &polygon); | 
|---|
| 659 |  | 
|---|
| 660 | Qt::FillRule fillRule() const; | 
|---|
| 661 | void setFillRule(Qt::FillRule rule); | 
|---|
| 662 |  | 
|---|
| 663 | QRectF boundingRect() const; | 
|---|
| 664 | QPainterPath shape() const; | 
|---|
| 665 | bool contains(const QPointF &point) const; | 
|---|
| 666 |  | 
|---|
| 667 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); | 
|---|
| 668 |  | 
|---|
| 669 | bool isObscuredBy(const QGraphicsItem *item) const; | 
|---|
| 670 | QPainterPath opaqueArea() const; | 
|---|
| 671 |  | 
|---|
| 672 | enum { Type = 5 }; | 
|---|
| 673 | int type() const; | 
|---|
| 674 |  | 
|---|
| 675 | protected: | 
|---|
| 676 | bool supportsExtension(Extension extension) const; | 
|---|
| 677 | void setExtension(Extension extension, const QVariant &variant); | 
|---|
| 678 | QVariant extension(const QVariant &variant) const; | 
|---|
| 679 |  | 
|---|
| 680 | private: | 
|---|
| 681 | Q_DISABLE_COPY(QGraphicsPolygonItem) | 
|---|
| 682 | Q_DECLARE_PRIVATE(QGraphicsPolygonItem) | 
|---|
| 683 | }; | 
|---|
| 684 |  | 
|---|
| 685 | class QGraphicsLineItemPrivate; | 
|---|
| 686 | class Q_GUI_EXPORT QGraphicsLineItem : public QGraphicsItem | 
|---|
| 687 | { | 
|---|
| 688 | public: | 
|---|
| 689 | QGraphicsLineItem(QGraphicsItem *parent = 0 | 
|---|
| 690 | #ifndef Q_QDOC | 
|---|
| 691 | // obsolete argument | 
|---|
| 692 | , QGraphicsScene *scene = 0 | 
|---|
| 693 | #endif | 
|---|
| 694 | ); | 
|---|
| 695 | QGraphicsLineItem(const QLineF &line, QGraphicsItem *parent = 0 | 
|---|
| 696 | #ifndef Q_QDOC | 
|---|
| 697 | // obsolete argument | 
|---|
| 698 | , QGraphicsScene *scene = 0 | 
|---|
| 699 | #endif | 
|---|
| 700 | ); | 
|---|
| 701 | QGraphicsLineItem(qreal x1, qreal y1, qreal x2, qreal y2, QGraphicsItem *parent = 0 | 
|---|
| 702 | #ifndef Q_QDOC | 
|---|
| 703 | // obsolete argument | 
|---|
| 704 | , QGraphicsScene *scene = 0 | 
|---|
| 705 | #endif | 
|---|
| 706 | ); | 
|---|
| 707 | ~QGraphicsLineItem(); | 
|---|
| 708 |  | 
|---|
| 709 | QPen pen() const; | 
|---|
| 710 | void setPen(const QPen &pen); | 
|---|
| 711 |  | 
|---|
| 712 | QLineF line() const; | 
|---|
| 713 | void setLine(const QLineF &line); | 
|---|
| 714 | inline void setLine(qreal x1, qreal y1, qreal x2, qreal y2) | 
|---|
| 715 | { setLine(QLineF(x1, y1, x2, y2)); } | 
|---|
| 716 |  | 
|---|
| 717 | QRectF boundingRect() const; | 
|---|
| 718 | QPainterPath shape() const; | 
|---|
| 719 | bool contains(const QPointF &point) const; | 
|---|
| 720 |  | 
|---|
| 721 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); | 
|---|
| 722 |  | 
|---|
| 723 | bool isObscuredBy(const QGraphicsItem *item) const; | 
|---|
| 724 | QPainterPath opaqueArea() const; | 
|---|
| 725 |  | 
|---|
| 726 | enum { Type = 6 }; | 
|---|
| 727 | int type() const; | 
|---|
| 728 |  | 
|---|
| 729 | protected: | 
|---|
| 730 | bool supportsExtension(Extension extension) const; | 
|---|
| 731 | void setExtension(Extension extension, const QVariant &variant); | 
|---|
| 732 | QVariant extension(const QVariant &variant) const; | 
|---|
| 733 |  | 
|---|
| 734 | private: | 
|---|
| 735 | Q_DISABLE_COPY(QGraphicsLineItem) | 
|---|
| 736 | Q_DECLARE_PRIVATE(QGraphicsLineItem) | 
|---|
| 737 | }; | 
|---|
| 738 |  | 
|---|
| 739 | class QGraphicsPixmapItemPrivate; | 
|---|
| 740 | class Q_GUI_EXPORT QGraphicsPixmapItem : public QGraphicsItem | 
|---|
| 741 | { | 
|---|
| 742 | public: | 
|---|
| 743 | enum ShapeMode { | 
|---|
| 744 | MaskShape, | 
|---|
| 745 | BoundingRectShape, | 
|---|
| 746 | HeuristicMaskShape | 
|---|
| 747 | }; | 
|---|
| 748 |  | 
|---|
| 749 | QGraphicsPixmapItem(QGraphicsItem *parent = 0 | 
|---|
| 750 | #ifndef Q_QDOC | 
|---|
| 751 | // obsolete argument | 
|---|
| 752 | , QGraphicsScene *scene = 0 | 
|---|
| 753 | #endif | 
|---|
| 754 | ); | 
|---|
| 755 | QGraphicsPixmapItem(const QPixmap &pixmap, QGraphicsItem *parent = 0 | 
|---|
| 756 | #ifndef Q_QDOC | 
|---|
| 757 | // obsolete argument | 
|---|
| 758 | , QGraphicsScene *scene = 0 | 
|---|
| 759 | #endif | 
|---|
| 760 | ); | 
|---|
| 761 | ~QGraphicsPixmapItem(); | 
|---|
| 762 |  | 
|---|
| 763 | QPixmap pixmap() const; | 
|---|
| 764 | void setPixmap(const QPixmap &pixmap); | 
|---|
| 765 |  | 
|---|
| 766 | Qt::TransformationMode transformationMode() const; | 
|---|
| 767 | void setTransformationMode(Qt::TransformationMode mode); | 
|---|
| 768 |  | 
|---|
| 769 | QPointF offset() const; | 
|---|
| 770 | void setOffset(const QPointF &offset); | 
|---|
| 771 | inline void setOffset(qreal x, qreal y); | 
|---|
| 772 |  | 
|---|
| 773 | QRectF boundingRect() const; | 
|---|
| 774 | QPainterPath shape() const; | 
|---|
| 775 | bool contains(const QPointF &point) const; | 
|---|
| 776 |  | 
|---|
| 777 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); | 
|---|
| 778 |  | 
|---|
| 779 | bool isObscuredBy(const QGraphicsItem *item) const; | 
|---|
| 780 | QPainterPath opaqueArea() const; | 
|---|
| 781 |  | 
|---|
| 782 | enum { Type = 7 }; | 
|---|
| 783 | int type() const; | 
|---|
| 784 |  | 
|---|
| 785 | ShapeMode shapeMode() const; | 
|---|
| 786 | void setShapeMode(ShapeMode mode); | 
|---|
| 787 |  | 
|---|
| 788 | protected: | 
|---|
| 789 | bool supportsExtension(Extension extension) const; | 
|---|
| 790 | void setExtension(Extension extension, const QVariant &variant); | 
|---|
| 791 | QVariant extension(const QVariant &variant) const; | 
|---|
| 792 |  | 
|---|
| 793 | private: | 
|---|
| 794 | Q_DISABLE_COPY(QGraphicsPixmapItem) | 
|---|
| 795 | Q_DECLARE_PRIVATE(QGraphicsPixmapItem) | 
|---|
| 796 | }; | 
|---|
| 797 |  | 
|---|
| 798 | inline void QGraphicsPixmapItem::setOffset(qreal ax, qreal ay) | 
|---|
| 799 | { setOffset(QPointF(ax, ay)); } | 
|---|
| 800 |  | 
|---|
| 801 | class QGraphicsTextItemPrivate; | 
|---|
| 802 | class QTextDocument; | 
|---|
| 803 | class QTextCursor; | 
|---|
| 804 | class Q_GUI_EXPORT QGraphicsTextItem : public QObject, public QGraphicsItem | 
|---|
| 805 | { | 
|---|
| 806 | Q_OBJECT | 
|---|
| 807 | QDOC_PROPERTY(bool openExternalLinks READ openExternalLinks WRITE setOpenExternalLinks) | 
|---|
| 808 | QDOC_PROPERTY(QTextCursor textCursor READ textCursor WRITE setTextCursor) | 
|---|
| 809 |  | 
|---|
| 810 | public: | 
|---|
| 811 | QGraphicsTextItem(QGraphicsItem *parent = 0 | 
|---|
| 812 | #ifndef Q_QDOC | 
|---|
| 813 | // obsolete argument | 
|---|
| 814 | , QGraphicsScene *scene = 0 | 
|---|
| 815 | #endif | 
|---|
| 816 | ); | 
|---|
| 817 | QGraphicsTextItem(const QString &text, QGraphicsItem *parent = 0 | 
|---|
| 818 | #ifndef Q_QDOC | 
|---|
| 819 | // obsolete argument | 
|---|
| 820 | , QGraphicsScene *scene = 0 | 
|---|
| 821 | #endif | 
|---|
| 822 | ); | 
|---|
| 823 | ~QGraphicsTextItem(); | 
|---|
| 824 |  | 
|---|
| 825 | QString toHtml() const; | 
|---|
| 826 | void setHtml(const QString &html); | 
|---|
| 827 |  | 
|---|
| 828 | QString toPlainText() const; | 
|---|
| 829 | void setPlainText(const QString &text); | 
|---|
| 830 |  | 
|---|
| 831 | QFont font() const; | 
|---|
| 832 | void setFont(const QFont &font); | 
|---|
| 833 |  | 
|---|
| 834 | void setDefaultTextColor(const QColor &c); | 
|---|
| 835 | QColor defaultTextColor() const; | 
|---|
| 836 |  | 
|---|
| 837 | QRectF boundingRect() const; | 
|---|
| 838 | QPainterPath shape() const; | 
|---|
| 839 | bool contains(const QPointF &point) const; | 
|---|
| 840 |  | 
|---|
| 841 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); | 
|---|
| 842 |  | 
|---|
| 843 | bool isObscuredBy(const QGraphicsItem *item) const; | 
|---|
| 844 | QPainterPath opaqueArea() const; | 
|---|
| 845 |  | 
|---|
| 846 | enum { Type = 8 }; | 
|---|
| 847 | int type() const; | 
|---|
| 848 |  | 
|---|
| 849 | void setTextWidth(qreal width); | 
|---|
| 850 | qreal textWidth() const; | 
|---|
| 851 |  | 
|---|
| 852 | void adjustSize(); | 
|---|
| 853 |  | 
|---|
| 854 | void setDocument(QTextDocument *document); | 
|---|
| 855 | QTextDocument *document() const; | 
|---|
| 856 |  | 
|---|
| 857 | void setTextInteractionFlags(Qt::TextInteractionFlags flags); | 
|---|
| 858 | Qt::TextInteractionFlags textInteractionFlags() const; | 
|---|
| 859 |  | 
|---|
| 860 | void setTabChangesFocus(bool b); | 
|---|
| 861 | bool tabChangesFocus() const; | 
|---|
| 862 |  | 
|---|
| 863 | void setOpenExternalLinks(bool open); | 
|---|
| 864 | bool openExternalLinks() const; | 
|---|
| 865 |  | 
|---|
| 866 | void setTextCursor(const QTextCursor &cursor); | 
|---|
| 867 | QTextCursor textCursor() const; | 
|---|
| 868 |  | 
|---|
| 869 | Q_SIGNALS: | 
|---|
| 870 | void linkActivated(const QString &); | 
|---|
| 871 | void linkHovered(const QString &); | 
|---|
| 872 |  | 
|---|
| 873 | protected: | 
|---|
| 874 | bool sceneEvent(QEvent *event); | 
|---|
| 875 | void mousePressEvent(QGraphicsSceneMouseEvent *event); | 
|---|
| 876 | void mouseMoveEvent(QGraphicsSceneMouseEvent *event); | 
|---|
| 877 | void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); | 
|---|
| 878 | void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event); | 
|---|
| 879 | void contextMenuEvent(QGraphicsSceneContextMenuEvent *event); | 
|---|
| 880 | void keyPressEvent(QKeyEvent *event); | 
|---|
| 881 | void keyReleaseEvent(QKeyEvent *event); | 
|---|
| 882 | void focusInEvent(QFocusEvent *event); | 
|---|
| 883 | void focusOutEvent(QFocusEvent *event); | 
|---|
| 884 | void dragEnterEvent(QGraphicsSceneDragDropEvent *event); | 
|---|
| 885 | void dragLeaveEvent(QGraphicsSceneDragDropEvent *event); | 
|---|
| 886 | void dragMoveEvent(QGraphicsSceneDragDropEvent *event); | 
|---|
| 887 | void dropEvent(QGraphicsSceneDragDropEvent *event); | 
|---|
| 888 | void inputMethodEvent(QInputMethodEvent *event); | 
|---|
| 889 | void hoverEnterEvent(QGraphicsSceneHoverEvent *event); | 
|---|
| 890 | void hoverMoveEvent(QGraphicsSceneHoverEvent *event); | 
|---|
| 891 | void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); | 
|---|
| 892 |  | 
|---|
| 893 | QVariant inputMethodQuery(Qt::InputMethodQuery query) const; | 
|---|
| 894 |  | 
|---|
| 895 | bool supportsExtension(Extension extension) const; | 
|---|
| 896 | void setExtension(Extension extension, const QVariant &variant); | 
|---|
| 897 | QVariant extension(const QVariant &variant) const; | 
|---|
| 898 |  | 
|---|
| 899 | private: | 
|---|
| 900 | Q_DISABLE_COPY(QGraphicsTextItem) | 
|---|
| 901 | Q_PRIVATE_SLOT(dd, void _q_updateBoundingRect(const QSizeF &)) | 
|---|
| 902 | Q_PRIVATE_SLOT(dd, void _q_update(QRectF)) | 
|---|
| 903 | Q_PRIVATE_SLOT(dd, void _q_ensureVisible(QRectF)) | 
|---|
| 904 | QGraphicsTextItemPrivate *dd; | 
|---|
| 905 | friend class QGraphicsTextItemPrivate; | 
|---|
| 906 | }; | 
|---|
| 907 |  | 
|---|
| 908 | class QGraphicsSimpleTextItemPrivate; | 
|---|
| 909 | class Q_GUI_EXPORT QGraphicsSimpleTextItem : public QAbstractGraphicsShapeItem | 
|---|
| 910 | { | 
|---|
| 911 | public: | 
|---|
| 912 | QGraphicsSimpleTextItem(QGraphicsItem *parent = 0 | 
|---|
| 913 | #ifndef Q_QDOC | 
|---|
| 914 | // obsolete argument | 
|---|
| 915 | , QGraphicsScene *scene = 0 | 
|---|
| 916 | #endif | 
|---|
| 917 | ); | 
|---|
| 918 | QGraphicsSimpleTextItem(const QString &text, QGraphicsItem *parent = 0 | 
|---|
| 919 | #ifndef Q_QDOC | 
|---|
| 920 | // obsolete argument | 
|---|
| 921 | , QGraphicsScene *scene = 0 | 
|---|
| 922 | #endif | 
|---|
| 923 | ); | 
|---|
| 924 | ~QGraphicsSimpleTextItem(); | 
|---|
| 925 |  | 
|---|
| 926 | void setText(const QString &text); | 
|---|
| 927 | QString text() const; | 
|---|
| 928 |  | 
|---|
| 929 | void setFont(const QFont &font); | 
|---|
| 930 | QFont font() const; | 
|---|
| 931 |  | 
|---|
| 932 | QRectF boundingRect() const; | 
|---|
| 933 | QPainterPath shape() const; | 
|---|
| 934 | bool contains(const QPointF &point) const; | 
|---|
| 935 |  | 
|---|
| 936 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); | 
|---|
| 937 |  | 
|---|
| 938 | bool isObscuredBy(const QGraphicsItem *item) const; | 
|---|
| 939 | QPainterPath opaqueArea() const; | 
|---|
| 940 |  | 
|---|
| 941 | enum { Type = 9 }; | 
|---|
| 942 | int type() const; | 
|---|
| 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(QGraphicsSimpleTextItem) | 
|---|
| 951 | Q_DECLARE_PRIVATE(QGraphicsSimpleTextItem) | 
|---|
| 952 | }; | 
|---|
| 953 |  | 
|---|
| 954 | class QGraphicsItemGroupPrivate; | 
|---|
| 955 | class Q_GUI_EXPORT QGraphicsItemGroup : public QGraphicsItem | 
|---|
| 956 | { | 
|---|
| 957 | public: | 
|---|
| 958 | QGraphicsItemGroup(QGraphicsItem *parent = 0 | 
|---|
| 959 | #ifndef Q_QDOC | 
|---|
| 960 | // obsolete argument | 
|---|
| 961 | , QGraphicsScene *scene = 0 | 
|---|
| 962 | #endif | 
|---|
| 963 | ); | 
|---|
| 964 | ~QGraphicsItemGroup(); | 
|---|
| 965 |  | 
|---|
| 966 | void addToGroup(QGraphicsItem *item); | 
|---|
| 967 | void removeFromGroup(QGraphicsItem *item); | 
|---|
| 968 |  | 
|---|
| 969 | QRectF boundingRect() const; | 
|---|
| 970 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); | 
|---|
| 971 |  | 
|---|
| 972 | bool isObscuredBy(const QGraphicsItem *item) const; | 
|---|
| 973 | QPainterPath opaqueArea() const; | 
|---|
| 974 |  | 
|---|
| 975 | enum { Type = 10 }; | 
|---|
| 976 | int type() const; | 
|---|
| 977 |  | 
|---|
| 978 | private: | 
|---|
| 979 | Q_DISABLE_COPY(QGraphicsItemGroup) | 
|---|
| 980 | Q_DECLARE_PRIVATE(QGraphicsItemGroup) | 
|---|
| 981 | }; | 
|---|
| 982 |  | 
|---|
| 983 | template <class T> inline T qgraphicsitem_cast(QGraphicsItem *item) | 
|---|
| 984 | { | 
|---|
| 985 | return int(static_cast<T>(0)->Type) == int(QGraphicsItem::Type) | 
|---|
| 986 | || (item && int(static_cast<T>(0)->Type) == item->type()) ? static_cast<T>(item) : 0; | 
|---|
| 987 | } | 
|---|
| 988 |  | 
|---|
| 989 | template <class T> inline T qgraphicsitem_cast(const QGraphicsItem *item) | 
|---|
| 990 | { | 
|---|
| 991 | return int(static_cast<T>(0)->Type) == int(QGraphicsItem::Type) | 
|---|
| 992 | || (item && int(static_cast<T>(0)->Type) == item->type()) ? static_cast<T>(item) : 0; | 
|---|
| 993 | } | 
|---|
| 994 |  | 
|---|
| 995 | #ifndef QT_NO_DEBUG_STREAM | 
|---|
| 996 | Q_GUI_EXPORT QDebug operator<<(QDebug debug, QGraphicsItem *item); | 
|---|
| 997 | Q_GUI_EXPORT QDebug operator<<(QDebug debug, QGraphicsItem::GraphicsItemChange change); | 
|---|
| 998 | Q_GUI_EXPORT QDebug operator<<(QDebug debug, QGraphicsItem::GraphicsItemFlag flag); | 
|---|
| 999 | Q_GUI_EXPORT QDebug operator<<(QDebug debug, QGraphicsItem::GraphicsItemFlags flags); | 
|---|
| 1000 | #endif | 
|---|
| 1001 |  | 
|---|
| 1002 | QT_END_NAMESPACE | 
|---|
| 1003 |  | 
|---|
| 1004 | Q_DECLARE_METATYPE(QGraphicsItem *) | 
|---|
| 1005 | Q_DECLARE_METATYPE(QGraphicsScene *) | 
|---|
| 1006 |  | 
|---|
| 1007 | QT_BEGIN_NAMESPACE | 
|---|
| 1008 |  | 
|---|
| 1009 | #endif // QT_NO_GRAPHICSVIEW | 
|---|
| 1010 |  | 
|---|
| 1011 | QT_END_NAMESPACE | 
|---|
| 1012 |  | 
|---|
| 1013 | QT_END_HEADER | 
|---|
| 1014 |  | 
|---|
| 1015 | #endif // QGRAPHICSITEM_H | 
|---|
| 1016 |  | 
|---|