Make GUI Widget move Comments through the backend properly
[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 #include "disassembler/Instruction.hxx"
13
14 class Mainwindow;
15 class CustomQGraphicsTextItem;
16 class BasicBlock;
17 class RenameFunctionEvent;
18 class ChangeCommentEvent;
19
20 class BasicBlockWidget : public QObject, public QGraphicsItem
21 {
22 Q_OBJECT
23 friend class CustomQGraphicsTextItem;
24 public:
25 BasicBlockWidget(const QString& name, BasicBlock * block, Mainwindow * mainwindow);
26
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 void populateWidget();
52 void changeCommentHandler(ChangeCommentEvent* event);
53 QString formatComments(Instruction* inst);
54
55 uint32_t width, height;
56 QString name;
57 std::unique_ptr<QGraphicsTextItem> _widget;
58 QTextTable* _table;
59 BasicBlock* block;
60 std::vector<Instruction> instructions;
61 Mainwindow* mainwindow;
62 std::vector<BasicBlockWidget*> previous;
63 BasicBlockWidget* next[2];
64 log4cxx::LoggerPtr logger;
65 };
66
67 #endif