]> git.siccegge.de Git - frida/frida.git/blob - src/gui/widgets/BasicBlockWidget.hxx
Make link to local functions clickable
[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 "disassembler/BasicBlock.hxx"
6 #include <vector>
7 #include <cassert>
8 #include <tuple>
9 #include <array>
10
11 class Mainwindow;
12
13 class BasicBlockWidget : public QGraphicsItem
14 {
15 public:
16 BasicBlockWidget(const QString& name, BasicBlock * block, Mainwindow * mainwindow);
17
18 void addItem(uint8_t* bytes, size_t num_bytes, QString line, const QString& href);
19
20 QRectF boundingRect() const {
21 qreal penWidth = 1;
22 QRectF result(- penWidth / 2, - penWidth / 2,
23 width + penWidth, height + penWidth);
24 return result;
25 }
26
27 void mouseMoveEvent(QGraphicsSceneMouseEvent * event) {
28 QGraphicsItem::mouseMoveEvent(event);
29 scene()->update();
30 }
31
32 QPointF getEntry() const {
33 return mapToScene(QPointF(width/2, 0));
34 }
35
36 std::array<QPointF, 3> getExits() const {
37 return { { mapToScene(QPointF( width/3, height)),
38 mapToScene(QPointF( width/2, height)),
39 mapToScene(QPointF(2*width/3, height)) } };
40 }
41
42 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
43 QWidget *widget) {
44 painter->fillRect(0, 0, width, height, QColor(0xcc, 0xcc, 0xff, 0xff));
45 painter->setPen(QColor(0x00, 0x00, 0xff, 0xff));
46 painter->drawRect(0, 0, width, height);
47 painter->drawText(5, 15, name);
48 }
49
50 void addPrevious(BasicBlockWidget * widget) {
51 previous.push_back(widget);
52 }
53
54 void addNext(BasicBlockWidget * left, BasicBlockWidget * right) {
55 next[0] = left;
56 next[1] = right;
57 }
58
59 BasicBlockWidget ** getNext() {
60 return next;
61 }
62
63 QString getName() const {
64 return name;
65 }
66 private:
67 uint32_t width, height;
68 QGraphicsProxyWidget _proxy;
69 QGridLayout _layout;
70 QLabel _widget;
71 QString name;
72 BasicBlock * block;
73 Mainwindow * mainwindow;
74 std::vector<BasicBlockWidget*> previous;
75 BasicBlockWidget* next[2];
76 };
77
78 #endif