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=10ea402267f5fc1dd1aa0088e3dc533b28644e0e;hb=98e46099f6366309366ea54fc4b97fd5cb383fa7;hpb=78942350b02f0b23d8152d3f5b06a8d500fedaab diff --git a/src/gui/widgets/BasicBlockWidget.hxx b/src/gui/widgets/BasicBlockWidget.hxx index 10ea402..7c402c0 100644 --- a/src/gui/widgets/BasicBlockWidget.hxx +++ b/src/gui/widgets/BasicBlockWidget.hxx @@ -1,34 +1,77 @@ -#include "gui/qt.hxx" -#include "disassembler/BasicBlock.hxx" +#ifndef INCLUDE__BasicBlockWidget_hxx +#define INCLUDE__BasicBlockWidget_hxx -class BasicBlockWidget : public QGraphicsItem +#include "qt.hxx" +#include +#include +#include +#include +#include +#include + +#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); + BasicBlockWidget(const QString& name, BasicBlock * block, Mainwindow * mainwindow); + + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, + QWidget *widget); + QRectF boundingRect() const; + std::array getExits() const; + + void mouseMoveEvent(QGraphicsSceneMouseEvent * event) + { QGraphicsItem::mouseMoveEvent(event); scene()->update(); } - void addItem(uint8_t* bytes, size_t num_bytes, const QString& line); + QPointF getEntry() const + { return mapToScene(QPointF(width/2, 0)); } - QRectF boundingRect() const { - qreal penWidth = 1; - return QRectF(x - penWidth / 2, y - penWidth / 2, - dx + penWidth, dy + penWidth); - } + void addPrevious(BasicBlockWidget * widget) + { previous.push_back(widget); } - QPointF getEntry() const { - return QPointF(x + dx/2, y); + void addNext(BasicBlockWidget * left, BasicBlockWidget * right) + { next[0] = left; next[1] = right; } + + BasicBlockWidget ** getNext() + { return next; } + + QString getName() const + { return name; } + + QColor setColor(const QColor& newColor) { + QColor lastcolor = currentColor; + currentColor = newColor; + return lastcolor; } - 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, name); - _widget.render(painter); - } + const QColor defaultColor = QColor(0xcc, 0xcc, 0xff, 0xff); + const QColor highlightColor = QColor(0xff, 0x99, 0xff, 0xff); private: - int x, y, dx, dy; - QTableWidget _widget; + void updateFunctionName(RenameFunctionEvent* event); + void populateWidget(); + void changeCommentHandler(ChangeCommentEvent* event); + QString formatComments(Instruction* inst); + + uint32_t width, height; 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