]> git.siccegge.de Git - frida/frida.git/blob - src/gui/widgets/BasicBlockWidget.cxx
0164bdc9513d67e541a2415ae7aa8cb1f9117a1a
[frida/frida.git] / src / gui / widgets / BasicBlockWidget.cxx
1 #include "BasicBlockWidget.hxx"
2
3 BasicBlockWidget::BasicBlockWidget(const QString& name, BasicBlock * block)
4 : x(-5), y(-20)
5 , dx(270), dy(45)
6 , name(name)
7 , block(block) {
8 next[0] = NULL; next[1] = NULL;
9 _widget.setGridStyle(Qt::NoPen);
10 _widget.setMinimumHeight(_widget.rowHeight(0) + 10);
11 _widget.setMaximumHeight(20);
12 _widget.resizeColumnToContents(0);
13 _widget.resizeColumnToContents(1);
14 _widget.resizeColumnToContents(2);
15 _widget.updateGeometry();
16 _widget.setMaximumWidth(260);
17 _widget.setColumnCount(3);
18 _widget.verticalHeader()->hide();
19 _widget.horizontalHeader()->hide();
20 dx = _widget.rowHeight(0) + 20;
21 if (dx < 270) dx = 270;
22 }
23
24 void BasicBlockWidget::addItem(uint8_t* bytes, size_t num_bytes,
25 const QString& line) {
26 size_t current_row = _widget.rowCount();
27 int column_width;
28
29 QString bytestring;
30
31 for (size_t i(0); i < num_bytes; ++i) {
32 const char * hexdigits = "0123456789ABCDEF";
33 bytestring += hexdigits[(bytes[i] >> 4) & 0xF];
34 bytestring += hexdigits[bytes[i] & 0xF];
35 bytestring += ' ';
36 }
37
38 _widget.setRowCount(current_row + 1);
39
40 _widget.setItem(current_row, 0, new QTableWidgetItem(bytestring));
41 _widget.setItem(current_row, 1, new QTableWidgetItem(line));
42 _widget.setItem(current_row, 2, new QTableWidgetItem(""));
43 _widget.updateGeometry();
44
45 _widget.resizeColumnToContents(0);
46 _widget.resizeColumnToContents(1);
47 _widget.resizeColumnToContents(2);
48
49 _widget.resizeRowToContents(current_row);
50
51 column_width =
52 _widget.columnWidth(0) +
53 _widget.columnWidth(1) +
54 _widget.columnWidth(2) +
55 2;
56
57 _widget.setMinimumWidth(column_width);
58 _widget.setMinimumHeight(_widget.rowHeight(0) * (_widget.rowCount()) + 2);
59 _widget.setMaximumHeight(_widget.rowHeight(0) * (_widget.rowCount()) + 2);
60
61
62 dy = _widget.rowHeight(0) * (_widget.rowCount()) + 25;
63 dx = column_width + 10;
64 if (dx < 270) dx = 270;
65 }