Added Load/Save function for the Watch window.

Made the floating windows toolbars dockable.
Scaled down the breakpoint toolbar icons to 16x16.
This commit is contained in:
skidau 2014-10-24 22:24:17 +11:00
parent b34e220086
commit b73130af77
4 changed files with 96 additions and 12 deletions

View File

@ -234,7 +234,7 @@ Watches::TWatchesStr Watches::GetStrings() const
for (const TWatch& bp : m_Watches) for (const TWatch& bp : m_Watches)
{ {
std::stringstream ss; std::stringstream ss;
ss << std::hex << bp.iAddress << " " << (bp.bOn ? "n" : ""); ss << std::hex << bp.iAddress << " " << bp.name;
bps.push_back(ss.str()); bps.push_back(ss.str());
} }
@ -249,7 +249,7 @@ void Watches::AddFromStrings(const TWatchesStr& bpstrs)
std::stringstream ss; std::stringstream ss;
ss << std::hex << bpstr; ss << std::hex << bpstr;
ss >> bp.iAddress; ss >> bp.iAddress;
bp.bOn = bpstr.find("n") != bpstr.npos; ss >> bp.name;
Add(bp); Add(bp);
} }
} }

View File

@ -45,9 +45,9 @@ public:
{ {
SetToolBitmapSize(wxSize(24, 24)); SetToolBitmapSize(wxSize(24, 24));
m_Bitmaps[Toolbar_Delete] = wxBitmap(wxGetBitmapFromMemory(toolbar_delete_png).ConvertToImage().Rescale(24, 24)); m_Bitmaps[Toolbar_Delete] = wxBitmap(wxGetBitmapFromMemory(toolbar_delete_png).ConvertToImage().Rescale(16, 16));
m_Bitmaps[Toolbar_Add_BP] = wxBitmap(wxGetBitmapFromMemory(toolbar_add_breakpoint_png).ConvertToImage().Rescale(24, 24)); m_Bitmaps[Toolbar_Add_BP] = wxBitmap(wxGetBitmapFromMemory(toolbar_add_breakpoint_png).ConvertToImage().Rescale(16, 16));
m_Bitmaps[Toolbar_Add_MC] = wxBitmap(wxGetBitmapFromMemory(toolbar_add_memcheck_png).ConvertToImage().Rescale(24, 24)); m_Bitmaps[Toolbar_Add_MC] = wxBitmap(wxGetBitmapFromMemory(toolbar_add_memcheck_png).ConvertToImage().Rescale(16, 16));
AddTool(ID_DELETE, _("Delete"), m_Bitmaps[Toolbar_Delete]); AddTool(ID_DELETE, _("Delete"), m_Bitmaps[Toolbar_Delete]);
Bind(wxEVT_TOOL, &CBreakPointWindow::OnDelete, parent, ID_DELETE); Bind(wxEVT_TOOL, &CBreakPointWindow::OnDelete, parent, ID_DELETE);
@ -112,7 +112,7 @@ CBreakPointWindow::CBreakPointWindow(CCodeWindow* _pCodeWindow, wxWindow* parent
m_BreakPointListView = new CBreakPointView(this, wxID_ANY); m_BreakPointListView = new CBreakPointView(this, wxID_ANY);
m_mgr.AddPane(new CBreakPointBar(this, wxID_ANY), wxAuiPaneInfo().ToolbarPane().Top(). m_mgr.AddPane(new CBreakPointBar(this, wxID_ANY), wxAuiPaneInfo().ToolbarPane().Top().
LeftDockable(false).RightDockable(false).BottomDockable(false).Floatable(false)); LeftDockable(true).RightDockable(true).BottomDockable(false).Floatable(false));
m_mgr.AddPane(m_BreakPointListView, wxAuiPaneInfo().CenterPane()); m_mgr.AddPane(m_BreakPointListView, wxAuiPaneInfo().CenterPane());
m_mgr.Update(); m_mgr.Update();
} }

View File

@ -3,6 +3,8 @@
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <cstddef> #include <cstddef>
#include <wx/bitmap.h>
#include <wx/defs.h> #include <wx/defs.h>
#include <wx/event.h> #include <wx/event.h>
#include <wx/gdicmn.h> #include <wx/gdicmn.h>
@ -10,10 +12,19 @@
#include <wx/sizer.h> #include <wx/sizer.h>
#include <wx/string.h> #include <wx/string.h>
#include <wx/windowid.h> #include <wx/windowid.h>
#include <wx/aui/auibar.h>
#include "Common/FileUtil.h"
#include "Common/IniFile.h"
#include "Core/PowerPC/PowerPC.h"
#include "DolphinWX/WxUtils.h"
#include "DolphinWX/Debugger/WatchView.h" #include "DolphinWX/Debugger/WatchView.h"
#include "DolphinWX/Debugger/WatchWindow.h" #include "DolphinWX/Debugger/WatchWindow.h"
extern "C" {
#include "DolphinWX/resources/toolbar_debugger_delete.c"
}
class wxWindow; class wxWindow;
BEGIN_EVENT_TABLE(CWatchWindow, wxPanel) BEGIN_EVENT_TABLE(CWatchWindow, wxPanel)
@ -21,6 +32,40 @@ EVT_GRID_CELL_RIGHT_CLICK(CWatchView::OnMouseDownR)
EVT_MENU(-1, CWatchView::OnPopupMenu) EVT_MENU(-1, CWatchView::OnPopupMenu)
END_EVENT_TABLE() END_EVENT_TABLE()
class CWatchToolbar : public wxAuiToolBar
{
public:
CWatchToolbar(CWatchWindow* parent, const wxWindowID id)
: wxAuiToolBar(parent, id, wxDefaultPosition, wxDefaultSize,
wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_TEXT)
{
SetToolBitmapSize(wxSize(16, 16));
m_Bitmaps[Toolbar_File] = wxBitmap(wxGetBitmapFromMemory(toolbar_delete_png).ConvertToImage().Rescale(16, 16));
AddTool(ID_LOAD, _("Load"), m_Bitmaps[Toolbar_File]);
Bind(wxEVT_TOOL, &CWatchWindow::LoadAll, parent, ID_LOAD);
AddTool(ID_SAVE, _("Save"), m_Bitmaps[Toolbar_File]);
Bind(wxEVT_TOOL, &CWatchWindow::Event_SaveAll, parent, ID_SAVE);
}
private:
enum
{
Toolbar_File,
Num_Bitmaps
};
enum
{
ID_LOAD,
ID_SAVE
};
wxBitmap m_Bitmaps[Num_Bitmaps];
};
CWatchWindow::CWatchWindow(wxWindow* parent, wxWindowID id, CWatchWindow::CWatchWindow(wxWindow* parent, wxWindowID id,
const wxPoint& position, const wxSize& size, const wxPoint& position, const wxSize& size,
@ -28,17 +73,18 @@ CWatchWindow::CWatchWindow(wxWindow* parent, wxWindowID id,
: wxPanel(parent, id, position, size, style, name) : wxPanel(parent, id, position, size, style, name)
, m_GPRGridView(nullptr) , m_GPRGridView(nullptr)
{ {
CreateGUIControls(); m_mgr.SetManagedWindow(this);
} m_mgr.SetFlags(wxAUI_MGR_DEFAULT | wxAUI_MGR_LIVE_RESIZE);
void CWatchWindow::CreateGUIControls()
{
wxBoxSizer *sGrid = new wxBoxSizer(wxVERTICAL); wxBoxSizer *sGrid = new wxBoxSizer(wxVERTICAL);
m_GPRGridView = new CWatchView(this, ID_GPR); m_GPRGridView = new CWatchView(this, ID_GPR);
sGrid->Add(m_GPRGridView, 1, wxGROW); sGrid->Add(m_GPRGridView, 1, wxGROW);
SetSizer(sGrid); SetSizer(sGrid);
NotifyUpdate(); m_mgr.AddPane(new CWatchToolbar(this, wxID_ANY), wxAuiPaneInfo().ToolbarPane().Top().
LeftDockable(true).RightDockable(true).BottomDockable(false).Floatable(false));
m_mgr.AddPane(m_GPRGridView, wxAuiPaneInfo().CenterPane());
m_mgr.Update();
} }
void CWatchWindow::NotifyUpdate() void CWatchWindow::NotifyUpdate()
@ -46,3 +92,36 @@ void CWatchWindow::NotifyUpdate()
if (m_GPRGridView != nullptr) if (m_GPRGridView != nullptr)
m_GPRGridView->Update(); m_GPRGridView->Update();
} }
void CWatchWindow::Event_SaveAll(wxCommandEvent& WXUNUSED(event))
{
SaveAll();
}
void CWatchWindow::SaveAll()
{
IniFile ini;
if (ini.Load(File::GetUserPath(F_DEBUGGERCONFIG_IDX)))
{
ini.SetLines("Watches", PowerPC::watches.GetStrings());
ini.Save(File::GetUserPath(F_DEBUGGERCONFIG_IDX));
}
}
void CWatchWindow::LoadAll(wxCommandEvent& WXUNUSED(event))
{
IniFile ini;
Watches::TWatchesStr watches;
if (!ini.Load(File::GetUserPath(F_DEBUGGERCONFIG_IDX)))
{
return;
}
if (ini.GetLines("Watches", &watches, false))
{
PowerPC::watches.AddFromStrings(watches);
}
NotifyUpdate();
}

View File

@ -11,6 +11,7 @@
#include <wx/string.h> #include <wx/string.h>
#include <wx/translation.h> #include <wx/translation.h>
#include <wx/windowid.h> #include <wx/windowid.h>
#include <wx/aui/framemanager.h>
class CWatchView; class CWatchView;
class wxWindow; class wxWindow;
@ -27,11 +28,15 @@ public:
const wxString& name = _("Watch")); const wxString& name = _("Watch"));
void NotifyUpdate(); void NotifyUpdate();
void Event_SaveAll(wxCommandEvent& WXUNUSED(event));
void SaveAll();
void LoadAll(wxCommandEvent& WXUNUSED(event));
private: private:
DECLARE_EVENT_TABLE(); DECLARE_EVENT_TABLE();
wxAuiManager m_mgr;
enum enum
{ {
ID_GPR = 1002 ID_GPR = 1002