change how the "toolbar" of bp window is handled -> works correctly in release build.

code is still ugly, so if you feel like writing a shiny debugger...

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7249 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Shawn Hoffman 2011-02-25 23:15:53 +00:00
parent 992f8be5b0
commit 19524a8bb7
5 changed files with 83 additions and 120 deletions

View File

@ -26,14 +26,8 @@
#include "PowerPC/PowerPC.h"
#include "HW/Memmap.h"
extern "C" {
#include "../../resources/toolbar_add_breakpoint.c"
#include "../../resources/toolbar_add_memorycheck.c"
#include "../../resources/toolbar_debugger_delete.c"
}
CBreakPointView::CBreakPointView(wxWindow* parent, const wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
CBreakPointView::CBreakPointView(wxWindow* parent, const wxWindowID id,
const wxPoint& pos, const wxSize& size, long style)
: wxListCtrl(parent, id, pos, size, style)
{
SetFont(DebuggerFont);
@ -41,7 +35,6 @@ CBreakPointView::CBreakPointView(wxWindow* parent, const wxWindowID id, const wx
Refresh();
}
void CBreakPointView::Update()
{
ClearAll();
@ -129,45 +122,3 @@ void CBreakPointView::DeleteCurrentSelection()
Update();
}
}
CBreakPointBar::CBreakPointBar(CBreakPointWindow* parent, const wxWindowID id, const wxPoint& pos, const wxSize& size, long style)
: wxListCtrl((wxWindow*)parent, id, pos, size, style)
{
BPWindow = parent;
SetBackgroundColour(wxColour(0x555555));
SetForegroundColour(wxColour(0xffffff));
// load original size 48x48
wxMemoryInputStream st1(toolbar_delete_png, sizeof(toolbar_delete_png));
wxMemoryInputStream st2(toolbar_add_breakpoint_png, sizeof(toolbar_add_breakpoint_png));
wxMemoryInputStream st3(toolbar_add_memcheck_png, sizeof(toolbar_add_memcheck_png));
m_Bitmaps[Toolbar_Delete] = wxBitmap(wxImage(st1, wxBITMAP_TYPE_ANY, -1).Rescale(24,24), -1);
m_Bitmaps[Toolbar_Add_BP] = wxBitmap(wxImage(st2, wxBITMAP_TYPE_ANY, -1).Rescale(24,24), -1);
m_Bitmaps[Toolbar_Add_MC] = wxBitmap(wxImage(st3, wxBITMAP_TYPE_ANY, -1).Rescale(24,24), -1);
m_imageListNormal = new wxImageList(24, 24);
m_imageListNormal->Add(m_Bitmaps[Toolbar_Delete]);
m_imageListNormal->Add(m_Bitmaps[Toolbar_Add_BP]);
m_imageListNormal->Add(m_Bitmaps[Toolbar_Add_MC]);
SetImageList(m_imageListNormal, wxIMAGE_LIST_NORMAL);
PopulateBar();
}
void CBreakPointBar::PopulateBar()
{
InsertItem(IDM_DELETE, _("Delete"), 0);
InsertItem(IDM_CLEAR, _("Clear"), 0);
InsertItem(IDM_ADD_BREAKPOINT, _("+BP"), 1);
// just add memory breakpoints if you can use them
if (Memory::AreMemoryBreakpointsActivated())
InsertItem(IDM_ADD_MEMORYCHECK, _("+MC"), 2);
InsertItem(IDM_SAVEALL, _("Load"));
InsertItem(IDM_SAVEALL, _("Save"));
}

View File

@ -19,43 +19,17 @@
#define __BREAKPOINTVIEW_h__
#include <wx/listctrl.h>
#include "Common.h"
#include "BreakpointWindow.h"
class CBreakPointView
: public wxListCtrl
class CBreakPointView : public wxListCtrl
{
public:
public:
CBreakPointView(wxWindow* parent, const wxWindowID id, const wxPoint& pos,
const wxSize& size, long style);
CBreakPointView(wxWindow* parent, const wxWindowID id, const wxPoint& pos, const wxSize& size, long style);
void Update();
void DeleteCurrentSelection();
};
class CBreakPointBar
: public wxListCtrl
{
public:
CBreakPointBar(CBreakPointWindow* parent, const wxWindowID id, const wxPoint& pos, const wxSize& size, long style);
void PopulateBar();
private:
void OnSelectItem(wxListEvent& event);
enum
{
Toolbar_Delete,
Toolbar_Add_BP,
Toolbar_Add_MC,
Bitmaps_max
};
CBreakPointWindow* BPWindow;
wxBitmap m_Bitmaps[Bitmaps_max];
void Update();
void DeleteCurrentSelection();
};
#endif

View File

@ -26,6 +26,70 @@
#include "PowerPC/PowerPC.h"
#include "FileUtil.h"
extern "C" {
#include "../../resources/toolbar_add_breakpoint.c"
#include "../../resources/toolbar_add_memorycheck.c"
#include "../../resources/toolbar_debugger_delete.c"
}
#include <map>
typedef void (CBreakPointWindow::*toolbar_func)();
typedef std::map<long, toolbar_func> toolbar_m;
typedef std::pair<long, toolbar_func> toolbar_p;
toolbar_m toolbar_map;
class CBreakPointBar : public wxListCtrl
{
enum
{
Toolbar_Delete,
Toolbar_Add_BP,
Toolbar_Add_MC,
Bitmaps_max
};
wxBitmap m_Bitmaps[Bitmaps_max];
public:
CBreakPointBar::CBreakPointBar(CBreakPointWindow* parent, const wxWindowID id,
const wxPoint& pos, const wxSize& size, long style)
: wxListCtrl((wxWindow*)parent, id, pos, size, style)
{
SetBackgroundColour(wxColour(0x555555));
SetForegroundColour(wxColour(0xffffff));
// load original size 48x48
wxMemoryInputStream st1(toolbar_delete_png, sizeof(toolbar_delete_png));
wxMemoryInputStream st2(toolbar_add_breakpoint_png, sizeof(toolbar_add_breakpoint_png));
wxMemoryInputStream st3(toolbar_add_memcheck_png, sizeof(toolbar_add_memcheck_png));
m_Bitmaps[Toolbar_Delete] = wxBitmap(wxImage(st1, wxBITMAP_TYPE_ANY, -1).Rescale(24,24), -1);
m_Bitmaps[Toolbar_Add_BP] = wxBitmap(wxImage(st2, wxBITMAP_TYPE_ANY, -1).Rescale(24,24), -1);
m_Bitmaps[Toolbar_Add_MC] = wxBitmap(wxImage(st3, wxBITMAP_TYPE_ANY, -1).Rescale(24,24), -1);
m_imageListNormal = new wxImageList(24, 24);
m_imageListNormal->Add(m_Bitmaps[Toolbar_Delete]);
m_imageListNormal->Add(m_Bitmaps[Toolbar_Add_BP]);
m_imageListNormal->Add(m_Bitmaps[Toolbar_Add_MC]);
SetImageList(m_imageListNormal, wxIMAGE_LIST_NORMAL);
toolbar_map.insert(toolbar_p(InsertItem(0, _("Delete"), 0), &CBreakPointWindow::OnDelete));
toolbar_map.insert(toolbar_p(InsertItem(1, _("Clear"), 0), &CBreakPointWindow::OnClear));
toolbar_map.insert(toolbar_p(InsertItem(2, _("+BP"), 1), &CBreakPointWindow::OnAddBreakPoint));
// just add memory breakpoints if you can use them
if (Memory::AreMemoryBreakpointsActivated())
{
toolbar_map.insert(toolbar_p(InsertItem(3, _("+MC"), 2), &CBreakPointWindow::OnAddMemoryCheck));
toolbar_map.insert(toolbar_p(InsertItem(4, _("Load"), 0), &CBreakPointWindow::LoadAll));
toolbar_map.insert(toolbar_p(InsertItem(5, _("Save"), 0), &CBreakPointWindow::SaveAll));
}
else
{
toolbar_map.insert(toolbar_p(InsertItem(3, _("Load"), 0), &CBreakPointWindow::LoadAll));
toolbar_map.insert(toolbar_p(InsertItem(4, _("Save"), 0), &CBreakPointWindow::SaveAll));
}
}
};
BEGIN_EVENT_TABLE(CBreakPointWindow, wxPanel)
EVT_CLOSE(CBreakPointWindow::OnClose)
EVT_LIST_ITEM_SELECTED(ID_BPS, CBreakPointWindow::OnSelectBP)
@ -67,26 +131,8 @@ void CBreakPointWindow::CreateGUIControls()
void CBreakPointWindow::OnSelectToolbar(wxListEvent& event)
{
switch(event.GetItem().GetId())
{
case IDM_DELETE:
OnDelete();
break;
case IDM_CLEAR:
OnClear();
break;
case IDM_ADD_BREAKPOINT:
OnAddBreakPoint();
break;
case IDM_ADD_MEMORYCHECK:
OnAddMemoryCheck();
break;
case IDM_LOADALL:
LoadAll();
case IDM_SAVEALL:
SaveAll();
break;
}
(this->*toolbar_map[event.GetItem().GetId()])();
m_BreakPointBar->SetItemState(event.GetItem().GetId(), 0, wxLIST_STATE_SELECTED);
}
void CBreakPointWindow::NotifyUpdate()
@ -159,7 +205,7 @@ void CBreakPointWindow::LoadAll()
if (!ini.Load(File::GetUserPath(F_DEBUGGERCONFIG_IDX)))
return;
if (ini.GetLines("BreakPoints", newbps))
if (ini.GetLines("BreakPoints", newbps, false))
PowerPC::breakpoints.AddFromStrings(newbps);
if (ini.GetLines("MemoryChecks", newmcs, false))
PowerPC::memchecks.AddFromStrings(newmcs);

View File

@ -24,16 +24,6 @@ class CCodeWindow;
class wxListEvent;
class IniFile;
enum
{
IDM_DELETE = 0,
IDM_CLEAR,
IDM_ADD_BREAKPOINT,
IDM_ADD_MEMORYCHECK,
IDM_LOADALL,
IDM_SAVEALL
};
class CBreakPointWindow
: public wxPanel
{
@ -49,6 +39,13 @@ public:
void NotifyUpdate();
void OnDelete();
void OnClear();
void OnAddBreakPoint();
void OnAddMemoryCheck();
void SaveAll();
void LoadAll();
private:
DECLARE_EVENT_TABLE();
@ -67,12 +64,6 @@ private:
void OnSelectBP(wxListEvent& event);
void OnRightClick(wxListEvent& event);
void CreateGUIControls();
void OnDelete();
void OnClear();
void OnAddBreakPoint();
void OnAddMemoryCheck();
void SaveAll();
void LoadAll();
};
#endif

View File

@ -164,6 +164,7 @@ void CCodeWindow::OnHostMessage(wxCommandEvent& event)
{
case IDM_NOTIFYMAPLOADED:
NotifyMapLoaded();
if (m_BreakpointWindow) m_BreakpointWindow->NotifyUpdate();
break;
case IDM_UPDATEDISASMDIALOG: