From: Christoph Egger Date: Tue, 3 Jun 2014 13:25:14 +0000 (+0200) Subject: Move stuff for BasicBlockWidget out of the header file X-Git-Tag: v0.1~182 X-Git-Url: https://git.siccegge.de//index.cgi?a=commitdiff_plain;h=78942350b02f0b23d8152d3f5b06a8d500fedaab;p=frida%2Ffrida.git Move stuff for BasicBlockWidget out of the header file --- diff --git a/src/gui/widgets/BasicBlockWidget.cxx b/src/gui/widgets/BasicBlockWidget.cxx index b28b04f..689223c 100644 --- a/src/gui/widgets/BasicBlockWidget.cxx +++ b/src/gui/widgets/BasicBlockWidget.cxx @@ -1,3 +1,63 @@ +#include "BasicBlockWidget.hxx" +BasicBlockWidget::BasicBlockWidget(const QString& name) + : x(-5), y(-20) + , dx(270), dy(45) + , name(name) { + _widget.setGridStyle(Qt::NoPen); + _widget.setMinimumHeight(_widget.rowHeight(0) + 10); + _widget.setMaximumHeight(20); + _widget.resizeColumnToContents(0); + _widget.resizeColumnToContents(1); + _widget.resizeColumnToContents(2); + _widget.updateGeometry(); + _widget.setMaximumWidth(260); + _widget.setColumnCount(3); + _widget.verticalHeader()->hide(); + _widget.horizontalHeader()->hide(); + dx = _widget.rowHeight(0) + 20; + if (dx < 270) dx = 270; +} +void BasicBlockWidget::addItem(uint8_t* bytes, size_t num_bytes, + const QString& line) { + size_t current_row = _widget.rowCount(); + int column_width; + QString bytestring; + + for (size_t i(0); i < num_bytes; ++i) { + const char * hexdigits = "0123456789ABCDEF"; + bytestring += hexdigits[(bytes[i] >> 4) & 0xF]; + bytestring += hexdigits[bytes[i] & 0xF]; + bytestring += ' '; + } + + _widget.setRowCount(current_row + 1); + + _widget.setItem(current_row, 0, new QTableWidgetItem(bytestring)); + _widget.setItem(current_row, 1, new QTableWidgetItem(line)); + _widget.setItem(current_row, 2, new QTableWidgetItem("")); + _widget.updateGeometry(); + + _widget.resizeColumnToContents(0); + _widget.resizeColumnToContents(1); + _widget.resizeColumnToContents(2); + + _widget.resizeRowToContents(current_row); + + column_width = + _widget.columnWidth(0) + + _widget.columnWidth(1) + + _widget.columnWidth(2) + + 2; + + _widget.setMinimumWidth(column_width); + _widget.setMinimumHeight(_widget.rowHeight(1) * (_widget.rowCount()) + 2); + _widget.setMaximumHeight(_widget.rowHeight(1) * (_widget.rowCount()) + 2); + + + dy = _widget.rowHeight(0) * (_widget.rowCount()) + 25; + dx = column_width + 10; + if (dx < 270) dx = 270; +} diff --git a/src/gui/widgets/BasicBlockWidget.hxx b/src/gui/widgets/BasicBlockWidget.hxx index 557f556..10ea402 100644 --- a/src/gui/widgets/BasicBlockWidget.hxx +++ b/src/gui/widgets/BasicBlockWidget.hxx @@ -1,80 +1,25 @@ #include "gui/qt.hxx" +#include "disassembler/BasicBlock.hxx" class BasicBlockWidget : public QGraphicsItem { public: - BasicBlockWidget(const QString& name) - : x(-5), y(-20) - , dx(270), dy(45) - , name(name) { - _widget.setGridStyle(Qt::NoPen); - _widget.setMinimumHeight(_widget.rowHeight(0) + 10); - _widget.setMaximumHeight(20); - _widget.resizeColumnToContents(0); - _widget.resizeColumnToContents(1); - _widget.resizeColumnToContents(2); - _widget.updateGeometry(); - _widget.setMaximumWidth(260); - _widget.setColumnCount(3); - _widget.verticalHeader()->hide(); - _widget.horizontalHeader()->hide(); - dx = _widget.rowHeight(0) + 20; - if (dx < 270) dx = 270; - } - - void addItem(uint8_t* bytes, size_t num_bytes, - const QString& line) { - size_t current_row = _widget.rowCount(); - int column_width; - - QString bytestring; - - for (size_t i(0); i < num_bytes; ++i) { - const char * hexdigits = "0123456789ABCDEF"; - bytestring += hexdigits[(bytes[i] >> 4) & 0xF]; - bytestring += hexdigits[bytes[i] & 0xF]; - bytestring += ' '; - } - - _widget.setRowCount(current_row + 1); - - _widget.setItem(current_row, 0, new QTableWidgetItem(bytestring)); - _widget.setItem(current_row, 1, new QTableWidgetItem(line)); - _widget.setItem(current_row, 2, new QTableWidgetItem("")); - _widget.updateGeometry(); - - _widget.resizeColumnToContents(0); - _widget.resizeColumnToContents(1); - _widget.resizeColumnToContents(2); + BasicBlockWidget(const QString& name); - _widget.resizeRowToContents(current_row); + void addItem(uint8_t* bytes, size_t num_bytes, const QString& line); - column_width = - _widget.columnWidth(0) + - _widget.columnWidth(1) + - _widget.columnWidth(2) + - 2; - - _widget.setMinimumWidth(column_width); - _widget.setMinimumHeight(_widget.rowHeight(1) * (_widget.rowCount()) + 2); - _widget.setMaximumHeight(_widget.rowHeight(1) * (_widget.rowCount()) + 2); - - - dy = _widget.rowHeight(0) * (_widget.rowCount()) + 25; - dx = column_width + 10; - if (dx < 270) dx = 270; - } - - QRectF boundingRect() const - { + QRectF boundingRect() const { qreal penWidth = 1; return QRectF(x - penWidth / 2, y - penWidth / 2, dx + penWidth, dy + penWidth); } + QPointF getEntry() const { + return QPointF(x + dx/2, y); + } + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, - QWidget *widget) - { + 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); @@ -85,4 +30,5 @@ private: int x, y, dx, dy; QTableWidget _widget; QString name; + BasicBlock * block; };