]> git.siccegge.de Git - frida/frida.git/blob - src/gui/widgets/BasicBlockWidget.hxx
Move Function/BasicBlock to core and clean up includes
[frida/frida.git] / src / gui / widgets / BasicBlockWidget.hxx
1 #ifndef INCLUDE__BasicBlockWidget_hxx
2 #define INCLUDE__BasicBlockWidget_hxx
3
4 #include "gui/qt.hxx"
5 #include <vector>
6 #include <cassert>
7 #include <tuple>
8 #include <array>
9 #include <memory>
10
11 class Mainwindow;
12 class BasicBlock;
13
14 class BasicBlockWidget : public QObject, public QGraphicsItem
15 {
16 Q_OBJECT
17 public:
18 BasicBlockWidget(const QString& name, BasicBlock * block, Mainwindow * mainwindow);
19
20 void addItem(uint8_t* bytes, size_t num_bytes, QString line, const QString& href);
21 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
22 QWidget *widget);
23 QRectF boundingRect() const;
24 std::array<QPointF, 3> getExits() const;
25
26 void mouseMoveEvent(QGraphicsSceneMouseEvent * event)
27 { QGraphicsItem::mouseMoveEvent(event); scene()->update(); }
28
29 QPointF getEntry() const
30 { return mapToScene(QPointF(width/2, 0)); }
31
32 void addPrevious(BasicBlockWidget * widget)
33 { previous.push_back(widget); }
34
35 void addNext(BasicBlockWidget * left, BasicBlockWidget * right)
36 { next[0] = left; next[1] = right; }
37
38 BasicBlockWidget ** getNext()
39 { return next; }
40
41 QString getName() const
42 { return name; }
43 private:
44 uint32_t width, height;
45 QString name;
46 std::unique_ptr<QGraphicsTextItem> _widget;
47 QTextTable* _table;
48 BasicBlock* block;
49 Mainwindow* mainwindow;
50 std::vector<BasicBlockWidget*> previous;
51 BasicBlockWidget* next[2];
52 };
53
54 #endif