X-Git-Url: https://git.siccegge.de//index.cgi?p=frida%2Ffrida.git;a=blobdiff_plain;f=src%2Fgui%2Fwidgets%2FBasicBlockWidget.hxx;h=8ee33a56f21a43e6bcccfb26bbde48b6e395f58f;hp=6ea927b3e4706965447c0adc633f4226637691cd;hb=ac5817edcb30c89bc1e5fdcf3a124c3dc2e49630;hpb=2a014774e29e324bc5b5f26143d0384351738ca1 diff --git a/src/gui/widgets/BasicBlockWidget.hxx b/src/gui/widgets/BasicBlockWidget.hxx index 6ea927b..8ee33a5 100644 --- a/src/gui/widgets/BasicBlockWidget.hxx +++ b/src/gui/widgets/BasicBlockWidget.hxx @@ -1,36 +1,78 @@ +#ifndef INCLUDE__BasicBlockWidget_hxx +#define INCLUDE__BasicBlockWidget_hxx + #include "gui/qt.hxx" +#include "disassembler/BasicBlock.hxx" +#include +#include +#include +#include + +class Mainwindow; -class BasicBlockWidget : public QGraphicsItem +class BasicBlockWidget : public QObject, public QGraphicsItem { + Q_OBJECT public: - BasicBlockWidget() { - x = -5; - y = -20; - dx = 250; - dy = 270; - _widget.addItem("THIS"); - _widget.addItem("IS"); - _widget.addItem("A"); - _widget.addItem("TEST"); - } - - QRectF boundingRect() const - { - qreal penWidth = 1; - return QRectF(x - penWidth / 2, y - penWidth / 2, - dx + penWidth, dy + penWidth); - } - - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, - QWidget *widget) - { - painter->fillRect(x, y, dx, dy, QColor(0xcc, 0xcc, 0xff, 0xff)); - painter->setPen(QColor(0x00, 0x00, 0xff, 0xff)); - painter->drawRect(x, y, dx, dy); - painter->drawText(0, -5, "BLOCK"); - _widget.render(painter); - } + BasicBlockWidget(const QString& name, BasicBlock * block, Mainwindow * mainwindow); + + void addItem(uint8_t* bytes, size_t num_bytes, QString line, const QString& href); + + QRectF boundingRect() const { + qreal penWidth = 1; + 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 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(0, 0, width, height, QColor(0xcc, 0xcc, 0xff, 0xff)); + painter->setPen(QColor(0x00, 0x00, 0xff, 0xff)); + painter->drawRect(0, 0, width, height); + painter->drawText(5, 15, name); + } + + void addPrevious(BasicBlockWidget * widget) { + previous.push_back(widget); + } + + void addNext(BasicBlockWidget * left, BasicBlockWidget * right) { + next[0] = left; + next[1] = right; + } + + BasicBlockWidget ** getNext() { + return next; + } + + QString getName() const { + return name; + } private: - int x, y, dx, dy; - QListWidget _widget; + uint32_t width, height; + QGraphicsTextItem _widget; + QTextTable* _table; + QString name; + BasicBlock * block; + Mainwindow * mainwindow; + std::vector previous; + BasicBlockWidget* next[2]; }; + +#endif