]> git.siccegge.de Git - frida/frida.git/blob - src/gui/widgets/BasicBlockWidget.hxx
Make signals from geiser work
[frida/frida.git] / src / gui / widgets / BasicBlockWidget.hxx
1 #ifndef INCLUDE__BasicBlockWidget_hxx
2 #define INCLUDE__BasicBlockWidget_hxx
3
4 #include "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
50 QColor setColor(const QColor& newColor) {
51 QColor lastcolor = currentColor;
52 currentColor = newColor;
53 return lastcolor;
54 }
55
56 const QColor defaultColor = QColor(0xcc, 0xcc, 0xff, 0xff);
57 const QColor highlightColor = QColor(0xff, 0x99, 0xff, 0xff);
58 private:
59 void updateFunctionName(RenameFunctionEvent* event);
60 void populateWidget();
61 void changeCommentHandler(ChangeCommentEvent* event);
62 QString formatComments(Instruction* inst);
63
64 uint32_t width, height;
65 QString name;
66 QColor currentColor;
67 std::unique_ptr<QGraphicsTextItem> _widget;
68 QTextTable* _table;
69 BasicBlock* block;
70 std::vector<Instruction> instructions;
71 Mainwindow* mainwindow;
72 std::vector<BasicBlockWidget*> previous;
73 BasicBlockWidget* next[2];
74 log4cxx::LoggerPtr logger;
75 };
76
77 #endif