#include <QKeyEvent>
#include <QScrollBar>
#include <QSize>
+#include <QString>
#include <QPainter>
#include <QPaintEvent>
charWidth_ = fontMetrics().boundingRect('X').width();
charHeight_ = fontMetrics().height();
- // Determine X coordinates of the three sub-areas
- posAddr_ = 0;
- posHex_ = 10 * charWidth_ + GAP_ADR_HEX;
- posAscii_ = posHex_ + HEXCHARS_IN_LINE * charWidth_ + GAP_HEX_ASCII;
-
setFocusPolicy(Qt::StrongFocus);
if (palette().color(QPalette::ButtonText).toHsv().value() > 127) {
}
data_size_ = size;
+ address_digits_ = (uint8_t)QString::number(data_size_, 16).length();
+
+ // Calculate X coordinates of the three sub-areas
+ posAddr_ = 0;
+ posHex_ = address_digits_ * charWidth_ + GAP_ADR_HEX;
+ posAscii_ = posHex_ + HEXCHARS_IN_LINE * charWidth_ + GAP_HEX_ASCII;
+
viewport()->update();
}
end = std::min((uint64_t)end, offset + BYTES_PER_LINE);
if (with_offset)
- dest->append(QString("%1 ").arg(row * BYTES_PER_LINE, 10, 16, QChar('0')).toUpper());
+ dest->append(QString("%1 ").arg(row * BYTES_PER_LINE, address_digits_, 16, QChar('0')).toUpper());
initialize_byte_iterator(offset);
for (size_t i = offset; i < offset + BYTES_PER_LINE; i++) {
int yStart = 2 * charHeight_;
for (size_t lineIdx = firstLineIdx, y = yStart; lineIdx < lastLineIdx; lineIdx++) {
- QString address = QString("%1").arg(lineIdx * 16, 10, 16, QChar('0')).toUpper();
+ QString address = QString("%1").arg(lineIdx * 16, address_digits_, 16, QChar('0')).toUpper();
painter.drawText(posAddr_, y, address);
y += charHeight_;
}
size_t posAddr_, posHex_, posAscii_;
size_t charWidth_, charHeight_;
size_t selectBegin_, selectEnd_, selectInit_, cursorPos_;
+ uint8_t address_digits_;
size_t current_chunk_id_, current_chunk_offset_, current_offset_;
DecodeBinaryDataChunk current_chunk_; // Cache locally so that we're not messed up when the vector is re-allocating its data