convert the register window to wxGrid, allows multiplatform colors. fix wxw debug build error msg.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1454 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Shawn Hoffman 2008-12-09 05:29:14 +00:00
parent 5ede71fb84
commit 668337eb84
8 changed files with 2541 additions and 165 deletions

View File

@ -2239,7 +2239,7 @@ static const char *gprnames[] =
"r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31"
};
const char *GetGRPName(unsigned int index)
const char *GetGPRName(unsigned int index)
{
if (index < 32)
return gprnames[index];

File diff suppressed because it is too large Load Diff

View File

@ -19,140 +19,59 @@
#include "RegisterView.h"
#include "PowerPC/PowerPC.h"
extern const char* GetGRPName(unsigned int index);
extern const char* GetGPRName(unsigned int index);
BEGIN_EVENT_TABLE(CRegisterView, wxListCtrl)
END_EVENT_TABLE()
CRegisterView::CRegisterView(wxWindow* parent, const wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
: wxListCtrl(parent, id, pos, size, style)
wxString CRegTable::GetValue(int row, int col)
{
InsertColumn(1, wxT("Reg 16-31"), wxLIST_FORMAT_LEFT, 100);
InsertColumn(0, wxT("Value"), wxLIST_FORMAT_CENTER, 80);
InsertColumn(0, wxT("Reg 0-15"), wxLIST_FORMAT_LEFT, 100);
InsertColumn(0, wxT("Value"), wxLIST_FORMAT_CENTER, 80);
if (col % 2 == 0)
return wxString::FromAscii(GetGPRName(16*col/2 + row));
else
return wxString::Format(wxT("0x%08x"), GPR(col == 1 ? row : 16 + row));
}
SetFont(wxFont(9, wxSWISS, wxNORMAL, wxNORMAL, false, wxT("Segoe UI")));
void CRegTable::SetValue(int, int, const wxString &)
{
}
for (int i = 0; i < 16; i++)
{
// 0-15
int Item = InsertItem(0, wxString::FromAscii(GetGRPName(i)));
wxGridCellAttr *CRegTable::GetAttr(int row, int col, wxGridCellAttr::wxAttrKind)
{
wxGridCellAttr *attr = new wxGridCellAttr();
// 16-31
SetItem(Item, 2, wxString::FromAscii(GetGRPName(16 + i)));
attr->SetBackgroundColour(wxColour(wxT("#FFFFFF")));
attr->SetFont(wxFont(9, wxMODERN, wxNORMAL, wxNORMAL, false, wxT("monospace")));
attr->SetAlignment(col & 1 ? wxALIGN_CENTER : wxALIGN_LEFT, wxALIGN_CENTER);
// just for easy sort
if (col % 2 == 0)
attr->SetTextColour(wxColour(wxT("#000000")));
else
attr->SetTextColour(((CRegisterView*)GetView())->m_CachedRegHasChanged[col == 1 ? row : 16 + row]
? wxColor(wxT("#FF0000")) : wxColor(wxT("#000000")));
wxListItem item;
item.SetId(Item);
item.SetBackgroundColour(0xFFFFFF);
item.SetData(i);
SetItem(item);
}
Refresh();
attr->IncRef();
return attr;
}
void
CRegisterView::Update()
CRegisterView::CRegisterView(wxWindow *parent, wxWindowID id)
: wxGrid(parent, id)
{
for (size_t i = 0; i < 16; i++)
{
// 0-15
if (m_CachedRegs[i] != GPR(i))
{
m_CachedRegHasChanged[i] = true;
}
else
{
m_CachedRegHasChanged[i] = false;
}
SetTable(new CRegTable(), true);
EnableGridLines(false);
SetRowLabelSize(0);
SetColLabelSize(0);
DisableDragGridSize();
AutoSizeColumns();
}
void CRegisterView::Update()
{
ForceRefresh();
for (size_t i = 0; i < 32; ++i)
{
m_CachedRegHasChanged[i] = (m_CachedRegs[i] != GPR(i));
m_CachedRegs[i] = GPR(i);
// 16-31
if (m_CachedRegs[16 + i] != GPR(16 + i))
{
m_CachedRegHasChanged[16 + i] = true;
}
else
{
m_CachedRegHasChanged[16 + i] = false;
}
m_CachedRegs[16 + i] = GPR(16 + i);
}
Refresh();
}
void CRegisterView::Refresh()
{
for (size_t i = 0; i < 16; i++)
{
wxListItem item;
item.SetId(i);
item.SetColumn(1);
char temp[16];
sprintf(temp, "0x%08x",m_CachedRegs[i]);
item.SetText(wxString::FromAscii(temp));
SetItem(item);
}
for (size_t i = 0; i < 16; i++)
{
wxListItem item;
item.SetId(i);
item.SetColumn(3);
char temp[16];
sprintf(temp, "0x%08x",m_CachedRegs[16 + i]);
item.SetText(wxString::FromAscii(temp));
SetItem(item);
}
}
#ifdef _WIN32
bool
CRegisterView::MSWDrawSubItem(wxPaintDC& rPainDC, int item, int subitem)
{
bool Result = false;
#ifdef __WXMSW__
switch (subitem)
{
case 1:
case 3:
{
int Register = (subitem == 1) ? item : item + 16;
const wxChar* bgColor = _T("#ffffff");
wxBrush bgBrush(bgColor);
wxPen bgPen(bgColor);
wxRect SubItemRect;
this->GetSubItemRect(item, subitem, SubItemRect);
rPainDC.SetBrush(bgBrush);
rPainDC.SetPen(bgPen);
rPainDC.DrawRectangle(SubItemRect);
if (m_CachedRegHasChanged[Register])
{
rPainDC.SetTextForeground(_T("#FF0000"));
}
else
{
rPainDC.SetTextForeground(_T("#000000"));
}
wxString text;
text.Printf(wxT("0x%08x"), m_CachedRegs[Register]);
rPainDC.DrawText(text, SubItemRect.GetLeft() + 10, SubItemRect.GetTop() + 4);
return(true);
}
break;
}
#endif
return(Result);
}
#endif

View File

@ -18,30 +18,35 @@
#ifndef __REGISTERVIEW_h__
#define __REGISTERVIEW_h__
#include <wx/listctrl.h>
#include <wx/grid.h>
#include "Common.h"
class CRegTable
: public wxGridTableBase
{
public:
CRegTable(){;}
int GetNumberCols(void){return 4;}
int GetNumberRows(void){return 16;}
bool IsEmptyCell(int, int){return false;}
wxString GetValue(int, int);
void SetValue(int, int, const wxString &);
wxGridCellAttr *GetAttr(int, int, wxGridCellAttr::wxAttrKind);
private:
DECLARE_NO_COPY_CLASS(CRegTable);
};
class CRegisterView
: public wxListCtrl
: public wxGrid
{
public:
CRegisterView(wxWindow* parent, const wxWindowID id, const wxPoint& pos, const wxSize& size, long style);
CRegisterView(wxWindow* parent, wxWindowID id);
void Update();
void Refresh();
private:
DECLARE_EVENT_TABLE()
u32 m_CachedRegs[32];
bool m_CachedRegHasChanged[32];
#ifdef _WIN32
virtual bool MSWDrawSubItem(wxPaintDC& rPainDC, int item, int subitem);
#endif
};
#endif

View File

@ -25,20 +25,18 @@ extern const char* GetGRPName(unsigned int index);
BEGIN_EVENT_TABLE(CRegisterWindow, wxDialog)
EVT_CLOSE(CRegisterWindow::OnClose)
EVT_MENU(wxID_REFRESH, CRegisterWindow::OnRefresh)
END_EVENT_TABLE()
CRegisterWindow::CRegisterWindow(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& position, const wxSize& size, long style)
: wxDialog(parent, id, title, position, size, style)
, m_GPRListView(NULL)
, m_GPRGridView(NULL)
{
CreateGUIControls();
}
CRegisterWindow::~CRegisterWindow()
{}
{
}
void CRegisterWindow::Save(IniFile& _IniFile) const
{
@ -48,7 +46,6 @@ void CRegisterWindow::Save(IniFile& _IniFile) const
_IniFile.Set("RegisterWindow", "h", GetSize().GetHeight());
}
void CRegisterWindow::Load(IniFile& _IniFile)
{
int x,y,w,h;
@ -59,39 +56,30 @@ void CRegisterWindow::Load(IniFile& _IniFile)
SetSize(x, y, w, h);
}
void CRegisterWindow::CreateGUIControls()
{
SetTitle(wxT("Registers"));
SetIcon(wxNullIcon);
SetSize(8, 8, 400, 370);
Center();
m_GPRListView = new CRegisterView(this, ID_GPR, wxDefaultPosition, GetSize(),
wxLC_REPORT | wxSUNKEN_BORDER | wxLC_ALIGN_LEFT | wxLC_SINGLE_SEL | wxLC_SORT_ASCENDING);
wxBoxSizer *sGrid = new wxBoxSizer(wxVERTICAL);
m_GPRGridView = new CRegisterView(this, ID_GPR);
sGrid->Add(m_GPRGridView, 1, wxGROW);
SetSizer(sGrid);
sGrid->SetSizeHints(this);
NotifyUpdate();
}
void CRegisterWindow::OnClose(wxCloseEvent& /*event*/)
void CRegisterWindow::OnClose(wxCloseEvent& WXUNUSED (event))
{
Hide();
}
void CRegisterWindow::OnRefresh(wxCommandEvent& WXUNUSED (event))
{
m_GPRListView->Refresh();
m_GPRListView->Update();
}
void CRegisterWindow::NotifyUpdate()
{
if (m_GPRListView != NULL)
{
if (m_GPRGridView != NULL)
{
m_GPRListView->Update();
m_GPRGridView->Update();
}
}

View File

@ -49,8 +49,7 @@ class CRegisterWindow
ID_GPR = 1002
};
CRegisterView* m_GPRListView;
void OnRefresh(wxCommandEvent& WXUNUSED (event));
CRegisterView* m_GPRGridView;
void OnClose(wxCloseEvent& event);
void CreateGUIControls();
};

View File

@ -30,12 +30,9 @@ class CFrame : public wxFrame
Toolbar_Refresh,
Toolbar_Browse,
Toolbar_Play,
Toolbar_Play_Dis,
Toolbar_Stop,
Toolbar_Stop_Dis,
Toolbar_Pause,
Toolbar_PluginOptions,
Toolbar_PluginOptions_Dis,
Toolbar_PluginGFX,
Toolbar_PluginDSP,
Toolbar_PluginPAD,

View File

@ -4,6 +4,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Core", "Core\Core\Core.vcpr
ProjectSection(ProjectDependencies) = postProject
{48AD7E0A-25B1-4974-A1E3-03F8C438D34F} = {48AD7E0A-25B1-4974-A1E3-03F8C438D34F}
{0318BA30-EF48-441A-9E10-DC85EFAE39F0} = {0318BA30-EF48-441A-9E10-DC85EFAE39F0}
{71B16F46-0B00-4EDA-B253-D6D9D03A215C} = {71B16F46-0B00-4EDA-B253-D6D9D03A215C}
{29C2ABC1-ADA5-42CD-A5FC-96022D52A510} = {29C2ABC1-ADA5-42CD-A5FC-96022D52A510}
{C573CAF7-EE6A-458E-8049-16C0BF34C2E9} = {C573CAF7-EE6A-458E-8049-16C0BF34C2E9}
{B7F1A9FB-BEA8-416E-9460-AE35A6A5165C} = {B7F1A9FB-BEA8-416E-9460-AE35A6A5165C}
@ -20,6 +21,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Plugin_PadSimple", "Plugins
ProjectSection(ProjectDependencies) = postProject
{48AD7E0A-25B1-4974-A1E3-03F8C438D34F} = {48AD7E0A-25B1-4974-A1E3-03F8C438D34F}
{0318BA30-EF48-441A-9E10-DC85EFAE39F0} = {0318BA30-EF48-441A-9E10-DC85EFAE39F0}
{71B16F46-0B00-4EDA-B253-D6D9D03A215C} = {71B16F46-0B00-4EDA-B253-D6D9D03A215C}
{C573CAF7-EE6A-458E-8049-16C0BF34C2E9} = {C573CAF7-EE6A-458E-8049-16C0BF34C2E9}
EndProjectSection
EndProject
@ -41,6 +43,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Plugin_VideoOGL", "Plugins\
ProjectSection(ProjectDependencies) = postProject
{48AD7E0A-25B1-4974-A1E3-03F8C438D34F} = {48AD7E0A-25B1-4974-A1E3-03F8C438D34F}
{0318BA30-EF48-441A-9E10-DC85EFAE39F0} = {0318BA30-EF48-441A-9E10-DC85EFAE39F0}
{71B16F46-0B00-4EDA-B253-D6D9D03A215C} = {71B16F46-0B00-4EDA-B253-D6D9D03A215C}
{E5D1F0C0-AA07-4841-A4EB-4CF4DAA6B0FA} = {E5D1F0C0-AA07-4841-A4EB-4CF4DAA6B0FA}
{C573CAF7-EE6A-458E-8049-16C0BF34C2E9} = {C573CAF7-EE6A-458E-8049-16C0BF34C2E9}
EndProjectSection
@ -54,6 +57,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DolphinWX", "Core\DolphinWX
{D6E56527-BBB9-4EAD-A6EC-49D4BF6AFCD8} = {D6E56527-BBB9-4EAD-A6EC-49D4BF6AFCD8}
{0318BA30-EF48-441A-9E10-DC85EFAE39F0} = {0318BA30-EF48-441A-9E10-DC85EFAE39F0}
{8D612734-FAA5-4B8A-804F-4DEA2367D495} = {8D612734-FAA5-4B8A-804F-4DEA2367D495}
{71B16F46-0B00-4EDA-B253-D6D9D03A215C} = {71B16F46-0B00-4EDA-B253-D6D9D03A215C}
{9A183B48-ECC2-4121-876A-9B3793686073} = {9A183B48-ECC2-4121-876A-9B3793686073}
{636FAD5F-02D1-4E9A-BE67-FB8EA99B9A18} = {636FAD5F-02D1-4E9A-BE67-FB8EA99B9A18}
{33546D62-7F34-4EA6-A88E-D538B36E16BF} = {33546D62-7F34-4EA6-A88E-D538B36E16BF}
@ -75,6 +79,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DebuggerWX", "Core\Debugger
ProjectSection(ProjectDependencies) = postProject
{48AD7E0A-25B1-4974-A1E3-03F8C438D34F} = {48AD7E0A-25B1-4974-A1E3-03F8C438D34F}
{0318BA30-EF48-441A-9E10-DC85EFAE39F0} = {0318BA30-EF48-441A-9E10-DC85EFAE39F0}
{71B16F46-0B00-4EDA-B253-D6D9D03A215C} = {71B16F46-0B00-4EDA-B253-D6D9D03A215C}
{29C2ABC1-ADA5-42CD-A5FC-96022D52A510} = {29C2ABC1-ADA5-42CD-A5FC-96022D52A510}
{F0B874CB-4476-4199-9315-8343D05AE684} = {F0B874CB-4476-4199-9315-8343D05AE684}
{C573CAF7-EE6A-458E-8049-16C0BF34C2E9} = {C573CAF7-EE6A-458E-8049-16C0BF34C2E9}
@ -89,6 +94,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Plugin_nJoy_SDL", "Plugins\
ProjectSection(ProjectDependencies) = postProject
{48AD7E0A-25B1-4974-A1E3-03F8C438D34F} = {48AD7E0A-25B1-4974-A1E3-03F8C438D34F}
{0318BA30-EF48-441A-9E10-DC85EFAE39F0} = {0318BA30-EF48-441A-9E10-DC85EFAE39F0}
{71B16F46-0B00-4EDA-B253-D6D9D03A215C} = {71B16F46-0B00-4EDA-B253-D6D9D03A215C}
{C573CAF7-EE6A-458E-8049-16C0BF34C2E9} = {C573CAF7-EE6A-458E-8049-16C0BF34C2E9}
EndProjectSection
EndProject
@ -96,6 +102,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Plugin_DSP_HLE", "Plugins\P
ProjectSection(ProjectDependencies) = postProject
{48AD7E0A-25B1-4974-A1E3-03F8C438D34F} = {48AD7E0A-25B1-4974-A1E3-03F8C438D34F}
{0318BA30-EF48-441A-9E10-DC85EFAE39F0} = {0318BA30-EF48-441A-9E10-DC85EFAE39F0}
{71B16F46-0B00-4EDA-B253-D6D9D03A215C} = {71B16F46-0B00-4EDA-B253-D6D9D03A215C}
{C573CAF7-EE6A-458E-8049-16C0BF34C2E9} = {C573CAF7-EE6A-458E-8049-16C0BF34C2E9}
EndProjectSection
EndProject
@ -105,6 +112,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Plugin_Wiimote", "Plugins\P
ProjectSection(ProjectDependencies) = postProject
{48AD7E0A-25B1-4974-A1E3-03F8C438D34F} = {48AD7E0A-25B1-4974-A1E3-03F8C438D34F}
{0318BA30-EF48-441A-9E10-DC85EFAE39F0} = {0318BA30-EF48-441A-9E10-DC85EFAE39F0}
{71B16F46-0B00-4EDA-B253-D6D9D03A215C} = {71B16F46-0B00-4EDA-B253-D6D9D03A215C}
{C573CAF7-EE6A-458E-8049-16C0BF34C2E9} = {C573CAF7-EE6A-458E-8049-16C0BF34C2E9}
EndProjectSection
EndProject
@ -117,9 +125,12 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Plugin_nJoy_SDL_Test", "Plu
ProjectSection(ProjectDependencies) = postProject
{48AD7E0A-25B1-4974-A1E3-03F8C438D34F} = {48AD7E0A-25B1-4974-A1E3-03F8C438D34F}
{0318BA30-EF48-441A-9E10-DC85EFAE39F0} = {0318BA30-EF48-441A-9E10-DC85EFAE39F0}
{71B16F46-0B00-4EDA-B253-D6D9D03A215C} = {71B16F46-0B00-4EDA-B253-D6D9D03A215C}
{C573CAF7-EE6A-458E-8049-16C0BF34C2E9} = {C573CAF7-EE6A-458E-8049-16C0BF34C2E9}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wxAdv28", "..\Externals\wxWidgets\build\msw\wx_adv.vcproj", "{71B16F46-0B00-4EDA-B253-D6D9D03A215C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
@ -257,6 +268,7 @@ Global
{48AD7E0A-25B1-4974-A1E3-03F8C438D34F}.DebugFast|Win32.ActiveCfg = DebugFast|Win32
{48AD7E0A-25B1-4974-A1E3-03F8C438D34F}.DebugFast|Win32.Build.0 = DebugFast|Win32
{48AD7E0A-25B1-4974-A1E3-03F8C438D34F}.DebugFast|x64.ActiveCfg = DebugFast|x64
{48AD7E0A-25B1-4974-A1E3-03F8C438D34F}.DebugFast|x64.Build.0 = DebugFast|x64
{48AD7E0A-25B1-4974-A1E3-03F8C438D34F}.Release|Win32.ActiveCfg = Release|Win32
{48AD7E0A-25B1-4974-A1E3-03F8C438D34F}.Release|Win32.Build.0 = Release|Win32
{48AD7E0A-25B1-4974-A1E3-03F8C438D34F}.Release|x64.ActiveCfg = Release|x64
@ -268,6 +280,7 @@ Global
{0318BA30-EF48-441A-9E10-DC85EFAE39F0}.DebugFast|Win32.ActiveCfg = DebugFast|Win32
{0318BA30-EF48-441A-9E10-DC85EFAE39F0}.DebugFast|Win32.Build.0 = DebugFast|Win32
{0318BA30-EF48-441A-9E10-DC85EFAE39F0}.DebugFast|x64.ActiveCfg = DebugFast|x64
{0318BA30-EF48-441A-9E10-DC85EFAE39F0}.DebugFast|x64.Build.0 = DebugFast|x64
{0318BA30-EF48-441A-9E10-DC85EFAE39F0}.Release|Win32.ActiveCfg = Release|Win32
{0318BA30-EF48-441A-9E10-DC85EFAE39F0}.Release|Win32.Build.0 = Release|Win32
{0318BA30-EF48-441A-9E10-DC85EFAE39F0}.Release|x64.ActiveCfg = Release|x64
@ -368,6 +381,18 @@ Global
{ADF64291-57ED-4B7A-AB76-37B4A991504B}.Release|Win32.Build.0 = Release|Win32
{ADF64291-57ED-4B7A-AB76-37B4A991504B}.Release|x64.ActiveCfg = Release|x64
{ADF64291-57ED-4B7A-AB76-37B4A991504B}.Release|x64.Build.0 = Release|x64
{71B16F46-0B00-4EDA-B253-D6D9D03A215C}.Debug|Win32.ActiveCfg = Debug|Win32
{71B16F46-0B00-4EDA-B253-D6D9D03A215C}.Debug|Win32.Build.0 = Debug|Win32
{71B16F46-0B00-4EDA-B253-D6D9D03A215C}.Debug|x64.ActiveCfg = Debug|x64
{71B16F46-0B00-4EDA-B253-D6D9D03A215C}.Debug|x64.Build.0 = Debug|x64
{71B16F46-0B00-4EDA-B253-D6D9D03A215C}.DebugFast|Win32.ActiveCfg = Debug|Win32
{71B16F46-0B00-4EDA-B253-D6D9D03A215C}.DebugFast|Win32.Build.0 = Debug|Win32
{71B16F46-0B00-4EDA-B253-D6D9D03A215C}.DebugFast|x64.ActiveCfg = DebugFast|x64
{71B16F46-0B00-4EDA-B253-D6D9D03A215C}.DebugFast|x64.Build.0 = DebugFast|x64
{71B16F46-0B00-4EDA-B253-D6D9D03A215C}.Release|Win32.ActiveCfg = Release|Win32
{71B16F46-0B00-4EDA-B253-D6D9D03A215C}.Release|Win32.Build.0 = Release|Win32
{71B16F46-0B00-4EDA-B253-D6D9D03A215C}.Release|x64.ActiveCfg = Release|x64
{71B16F46-0B00-4EDA-B253-D6D9D03A215C}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE