]> git.siccegge.de Git - frida/frida.git/blobdiff - src/gui/widgets/BasicBlockWidget.hxx
QTableWidget -> QLabel + HTML
[frida/frida.git] / src / gui / widgets / BasicBlockWidget.hxx
index effb5880665a9c4eeaed5baa2105ed7c4a7e9c39..e40ed840a759bf838d6a1cb5f14765dd0b9217a5 100644 (file)
@@ -1,37 +1,72 @@
+#ifndef INCLUDE__BasicBlockWidget_hxx
+#define INCLUDE__BasicBlockWidget_hxx
+
 #include "gui/qt.hxx"
+#include "disassembler/BasicBlock.hxx"
+#include <vector>
+#include <cassert>
+#include <tuple>
+#include <array>
 
 class BasicBlockWidget : public QGraphicsItem
 {
 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);
-    }
+    BasicBlockWidget(const QString& name, BasicBlock * block);
 
-    QRectF boundingRect() const
-    {
+       void addItem(uint8_t* bytes, size_t num_bytes, const QString& line);
+
+    QRectF boundingRect() const  {
         qreal penWidth = 1;
-        return QRectF(x - penWidth / 2, y - penWidth / 2,
-                      dx + penWidth, dy + penWidth);
+               QRectF result(- penWidth / 2, - penWidth / 2,
+                      width + penWidth, height + penWidth);
+        return result;
+    }
+
+       void mouseMoveEvent(QGraphicsSceneMouseEvent * event) {
+               QGraphicsItem::mouseMoveEvent(event);
+        scene()->update();
+       }
+
+       QPointF getEntry() const {
+               return mapToScene(QPointF(width/2, 0));
+       }
+
+    std::array<QPointF, 3> getExits() const {
+        return { {  mapToScene(QPointF(  width/3, height)),
+                                       mapToScene(QPointF(  width/2, height)),
+                                       mapToScene(QPointF(2*width/3, height)) } };
     }
 
     void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
-               QWidget *widget)
-    {
-        painter->fillRect(x, y, dx, dy, QColor(0xcc, 0xcc, 0xff, 0xff));
+               QWidget *widget) {
+        painter->fillRect(0, 0, width, height, 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);
+        painter->drawRect(0, 0, width, height);
+        painter->drawText(5, 15, name);
+               if (_widget.text() != "")
+                       _widget.render(painter, QPoint(5, 20));
     }
+
+       void addPrevious(BasicBlockWidget * widget) {
+               previous.push_back(widget);
+       }
+
+       void addNext(BasicBlockWidget * left, BasicBlockWidget * right) {
+               next[0] = left;
+               next[1] = right;
+       }
+
+    BasicBlockWidget ** getNext() {
+        return next;
+    }
+
 private:
-    int x, y, dx, dy;
-    QListWidget _widget;
+    uint32_t width, height;
+    QLabel _widget;
        QString name;
+       BasicBlock * block;
+       std::vector<BasicBlockWidget*> previous;
+       BasicBlockWidget* next[2];
 };
+
+#endif