8cf709c9f2f821449ac689c6af147ada50db34e8
[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 #include <log4cxx/logger.h>
11
12 class Mainwindow;
13 class CustomQGraphicsTextItem;
14
15 class BasicBlock;
16
17 class RenameFunctionEvent;
18
19 class BasicBlockWidget : public QObject, public QGraphicsItem
20 {
21 Q_OBJECT
22 friend class CustomQGraphicsTextItem;
23 public:
24 BasicBlockWidget(const QString& name, BasicBlock * block, Mainwindow * mainwindow);
25
26 void addItem(uint8_t* bytes, size_t num_bytes, QString line, const QString& href);
27 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
28 QWidget *widget);
29 QRectF boundingRect() const;
30 std::array<QPointF, 3> getExits() const;
31
32 void mouseMoveEvent(QGraphicsSceneMouseEvent * event)
33 { QGraphicsItem::mouseMoveEvent(event); scene()->update(); }
34
35 QPointF getEntry() const
36 { return mapToScene(QPointF(width/2, 0)); }
37
38 void addPrevious(BasicBlockWidget * widget)
39 { previous.push_back(widget); }
40
41 void addNext(BasicBlockWidget * left, BasicBlockWidget * right)
42 { next[0] = left; next[1] = right; }
43
44 BasicBlockWidget ** getNext()
45 { return next; }
46
47 QString getName() const
48 { return name; }
49 private:
50 void updateFunctionName(RenameFunctionEvent* event);
51
52 uint32_t width, height;
53 QString name;
54 std::unique_ptr<QGraphicsTextItem> _widget;
55 QTextTable* _table;
56 BasicBlock* block;
57 Mainwindow* mainwindow;
58 std::vector<BasicBlockWidget*> previous;
59 BasicBlockWidget* next[2];
60 log4cxx::LoggerPtr logger;
61 };
62
63 #endif