Merge pull request #2729 from lioncash/magic

DolphinWX: Get rid of some magic numbers in MemoryView and MemoryWindow
This commit is contained in:
flacs 2015-07-09 16:35:58 +02:00
commit 95fed00cbb
3 changed files with 22 additions and 13 deletions

View File

@ -43,7 +43,6 @@ enum
CMemoryView::CMemoryView(DebugInterface* debuginterface, wxWindow* parent)
: wxControl(parent, wxID_ANY)
, curAddress(debuginterface->GetPC())
, debugger(debuginterface)
, align(debuginterface->GetInstructionSize(0))
, rowHeight(13)
@ -51,6 +50,8 @@ CMemoryView::CMemoryView(DebugInterface* debuginterface, wxWindow* parent)
, oldSelection(0)
, selecting(false)
, memory(0)
, curAddress(debuginterface->GetPC())
, dataType(MemoryDataType::U8)
, viewAsType(VIEWAS_FP)
{
Bind(wxEVT_PAINT, &CMemoryView::OnPaint, this);
@ -364,21 +365,21 @@ void CMemoryView::OnPaint(wxPaintEvent& event)
{
switch (dataType)
{
case 0:
case MemoryDataType::U8:
dis += StringFromFormat(" %02X %02X %02X %02X",
((word & 0xff000000) >> 24) & 0xFF,
((word & 0xff0000) >> 16) & 0xFF,
((word & 0xff00) >> 8) & 0xFF,
word & 0xff);
break;
case 1:
case MemoryDataType::U16:
dis += StringFromFormat(" %02X%02X %02X%02X",
((word & 0xff000000) >> 24) & 0xFF,
((word & 0xff0000) >> 16) & 0xFF,
((word & 0xff00) >> 8) & 0xFF,
word & 0xff);
break;
case 2:
case MemoryDataType::U32:
dis += StringFromFormat(" %02X%02X%02X%02X",
((word & 0xff000000) >> 24) & 0xFF,
((word & 0xff0000) >> 16) & 0xFF,

View File

@ -9,6 +9,11 @@
class DebugInterface;
enum class MemoryDataType
{
U8, U16, U32
};
class CMemoryView : public wxControl
{
public:
@ -22,8 +27,12 @@ public:
curAddress = addr;
Refresh();
}
int dataType; // u8,u16,u32
int curAddress; // Will be accessed by parent
void SetDataType(MemoryDataType data_type)
{
dataType = data_type;
Refresh();
}
private:
void OnPaint(wxPaintEvent& event);
@ -47,6 +56,8 @@ private:
bool selecting;
int memory;
int curAddress;
MemoryDataType dataType;
enum EViewAsType
{

View File

@ -79,7 +79,7 @@ CMemoryWindow::CMemoryWindow(wxWindow* parent, wxWindowID id,
// wxSize(20, 100), 0, nullptr, wxLB_SORT);
//sizerLeft->Add(symbols, 1, wxEXPAND);
memview = new CMemoryView(di, this);
memview->dataType = 0;
//sizerBig->Add(sizerLeft, 1, wxEXPAND);
sizerBig->Add(memview, 20, wxEXPAND);
sizerBig->Add(sizerRight, 0, wxEXPAND | wxALL, 3);
@ -281,24 +281,21 @@ void CMemoryWindow::U8(wxCommandEvent& event)
{
chk16->SetValue(0);
chk32->SetValue(0);
memview->dataType = 0;
memview->Refresh();
memview->SetDataType(MemoryDataType::U8);
}
void CMemoryWindow::U16(wxCommandEvent& event)
{
chk8->SetValue(0);
chk32->SetValue(0);
memview->dataType = 1;
memview->Refresh();
memview->SetDataType(MemoryDataType::U16);
}
void CMemoryWindow::U32(wxCommandEvent& event)
{
chk16->SetValue(0);
chk8->SetValue(0);
memview->dataType = 2;
memview->Refresh();
memview->SetDataType(MemoryDataType::U32);
}
void CMemoryWindow::onSearch(wxCommandEvent& event)