// qgraphicsscene.sip generated by MetaSIP on Fri Sep 28 17:07:47 2007 // // This file is part of the QtGui Python extension module. // // Copyright (c) 2007 // Phil Thompson // // This file is part of PyQt. // // This copy of PyQt is free software; you can redistribute it and/or modify it // under the terms of the GNU General Public License version 2 as published by // the Free Software Foundation and appearing in the file LICENSE included in the // packaging of this file. // // PyQt is supplied in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS // FOR A PARTICULAR PURPOSE. See the GNU General Public License for more // details. // // You should have received a copy of the GNU General Public License along with // PyQt; see the file LICENSE. If not, write to the Free Software Foundation, // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. %If (Qt_4_2_0 -) %ModuleCode #include %End %End %If (Qt_4_2_0 -) class QGraphicsScene : QObject { %TypeHeaderCode #include %End public: enum ItemIndexMethod { BspTreeIndex, NoIndex, }; QGraphicsScene(QObject *parent /TransferThis/ = 0); %MethodCode // We want to track the instance. Py_BEGIN_ALLOW_THREADS sipCpp = new sipQGraphicsScene(a0); qtgui_track(sipCpp); Py_END_ALLOW_THREADS %End QGraphicsScene(const QRectF &sceneRect, QObject *parent /TransferThis/ = 0); %MethodCode // We want to track the instance. Py_BEGIN_ALLOW_THREADS sipCpp = new sipQGraphicsScene(*a0, a1); qtgui_track(sipCpp); Py_END_ALLOW_THREADS %End QGraphicsScene(qreal x, qreal y, qreal width, qreal height, QObject *parent /TransferThis/ = 0); %MethodCode // We want to track the instance. Py_BEGIN_ALLOW_THREADS sipCpp = new sipQGraphicsScene(a0, a1, a2, a3, a4); qtgui_track(sipCpp); Py_END_ALLOW_THREADS %End virtual ~QGraphicsScene(); QRectF sceneRect() const; qreal width() const; qreal height() const; void setSceneRect(const QRectF &rect); void setSceneRect(qreal x, qreal y, qreal w, qreal h); void render(QPainter *painter, const QRectF &target = QRectF(), const QRectF &source = QRectF(), Qt::AspectRatioMode aspectRatioMode = Qt::KeepAspectRatio); QGraphicsScene::ItemIndexMethod itemIndexMethod() const; void setItemIndexMethod(QGraphicsScene::ItemIndexMethod method); QRectF itemsBoundingRect() const; QList items() const; QList items(const QPointF &pos) const; QList items(const QRectF &rect, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const; QList items(const QPolygonF &polygon, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const; QList items(const QPainterPath &path, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const; %If (Qt_4_3_0 -) QList items(qreal x, qreal y, qreal w, qreal h, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const; %End QList collidingItems(const QGraphicsItem *item, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const; QGraphicsItem *itemAt(const QPointF &pos) const; QGraphicsItem *itemAt(qreal x, qreal y) const; QList selectedItems() const; void setSelectionArea(const QPainterPath &path); void clearSelection(); QGraphicsItemGroup *createItemGroup(const QList &items /Transfer/); void destroyItemGroup(QGraphicsItemGroup *group /Transfer/); void addItem(QGraphicsItem *item /Transfer/); QGraphicsEllipseItem *addEllipse(const QRectF &rect, const QPen &pen = QPen(), const QBrush &brush = QBrush()); %If (Qt_4_3_0 -) QGraphicsEllipseItem *addEllipse(qreal x, qreal y, qreal w, qreal h, const QPen &pen = QPen(), const QBrush &brush = QBrush()); %End QGraphicsLineItem *addLine(const QLineF &line, const QPen &pen = QPen()); %If (Qt_4_3_0 -) QGraphicsLineItem *addLine(qreal x1, qreal y1, qreal x2, qreal y2, const QPen &pen = QPen()); %End QGraphicsPathItem *addPath(const QPainterPath &path, const QPen &pen = QPen(), const QBrush &brush = QBrush()); QGraphicsPixmapItem *addPixmap(const QPixmap &pixmap); QGraphicsPolygonItem *addPolygon(const QPolygonF &polygon, const QPen &pen = QPen(), const QBrush &brush = QBrush()); QGraphicsRectItem *addRect(const QRectF &rect, const QPen &pen = QPen(), const QBrush &brush = QBrush()); %If (Qt_4_3_0 -) QGraphicsRectItem *addRect(qreal x, qreal y, qreal w, qreal h, const QPen &pen = QPen(), const QBrush &brush = QBrush()); %End %If (Qt_4_3_0 -) QGraphicsSimpleTextItem *addSimpleText(const QString &text, const QFont &font = QFont()); %End QGraphicsTextItem *addText(const QString &text, const QFont &font = QFont()); void removeItem(QGraphicsItem *item /TransferBack/); QGraphicsItem *focusItem() const; void setFocusItem(QGraphicsItem *item, Qt::FocusReason focusReason = Qt::OtherFocusReason); bool hasFocus() const; void setFocus(Qt::FocusReason focusReason = Qt::OtherFocusReason); void clearFocus(); QGraphicsItem *mouseGrabberItem() const; QBrush backgroundBrush() const; void setBackgroundBrush(const QBrush &brush); QBrush foregroundBrush() const; void setForegroundBrush(const QBrush &brush); virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const; QList views() const; public slots: void advance(); void update(const QRectF &rect = QRectF()); %If (Qt_4_3_0 -) void invalidate(const QRectF &rect = QRectF(), QFlags layers = QGraphicsScene::AllLayers); %End signals: void changed(const QList ®ion); void sceneRectChanged(const QRectF &rect); %If (Qt_4_3_0 -) void selectionChanged(); %End protected: virtual bool event(QEvent *event); virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent *event); virtual void dragEnterEvent(QGraphicsSceneDragDropEvent *event); virtual void dragMoveEvent(QGraphicsSceneDragDropEvent *event); virtual void dragLeaveEvent(QGraphicsSceneDragDropEvent *event); virtual void dropEvent(QGraphicsSceneDragDropEvent *event); virtual void focusInEvent(QFocusEvent *event); virtual void focusOutEvent(QFocusEvent *event); virtual void helpEvent(QGraphicsSceneHelpEvent *event); virtual void keyPressEvent(QKeyEvent *event); virtual void keyReleaseEvent(QKeyEvent *event); virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event); virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event); virtual void wheelEvent(QGraphicsSceneWheelEvent *event); virtual void inputMethodEvent(QInputMethodEvent *event); virtual void drawBackground(QPainter *painter, const QRectF &rect); virtual void drawForeground(QPainter *painter, const QRectF &rect); virtual void drawItems(QPainter *painter, SIP_PYLIST items, SIP_PYLIST options, QWidget *widget = 0) [void (QPainter *painter, int numItems, QGraphicsItem **items, const QStyleOptionGraphicsItem *options, QWidget *widget = 0)]; %MethodCode // PyQt takes lists as the items and options arguments. // Adjust the number items according to the actual list lengths. int numItems = PyList_GET_SIZE(a1); if (numItems > PyList_GET_SIZE(a2)) numItems = PyList_GET_SIZE(a2); // Allocate temporary storage for the C++ conversions. QGraphicsItem **items = new QGraphicsItem *[numItems]; QStyleOptionGraphicsItem *options = new QStyleOptionGraphicsItem[numItems]; for (int i = 0; i < numItems; ++i) { void *cpp; cpp = sipForceConvertToInstance(PyList_GET_ITEM(a1, i), sipClass_QGraphicsItem, NULL, SIP_NO_CONVERTORS, NULL, &sipIsErr); items[i] = reinterpret_cast(cpp); cpp = sipForceConvertToInstance(PyList_GET_ITEM(a2, i), sipClass_QStyleOptionGraphicsItem, NULL, SIP_NOT_NONE|SIP_NO_CONVERTORS, NULL, &sipIsErr); options[i] = *reinterpret_cast(cpp); } if (!sipIsErr) { Py_BEGIN_ALLOW_THREADS sipCpp->sipProtectVirt_drawItems(sipSelfWasArg, a0, numItems, items, options, a3); Py_END_ALLOW_THREADS } delete[] items; delete[] options; %End %VirtualCatcherCode // PyQt handles the items and options arguments as lists, but keeps the // numItems argument. PyObject *items = PyList_New(a1); PyObject *options = PyList_New(a1); sipIsErr = (!items || !options); if (!sipIsErr) for (int i = 0; i < a1; ++i) { PyObject *obj; obj = sipConvertFromInstance(a2[i], sipClass_QGraphicsItem, 0); if (!obj) { sipIsErr = true; break; } PyList_SET_ITEM(items, i, obj); obj = sipConvertFromInstance(const_cast(&a3[i]), sipClass_QStyleOptionGraphicsItem, 0); if (!obj) { sipIsErr = true; break; } PyList_SET_ITEM(options, i, obj); } if (!sipIsErr) { PyObject *res = sipCallMethod(&sipIsErr, sipMethod, "CSSC", a0, sipClass_QPainter, NULL, items, options, a4, sipClass_QWidget, NULL); if (res) { sipParseResult(&sipIsErr, sipMethod, res, "Z"); Py_DECREF(res); } } Py_XDECREF(items); Py_XDECREF(options); %End public: %If (Qt_4_3_0 -) enum SceneLayer { ItemLayer, BackgroundLayer, ForegroundLayer, AllLayers, }; %End %If (Qt_4_3_0 -) typedef QFlags SceneLayers; %End %If (Qt_4_3_0 -) int bspTreeDepth() const; %End %If (Qt_4_3_0 -) void setBspTreeDepth(int depth); %End %If (Qt_4_3_0 -) QPainterPath selectionArea() const; %End %If (Qt_4_3_0 -) void setSelectionArea(const QPainterPath &path, Qt::ItemSelectionMode); %End %If (Qt_4_3_0 -) void update(qreal x, qreal y, qreal w, qreal h); %End %If (Qt_4_3_0 -) void invalidate(qreal x, qreal y, qreal w, qreal h, QFlags layers = QGraphicsScene::AllLayers); %End }; %End %If (Qt_4_3_0 -) QFlags operator|(QGraphicsScene::SceneLayer f1, QFlags f2); %End %If (Qt_4_3_0 -) QFlags operator|(QGraphicsScene::SceneLayer f1, QGraphicsScene::SceneLayer f2); %End