| 304 | } |
| 305 | |
| 306 | void HexWidget::paintEvent(QPaintEvent *event) { |
| 307 | QRect r; |
| 308 | QPainter painter(viewport()); |
| 309 | const QRect ®ion = event->rect(); |
| 310 | const QPalette &pal = viewport()->palette(); |
| 311 | const QColor &cText = pal.color(QPalette::WindowText); |
| 312 | const QColor &cBg = pal.color(QPalette::Window); |
| 313 | const QColor &cSelected = pal.color(QPalette::Highlight); |
| 314 | const QColor cModified = QColor(Qt::blue).lighter(160); |
| 315 | const QColor cBoth = QColor(Qt::green).lighter(160); |
| 316 | const int xOffset = horizontalScrollBar()->value(); |
| 317 | const int xAddr = m_addrLoc - xOffset; |
| 318 | |
| 319 | painter.setRenderHint(QPainter::Antialiasing); |
| 320 | painter.fillRect(region, cBg); |
| 321 | |
| 322 | painter.setPen(Qt::gray); |
| 323 | painter.drawLine(m_dataLine - xOffset, region.top(), m_dataLine - xOffset, height()); |
| 324 | if (m_asciiArea) { |
| 325 | painter.drawLine(m_asciiLine - xOffset, region.top(), m_asciiLine - xOffset, height()); |
| 326 | } |
| 327 | |
| 328 | for (int row = 0, y = m_charHeight; row <= m_visibleRows; row++, y += m_charHeight) { |
| 329 | int xData = m_dataLoc - xOffset; |
| 330 | int xAscii = m_asciiLoc - xOffset; |
| 331 | int lineAddr = m_lineStart + row * m_bytesPerLine; |
| 332 | int addr = lineAddr; |
| 333 | if (addr + m_base > 0xffffff) { break; } |
| 334 | painter.setPen(cText); |
| 335 | painter.drawText(xAddr, y, int2hex(m_base + lineAddr, 6)); |
| 336 | for (int col = 0; col < m_bytesPerLine && addr < m_maxOffset; col++) { |
| 337 | addr = lineAddr + col; |
| 338 | |
| 339 | painter.setPen(cText); |
| 340 | uint8_t data = static_cast<uint8_t>(m_data[addr]); |
| 341 | uint8_t flags = debug.addr[addr + m_base]; |
| 342 | bool selected = addr >= m_selectStart && addr <= m_selectEnd; |
| 343 | bool modified = !m_modified.isEmpty() && m_modified[addr]; |
| 344 | |
| 345 | QFont font = painter.font(); |
| 346 | const QFont fontorig = painter.font(); |
| 347 | |
| 348 | if (flags & DBG_MASK_READ) { |
| 349 | font.setWeight(QFont::DemiBold); |
| 350 | painter.setFont(font); |
| 351 | painter.setPen(Qt::darkGreen); |
| 352 | } |
| 353 | if (flags & DBG_MASK_WRITE) { |
| 354 | font.setWeight(QFont::DemiBold); |
| 355 | painter.setFont(font); |
| 356 | painter.setPen(Qt::darkYellow); |
| 357 | } |
| 358 | if (flags & DBG_MASK_EXEC) { |
| 359 | font.setWeight(QFont::DemiBold); |
| 360 | painter.setFont(font); |
| 361 | painter.setPen(Qt::darkRed); |
| 362 | } |
| 363 | |