1 #ifndef INCLUDE__BasicBlockWidget_hxx
2 #define INCLUDE__BasicBlockWidget_hxx
10 #include <log4cxx/logger.h>
12 #include "disassembler/Instruction.hxx"
15 class CustomQGraphicsTextItem;
17 class RenameFunctionEvent;
18 class ChangeCommentEvent;
20 class BasicBlockWidget : public QObject, public QGraphicsItem
23 friend class CustomQGraphicsTextItem;
25 BasicBlockWidget(const QString& name, BasicBlock * block, Mainwindow * mainwindow);
27 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
29 QRectF boundingRect() const;
30 std::array<QPointF, 3> getExits() const;
32 void mouseMoveEvent(QGraphicsSceneMouseEvent * event)
33 { QGraphicsItem::mouseMoveEvent(event); scene()->update(); }
35 QPointF getEntry() const
36 { return mapToScene(QPointF(width/2, 0)); }
38 void addPrevious(BasicBlockWidget * widget)
39 { previous.push_back(widget); }
41 void addNext(BasicBlockWidget * left, BasicBlockWidget * right)
42 { next[0] = left; next[1] = right; }
44 BasicBlockWidget ** getNext()
47 QString getName() const
50 QColor setColor(const QColor& newColor) {
51 QColor lastcolor = currentColor;
52 currentColor = newColor;
56 const QColor defaultColor = QColor(0xcc, 0xcc, 0xff, 0xff);
57 const QColor highlightColor = QColor(0xff, 0x99, 0xff, 0xff);
59 void updateFunctionName(RenameFunctionEvent* event);
60 void populateWidget();
61 void changeCommentHandler(ChangeCommentEvent* event);
62 QString formatComments(Instruction* inst);
65 uint32_t width, height;
68 std::unique_ptr<QGraphicsTextItem> _widget;
71 std::vector<Instruction> instructions;
72 Mainwindow* mainwindow;
73 std::vector<BasicBlockWidget*> previous;
74 BasicBlockWidget* next[2];
75 log4cxx::LoggerPtr logger;