void CtrlRegisterList::OnDraw(wxDC& dc) { wxFont font = pxGetFixedFont(8); font.SetPixelSize(wxSize(charWidth,rowHeight-2)); dc.SetFont(font); refreshChangedRegs(); wxColor colorChanged = wxColor(0xFF0000FF); wxColor colorUnchanged = wxColor(0xFF004000); wxColor colorNormal = wxColor(0xFF600000); int startRow; GetViewStart(nullptr,&startRow); int endRow = startRow + ceil(float(GetClientSize().y) / rowHeight); // draw categories int width = GetClientSize().x; if (startRow == 0) { int piece = width /cpu->getRegisterCategoryCount(); for (int i = 0; i < cpu->getRegisterCategoryCount(); i++) { const char* name = cpu->getRegisterCategoryName(i); int x = i*piece; if (i == category) { dc.SetBrush(wxBrush(wxColor(0xFF70FF70))); dc.SetPen(wxPen(wxColor(0xFF000000))); } else { dc.SetBrush(wxBrush(wxColor(0xFFFFEFE8))); dc.SetPen(wxPen(wxColor(0xFF000000))); } if (i == cpu->getRegisterCategoryCount()-1) piece += width-piece*cpu->getRegisterCategoryCount()-1; dc.DrawRectangle(x,0,piece+1,rowHeight); // center text x += (piece-strlen(name)*charWidth)/2; dc.DrawText(wxString(name,wxConvUTF8),x,2); } } // skip the tab row startRow = std::max<int>(0,startRow-1); endRow = std::min<int>(cpu->getRegisterCount(category)-1,endRow-1); int nameStart = 17; int valueStart = startPositions[category]; ChangedReg* changedRegs = changedCategories[category]; int registerBits = cpu->getRegisterSize(category); DebugInterface::RegisterType type = cpu->getRegisterType(category); for (int i = startRow; i <= endRow; i++) { int x = valueStart; int y = rowHeight*(i+1); wxColor backgroundColor; if (currentRows[category] == i) backgroundColor = wxColor(0xFFFFCFC8); else if (i % 2) backgroundColor = wxColor(237, 242, 255, 255); else backgroundColor = wxColor(0xFFFFFFFF); dc.SetBrush(backgroundColor); dc.SetPen(backgroundColor); dc.DrawRectangle(0, y, width, rowHeight); const char* name = cpu->getRegisterName(category,i); dc.SetTextForeground(colorNormal); dc.DrawText(wxString(name,wxConvUTF8),nameStart,y+2); u128 value = cpu->getRegister(category,i); ChangedReg& changed = changedRegs[i]; switch (type) { case DebugInterface::NORMAL: // display them in 32 bit parts switch (registerBits) { case 128: { int startIndex = std::min<int>(3, maxBits / 32 - 1); if (resolvePointerStrings && cpu->isAlive()) { char *strval = cpu->stringFromPointer(value._u32[0]); if (strval) { static wxColor clr = wxColor(0xFF228822); dc.SetTextForeground(clr); dc.DrawText(wxString(strval), width - (32 * charWidth + 12), y + 2); startIndex = 0; } } int actualX = width-4-(startIndex+1)*(8*charWidth+2); x = std::max<int>(actualX,x); if (startIndex != 3) { bool c = false; for (int i = 3; i > startIndex; i--) c = c || changed.changed[i]; if (c) { dc.SetTextForeground(colorChanged); dc.DrawText(L"+",x-charWidth,y+2); } } for (int i = startIndex; i >= 0; i--) { if (changed.changed[i]) dc.SetTextForeground(colorChanged); else dc.SetTextForeground(colorUnchanged); drawU32Text(dc,value._u32[i],x,y+2); x += charWidth*8+2; } break; } case 64: { if (maxBits < 64 && changed.changed[1]) { dc.SetTextForeground(colorChanged); dc.DrawText(L"+",x-charWidth,y+2); } for (int i = 1; i >= 0; i--) { if (changed.changed[i]) dc.SetTextForeground(colorChanged); else dc.SetTextForeground(colorUnchanged); drawU32Text(dc,value._u32[i],x,y+2); x += charWidth*8+2; } break; } case 32: { if (changed.changed[0]) dc.SetTextForeground(colorChanged); else dc.SetTextForeground(colorUnchanged); drawU32Text(dc,value._u32[0],x,y+2); break; } } break; case DebugInterface::SPECIAL: // let debug interface format them and just display them { if (changed.changed[0] || changed.changed[1] || changed.changed[2] || changed.changed[3]) dc.SetTextForeground(colorChanged); else dc.SetTextForeground(colorUnchanged); dc.DrawText(cpu->getRegisterString(category,i),x,y+2); break; } } } }
void CtrlRegisterList::render(wxDC& dc) { #ifdef WIN32 wxFont font = wxFont(wxSize(charWidth,rowHeight-2),wxFONTFAMILY_DEFAULT,wxFONTSTYLE_NORMAL,wxFONTWEIGHT_NORMAL,false,L"Lucida Console"); #else wxFont font = wxFont(8,wxFONTFAMILY_DEFAULT,wxFONTSTYLE_NORMAL,wxFONTWEIGHT_NORMAL,false,L"Lucida Console"); font.SetPixelSize(wxSize(charWidth,rowHeight-2)); #endif dc.SetFont(font); // clear background wxColor white = wxColor(0xFFFFFFFF); dc.SetBrush(wxBrush(white)); dc.SetPen(wxPen(white)); wxSize size = GetSize(); dc.DrawRectangle(0,0,size.x,size.y); refreshChangedRegs(); wxColor colorChanged = wxColor(0xFF0000FF); wxColor colorUnchanged = wxColor(0xFF004000); wxColor colorNormal = wxColor(0xFF600000); // draw categories int piece = size.x/cpu->getRegisterCategoryCount(); for (int i = 0; i < cpu->getRegisterCategoryCount(); i++) { const char* name = cpu->getRegisterCategoryName(i); int x = i*piece; if (i == category) { dc.SetBrush(wxBrush(wxColor(0xFF70FF70))); dc.SetPen(wxPen(wxColor(0xFF000000))); } else { dc.SetBrush(wxBrush(wxColor(0xFFFFEFE8))); dc.SetPen(wxPen(wxColor(0xFF000000))); } dc.DrawRectangle(x-1,-1,piece+1,rowHeight+1); // center text x += (piece-strlen(name)*charWidth)/2; dc.DrawText(wxString(name,wxConvUTF8),x,1); } int nameStart = 17; int valueStart = startPositions[category]; ChangedReg* changedRegs = changedCategories[category]; int registerBits = cpu->getRegisterSize(category); DebugInterface::RegisterType type = cpu->getRegisterType(category); for (int i = 0; i < cpu->getRegisterCount(category); i++) { int x = valueStart; int y = rowHeight*(i+1); if (currentRows[category] == i) { dc.SetBrush(wxBrush(wxColor(0xFFFFEFE8))); dc.SetPen(wxPen(wxColor(0xFFFFEFE8))); dc.DrawRectangle(0,y,size.x,rowHeight); } const char* name = cpu->getRegisterName(category,i); dc.SetTextForeground(colorNormal); dc.DrawText(wxString(name,wxConvUTF8),nameStart,y+2); u128 value = cpu->getRegister(category,i); ChangedReg& changed = changedRegs[i]; switch (type) { case DebugInterface::NORMAL: // display them in 32 bit parts switch (registerBits) { case 128: { int startIndex = std::min<int>(3,maxBits/32-1); int actualX = size.x-4-(startIndex+1)*(8*charWidth+2); x = std::max<int>(actualX,x); if (startIndex != 3) { bool c = false; for (int i = 3; i > startIndex; i--) c = c || changed.changed[i]; if (c) { dc.SetTextForeground(colorChanged); dc.DrawText(L"+",x-charWidth,y+2); } } for (int i = startIndex; i >= 0; i--) { if (changed.changed[i]) dc.SetTextForeground(colorChanged); else dc.SetTextForeground(colorUnchanged); drawU32Text(dc,value._u32[i],x,y+2); x += charWidth*8+2; } break; } case 64: { if (maxBits < 64 && changed.changed[1]) { dc.SetTextForeground(colorChanged); dc.DrawText(L"+",x-charWidth,y+2); } for (int i = 1; i >= 0; i--) { if (changed.changed[i]) dc.SetTextForeground(colorChanged); else dc.SetTextForeground(colorUnchanged); drawU32Text(dc,value._u32[i],x,y+2); x += charWidth*8+2; } break; } case 32: { if (changed.changed[0]) dc.SetTextForeground(colorChanged); else dc.SetTextForeground(colorUnchanged); drawU32Text(dc,value._u32[0],x,y+2); break; } } break; case DebugInterface::SPECIAL: // let debug interface format them and just display them { if (changed.changed[0] || changed.changed[1] || changed.changed[2] || changed.changed[3]) dc.SetTextForeground(colorChanged); else dc.SetTextForeground(colorUnchanged); dc.DrawText(cpu->getRegisterString(category,i),x,y+2); break; } } } }