QDebugView::QDebugView(QWidget *parent) : QWidget(parent) { QFont font = Common_GetMonospacedFont(); QFontMetrics fontmetrics(font); int cxChar = fontmetrics.averageCharWidth(); int cyLine = fontmetrics.height(); this->setMinimumSize(cxChar * 55, cyLine * 14 + cyLine / 2); this->setMaximumHeight(cyLine * 14 + cyLine / 2); setFocusPolicy(Qt::ClickFocus); memset(m_wDebugCpuR, 255, sizeof(m_wDebugCpuR)); memset(m_okDebugCpuRChanged, 1, sizeof(m_okDebugCpuRChanged)); }
QTeletypeView::QTeletypeView() { setMinimumSize(320, 180); m_log = new QTextEdit(this); QFont font = Common_GetMonospacedFont(); m_log->setReadOnly(true); m_log->setFont(font); m_log->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); QVBoxLayout *vboxlayout = new QVBoxLayout; vboxlayout->setMargin(0); vboxlayout->setSpacing(4); vboxlayout->addWidget(m_log); this->setLayout(vboxlayout); }
QConsoleView::QConsoleView() { setMinimumSize(320, 120); m_log = new QTextEdit(); m_edit = new QLineEdit(); QVBoxLayout *vboxlayout = new QVBoxLayout; vboxlayout->setMargin(0); vboxlayout->setSpacing(4); vboxlayout->addWidget(m_log); vboxlayout->addWidget(m_edit); this->setLayout(vboxlayout); QFont font = Common_GetMonospacedFont(); m_log->setReadOnly(true); m_log->setFont(font); m_edit->setFont(font); QObject::connect(m_edit, SIGNAL(returnPressed()), this, SLOT(execConsoleCommand())); this->print(_T("Use 'h' command to show help.\r\n\r\n")); }
void QDebugView::paintEvent(QPaintEvent * /*event*/) { if (g_pBoard == NULL) return; QPainter painter(this); painter.fillRect(0,0, this->width(), this->height(), Qt::white); QFont font = Common_GetMonospacedFont(); painter.setFont(font); QFontMetrics fontmetrics(font); int cxChar = fontmetrics.averageCharWidth(); int cyLine = fontmetrics.height(); CProcessor* pDebugPU = g_pBoard->GetCPU(); ASSERT(pDebugPU != NULL); WORD* arrR = m_wDebugCpuR; BOOL* arrRChanged = m_okDebugCpuRChanged; drawProcessor(painter, pDebugPU, cxChar * 2, 1 * cyLine, arrR, arrRChanged); // Draw stack drawMemoryForRegister(painter, 6, pDebugPU, 35 * cxChar, 1 * cyLine); drawPorts(painter, 57 * cxChar, 1 * cyLine); // Draw focus rect if (hasFocus()) { QStyleOptionFocusRect option; option.initFrom(this); option.state |= QStyle::State_KeyboardFocusChange; option.backgroundColor = QColor(Qt::gray); option.rect = this->rect(); style()->drawPrimitive(QStyle::PE_FrameFocusRect, &option, &painter, this); } }
QMemoryView::QMemoryView() { m_ByteMode = false; m_wBaseAddress = 0; m_cyLineMemory = 0; m_nPageSize = 0; QFont font = Common_GetMonospacedFont(); QFontMetrics fontmetrics(font); int cxChar = fontmetrics.averageCharWidth(); int cyLine = fontmetrics.height(); m_cyLine = cyLine; this->setFont(font); this->setMinimumSize(cxChar * 68, cyLine * 9 + cyLine / 2); m_scrollbar = new QScrollBar(Qt::Vertical, this); m_scrollbar->setRange(0, 65536 - 16); m_scrollbar->setSingleStep(16); QObject::connect(m_scrollbar, SIGNAL(valueChanged(int)), this, SLOT(scrollValueChanged())); setFocusPolicy(Qt::ClickFocus); }
void QMemoryView::paintEvent(QPaintEvent * /*event*/) { if (g_pBoard == NULL) return; QPainter painter(this); painter.fillRect(0,0, this->width(), this->height(), Qt::white); QFont font = Common_GetMonospacedFont(); painter.setFont(font); QFontMetrics fontmetrics(font); int cxChar = fontmetrics.averageCharWidth(); int cyLine = fontmetrics.height(); CProcessor* pDebugPU = g_pBoard->GetCPU(); ASSERT(pDebugPU != NULL); QColor colorText = painter.pen().color(); m_cyLineMemory = cyLine; TCHAR buffer[7]; const TCHAR* ADDRESS_LINE = _T(" address 0 2 4 6 10 12 14 16"); painter.drawText(0, cyLine, ADDRESS_LINE); // Calculate m_nPageSize m_nPageSize = this->height() / cyLine - 1; quint16 address = m_wBaseAddress; int y = 2 * cyLine; for (;;) { // Draw lines DrawOctalValue(painter, 2 * cxChar, y, address); int x = 10 * cxChar; ushort wchars[16]; for (int j = 0; j < 8; j++) { // Draw words as octal value // Get word from memory quint16 word = 0; int addrtype; bool okHalt = false; quint16 wChanged = 0; okHalt = pDebugPU->IsHaltMode(); word = g_pBoard->GetWordView(address, okHalt, false, &addrtype); wChanged = Emulator_GetChangeRamStatus(address); if ((addrtype & (ADDRTYPE_IO | ADDRTYPE_DENY)) == 0) { painter.setPen(wChanged != 0 ? Qt::red : colorText); if (m_ByteMode) { PrintOctalValue(buffer, (word & 0xff)); painter.drawText(x, y, buffer + 3); PrintOctalValue(buffer, (word >> 8)); painter.drawText(x + 3 * cxChar + cxChar / 2, y, buffer + 3); } else DrawOctalValue(painter, x, y, word); } // Prepare characters to draw at right quint8 ch1 = (quint8)(word & 0xff); // LOBYTE ushort wch1 = Translate_BK_Unicode(ch1); if (ch1 < 32) wch1 = 0x00b7; wchars[j * 2] = wch1; quint8 ch2 = (quint8)((word >> 8) & 0xff); // HIBYTE ushort wch2 = Translate_BK_Unicode(ch2); if (ch2 < 32) wch2 = 0x00b7; wchars[j * 2 + 1] = wch2; address += 2; x += 7 * cxChar; }