X-Git-Url: https://git.siccegge.de//index.cgi?p=frida%2Ffrida.git;a=blobdiff_plain;f=src%2Fgui%2Fwidgets%2FBasicBlockWidget.hxx;h=5fda53e68d5beb93420fe24ae59bd80484c4b3dd;hp=10ea402267f5fc1dd1aa0088e3dc533b28644e0e;hb=9230b2cf1a95c50e2bf0b4ca8e214bddd45cf65f;hpb=78942350b02f0b23d8152d3f5b06a8d500fedaab diff --git a/src/gui/widgets/BasicBlockWidget.hxx b/src/gui/widgets/BasicBlockWidget.hxx index 10ea402..5fda53e 100644 --- a/src/gui/widgets/BasicBlockWidget.hxx +++ b/src/gui/widgets/BasicBlockWidget.hxx @@ -1,34 +1,71 @@ +#ifndef INCLUDE__BasicBlockWidget_hxx +#define INCLUDE__BasicBlockWidget_hxx + #include "gui/qt.hxx" #include "disassembler/BasicBlock.hxx" +#include +#include +#include class BasicBlockWidget : public QGraphicsItem { public: - BasicBlockWidget(const QString& name); + BasicBlockWidget(const QString& name, BasicBlock * block); void addItem(uint8_t* bytes, size_t num_bytes, const QString& line); QRectF boundingRect() const { qreal penWidth = 1; - return QRectF(x - penWidth / 2, y - penWidth / 2, - dx + penWidth, dy + penWidth); + QRectF result(- penWidth / 2, - penWidth / 2, + width + penWidth, height + penWidth); + return result; } + void mouseMoveEvent(QGraphicsSceneMouseEvent * event) { + QGraphicsItem::mouseMoveEvent(event); + scene()->update(); + } + QPointF getEntry() const { - return QPointF(x + dx/2, y); + return mapToScene(QPointF(width/2, 0)); } + std::array getExits() const { + return { { mapToScene(QPointF( width/3, height)), + mapToScene(QPointF( width/2, height)), + mapToScene(QPointF(2*width/3, height)) } }; + } + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { - painter->fillRect(x, y, dx, dy, QColor(0xcc, 0xcc, 0xff, 0xff)); + painter->fillRect(0, 0, width, height, QColor(0xcc, 0xcc, 0xff, 0xff)); painter->setPen(QColor(0x00, 0x00, 0xff, 0xff)); - painter->drawRect(x, y, dx, dy); - painter->drawText(0, -5, name); - _widget.render(painter); + painter->drawRect(0, 0, width, height); + painter->drawText(5, 15, name); + if (_widget.rowCount() != 0) + _widget.render(painter, QPoint(5, 20)); } + + void addPrevious(BasicBlockWidget * widget) { + previous.push_back(widget); + } + + void addNext(BasicBlockWidget * left, BasicBlockWidget * right) { + next[0] = left; + next[1] = right; + } + + BasicBlockWidget ** getNext() { + return next; + } + private: - int x, y, dx, dy; + uint32_t width, height; QTableWidget _widget; QString name; BasicBlock * block; + std::vector previous; + BasicBlockWidget* next[2]; }; + +#endif