mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-30 17:49:48 -06:00
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:
@ -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
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -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();
|
||||
};
|
||||
|
@ -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,
|
||||
|
Reference in New Issue
Block a user