From 6c4573932bd403a2bba096c5eea978f4a0c6acc0 Mon Sep 17 00:00:00 2001 From: "fires.gc" Date: Thu, 24 Jul 2008 09:39:56 +0000 Subject: [PATCH] improved debugger - some meaningful icons would be nice :) git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@79 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/DebuggerWX/DebuggerWX.vcproj | 18 +- Source/Core/DebuggerWX/src/BreakpointView.cpp | 1 - Source/Core/DebuggerWX/src/CodeView.cpp | 16 +- Source/Core/DebuggerWX/src/CodeWindow.cpp | 254 +++++++++++------- Source/Core/DebuggerWX/src/CodeWindow.h | 43 ++- 5 files changed, 213 insertions(+), 119 deletions(-) diff --git a/Source/Core/DebuggerWX/DebuggerWX.vcproj b/Source/Core/DebuggerWX/DebuggerWX.vcproj index 0ad7535185..a28d06ec3f 100644 --- a/Source/Core/DebuggerWX/DebuggerWX.vcproj +++ b/Source/Core/DebuggerWX/DebuggerWX.vcproj @@ -1,7 +1,7 @@ + + + + + + + + diff --git a/Source/Core/DebuggerWX/src/BreakpointView.cpp b/Source/Core/DebuggerWX/src/BreakpointView.cpp index f1c7e2806f..760c778da5 100644 --- a/Source/Core/DebuggerWX/src/BreakpointView.cpp +++ b/Source/Core/DebuggerWX/src/BreakpointView.cpp @@ -24,7 +24,6 @@ BEGIN_EVENT_TABLE(CBreakPointView, wxListCtrl) - END_EVENT_TABLE() CBreakPointView::CBreakPointView(wxWindow* parent, const wxWindowID id, const wxPoint& pos, const wxSize& size, long style) diff --git a/Source/Core/DebuggerWX/src/CodeView.cpp b/Source/Core/DebuggerWX/src/CodeView.cpp index dad9bb7360..f530377cb8 100644 --- a/Source/Core/DebuggerWX/src/CodeView.cpp +++ b/Source/Core/DebuggerWX/src/CodeView.cpp @@ -35,14 +35,14 @@ enum BEGIN_EVENT_TABLE(CCodeView, wxControl) -EVT_ERASE_BACKGROUND(CCodeView::OnErase) -EVT_PAINT(CCodeView::OnPaint) -EVT_LEFT_DOWN(CCodeView::OnMouseDown) -EVT_LEFT_UP(CCodeView::OnMouseUpL) -EVT_MOTION(CCodeView::OnMouseMove) -EVT_RIGHT_DOWN(CCodeView::OnMouseDown) -EVT_RIGHT_UP(CCodeView::OnMouseUpR) -EVT_MENU(-1, CCodeView::OnPopupMenu) + EVT_ERASE_BACKGROUND(CCodeView::OnErase) + EVT_PAINT(CCodeView::OnPaint) + EVT_LEFT_DOWN(CCodeView::OnMouseDown) + EVT_LEFT_UP(CCodeView::OnMouseUpL) + EVT_MOTION(CCodeView::OnMouseMove) + EVT_RIGHT_DOWN(CCodeView::OnMouseDown) + EVT_RIGHT_UP(CCodeView::OnMouseUpR) + EVT_MENU(-1, CCodeView::OnPopupMenu) END_EVENT_TABLE() CCodeView::CCodeView(DebugInterface* debuginterface, wxWindow* parent, wxWindowID Id, const wxSize& Size) diff --git a/Source/Core/DebuggerWX/src/CodeWindow.cpp b/Source/Core/DebuggerWX/src/CodeWindow.cpp index 1752b8d4a7..8898f3b128 100644 --- a/Source/Core/DebuggerWX/src/CodeWindow.cpp +++ b/Source/Core/DebuggerWX/src/CodeWindow.cpp @@ -28,12 +28,15 @@ #include "wx/listctrl.h" #include "wx/thread.h" #include "wx/listctrl.h" +#include "wx/mstream.h" + #include "CodeWindow.h" #include "CodeView.h" #include "HW/CPU.h" #include "PowerPC/PowerPC.h" #include "Host.h" + #include "Debugger/PPCDebugInterface.h" #include "Debugger/Debugger_SymbolMap.h" @@ -43,42 +46,15 @@ // ugly that this lib included code from the main #include "../../DolphinWX/src/Globals.h" -class SymbolList - : public wxListCtrl -{ - wxString OnGetItemText(long item, long column) - { - return(_T("hello")); - } -}; +extern "C" { +#include "../resources/toolbar_add_breakpoint.c" +#include "../resources/toolbar_add_memorycheck.c" +#include "../resources/toolbar_delete.c" +} -enum -{ - IDM_DEBUG_GO = 350, - IDM_STEP, - IDM_STEPOVER, - IDM_SKIP, - IDM_SETPC, - IDM_GOTOPC, - IDM_ADDRBOX, - IDM_CALLSTACKLIST, - IDM_SYMBOLLIST, - IDM_INTERPRETER, - IDM_DUALCORE, - IDM_LOGWINDOW, - IDM_REGISTERWINDOW, - IDM_BREAKPOINTWINDOW, - IDM_MEMORYWINDOW, -}; +static const long TOOLBAR_STYLE = wxTB_FLAT | wxTB_DOCKABLE | wxTB_TEXT; -BEGIN_EVENT_TABLE(CCodeWindow, wxFrame) - EVT_BUTTON(IDM_DEBUG_GO, CCodeWindow::OnCodeStep) - EVT_BUTTON(IDM_STEP, CCodeWindow::OnCodeStep) - EVT_BUTTON(IDM_STEPOVER, CCodeWindow::OnCodeStep) - EVT_BUTTON(IDM_SKIP, CCodeWindow::OnCodeStep) - EVT_BUTTON(IDM_SETPC, CCodeWindow::OnCodeStep) - EVT_BUTTON(IDM_GOTOPC, CCodeWindow::OnCodeStep) - EVT_TEXT(IDM_ADDRBOX, CCodeWindow::OnAddrBoxChange) +BEGIN_EVENT_TABLE(CCodeWindow, wxFrame) EVT_LISTBOX(IDM_SYMBOLLIST, CCodeWindow::OnSymbolListChange) EVT_LISTBOX(IDM_CALLSTACKLIST, CCodeWindow::OnCallstackListChange) EVT_HOST_COMMAND(wxID_ANY, CCodeWindow::OnHostMessage) @@ -86,8 +62,23 @@ BEGIN_EVENT_TABLE(CCodeWindow, wxFrame) EVT_MENU(IDM_REGISTERWINDOW, CCodeWindow::OnToggleRegisterWindow) EVT_MENU(IDM_BREAKPOINTWINDOW, CCodeWindow::OnToggleBreakPointWindow) EVT_MENU(IDM_MEMORYWINDOW, CCodeWindow::OnToggleMemoryWindow) + // toolbar + EVT_MENU(IDM_DEBUG_GO, CCodeWindow::OnCodeStep) + EVT_MENU(IDM_STEP, CCodeWindow::OnCodeStep) + EVT_MENU(IDM_STEPOVER, CCodeWindow::OnCodeStep) + EVT_MENU(IDM_SKIP, CCodeWindow::OnCodeStep) + EVT_MENU(IDM_SETPC, CCodeWindow::OnCodeStep) + EVT_MENU(IDM_GOTOPC, CCodeWindow::OnCodeStep) + EVT_TEXT(IDM_ADDRBOX, CCodeWindow::OnAddrBoxChange) END_EVENT_TABLE() +#define wxGetBitmapFromMemory(name) _wxGetBitmapFromMemory(name, sizeof(name)) +inline wxBitmap _wxGetBitmapFromMemory(const unsigned char* data, int length) +{ + wxMemoryInputStream is(data, length); + return(wxBitmap(wxImage(is, wxBITMAP_TYPE_ANY, -1), -1)); +} + CCodeWindow::CCodeWindow(const SCoreStartupParameter& _LocalCoreStartupParameter, wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style) @@ -95,67 +86,26 @@ CCodeWindow::CCodeWindow(const SCoreStartupParameter& _LocalCoreStartupParameter , m_RegisterWindow(NULL) , m_logwindow(NULL) { - CreateMenu(_LocalCoreStartupParameter); + InitBitmaps(); - wxBoxSizer* sizerBig = new wxBoxSizer(wxHORIZONTAL); - wxBoxSizer* sizerRight = new wxBoxSizer(wxVERTICAL); - wxBoxSizer* sizerLeft = new wxBoxSizer(wxVERTICAL); + CreateGUIControls(_LocalCoreStartupParameter); - DebugInterface* di = new PPCDebugInterface(); - - sizerLeft->Add(callstack = new wxListBox(this, IDM_CALLSTACKLIST, wxDefaultPosition, wxSize(90, 100)), 0, wxEXPAND); - sizerLeft->Add(symbols = new wxListBox(this, IDM_SYMBOLLIST, wxDefaultPosition, wxSize(90, 100), 0, NULL, wxLB_SORT), 1, wxEXPAND); - codeview = new CCodeView(di, this, wxID_ANY); - sizerBig->Add(sizerLeft, 2, wxEXPAND); - sizerBig->Add(codeview, 5, wxEXPAND); - sizerBig->Add(sizerRight, 0, wxEXPAND | wxALL, 3); - sizerRight->Add(buttonGo = new wxButton(this, IDM_DEBUG_GO, _T("&Go"))); - sizerRight->Add(buttonStep = new wxButton(this, IDM_STEP, _T("&Step"))); - sizerRight->Add(buttonStepOver = new wxButton(this, IDM_STEPOVER, _T("Step &Over"))); - sizerRight->Add(buttonSkip = new wxButton(this, IDM_SKIP, _T("Ski&p"))); - sizerRight->Add(buttonGotoPC = new wxButton(this, IDM_GOTOPC, _T("G&oto PC"))); - sizerRight->Add(addrbox = new wxTextCtrl(this, IDM_ADDRBOX, _T(""))); - sizerRight->Add(new wxButton(this, IDM_SETPC, _T("S&et PC"))); - - SetSizer(sizerBig); - - sizerLeft->SetSizeHints(this); - sizerLeft->Fit(this); - sizerRight->SetSizeHints(this); - sizerRight->Fit(this); - sizerBig->SetSizeHints(this); - sizerBig->Fit(this); - - sync_event.Init(); - - // additional dialogs - if (IsLoggingActivated()) - { - m_logwindow = new CLogWindow(this); - m_logwindow->Show(true); - } - - m_RegisterWindow = new CRegisterWindow(this); - m_RegisterWindow->Show(true); - - m_BreakpointWindow = new CBreakPointWindow(this, this); - m_BreakpointWindow->Show(true); - - m_MemoryWindow = new CMemoryWindow(this); - m_MemoryWindow->Show(true); + // Create the toolbar + RecreateToolbar(); UpdateButtonStates(); - int x,y,w,h; + // load ini... + int x,y,w,h; - IniFile file; - file.Load("Debugger.ini"); + IniFile file; + file.Load("Debugger.ini"); - file.Get("Code", "x", &x, GetPosition().x); - file.Get("Code", "y", &y, GetPosition().y); - file.Get("Code", "w", &w, GetSize().GetWidth()); - file.Get("Code", "h", &h, GetSize().GetHeight()); - this->SetSize(x, y, w, h); + file.Get("Code", "x", &x, GetPosition().x); + file.Get("Code", "y", &y, GetPosition().y); + file.Get("Code", "w", &w, GetSize().GetWidth()); + file.Get("Code", "h", &h, GetSize().GetHeight()); + this->SetSize(x, y, w, h); // These really should be in the respective constructors. if (m_BreakpointWindow) { @@ -192,6 +142,48 @@ CCodeWindow::CCodeWindow(const SCoreStartupParameter& _LocalCoreStartupParameter } +void CCodeWindow::CreateGUIControls(const SCoreStartupParameter& _LocalCoreStartupParameter) +{ + CreateMenu(_LocalCoreStartupParameter); + + wxBoxSizer* sizerBig = new wxBoxSizer(wxHORIZONTAL); + wxBoxSizer* sizerLeft = new wxBoxSizer(wxVERTICAL); + + DebugInterface* di = new PPCDebugInterface(); + + sizerLeft->Add(callstack = new wxListBox(this, IDM_CALLSTACKLIST, wxDefaultPosition, wxSize(90, 100)), 0, wxEXPAND); + sizerLeft->Add(symbols = new wxListBox(this, IDM_SYMBOLLIST, wxDefaultPosition, wxSize(90, 100), 0, NULL, wxLB_SORT), 1, wxEXPAND); + codeview = new CCodeView(di, this, wxID_ANY); + sizerBig->Add(sizerLeft, 2, wxEXPAND); + sizerBig->Add(codeview, 5, wxEXPAND); + + SetSizer(sizerBig); + + sizerLeft->SetSizeHints(this); + sizerLeft->Fit(this); + sizerBig->SetSizeHints(this); + sizerBig->Fit(this); + + sync_event.Init(); + + // additional dialogs + if (IsLoggingActivated()) + { + m_logwindow = new CLogWindow(this); + m_logwindow->Show(true); + } + + m_RegisterWindow = new CRegisterWindow(this); + m_RegisterWindow->Show(true); + + m_BreakpointWindow = new CBreakPointWindow(this, this); + m_BreakpointWindow->Show(true); + + m_MemoryWindow = new CMemoryWindow(this); + m_MemoryWindow->Show(true); +} + + CCodeWindow::~CCodeWindow() { IniFile file; @@ -352,7 +344,8 @@ void CCodeWindow::OnCodeStep(wxCommandEvent& event) void CCodeWindow::OnAddrBoxChange(wxCommandEvent& event) { - wxString txt = addrbox->GetValue(); + wxTextCtrl* pAddrCtrl = (wxTextCtrl*)GetToolBar()->FindControl(IDM_ADDRBOX); + wxString txt = pAddrCtrl->GetValue(); if (txt.size() == 8) { @@ -417,30 +410,31 @@ void CCodeWindow::NotifyMapLoaded() void CCodeWindow::UpdateButtonStates() { + wxToolBarBase* toolBar = GetToolBar(); if (Core::GetState() == Core::CORE_UNINITIALIZED) { - buttonGo->Enable(false); - buttonStep->Enable(false); - buttonStepOver->Enable(false); - buttonSkip->Enable(false); + toolBar->EnableTool(IDM_DEBUG_GO, false); + toolBar->EnableTool(IDM_STEP, false); + toolBar->EnableTool(IDM_STEPOVER, false); + toolBar->EnableTool(IDM_SKIP, false); } else { if (!CCPU::IsStepping()) { - buttonGo->SetLabel(_T("&Pause")); - buttonGo->Enable(true); - buttonStep->Enable(false); - buttonStepOver->Enable(false); - buttonSkip->Enable(false); + toolBar->SetToolShortHelp(IDM_DEBUG_GO, _T("&Pause")); + toolBar->EnableTool(IDM_DEBUG_GO, true); + toolBar->EnableTool(IDM_STEP, false); + toolBar->EnableTool(IDM_STEPOVER, false); + toolBar->EnableTool(IDM_SKIP, false); } else { - buttonGo->SetLabel(_T("&Go")); - buttonGo->Enable(true); - buttonStep->Enable(true); - buttonStepOver->Enable(true); - buttonSkip->Enable(true); + toolBar->SetToolShortHelp(IDM_DEBUG_GO, _T("&Go")); + toolBar->EnableTool(IDM_DEBUG_GO, true); + toolBar->EnableTool(IDM_STEP, true); + toolBar->EnableTool(IDM_STEPOVER, true); + toolBar->EnableTool(IDM_SKIP, true); } } } @@ -624,4 +618,58 @@ void CCodeWindow::OnHostMessage(wxCommandEvent& event) } } +void CCodeWindow::PopulateToolbar(wxToolBar* toolBar) +{ + int w = m_Bitmaps[Toolbar_DebugGo].GetWidth(), + h = m_Bitmaps[Toolbar_DebugGo].GetHeight(); + toolBar->SetToolBitmapSize(wxSize(w, h)); + toolBar->AddTool(IDM_DEBUG_GO, _T("Go"), m_Bitmaps[Toolbar_DebugGo], _T("Delete the selected BreakPoint or MemoryCheck")); + toolBar->AddTool(IDM_STEP, _T("Step"), m_Bitmaps[Toolbar_Step], _T("Add BreakPoint...")); + toolBar->AddTool(IDM_STEPOVER, _T("Step Over"), m_Bitmaps[Toolbar_StepOver], _T("Add BreakPoint...")); + toolBar->AddTool(IDM_SKIP, _T("Skip"), m_Bitmaps[Toolbar_Skip], _T("Add BreakPoint...")); + toolBar->AddSeparator(); + toolBar->AddTool(IDM_GOTOPC, _T("Goto PC"), m_Bitmaps[Toolbar_GotoPC], _T("Add BreakPoint...")); + toolBar->AddTool(IDM_SETPC, _T("Set PC"), m_Bitmaps[Toolbar_SetPC], _T("Add BreakPoint...")); + toolBar->AddSeparator(); + toolBar->AddControl(new wxTextCtrl(toolBar, IDM_ADDRBOX, _T(""))); + + // after adding the buttons to the toolbar, must call Realize() to reflect + // the changes + toolBar->Realize(); +} + + +void CCodeWindow::RecreateToolbar() +{ + // delete and recreate the toolbar + wxToolBarBase* toolBar = GetToolBar(); + delete toolBar; + SetToolBar(NULL); + + long style = TOOLBAR_STYLE; + style &= ~(wxTB_HORIZONTAL | wxTB_VERTICAL | wxTB_BOTTOM | wxTB_RIGHT | wxTB_HORZ_LAYOUT | wxTB_TOP); + wxToolBar* theToolBar = CreateToolBar(style, ID_TOOLBAR); + + PopulateToolbar(theToolBar); + SetToolBar(theToolBar); +} + + +void CCodeWindow::InitBitmaps() +{ + // load original size 48x48 + m_Bitmaps[Toolbar_DebugGo] = wxGetBitmapFromMemory(toolbar_delete_png); + m_Bitmaps[Toolbar_Step] = wxGetBitmapFromMemory(toolbar_add_breakpoint_png); + m_Bitmaps[Toolbar_StepOver] = wxGetBitmapFromMemory(toolbar_add_memcheck_png); + m_Bitmaps[Toolbar_Skip] = wxGetBitmapFromMemory(toolbar_add_memcheck_png); + m_Bitmaps[Toolbar_GotoPC] = wxGetBitmapFromMemory(toolbar_add_memcheck_png); + m_Bitmaps[Toolbar_SetPC] = wxGetBitmapFromMemory(toolbar_add_memcheck_png); + + + // scale to 16x16 for toolbar + for (size_t n = Toolbar_DebugGo; n < Bitmaps_max; n++) + { + m_Bitmaps[n] = wxBitmap(m_Bitmaps[n].ConvertToImage().Scale(16, 16)); + } +} diff --git a/Source/Core/DebuggerWX/src/CodeWindow.h b/Source/Core/DebuggerWX/src/CodeWindow.h index 81319e9d90..3d8a8db5d4 100644 --- a/Source/Core/DebuggerWX/src/CodeWindow.h +++ b/Source/Core/DebuggerWX/src/CodeWindow.h @@ -56,6 +56,37 @@ class CCodeWindow private: + enum + { + ID_TOOLBAR = 500, + IDM_DEBUG_GO, + IDM_STEP, + IDM_STEPOVER, + IDM_SKIP, + IDM_SETPC, + IDM_GOTOPC, + IDM_ADDRBOX, + IDM_CALLSTACKLIST, + IDM_SYMBOLLIST, + IDM_INTERPRETER, + IDM_DUALCORE, + IDM_LOGWINDOW, + IDM_REGISTERWINDOW, + IDM_BREAKPOINTWINDOW, + IDM_MEMORYWINDOW, + }; + + enum + { + Toolbar_DebugGo, + Toolbar_Step, + Toolbar_StepOver, + Toolbar_Skip, + Toolbar_GotoPC, + Toolbar_SetPC, + Bitmaps_max + }; + // sub dialogs CLogWindow* m_logwindow; CRegisterWindow* m_RegisterWindow; @@ -67,13 +98,8 @@ class CCodeWindow wxListBox* symbols; Common::Event sync_event; - wxButton* buttonGo; - wxButton* buttonStep; - wxButton* buttonStepOver; - wxButton* buttonSkip; - wxButton* buttonGotoPC; + wxBitmap m_Bitmaps[Bitmaps_max]; - wxTextCtrl* addrbox; DECLARE_EVENT_TABLE() void OnSymbolListChange(wxCommandEvent& event); @@ -90,6 +116,11 @@ class CCodeWindow void CreateMenu(const SCoreStartupParameter& _LocalCoreStartupParameter); void UpdateButtonStates(); + + void RecreateToolbar(); + void PopulateToolbar(wxToolBar* toolBar); + void InitBitmaps(); + void CreateGUIControls(const SCoreStartupParameter& _LocalCoreStartupParameter); }; #endif /*CODEWINDOW_*/