]> git.siccegge.de Git - frida/frida.git/blobdiff - src/gui/widgets/BasicBlockWidget.hxx
Add log widget to lower dock
[frida/frida.git] / src / gui / widgets / BasicBlockWidget.hxx
index effb5880665a9c4eeaed5baa2105ed7c4a7e9c39..8cf709c9f2f821449ac689c6af147ada50db34e8 100644 (file)
@@ -1,37 +1,63 @@
+#ifndef INCLUDE__BasicBlockWidget_hxx
+#define INCLUDE__BasicBlockWidget_hxx
+
 #include "gui/qt.hxx"
+#include <vector>
+#include <cassert>
+#include <tuple>
+#include <array>
+#include <memory>
+#include <log4cxx/logger.h>
+
+class Mainwindow;
+class CustomQGraphicsTextItem;
+
+class BasicBlock;
+
+class RenameFunctionEvent;
 
-class BasicBlockWidget : public QGraphicsItem
+class BasicBlockWidget : public QObject, public QGraphicsItem
 {
+       Q_OBJECT
+       friend class CustomQGraphicsTextItem;
 public:
-    BasicBlockWidget(const QString& name)
-               : x(-5), y(-20)
-               , dx(250), dy(270)
-               , name(name) {
-        _widget.addItem("THIS");
-        _widget.addItem("IS");
-        _widget.addItem("A");
-        _widget.addItem("TEST");
-               _widget.resize(dx-20, dy-20);
-    }
-
-    QRectF boundingRect() const
-    {
-        qreal penWidth = 1;
-        return QRectF(x - penWidth / 2, y - penWidth / 2,
-                      dx + penWidth, dy + penWidth);
-    }
-
-    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
-               QWidget *widget)
-    {
-        painter->fillRect(x, y, dx, dy, QColor(0xcc, 0xcc, 0xff, 0xff));
-        painter->setPen(QColor(0x00, 0x00, 0xff, 0xff));
-        painter->drawRect(x, y, dx, dy);
-        painter->drawText(0, -5, name);
-        _widget.render(painter);
-    }
+       BasicBlockWidget(const QString& name, BasicBlock * block, Mainwindow * mainwindow);
+
+       void addItem(uint8_t* bytes, size_t num_bytes, QString line, const QString& href);
+       void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
+                  QWidget *widget);
+       QRectF boundingRect() const;
+       std::array<QPointF, 3> getExits() const;
+
+       void mouseMoveEvent(QGraphicsSceneMouseEvent * event)
+               { QGraphicsItem::mouseMoveEvent(event); scene()->update(); }
+
+       QPointF getEntry() const
+               { return mapToScene(QPointF(width/2, 0)); }
+
+       void addPrevious(BasicBlockWidget * widget)
+               { previous.push_back(widget); }
+
+       void addNext(BasicBlockWidget * left, BasicBlockWidget * right)
+               { next[0] = left; next[1] = right; }
+
+       BasicBlockWidget ** getNext()
+               { return next; }
+
+       QString getName() const
+               { return name; }
 private:
-    int x, y, dx, dy;
-    QListWidget _widget;
+       void updateFunctionName(RenameFunctionEvent* event);
+
+       uint32_t width, height;
        QString name;
+       std::unique_ptr<QGraphicsTextItem> _widget;
+       QTextTable* _table;
+       BasicBlock* block;
+       Mainwindow* mainwindow;
+       std::vector<BasicBlockWidget*> previous;
+       BasicBlockWidget* next[2];
+       log4cxx::LoggerPtr logger;
 };
+
+#endif