X-Git-Url: https://git.siccegge.de//index.cgi?p=frida%2Ffrida.git;a=blobdiff_plain;f=src%2Fgui%2Fwidgets%2FBasicBlockWidget.hxx;h=7c402c0a663bb4f89d8b0216ce6280aee5e752a6;hp=2dcc80c237b0890e5cfe3e1ecd39c617d73244b5;hb=98e46099f6366309366ea54fc4b97fd5cb383fa7;hpb=9e283567ac56a6433e832d0fa38cf534a0cb8f9f diff --git a/src/gui/widgets/BasicBlockWidget.hxx b/src/gui/widgets/BasicBlockWidget.hxx index 2dcc80c..7c402c0 100644 --- a/src/gui/widgets/BasicBlockWidget.hxx +++ b/src/gui/widgets/BasicBlockWidget.hxx @@ -1,72 +1,77 @@ #ifndef INCLUDE__BasicBlockWidget_hxx #define INCLUDE__BasicBlockWidget_hxx -#include "gui/qt.hxx" -#include "disassembler/BasicBlock.hxx" +#include "qt.hxx" #include #include #include #include +#include +#include -class BasicBlockWidget : public QGraphicsItem +#include "disassembler/Instruction.hxx" + +class Mainwindow; +class CustomQGraphicsTextItem; +class BasicBlock; +class RenameFunctionEvent; +class ChangeCommentEvent; + +class BasicBlockWidget : public QObject, public QGraphicsItem { + Q_OBJECT + friend class CustomQGraphicsTextItem; public: - BasicBlockWidget(const QString& name, BasicBlock * block); + BasicBlockWidget(const QString& name, BasicBlock * block, Mainwindow * mainwindow); - void addItem(uint8_t* bytes, size_t num_bytes, const QString& line); + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, + QWidget *widget); + QRectF boundingRect() const; + std::array getExits() const; - 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(); } - void mouseMoveEvent(QGraphicsSceneMouseEvent * event) { - QGraphicsItem::mouseMoveEvent(event); - scene()->update(); - } + QPointF getEntry() const + { return mapToScene(QPointF(width/2, 0)); } - QPointF getEntry() const { - return mapToScene(QPointF(width/2, 0)); - } + void addPrevious(BasicBlockWidget * widget) + { previous.push_back(widget); } - std::array getExits() const { - return { { mapToScene(QPointF( width/3, height)), - mapToScene(QPointF( width/2, height)), - mapToScene(QPointF(2*width/3, height)) } }; - } + void addNext(BasicBlockWidget * left, BasicBlockWidget * right) + { next[0] = left; next[1] = right; } - 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); - if (_widget.text() != "") - _widget.render(painter, QPoint(5, 20)); - } - - void addPrevious(BasicBlockWidget * widget) { - previous.push_back(widget); - } + BasicBlockWidget ** getNext() + { return next; } - void addNext(BasicBlockWidget * left, BasicBlockWidget * right) { - next[0] = left; - next[1] = right; - } + QString getName() const + { return name; } - BasicBlockWidget ** getNext() { - return next; + QColor setColor(const QColor& newColor) { + QColor lastcolor = currentColor; + currentColor = newColor; + return lastcolor; } + const QColor defaultColor = QColor(0xcc, 0xcc, 0xff, 0xff); + const QColor highlightColor = QColor(0xff, 0x99, 0xff, 0xff); private: + void updateFunctionName(RenameFunctionEvent* event); + void populateWidget(); + void changeCommentHandler(ChangeCommentEvent* event); + QString formatComments(Instruction* inst); + uint32_t width, height; - QLabel _widget; QString name; - BasicBlock * block; + QColor currentColor; + std::unique_ptr _widget; + QTextTable* _table; + BasicBlock* block; + std::vector instructions; + Mainwindow* mainwindow; std::vector previous; BasicBlockWidget* next[2]; + log4cxx::LoggerPtr logger; }; #endif